2000-11-05 20:25:02 +00:00
|
|
|
/* DirectInput Keyboard device
|
|
|
|
*
|
|
|
|
* Copyright 1998 Marcus Meissner
|
|
|
|
* Copyright 1998,1999 Lionel Ulmer
|
2002-06-14 00:39:44 +00:00
|
|
|
* Copyright 2000-2001 TransGaming Technologies Inc.
|
2005-03-24 15:08:27 +00:00
|
|
|
* Copyright 2005 Raphael Junqueira
|
2000-11-05 20:25:02 +00:00
|
|
|
*
|
2002-03-09 23:29:33 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2000-11-05 20:25:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2002-07-22 21:53:32 +00:00
|
|
|
#include "wine/port.h"
|
|
|
|
|
2003-09-05 23:08:26 +00:00
|
|
|
#include <stdarg.h>
|
2000-11-05 20:25:02 +00:00
|
|
|
#include <string.h>
|
2003-09-05 23:08:26 +00:00
|
|
|
#include "windef.h"
|
2001-10-18 21:30:06 +00:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
2000-11-05 20:25:02 +00:00
|
|
|
#include "winerror.h"
|
|
|
|
#include "dinput.h"
|
|
|
|
|
|
|
|
#include "dinput_private.h"
|
|
|
|
#include "device_private.h"
|
2002-03-09 23:29:33 +00:00
|
|
|
#include "wine/debug.h"
|
2003-06-16 20:22:13 +00:00
|
|
|
#include "wine/unicode.h"
|
2000-11-05 20:25:02 +00:00
|
|
|
|
2002-03-09 23:29:33 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
|
2000-11-05 20:25:02 +00:00
|
|
|
|
2005-03-24 15:08:27 +00:00
|
|
|
#define WINE_DINPUT_KEYBOARD_MAX_KEYS 256
|
|
|
|
|
2005-05-30 10:01:08 +00:00
|
|
|
static const IDirectInputDevice8AVtbl SysKeyboardAvt;
|
|
|
|
static const IDirectInputDevice8WVtbl SysKeyboardWvt;
|
2002-05-07 01:49:19 +00:00
|
|
|
|
2003-06-16 20:22:13 +00:00
|
|
|
typedef struct SysKeyboardImpl SysKeyboardImpl;
|
|
|
|
struct SysKeyboardImpl
|
2000-11-05 20:25:02 +00:00
|
|
|
{
|
2006-10-15 17:29:30 +00:00
|
|
|
struct IDirectInputDevice2AImpl base;
|
2007-06-28 12:34:04 +00:00
|
|
|
BYTE DInputKeyState[WINE_DINPUT_KEYBOARD_MAX_KEYS];
|
2000-11-05 20:25:02 +00:00
|
|
|
};
|
|
|
|
|
2007-07-07 05:36:30 +00:00
|
|
|
static void KeyboardCallback( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam )
|
2002-05-19 22:26:16 +00:00
|
|
|
{
|
2007-07-07 05:36:30 +00:00
|
|
|
SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
|
2006-07-27 14:19:59 +00:00
|
|
|
int dik_code;
|
2006-03-18 18:26:37 +00:00
|
|
|
KBDLLHOOKSTRUCT *hook = (KBDLLHOOKSTRUCT *)lparam;
|
|
|
|
BYTE new_diks;
|
2005-03-24 15:08:27 +00:00
|
|
|
|
2007-07-07 05:36:30 +00:00
|
|
|
if (wparam != WM_KEYDOWN && wparam != WM_KEYUP &&
|
|
|
|
wparam != WM_SYSKEYDOWN && wparam != WM_SYSKEYUP)
|
|
|
|
return;
|
|
|
|
|
|
|
|
TRACE("(%p) %ld,%ld\n", iface, wparam, lparam);
|
2002-08-06 23:49:12 +00:00
|
|
|
|
2006-07-27 14:19:59 +00:00
|
|
|
dik_code = hook->scanCode & 0xff;
|
2008-04-26 23:35:43 +00:00
|
|
|
/* R-Shift is special - it is an extended key with separate scan code */
|
|
|
|
if (hook->flags & LLKHF_EXTENDED && dik_code != 0x36)
|
|
|
|
dik_code |= 0x80;
|
2005-03-24 15:08:27 +00:00
|
|
|
|
2006-07-27 14:19:59 +00:00
|
|
|
new_diks = hook->flags & LLKHF_UP ? 0 : 0x80;
|
|
|
|
|
|
|
|
/* returns now if key event already known */
|
2007-06-28 12:34:04 +00:00
|
|
|
if (new_diks == This->DInputKeyState[dik_code])
|
2007-07-07 05:36:30 +00:00
|
|
|
return;
|
2005-03-24 15:08:27 +00:00
|
|
|
|
2007-06-28 12:34:04 +00:00
|
|
|
This->DInputKeyState[dik_code] = new_diks;
|
|
|
|
TRACE(" setting %02X to %02X\n", dik_code, This->DInputKeyState[dik_code]);
|
2005-03-24 15:08:27 +00:00
|
|
|
|
2007-01-07 07:14:43 +00:00
|
|
|
dik_code = id_to_offset(&This->base.data_format, DIDFT_MAKEINSTANCE(dik_code) | DIDFT_PSHBUTTON);
|
2006-12-01 17:56:00 +00:00
|
|
|
EnterCriticalSection(&This->base.crit);
|
2007-06-27 12:58:08 +00:00
|
|
|
queue_event((LPDIRECTINPUTDEVICE8A)This, dik_code, new_diks, hook->time, This->base.dinput->evsequence++);
|
2006-12-01 17:56:00 +00:00
|
|
|
LeaveCriticalSection(&This->base.crit);
|
2002-05-19 22:26:16 +00:00
|
|
|
}
|
2002-05-07 01:49:19 +00:00
|
|
|
|
2007-07-07 05:36:22 +00:00
|
|
|
const GUID DInput_Wine_Keyboard_GUID = { /* 0ab8648a-7735-11d2-8c73-71df54a96441 */
|
|
|
|
0x0ab8648a, 0x7735, 0x11d2, {0x8c, 0x73, 0x71, 0xdf, 0x54, 0xa9, 0x64, 0x41}
|
2000-11-05 20:25:02 +00:00
|
|
|
};
|
|
|
|
|
2005-05-16 08:44:14 +00:00
|
|
|
static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version) {
|
2003-02-24 20:41:28 +00:00
|
|
|
DWORD dwSize;
|
|
|
|
DIDEVICEINSTANCEA ddi;
|
|
|
|
|
|
|
|
dwSize = lpddi->dwSize;
|
|
|
|
|
2006-10-07 23:55:40 +00:00
|
|
|
TRACE("%d %p\n", dwSize, lpddi);
|
2003-02-24 20:41:28 +00:00
|
|
|
|
|
|
|
memset(lpddi, 0, dwSize);
|
|
|
|
memset(&ddi, 0, sizeof(ddi));
|
|
|
|
|
|
|
|
ddi.dwSize = dwSize;
|
|
|
|
ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
|
|
|
|
ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
|
2005-05-16 08:44:14 +00:00
|
|
|
if (version >= 0x0800)
|
2003-06-13 18:55:41 +00:00
|
|
|
ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
|
|
|
|
else
|
|
|
|
ddi.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
|
2003-02-24 20:41:28 +00:00
|
|
|
strcpy(ddi.tszInstanceName, "Keyboard");
|
|
|
|
strcpy(ddi.tszProductName, "Wine Keyboard");
|
|
|
|
|
|
|
|
memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
|
|
|
|
}
|
|
|
|
|
2005-05-16 08:44:14 +00:00
|
|
|
static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version) {
|
2003-06-16 20:22:13 +00:00
|
|
|
DWORD dwSize;
|
|
|
|
DIDEVICEINSTANCEW ddi;
|
|
|
|
|
|
|
|
dwSize = lpddi->dwSize;
|
|
|
|
|
2006-10-07 23:55:40 +00:00
|
|
|
TRACE("%d %p\n", dwSize, lpddi);
|
2003-06-16 20:22:13 +00:00
|
|
|
|
|
|
|
memset(lpddi, 0, dwSize);
|
|
|
|
memset(&ddi, 0, sizeof(ddi));
|
|
|
|
|
|
|
|
ddi.dwSize = dwSize;
|
|
|
|
ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
|
|
|
|
ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
|
2005-05-16 08:44:14 +00:00
|
|
|
if (version >= 0x0800)
|
2003-06-16 20:22:13 +00:00
|
|
|
ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
|
|
|
|
else
|
|
|
|
ddi.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, "Keyboard", -1, ddi.tszInstanceName, MAX_PATH);
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, "Wine Keyboard", -1, ddi.tszProductName, MAX_PATH);
|
|
|
|
|
|
|
|
memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
|
|
|
|
}
|
|
|
|
|
2005-05-16 08:44:14 +00:00
|
|
|
static BOOL keyboarddev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
|
2003-06-16 20:22:13 +00:00
|
|
|
{
|
2004-09-13 19:16:47 +00:00
|
|
|
if (id != 0)
|
|
|
|
return FALSE;
|
|
|
|
|
2003-06-16 20:22:13 +00:00
|
|
|
if ((dwDevType == 0) ||
|
2005-05-16 08:44:14 +00:00
|
|
|
((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 0x0800)) ||
|
|
|
|
(((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 0x0800))) {
|
2003-06-16 20:22:13 +00:00
|
|
|
TRACE("Enumerating the Keyboard device\n");
|
|
|
|
|
|
|
|
fill_keyboard_dideviceinstanceA(lpddi, version);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-05-16 08:44:14 +00:00
|
|
|
static BOOL keyboarddev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
|
2000-11-05 20:25:02 +00:00
|
|
|
{
|
2004-09-13 19:16:47 +00:00
|
|
|
if (id != 0)
|
|
|
|
return FALSE;
|
|
|
|
|
2003-06-13 18:55:41 +00:00
|
|
|
if ((dwDevType == 0) ||
|
2005-05-16 08:44:14 +00:00
|
|
|
((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 0x0800)) ||
|
|
|
|
(((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 0x0800))) {
|
2000-11-05 20:25:02 +00:00
|
|
|
TRACE("Enumerating the Keyboard device\n");
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2003-06-16 20:22:13 +00:00
|
|
|
fill_keyboard_dideviceinstanceW(lpddi, version);
|
2003-02-24 20:41:28 +00:00
|
|
|
|
2000-11-05 20:25:02 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-05-30 10:01:08 +00:00
|
|
|
static SysKeyboardImpl *alloc_device(REFGUID rguid, const void *kvt, IDirectInputImpl *dinput)
|
2000-11-05 20:25:02 +00:00
|
|
|
{
|
2003-06-16 20:22:13 +00:00
|
|
|
SysKeyboardImpl* newDevice;
|
2006-12-29 05:45:53 +00:00
|
|
|
LPDIDATAFORMAT df = NULL;
|
|
|
|
int i, idx = 0;
|
2005-03-24 15:08:27 +00:00
|
|
|
|
2003-06-16 20:22:13 +00:00
|
|
|
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardImpl));
|
2006-10-15 17:29:30 +00:00
|
|
|
newDevice->base.lpVtbl = kvt;
|
|
|
|
newDevice->base.ref = 1;
|
|
|
|
memcpy(&newDevice->base.guid, rguid, sizeof(*rguid));
|
2007-06-27 12:58:08 +00:00
|
|
|
newDevice->base.dinput = dinput;
|
2007-07-07 05:36:30 +00:00
|
|
|
newDevice->base.event_proc = KeyboardCallback;
|
2006-12-01 17:56:00 +00:00
|
|
|
InitializeCriticalSection(&newDevice->base.crit);
|
2007-03-08 15:32:50 +00:00
|
|
|
newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SysKeyboardImpl*->base.crit");
|
2000-11-05 20:25:02 +00:00
|
|
|
|
2006-12-29 05:45:53 +00:00
|
|
|
/* Create copy of default data format */
|
|
|
|
if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIKeyboard.dwSize))) goto failed;
|
|
|
|
memcpy(df, &c_dfDIKeyboard, c_dfDIKeyboard.dwSize);
|
|
|
|
if (!(df->rgodf = HeapAlloc(GetProcessHeap(), 0, df->dwNumObjs * df->dwObjSize))) goto failed;
|
|
|
|
|
|
|
|
for (i = 0; i < df->dwNumObjs; i++)
|
2006-12-22 17:54:29 +00:00
|
|
|
{
|
2006-12-29 05:45:53 +00:00
|
|
|
char buf[MAX_PATH];
|
|
|
|
|
|
|
|
if (!GetKeyNameTextA(((i & 0x7f) << 16) | ((i & 0x80) << 17), buf, sizeof(buf)))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
memcpy(&df->rgodf[idx], &c_dfDIKeyboard.rgodf[i], df->dwObjSize);
|
|
|
|
df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_PSHBUTTON;
|
2006-12-22 17:54:29 +00:00
|
|
|
}
|
2006-12-29 05:45:53 +00:00
|
|
|
df->dwNumObjs = idx;
|
2006-12-22 17:54:29 +00:00
|
|
|
|
2006-12-29 05:45:53 +00:00
|
|
|
newDevice->base.data_format.wine_df = df;
|
2007-06-27 12:58:08 +00:00
|
|
|
IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->base.dinput);
|
2006-12-29 05:45:53 +00:00
|
|
|
return newDevice;
|
|
|
|
|
|
|
|
failed:
|
|
|
|
if (df) HeapFree(GetProcessHeap(), 0, df->rgodf);
|
|
|
|
HeapFree(GetProcessHeap(), 0, df);
|
2006-12-22 17:54:29 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, newDevice);
|
2006-12-12 15:58:29 +00:00
|
|
|
return NULL;
|
2000-11-05 20:25:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-16 20:22:13 +00:00
|
|
|
static HRESULT keyboarddev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
|
2000-11-05 20:25:02 +00:00
|
|
|
{
|
|
|
|
if ((IsEqualGUID(&GUID_SysKeyboard,rguid)) || /* Generic Keyboard */
|
|
|
|
(IsEqualGUID(&DInput_Wine_Keyboard_GUID,rguid))) { /* Wine Keyboard */
|
2002-06-14 00:39:44 +00:00
|
|
|
if ((riid == NULL) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDeviceA,riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
|
2003-06-16 20:22:13 +00:00
|
|
|
*pdev = (IDirectInputDeviceA*) alloc_device(rguid, &SysKeyboardAvt, dinput);
|
2000-11-05 20:25:02 +00:00
|
|
|
TRACE("Creating a Keyboard device (%p)\n", *pdev);
|
2006-12-22 17:54:29 +00:00
|
|
|
if (!*pdev) return DIERR_OUTOFMEMORY;
|
2000-11-05 20:25:02 +00:00
|
|
|
return DI_OK;
|
|
|
|
} else
|
|
|
|
return DIERR_NOINTERFACE;
|
|
|
|
}
|
2003-06-16 20:22:13 +00:00
|
|
|
return DIERR_DEVICENOTREG;
|
|
|
|
}
|
2000-11-05 20:25:02 +00:00
|
|
|
|
2003-06-16 20:22:13 +00:00
|
|
|
static HRESULT keyboarddev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
|
|
|
|
{
|
|
|
|
if ((IsEqualGUID(&GUID_SysKeyboard,rguid)) || /* Generic Keyboard */
|
|
|
|
(IsEqualGUID(&DInput_Wine_Keyboard_GUID,rguid))) { /* Wine Keyboard */
|
|
|
|
if ((riid == NULL) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
|
|
|
|
*pdev = (IDirectInputDeviceW*) alloc_device(rguid, &SysKeyboardWvt, dinput);
|
|
|
|
TRACE("Creating a Keyboard device (%p)\n", *pdev);
|
2006-12-22 17:54:29 +00:00
|
|
|
if (!*pdev) return DIERR_OUTOFMEMORY;
|
2003-06-16 20:22:13 +00:00
|
|
|
return DI_OK;
|
|
|
|
} else
|
|
|
|
return DIERR_NOINTERFACE;
|
|
|
|
}
|
2000-11-05 20:25:02 +00:00
|
|
|
return DIERR_DEVICENOTREG;
|
|
|
|
}
|
|
|
|
|
2005-03-15 19:36:15 +00:00
|
|
|
const struct dinput_device keyboard_device = {
|
2004-06-04 18:06:37 +00:00
|
|
|
"Wine keyboard driver",
|
2003-06-16 20:22:13 +00:00
|
|
|
keyboarddev_enum_deviceA,
|
|
|
|
keyboarddev_enum_deviceW,
|
|
|
|
keyboarddev_create_deviceA,
|
|
|
|
keyboarddev_create_deviceW
|
2000-11-05 20:25:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState(
|
2002-06-14 00:39:44 +00:00
|
|
|
LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
|
2000-11-05 20:25:02 +00:00
|
|
|
)
|
|
|
|
{
|
2005-03-24 15:08:27 +00:00
|
|
|
SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
|
2006-10-07 23:55:40 +00:00
|
|
|
TRACE("(%p)->(%d,%p)\n", This, len, ptr);
|
2003-06-13 18:55:41 +00:00
|
|
|
|
2006-12-01 17:54:42 +00:00
|
|
|
if (!This->base.acquired) return DIERR_NOTACQUIRED;
|
2006-04-02 02:55:00 +00:00
|
|
|
|
2005-03-24 15:08:27 +00:00
|
|
|
if (len != WINE_DINPUT_KEYBOARD_MAX_KEYS)
|
2006-12-27 23:30:39 +00:00
|
|
|
return DIERR_INVALIDPARAM;
|
2003-06-04 20:11:56 +00:00
|
|
|
|
2006-12-01 17:56:00 +00:00
|
|
|
EnterCriticalSection(&This->base.crit);
|
2005-03-24 15:08:27 +00:00
|
|
|
|
2004-04-12 22:07:12 +00:00
|
|
|
if (TRACE_ON(dinput)) {
|
|
|
|
int i;
|
2005-03-24 15:08:27 +00:00
|
|
|
for (i = 0; i < WINE_DINPUT_KEYBOARD_MAX_KEYS; i++) {
|
2007-06-28 12:34:04 +00:00
|
|
|
if (This->DInputKeyState[i] != 0x00)
|
|
|
|
TRACE(" - %02X: %02x\n", i, This->DInputKeyState[i]);
|
2004-04-12 22:07:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-28 12:34:04 +00:00
|
|
|
memcpy(ptr, This->DInputKeyState, WINE_DINPUT_KEYBOARD_MAX_KEYS);
|
2006-12-01 17:56:00 +00:00
|
|
|
LeaveCriticalSection(&This->base.crit);
|
2005-03-24 15:08:27 +00:00
|
|
|
|
2001-10-18 21:30:06 +00:00
|
|
|
return DI_OK;
|
2000-11-05 20:25:02 +00:00
|
|
|
}
|
|
|
|
|
2002-05-19 22:26:16 +00:00
|
|
|
/******************************************************************************
|
2008-03-27 17:57:17 +00:00
|
|
|
* GetCapabilities : get the device capabilities
|
2002-05-19 22:26:16 +00:00
|
|
|
*/
|
2000-11-05 20:25:02 +00:00
|
|
|
static HRESULT WINAPI SysKeyboardAImpl_GetCapabilities(
|
2002-06-14 00:39:44 +00:00
|
|
|
LPDIRECTINPUTDEVICE8A iface,
|
2000-11-05 20:25:02 +00:00
|
|
|
LPDIDEVCAPS lpDIDevCaps)
|
|
|
|
{
|
2004-12-13 13:17:03 +00:00
|
|
|
SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
|
|
|
|
DIDEVCAPS devcaps;
|
2000-11-05 20:25:02 +00:00
|
|
|
|
2004-12-13 13:17:03 +00:00
|
|
|
TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
|
2000-11-05 20:25:02 +00:00
|
|
|
|
2004-12-13 13:17:03 +00:00
|
|
|
if ((lpDIDevCaps->dwSize != sizeof(DIDEVCAPS)) && (lpDIDevCaps->dwSize != sizeof(DIDEVCAPS_DX3))) {
|
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return DIERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
devcaps.dwSize = lpDIDevCaps->dwSize;
|
|
|
|
devcaps.dwFlags = DIDC_ATTACHED;
|
2007-06-27 12:58:08 +00:00
|
|
|
if (This->base.dinput->dwVersion >= 0x0800)
|
2004-12-13 13:17:03 +00:00
|
|
|
devcaps.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
|
2003-06-13 18:55:41 +00:00
|
|
|
else
|
2004-12-13 13:17:03 +00:00
|
|
|
devcaps.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
|
|
|
|
devcaps.dwAxes = 0;
|
2006-12-29 05:45:53 +00:00
|
|
|
devcaps.dwButtons = This->base.data_format.wine_df->dwNumObjs;
|
2004-12-13 13:17:03 +00:00
|
|
|
devcaps.dwPOVs = 0;
|
|
|
|
devcaps.dwFFSamplePeriod = 0;
|
|
|
|
devcaps.dwFFMinTimeResolution = 0;
|
|
|
|
devcaps.dwFirmwareRevision = 100;
|
|
|
|
devcaps.dwHardwareRevision = 100;
|
|
|
|
devcaps.dwFFDriverVersion = 0;
|
|
|
|
|
|
|
|
memcpy(lpDIDevCaps, &devcaps, lpDIDevCaps->dwSize);
|
|
|
|
|
|
|
|
return DI_OK;
|
2000-11-05 20:25:02 +00:00
|
|
|
}
|
|
|
|
|
2003-02-24 20:41:28 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* GetObjectInfo : get information about a device object such as a button
|
|
|
|
* or axis
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
SysKeyboardAImpl_GetObjectInfo(
|
|
|
|
LPDIRECTINPUTDEVICE8A iface,
|
|
|
|
LPDIDEVICEOBJECTINSTANCEA pdidoi,
|
|
|
|
DWORD dwObj,
|
|
|
|
DWORD dwHow)
|
|
|
|
{
|
2007-01-04 06:04:31 +00:00
|
|
|
HRESULT res;
|
2003-02-24 20:41:28 +00:00
|
|
|
|
2007-01-04 06:04:31 +00:00
|
|
|
res = IDirectInputDevice2AImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
|
|
|
|
if (res != DI_OK) return res;
|
2003-02-24 20:41:28 +00:00
|
|
|
|
2007-01-04 06:04:31 +00:00
|
|
|
if (!GetKeyNameTextA((DIDFT_GETINSTANCE(pdidoi->dwType) & 0x80) << 17 |
|
|
|
|
(DIDFT_GETINSTANCE(pdidoi->dwType) & 0x7f) << 16,
|
|
|
|
pdidoi->tszName, sizeof(pdidoi->tszName)))
|
2006-12-18 06:20:52 +00:00
|
|
|
return DIERR_OBJECTNOTFOUND;
|
2003-02-24 20:41:28 +00:00
|
|
|
|
|
|
|
_dump_OBJECTINSTANCEA(pdidoi);
|
2007-01-04 06:04:31 +00:00
|
|
|
return res;
|
2003-02-24 20:41:28 +00:00
|
|
|
}
|
|
|
|
|
2003-06-16 20:22:13 +00:00
|
|
|
static HRESULT WINAPI SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
|
|
|
|
LPDIDEVICEOBJECTINSTANCEW pdidoi,
|
|
|
|
DWORD dwObj,
|
|
|
|
DWORD dwHow)
|
|
|
|
{
|
2007-01-04 06:04:31 +00:00
|
|
|
HRESULT res;
|
2003-06-16 20:22:13 +00:00
|
|
|
|
2007-01-04 06:04:31 +00:00
|
|
|
res = IDirectInputDevice2WImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
|
|
|
|
if (res != DI_OK) return res;
|
2003-06-16 20:22:13 +00:00
|
|
|
|
2007-01-04 06:04:31 +00:00
|
|
|
if (!GetKeyNameTextW((DIDFT_GETINSTANCE(pdidoi->dwType) & 0x80) << 17 |
|
|
|
|
(DIDFT_GETINSTANCE(pdidoi->dwType) & 0x7f) << 16,
|
2008-02-25 09:01:49 +00:00
|
|
|
pdidoi->tszName,
|
|
|
|
sizeof(pdidoi->tszName)/sizeof(pdidoi->tszName[0])))
|
2006-12-18 06:20:52 +00:00
|
|
|
return DIERR_OBJECTNOTFOUND;
|
2003-06-16 20:22:13 +00:00
|
|
|
|
|
|
|
_dump_OBJECTINSTANCEW(pdidoi);
|
2007-01-04 06:04:31 +00:00
|
|
|
return res;
|
2003-06-16 20:22:13 +00:00
|
|
|
}
|
|
|
|
|
2003-02-24 20:41:28 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* GetDeviceInfo : get information about a device's identity
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI SysKeyboardAImpl_GetDeviceInfo(
|
|
|
|
LPDIRECTINPUTDEVICE8A iface,
|
|
|
|
LPDIDEVICEINSTANCEA pdidi)
|
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
|
2003-02-24 20:41:28 +00:00
|
|
|
TRACE("(this=%p,%p)\n", This, pdidi);
|
|
|
|
|
|
|
|
if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA)) {
|
2005-03-24 15:08:27 +00:00
|
|
|
WARN(" dinput3 not supported yet...\n");
|
2003-02-24 20:41:28 +00:00
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
2007-06-27 12:58:08 +00:00
|
|
|
fill_keyboard_dideviceinstanceA(pdidi, This->base.dinput->dwVersion);
|
2003-02-24 20:41:28 +00:00
|
|
|
|
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
2003-06-16 20:22:13 +00:00
|
|
|
static HRESULT WINAPI SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi)
|
|
|
|
{
|
2004-09-09 20:17:07 +00:00
|
|
|
SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
|
2003-06-16 20:22:13 +00:00
|
|
|
TRACE("(this=%p,%p)\n", This, pdidi);
|
|
|
|
|
|
|
|
if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)) {
|
2005-03-24 15:08:27 +00:00
|
|
|
WARN(" dinput3 not supported yet...\n");
|
2003-06-16 20:22:13 +00:00
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
2007-06-27 12:58:08 +00:00
|
|
|
fill_keyboard_dideviceinstanceW(pdidi, This->base.dinput->dwVersion);
|
2003-06-16 20:22:13 +00:00
|
|
|
|
|
|
|
return DI_OK;
|
|
|
|
}
|
2003-02-24 20:41:28 +00:00
|
|
|
|
2005-05-30 10:01:08 +00:00
|
|
|
static const IDirectInputDevice8AVtbl SysKeyboardAvt =
|
2000-11-05 20:25:02 +00:00
|
|
|
{
|
|
|
|
IDirectInputDevice2AImpl_QueryInterface,
|
|
|
|
IDirectInputDevice2AImpl_AddRef,
|
2007-06-27 12:58:27 +00:00
|
|
|
IDirectInputDevice2AImpl_Release,
|
2000-11-05 20:25:02 +00:00
|
|
|
SysKeyboardAImpl_GetCapabilities,
|
2006-12-29 05:45:53 +00:00
|
|
|
IDirectInputDevice2AImpl_EnumObjects,
|
2006-12-04 17:54:30 +00:00
|
|
|
IDirectInputDevice2AImpl_GetProperty,
|
|
|
|
IDirectInputDevice2AImpl_SetProperty,
|
2007-07-07 05:36:39 +00:00
|
|
|
IDirectInputDevice2AImpl_Acquire,
|
|
|
|
IDirectInputDevice2AImpl_Unacquire,
|
2000-11-05 20:25:02 +00:00
|
|
|
SysKeyboardAImpl_GetDeviceState,
|
2006-12-04 17:54:30 +00:00
|
|
|
IDirectInputDevice2AImpl_GetDeviceData,
|
2000-11-05 20:25:02 +00:00
|
|
|
IDirectInputDevice2AImpl_SetDataFormat,
|
2006-10-15 17:29:48 +00:00
|
|
|
IDirectInputDevice2AImpl_SetEventNotification,
|
2000-11-05 20:25:02 +00:00
|
|
|
IDirectInputDevice2AImpl_SetCooperativeLevel,
|
2003-02-24 20:41:28 +00:00
|
|
|
SysKeyboardAImpl_GetObjectInfo,
|
|
|
|
SysKeyboardAImpl_GetDeviceInfo,
|
2000-11-05 20:25:02 +00:00
|
|
|
IDirectInputDevice2AImpl_RunControlPanel,
|
|
|
|
IDirectInputDevice2AImpl_Initialize,
|
|
|
|
IDirectInputDevice2AImpl_CreateEffect,
|
|
|
|
IDirectInputDevice2AImpl_EnumEffects,
|
|
|
|
IDirectInputDevice2AImpl_GetEffectInfo,
|
|
|
|
IDirectInputDevice2AImpl_GetForceFeedbackState,
|
|
|
|
IDirectInputDevice2AImpl_SendForceFeedbackCommand,
|
|
|
|
IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
|
|
|
|
IDirectInputDevice2AImpl_Escape,
|
2007-01-09 20:36:59 +00:00
|
|
|
IDirectInputDevice2AImpl_Poll,
|
2002-06-14 00:39:44 +00:00
|
|
|
IDirectInputDevice2AImpl_SendDeviceData,
|
|
|
|
IDirectInputDevice7AImpl_EnumEffectsInFile,
|
|
|
|
IDirectInputDevice7AImpl_WriteEffectToFile,
|
|
|
|
IDirectInputDevice8AImpl_BuildActionMap,
|
|
|
|
IDirectInputDevice8AImpl_SetActionMap,
|
|
|
|
IDirectInputDevice8AImpl_GetImageInfo
|
2000-11-05 20:25:02 +00:00
|
|
|
};
|
2003-06-16 20:22:13 +00:00
|
|
|
|
|
|
|
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
|
|
|
|
# define XCAST(fun) (typeof(SysKeyboardWvt.fun))
|
|
|
|
#else
|
|
|
|
# define XCAST(fun) (void*)
|
|
|
|
#endif
|
|
|
|
|
2005-05-30 10:01:08 +00:00
|
|
|
static const IDirectInputDevice8WVtbl SysKeyboardWvt =
|
2003-06-16 20:22:13 +00:00
|
|
|
{
|
|
|
|
IDirectInputDevice2WImpl_QueryInterface,
|
|
|
|
XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
|
2007-06-27 12:58:27 +00:00
|
|
|
XCAST(Release)IDirectInputDevice2AImpl_Release,
|
2003-06-16 20:22:13 +00:00
|
|
|
XCAST(GetCapabilities)SysKeyboardAImpl_GetCapabilities,
|
2006-12-29 05:45:53 +00:00
|
|
|
IDirectInputDevice2WImpl_EnumObjects,
|
2006-12-04 17:54:30 +00:00
|
|
|
XCAST(GetProperty)IDirectInputDevice2AImpl_GetProperty,
|
|
|
|
XCAST(SetProperty)IDirectInputDevice2AImpl_SetProperty,
|
2007-07-07 05:36:39 +00:00
|
|
|
XCAST(Acquire)IDirectInputDevice2AImpl_Acquire,
|
|
|
|
XCAST(Unacquire)IDirectInputDevice2AImpl_Unacquire,
|
2003-06-16 20:22:13 +00:00
|
|
|
XCAST(GetDeviceState)SysKeyboardAImpl_GetDeviceState,
|
2006-12-04 17:54:30 +00:00
|
|
|
XCAST(GetDeviceData)IDirectInputDevice2AImpl_GetDeviceData,
|
2003-06-16 20:22:13 +00:00
|
|
|
XCAST(SetDataFormat)IDirectInputDevice2AImpl_SetDataFormat,
|
2006-10-15 17:29:48 +00:00
|
|
|
XCAST(SetEventNotification)IDirectInputDevice2AImpl_SetEventNotification,
|
2003-06-16 20:22:13 +00:00
|
|
|
XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
|
|
|
|
SysKeyboardWImpl_GetObjectInfo,
|
|
|
|
SysKeyboardWImpl_GetDeviceInfo,
|
|
|
|
XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
|
|
|
|
XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
|
|
|
|
XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,
|
|
|
|
IDirectInputDevice2WImpl_EnumEffects,
|
|
|
|
IDirectInputDevice2WImpl_GetEffectInfo,
|
|
|
|
XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,
|
|
|
|
XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,
|
|
|
|
XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
|
|
|
|
XCAST(Escape)IDirectInputDevice2AImpl_Escape,
|
2007-01-09 20:36:59 +00:00
|
|
|
XCAST(Poll)IDirectInputDevice2AImpl_Poll,
|
2003-06-16 20:22:13 +00:00
|
|
|
XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
|
|
|
|
IDirectInputDevice7WImpl_EnumEffectsInFile,
|
|
|
|
IDirectInputDevice7WImpl_WriteEffectToFile,
|
|
|
|
IDirectInputDevice8WImpl_BuildActionMap,
|
|
|
|
IDirectInputDevice8WImpl_SetActionMap,
|
|
|
|
IDirectInputDevice8WImpl_GetImageInfo
|
|
|
|
};
|
|
|
|
#undef XCAST
|