2000-11-05 21:25:02 +01:00
|
|
|
/* DirectInput Keyboard device
|
|
|
|
*
|
|
|
|
* Copyright 1998 Marcus Meissner
|
|
|
|
* Copyright 1998,1999 Lionel Ulmer
|
2002-06-14 02:39:44 +02:00
|
|
|
* Copyright 2000-2001 TransGaming Technologies Inc.
|
2005-03-24 16:08:27 +01:00
|
|
|
* Copyright 2005 Raphael Junqueira
|
2000-11-05 21:25:02 +01:00
|
|
|
*
|
2002-03-10 00:29:33 +01: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 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2000-11-05 21:25:02 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2002-07-22 23:53:32 +02:00
|
|
|
#include "wine/port.h"
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-11-05 21:25:02 +01:00
|
|
|
#include <string.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2001-10-18 23:30:06 +02:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
2000-11-05 21:25:02 +01:00
|
|
|
#include "winerror.h"
|
|
|
|
#include "dinput.h"
|
|
|
|
|
|
|
|
#include "dinput_private.h"
|
|
|
|
#include "device_private.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2003-06-16 22:22:13 +02:00
|
|
|
#include "wine/unicode.h"
|
2000-11-05 21:25:02 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
|
2000-11-05 21:25:02 +01:00
|
|
|
|
2005-03-24 16:08:27 +01:00
|
|
|
#define WINE_DINPUT_KEYBOARD_MAX_KEYS 256
|
|
|
|
|
2005-05-30 12:01:08 +02:00
|
|
|
static const IDirectInputDevice8AVtbl SysKeyboardAvt;
|
|
|
|
static const IDirectInputDevice8WVtbl SysKeyboardWvt;
|
2002-05-07 03:49:19 +02:00
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
typedef struct SysKeyboardImpl SysKeyboardImpl;
|
|
|
|
struct SysKeyboardImpl
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
2011-01-03 15:25:07 +01:00
|
|
|
struct IDirectInputDeviceImpl base;
|
2007-06-28 14:34:04 +02:00
|
|
|
BYTE DInputKeyState[WINE_DINPUT_KEYBOARD_MAX_KEYS];
|
2000-11-05 21:25:02 +01:00
|
|
|
};
|
|
|
|
|
2011-01-09 23:43:32 +01:00
|
|
|
static inline SysKeyboardImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
|
|
|
|
{
|
2011-01-09 23:44:19 +01:00
|
|
|
return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface), SysKeyboardImpl, base);
|
2011-01-09 23:43:32 +01:00
|
|
|
}
|
|
|
|
static inline SysKeyboardImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
|
|
|
|
{
|
2011-01-09 23:44:19 +01:00
|
|
|
return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface), SysKeyboardImpl, base);
|
2011-01-09 23:43:32 +01:00
|
|
|
}
|
2011-01-09 23:43:58 +01:00
|
|
|
static inline IDirectInputDevice8A *IDirectInputDevice8A_from_impl(SysKeyboardImpl *This)
|
|
|
|
{
|
2011-01-09 23:44:19 +01:00
|
|
|
return &This->base.IDirectInputDevice8A_iface;
|
2011-01-09 23:43:58 +01:00
|
|
|
}
|
|
|
|
static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(SysKeyboardImpl *This)
|
|
|
|
{
|
2011-01-09 23:44:19 +01:00
|
|
|
return &This->base.IDirectInputDevice8W_iface;
|
2011-01-09 23:43:58 +01:00
|
|
|
}
|
2011-01-09 23:43:32 +01:00
|
|
|
|
2008-08-06 15:04:36 +02:00
|
|
|
static BYTE map_dik_code(DWORD scanCode, DWORD vkCode)
|
|
|
|
{
|
|
|
|
static const BYTE asciiCodes[] =
|
2008-10-15 23:16:48 +02:00
|
|
|
{/*32*/ DIK_SPACE,0,0,0,0,0,0,DIK_APOSTROPHE,
|
|
|
|
/*40*/ 0,0,0,0,DIK_COMMA,DIK_MINUS,DIK_PERIOD,DIK_SLASH,
|
|
|
|
/*48*/ DIK_0,DIK_1,DIK_2,DIK_3,DIK_4,DIK_5,DIK_6,DIK_7,
|
|
|
|
/*56*/ DIK_8,DIK_9,DIK_COLON,DIK_SEMICOLON,0,DIK_EQUALS,0,0,
|
|
|
|
/*64*/ DIK_AT,DIK_A,DIK_B,DIK_C,DIK_D,DIK_E,DIK_F,DIK_G,
|
|
|
|
/*72*/ DIK_H,DIK_I,DIK_J,DIK_K,DIK_L,DIK_M,DIK_N,DIK_O,
|
|
|
|
/*80*/ DIK_P,DIK_Q,DIK_R,DIK_S,DIK_T,DIK_U,DIK_V,DIK_W,
|
2008-08-06 15:04:36 +02:00
|
|
|
/*88*/ DIK_X,DIK_Y,DIK_Z,DIK_LBRACKET,0,DIK_RBRACKET,DIK_CIRCUMFLEX,DIK_UNDERLINE} /*95*/ ;
|
|
|
|
|
|
|
|
BYTE out_code = 0;
|
|
|
|
WCHAR c = MapVirtualKeyW(vkCode,MAPVK_VK_TO_CHAR);
|
|
|
|
|
|
|
|
if (c > 31 && c < 96)
|
|
|
|
out_code = asciiCodes[c - 32];
|
|
|
|
|
|
|
|
if (out_code == 0)
|
|
|
|
out_code = scanCode;
|
|
|
|
|
|
|
|
return out_code;
|
|
|
|
}
|
|
|
|
|
2009-02-21 20:54:37 +01:00
|
|
|
static int KeyboardCallback( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam )
|
2002-05-20 00:26:16 +02:00
|
|
|
{
|
2011-01-09 23:43:32 +01:00
|
|
|
SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
|
2009-02-21 20:54:37 +01:00
|
|
|
int dik_code, ret = This->base.dwCoopLevel & DISCL_EXCLUSIVE;
|
2006-03-18 19:26:37 +01:00
|
|
|
KBDLLHOOKSTRUCT *hook = (KBDLLHOOKSTRUCT *)lparam;
|
|
|
|
BYTE new_diks;
|
2005-03-24 16:08:27 +01:00
|
|
|
|
2007-07-07 07:36:30 +02:00
|
|
|
if (wparam != WM_KEYDOWN && wparam != WM_KEYUP &&
|
|
|
|
wparam != WM_SYSKEYDOWN && wparam != WM_SYSKEYUP)
|
2009-02-21 20:54:37 +01:00
|
|
|
return 0;
|
2007-07-07 07:36:30 +02:00
|
|
|
|
|
|
|
TRACE("(%p) %ld,%ld\n", iface, wparam, lparam);
|
2002-08-07 01:49:12 +02:00
|
|
|
|
2009-02-27 17:20:08 +01:00
|
|
|
switch (hook->vkCode)
|
|
|
|
{
|
|
|
|
/* R-Shift is special - it is an extended key with separate scan code */
|
|
|
|
case VK_RSHIFT : dik_code = DIK_RSHIFT; break;
|
|
|
|
case VK_PAUSE : dik_code = DIK_PAUSE; break;
|
|
|
|
case VK_NUMLOCK : dik_code = DIK_NUMLOCK; break;
|
|
|
|
case VK_SUBTRACT: dik_code = DIK_SUBTRACT; break;
|
|
|
|
default:
|
|
|
|
dik_code = map_dik_code(hook->scanCode & 0xff, hook->vkCode);
|
|
|
|
if (hook->flags & LLKHF_EXTENDED) dik_code |= 0x80;
|
|
|
|
}
|
2006-07-27 16:19:59 +02:00
|
|
|
new_diks = hook->flags & LLKHF_UP ? 0 : 0x80;
|
|
|
|
|
|
|
|
/* returns now if key event already known */
|
2007-06-28 14:34:04 +02:00
|
|
|
if (new_diks == This->DInputKeyState[dik_code])
|
2009-02-21 20:54:37 +01:00
|
|
|
return ret;
|
2005-03-24 16:08:27 +01:00
|
|
|
|
2007-06-28 14:34:04 +02:00
|
|
|
This->DInputKeyState[dik_code] = new_diks;
|
|
|
|
TRACE(" setting %02X to %02X\n", dik_code, This->DInputKeyState[dik_code]);
|
2009-02-21 20:54:37 +01:00
|
|
|
|
2006-12-01 18:56:00 +01:00
|
|
|
EnterCriticalSection(&This->base.crit);
|
2011-01-09 23:43:17 +01:00
|
|
|
queue_event(iface, DIDFT_MAKEINSTANCE(dik_code) | DIDFT_PSHBUTTON,
|
2013-12-11 01:45:28 +01:00
|
|
|
new_diks, GetCurrentTime(), This->base.dinput->evsequence++);
|
2006-12-01 18:56:00 +01:00
|
|
|
LeaveCriticalSection(&This->base.crit);
|
2009-02-21 20:54:37 +01:00
|
|
|
|
|
|
|
return ret;
|
2002-05-20 00:26:16 +02:00
|
|
|
}
|
2002-05-07 03:49:19 +02:00
|
|
|
|
2007-07-07 07:36:22 +02: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 21:25:02 +01:00
|
|
|
};
|
|
|
|
|
2005-05-16 10:44:14 +02:00
|
|
|
static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version) {
|
2003-02-24 21:41:28 +01:00
|
|
|
DWORD dwSize;
|
|
|
|
DIDEVICEINSTANCEA ddi;
|
|
|
|
|
|
|
|
dwSize = lpddi->dwSize;
|
|
|
|
|
2006-10-08 01:55:40 +02:00
|
|
|
TRACE("%d %p\n", dwSize, lpddi);
|
2003-02-24 21:41:28 +01: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 10:44:14 +02:00
|
|
|
if (version >= 0x0800)
|
2003-06-13 20:55:41 +02:00
|
|
|
ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
|
|
|
|
else
|
|
|
|
ddi.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
|
2003-02-24 21:41:28 +01:00
|
|
|
strcpy(ddi.tszInstanceName, "Keyboard");
|
|
|
|
strcpy(ddi.tszProductName, "Wine Keyboard");
|
|
|
|
|
|
|
|
memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
|
|
|
|
}
|
|
|
|
|
2005-05-16 10:44:14 +02:00
|
|
|
static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version) {
|
2003-06-16 22:22:13 +02:00
|
|
|
DWORD dwSize;
|
|
|
|
DIDEVICEINSTANCEW ddi;
|
|
|
|
|
|
|
|
dwSize = lpddi->dwSize;
|
|
|
|
|
2006-10-08 01:55:40 +02:00
|
|
|
TRACE("%d %p\n", dwSize, lpddi);
|
2003-06-16 22:22:13 +02: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 10:44:14 +02:00
|
|
|
if (version >= 0x0800)
|
2003-06-16 22:22:13 +02: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)));
|
|
|
|
}
|
|
|
|
|
2013-05-20 21:10:02 +02:00
|
|
|
static HRESULT keyboarddev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
|
2003-06-16 22:22:13 +02:00
|
|
|
{
|
2004-09-13 21:16:47 +02:00
|
|
|
if (id != 0)
|
2013-05-20 21:10:02 +02:00
|
|
|
return E_FAIL;
|
2004-09-13 21:16:47 +02:00
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
if ((dwDevType == 0) ||
|
2005-05-16 10:44:14 +02:00
|
|
|
((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 0x0800)) ||
|
|
|
|
(((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 0x0800))) {
|
2003-06-16 22:22:13 +02:00
|
|
|
TRACE("Enumerating the Keyboard device\n");
|
|
|
|
|
|
|
|
fill_keyboard_dideviceinstanceA(lpddi, version);
|
|
|
|
|
2013-05-20 21:10:02 +02:00
|
|
|
return S_OK;
|
2003-06-16 22:22:13 +02:00
|
|
|
}
|
|
|
|
|
2013-05-20 21:10:02 +02:00
|
|
|
return S_FALSE;
|
2003-06-16 22:22:13 +02:00
|
|
|
}
|
|
|
|
|
2013-05-20 21:10:02 +02:00
|
|
|
static HRESULT keyboarddev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
2004-09-13 21:16:47 +02:00
|
|
|
if (id != 0)
|
2013-05-20 21:10:02 +02:00
|
|
|
return E_FAIL;
|
2004-09-13 21:16:47 +02:00
|
|
|
|
2003-06-13 20:55:41 +02:00
|
|
|
if ((dwDevType == 0) ||
|
2005-05-16 10:44:14 +02:00
|
|
|
((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 0x0800)) ||
|
|
|
|
(((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 0x0800))) {
|
2000-11-05 21:25:02 +01:00
|
|
|
TRACE("Enumerating the Keyboard device\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
fill_keyboard_dideviceinstanceW(lpddi, version);
|
2003-02-24 21:41:28 +01:00
|
|
|
|
2013-05-20 21:10:02 +02:00
|
|
|
return S_OK;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
2013-05-20 21:10:02 +02:00
|
|
|
return S_FALSE;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
2011-01-09 23:44:19 +01:00
|
|
|
static SysKeyboardImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput)
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
2003-06-16 22:22:13 +02:00
|
|
|
SysKeyboardImpl* newDevice;
|
2006-12-29 06:45:53 +01:00
|
|
|
LPDIDATAFORMAT df = NULL;
|
|
|
|
int i, idx = 0;
|
2005-03-24 16:08:27 +01:00
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardImpl));
|
2011-01-09 23:44:19 +01:00
|
|
|
newDevice->base.IDirectInputDevice8A_iface.lpVtbl = &SysKeyboardAvt;
|
|
|
|
newDevice->base.IDirectInputDevice8W_iface.lpVtbl = &SysKeyboardWvt;
|
2006-10-15 19:29:30 +02:00
|
|
|
newDevice->base.ref = 1;
|
|
|
|
memcpy(&newDevice->base.guid, rguid, sizeof(*rguid));
|
2007-06-27 14:58:08 +02:00
|
|
|
newDevice->base.dinput = dinput;
|
2007-07-07 07:36:30 +02:00
|
|
|
newDevice->base.event_proc = KeyboardCallback;
|
2006-12-01 18:56:00 +01:00
|
|
|
InitializeCriticalSection(&newDevice->base.crit);
|
2007-03-08 16:32:50 +01:00
|
|
|
newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SysKeyboardImpl*->base.crit");
|
2000-11-05 21:25:02 +01:00
|
|
|
|
2006-12-29 06:45:53 +01: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 18:54:29 +01:00
|
|
|
{
|
2006-12-29 06:45:53 +01: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 18:54:29 +01:00
|
|
|
}
|
2006-12-29 06:45:53 +01:00
|
|
|
df->dwNumObjs = idx;
|
2006-12-22 18:54:29 +01:00
|
|
|
|
2006-12-29 06:45:53 +01:00
|
|
|
newDevice->base.data_format.wine_df = df;
|
2011-01-09 23:43:09 +01:00
|
|
|
IDirectInput_AddRef(&newDevice->base.dinput->IDirectInput7A_iface);
|
2011-01-19 05:06:37 +01:00
|
|
|
|
|
|
|
EnterCriticalSection(&dinput->crit);
|
|
|
|
list_add_tail(&dinput->devices_list, &newDevice->base.entry);
|
|
|
|
LeaveCriticalSection(&dinput->crit);
|
|
|
|
|
2006-12-29 06:45:53 +01:00
|
|
|
return newDevice;
|
|
|
|
|
|
|
|
failed:
|
|
|
|
if (df) HeapFree(GetProcessHeap(), 0, df->rgodf);
|
|
|
|
HeapFree(GetProcessHeap(), 0, df);
|
2006-12-22 18:54:29 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, newDevice);
|
2006-12-12 16:58:29 +01:00
|
|
|
return NULL;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-23 20:44:20 +01:00
|
|
|
static HRESULT keyboarddev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode)
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
2011-01-23 20:44:20 +01:00
|
|
|
TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode);
|
|
|
|
*pdev = NULL;
|
2000-11-05 21:25:02 +01:00
|
|
|
|
2011-01-23 20:44:20 +01:00
|
|
|
if (IsEqualGUID(&GUID_SysKeyboard, rguid) || /* Generic Keyboard */
|
|
|
|
IsEqualGUID(&DInput_Wine_Keyboard_GUID, rguid)) /* Wine Keyboard */
|
|
|
|
{
|
|
|
|
SysKeyboardImpl *This;
|
|
|
|
|
|
|
|
if (riid == NULL)
|
|
|
|
;/* nothing */
|
|
|
|
else if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice2A, riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice7A, riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice8A, riid))
|
|
|
|
{
|
|
|
|
unicode = 0;
|
|
|
|
}
|
|
|
|
else if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice2W, riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice7W, riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice8W, riid))
|
|
|
|
{
|
|
|
|
unicode = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WARN("no interface\n");
|
|
|
|
return DIERR_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
This = alloc_device(rguid, dinput);
|
|
|
|
TRACE("Created a Keyboard device (%p)\n", This);
|
|
|
|
|
|
|
|
if (!This) return DIERR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (unicode)
|
|
|
|
*pdev = &This->base.IDirectInputDevice8W_iface;
|
|
|
|
else
|
|
|
|
*pdev = &This->base.IDirectInputDevice8A_iface;
|
|
|
|
|
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DIERR_DEVICENOTREG;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
2005-03-15 20:36:15 +01:00
|
|
|
const struct dinput_device keyboard_device = {
|
2004-06-04 20:06:37 +02:00
|
|
|
"Wine keyboard driver",
|
2003-06-16 22:22:13 +02:00
|
|
|
keyboarddev_enum_deviceA,
|
|
|
|
keyboarddev_enum_deviceW,
|
2011-01-23 20:44:20 +01:00
|
|
|
keyboarddev_create_device
|
2000-11-05 21:25:02 +01:00
|
|
|
};
|
|
|
|
|
2011-01-09 23:43:58 +01:00
|
|
|
static HRESULT WINAPI SysKeyboardWImpl_GetDeviceState(LPDIRECTINPUTDEVICE8W iface, DWORD len, LPVOID ptr)
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
2011-01-09 23:43:58 +01:00
|
|
|
SysKeyboardImpl *This = impl_from_IDirectInputDevice8W(iface);
|
2006-10-08 01:55:40 +02:00
|
|
|
TRACE("(%p)->(%d,%p)\n", This, len, ptr);
|
2003-06-13 20:55:41 +02:00
|
|
|
|
2006-12-01 18:54:42 +01:00
|
|
|
if (!This->base.acquired) return DIERR_NOTACQUIRED;
|
2006-04-02 04:55:00 +02:00
|
|
|
|
2008-04-24 22:32:32 +02:00
|
|
|
if (len != This->base.data_format.user_df->dwDataSize )
|
2006-12-28 00:30:39 +01:00
|
|
|
return DIERR_INVALIDPARAM;
|
2003-06-04 22:11:56 +02:00
|
|
|
|
2006-12-01 18:56:00 +01:00
|
|
|
EnterCriticalSection(&This->base.crit);
|
2005-03-24 16:08:27 +01:00
|
|
|
|
2004-04-13 00:07:12 +02:00
|
|
|
if (TRACE_ON(dinput)) {
|
|
|
|
int i;
|
2005-03-24 16:08:27 +01:00
|
|
|
for (i = 0; i < WINE_DINPUT_KEYBOARD_MAX_KEYS; i++) {
|
2007-06-28 14:34:04 +02:00
|
|
|
if (This->DInputKeyState[i] != 0x00)
|
|
|
|
TRACE(" - %02X: %02x\n", i, This->DInputKeyState[i]);
|
2004-04-13 00:07:12 +02:00
|
|
|
}
|
|
|
|
}
|
2008-04-24 22:32:32 +02:00
|
|
|
|
2008-07-27 17:53:34 +02:00
|
|
|
fill_DataFormat(ptr, len, This->DInputKeyState, &This->base.data_format);
|
2006-12-01 18:56:00 +01:00
|
|
|
LeaveCriticalSection(&This->base.crit);
|
2005-03-24 16:08:27 +01:00
|
|
|
|
2001-10-18 23:30:06 +02:00
|
|
|
return DI_OK;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
2011-01-09 23:43:58 +01:00
|
|
|
static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState(LPDIRECTINPUTDEVICE8A iface, DWORD len, LPVOID ptr)
|
|
|
|
{
|
|
|
|
SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
|
|
|
|
return SysKeyboardWImpl_GetDeviceState(IDirectInputDevice8W_from_impl(This), len, ptr);
|
|
|
|
}
|
|
|
|
|
2002-05-20 00:26:16 +02:00
|
|
|
/******************************************************************************
|
2008-03-27 18:57:17 +01:00
|
|
|
* GetCapabilities : get the device capabilities
|
2002-05-20 00:26:16 +02:00
|
|
|
*/
|
2011-01-09 23:43:58 +01:00
|
|
|
static HRESULT WINAPI SysKeyboardWImpl_GetCapabilities(LPDIRECTINPUTDEVICE8W iface, LPDIDEVCAPS lpDIDevCaps)
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
2011-01-09 23:43:58 +01:00
|
|
|
SysKeyboardImpl *This = impl_from_IDirectInputDevice8W(iface);
|
2004-12-13 14:17:03 +01:00
|
|
|
DIDEVCAPS devcaps;
|
2000-11-05 21:25:02 +01:00
|
|
|
|
2004-12-13 14:17:03 +01:00
|
|
|
TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
|
2000-11-05 21:25:02 +01:00
|
|
|
|
2004-12-13 14:17:03 +01:00
|
|
|
if ((lpDIDevCaps->dwSize != sizeof(DIDEVCAPS)) && (lpDIDevCaps->dwSize != sizeof(DIDEVCAPS_DX3))) {
|
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return DIERR_INVALIDPARAM;
|
|
|
|
}
|
2011-01-09 23:43:58 +01:00
|
|
|
|
2004-12-13 14:17:03 +01:00
|
|
|
devcaps.dwSize = lpDIDevCaps->dwSize;
|
2011-10-30 21:52:45 +01:00
|
|
|
devcaps.dwFlags = DIDC_ATTACHED | DIDC_EMULATED;
|
2007-06-27 14:58:08 +02:00
|
|
|
if (This->base.dinput->dwVersion >= 0x0800)
|
2012-08-20 08:52:17 +02:00
|
|
|
devcaps.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_PCENH << 8);
|
2003-06-13 20:55:41 +02:00
|
|
|
else
|
2012-08-20 08:52:17 +02:00
|
|
|
devcaps.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_PCENH << 8);
|
2004-12-13 14:17:03 +01:00
|
|
|
devcaps.dwAxes = 0;
|
2006-12-29 06:45:53 +01:00
|
|
|
devcaps.dwButtons = This->base.data_format.wine_df->dwNumObjs;
|
2004-12-13 14:17:03 +01:00
|
|
|
devcaps.dwPOVs = 0;
|
|
|
|
devcaps.dwFFSamplePeriod = 0;
|
|
|
|
devcaps.dwFFMinTimeResolution = 0;
|
|
|
|
devcaps.dwFirmwareRevision = 100;
|
|
|
|
devcaps.dwHardwareRevision = 100;
|
|
|
|
devcaps.dwFFDriverVersion = 0;
|
|
|
|
|
|
|
|
memcpy(lpDIDevCaps, &devcaps, lpDIDevCaps->dwSize);
|
2011-01-09 23:43:58 +01:00
|
|
|
|
2004-12-13 14:17:03 +01:00
|
|
|
return DI_OK;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
2011-01-09 23:43:58 +01:00
|
|
|
static HRESULT WINAPI SysKeyboardAImpl_GetCapabilities(LPDIRECTINPUTDEVICE8A iface, LPDIDEVCAPS lpDIDevCaps)
|
|
|
|
{
|
|
|
|
SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
|
|
|
|
return SysKeyboardWImpl_GetCapabilities(IDirectInputDevice8W_from_impl(This), lpDIDevCaps);
|
|
|
|
}
|
|
|
|
|
2003-02-24 21:41:28 +01: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 07:04:31 +01:00
|
|
|
HRESULT res;
|
2011-11-08 18:59:20 +01:00
|
|
|
LONG scan;
|
2003-02-24 21:41:28 +01:00
|
|
|
|
2007-01-04 07:04:31 +01:00
|
|
|
res = IDirectInputDevice2AImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
|
|
|
|
if (res != DI_OK) return res;
|
2003-02-24 21:41:28 +01:00
|
|
|
|
2011-11-08 18:59:20 +01:00
|
|
|
scan = DIDFT_GETINSTANCE(pdidoi->dwType);
|
|
|
|
if (scan == DIK_PAUSE || scan == DIK_NUMLOCK) scan ^= 0x80;
|
|
|
|
if (!GetKeyNameTextA((scan & 0x80) << 17 | (scan & 0x7f) << 16,
|
2007-01-04 07:04:31 +01:00
|
|
|
pdidoi->tszName, sizeof(pdidoi->tszName)))
|
2006-12-18 07:20:52 +01:00
|
|
|
return DIERR_OBJECTNOTFOUND;
|
2003-02-24 21:41:28 +01:00
|
|
|
|
|
|
|
_dump_OBJECTINSTANCEA(pdidoi);
|
2007-01-04 07:04:31 +01:00
|
|
|
return res;
|
2003-02-24 21:41:28 +01:00
|
|
|
}
|
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
static HRESULT WINAPI SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
|
|
|
|
LPDIDEVICEOBJECTINSTANCEW pdidoi,
|
|
|
|
DWORD dwObj,
|
|
|
|
DWORD dwHow)
|
|
|
|
{
|
2007-01-04 07:04:31 +01:00
|
|
|
HRESULT res;
|
2011-11-08 18:59:20 +01:00
|
|
|
LONG scan;
|
2003-06-16 22:22:13 +02:00
|
|
|
|
2007-01-04 07:04:31 +01:00
|
|
|
res = IDirectInputDevice2WImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
|
|
|
|
if (res != DI_OK) return res;
|
2003-06-16 22:22:13 +02:00
|
|
|
|
2011-11-08 18:59:20 +01:00
|
|
|
scan = DIDFT_GETINSTANCE(pdidoi->dwType);
|
|
|
|
if (scan == DIK_PAUSE || scan == DIK_NUMLOCK) scan ^= 0x80;
|
|
|
|
if (!GetKeyNameTextW((scan & 0x80) << 17 | (scan & 0x7f) << 16,
|
2013-05-11 19:27:27 +02:00
|
|
|
pdidoi->tszName, sizeof(pdidoi->tszName)/sizeof(pdidoi->tszName[0])))
|
2006-12-18 07:20:52 +01:00
|
|
|
return DIERR_OBJECTNOTFOUND;
|
2003-06-16 22:22:13 +02:00
|
|
|
|
|
|
|
_dump_OBJECTINSTANCEW(pdidoi);
|
2007-01-04 07:04:31 +01:00
|
|
|
return res;
|
2003-06-16 22:22:13 +02:00
|
|
|
}
|
|
|
|
|
2003-02-24 21:41:28 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* GetDeviceInfo : get information about a device's identity
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI SysKeyboardAImpl_GetDeviceInfo(
|
|
|
|
LPDIRECTINPUTDEVICE8A iface,
|
|
|
|
LPDIDEVICEINSTANCEA pdidi)
|
|
|
|
{
|
2011-01-09 23:43:32 +01:00
|
|
|
SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
|
2003-02-24 21:41:28 +01:00
|
|
|
TRACE("(this=%p,%p)\n", This, pdidi);
|
|
|
|
|
|
|
|
if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA)) {
|
2005-03-24 16:08:27 +01:00
|
|
|
WARN(" dinput3 not supported yet...\n");
|
2003-02-24 21:41:28 +01:00
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
2007-06-27 14:58:08 +02:00
|
|
|
fill_keyboard_dideviceinstanceA(pdidi, This->base.dinput->dwVersion);
|
2003-02-24 21:41:28 +01:00
|
|
|
|
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-09 23:43:32 +01:00
|
|
|
static HRESULT WINAPI SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi)
|
2003-06-16 22:22:13 +02:00
|
|
|
{
|
2011-01-09 23:43:32 +01:00
|
|
|
SysKeyboardImpl *This = impl_from_IDirectInputDevice8W(iface);
|
2003-06-16 22:22:13 +02:00
|
|
|
TRACE("(this=%p,%p)\n", This, pdidi);
|
|
|
|
|
|
|
|
if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)) {
|
2005-03-24 16:08:27 +01:00
|
|
|
WARN(" dinput3 not supported yet...\n");
|
2003-06-16 22:22:13 +02:00
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
2007-06-27 14:58:08 +02:00
|
|
|
fill_keyboard_dideviceinstanceW(pdidi, This->base.dinput->dwVersion);
|
2003-06-16 22:22:13 +02:00
|
|
|
|
|
|
|
return DI_OK;
|
|
|
|
}
|
2003-02-24 21:41:28 +01:00
|
|
|
|
2008-09-14 20:51:23 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* GetProperty : Retrieves information about the input device.
|
|
|
|
*/
|
2011-01-09 23:43:58 +01:00
|
|
|
static HRESULT WINAPI SysKeyboardWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface,
|
|
|
|
REFGUID rguid, LPDIPROPHEADER pdiph)
|
2008-09-14 20:51:23 +02:00
|
|
|
{
|
2011-01-09 23:43:58 +01:00
|
|
|
SysKeyboardImpl *This = impl_from_IDirectInputDevice8W(iface);
|
|
|
|
|
2008-09-14 20:51:23 +02:00
|
|
|
TRACE("(%p) %s,%p\n", iface, debugstr_guid(rguid), pdiph);
|
|
|
|
_dump_DIPROPHEADER(pdiph);
|
|
|
|
|
2010-02-02 00:11:49 +01:00
|
|
|
if (!IS_DIPROP(rguid)) return DI_OK;
|
2008-09-14 20:51:23 +02:00
|
|
|
|
|
|
|
switch (LOWORD(rguid))
|
|
|
|
{
|
2009-01-05 12:39:44 +01:00
|
|
|
case (DWORD_PTR)DIPROP_KEYNAME:
|
2008-09-14 20:51:23 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
LPDIPROPSTRING ps = (LPDIPROPSTRING)pdiph;
|
|
|
|
DIDEVICEOBJECTINSTANCEW didoi;
|
|
|
|
|
|
|
|
if (pdiph->dwSize != sizeof(DIPROPSTRING))
|
|
|
|
return DIERR_INVALIDPARAM;
|
|
|
|
|
|
|
|
didoi.dwSize = sizeof(DIDEVICEOBJECTINSTANCEW);
|
|
|
|
|
2011-01-09 23:43:58 +01:00
|
|
|
hr = SysKeyboardWImpl_GetObjectInfo(iface, &didoi, ps->diph.dwObj, ps->diph.dwHow);
|
2008-09-14 20:51:23 +02:00
|
|
|
if (hr == DI_OK)
|
|
|
|
memcpy(ps->wsz, didoi.tszName, sizeof(ps->wsz));
|
|
|
|
return hr;
|
|
|
|
}
|
2011-05-31 00:31:17 +02:00
|
|
|
case (DWORD_PTR) DIPROP_RANGE:
|
|
|
|
return DIERR_UNSUPPORTED;
|
2008-09-14 20:51:23 +02:00
|
|
|
default:
|
2011-01-09 23:43:58 +01:00
|
|
|
return IDirectInputDevice2AImpl_GetProperty( IDirectInputDevice8A_from_impl(This), rguid, pdiph );
|
2008-09-14 20:51:23 +02:00
|
|
|
}
|
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-09 23:43:58 +01:00
|
|
|
static HRESULT WINAPI SysKeyboardAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
|
|
|
|
REFGUID rguid, LPDIPROPHEADER pdiph)
|
|
|
|
{
|
|
|
|
SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
|
|
|
|
return SysKeyboardWImpl_GetProperty(IDirectInputDevice8W_from_impl(This), rguid, pdiph);
|
|
|
|
}
|
|
|
|
|
2015-04-11 10:06:05 +02:00
|
|
|
static HRESULT WINAPI SysKeyboardWImpl_Acquire(LPDIRECTINPUTDEVICE8W iface)
|
|
|
|
{
|
|
|
|
SysKeyboardImpl *This = impl_from_IDirectInputDevice8W(iface);
|
|
|
|
HRESULT res;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
res = IDirectInputDevice2WImpl_Acquire(iface);
|
|
|
|
if (res == DI_OK)
|
|
|
|
{
|
|
|
|
TRACE("clearing keystate\n");
|
|
|
|
memset(This->DInputKeyState, 0, sizeof(This->DInputKeyState));
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
|
|
|
|
{
|
|
|
|
SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
|
|
|
|
return SysKeyboardWImpl_Acquire(IDirectInputDevice8W_from_impl(This));
|
|
|
|
}
|
|
|
|
|
2011-07-02 06:06:37 +02:00
|
|
|
static HRESULT WINAPI SysKeyboardWImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
|
|
|
|
LPDIACTIONFORMATW lpdiaf,
|
|
|
|
LPCWSTR lpszUserName,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
|
|
|
|
|
2011-08-24 04:42:49 +02:00
|
|
|
return _build_action_map(iface, lpdiaf, lpszUserName, dwFlags, DIKEYBOARD_MASK, &c_dfDIKeyboard);
|
2011-07-02 06:06:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SysKeyboardAImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface,
|
|
|
|
LPDIACTIONFORMATA lpdiaf,
|
|
|
|
LPCSTR lpszUserName,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
|
|
|
|
DIACTIONFORMATW diafW;
|
|
|
|
HRESULT hr;
|
2011-08-24 04:42:53 +02:00
|
|
|
WCHAR *lpszUserNameW = NULL;
|
|
|
|
int username_size;
|
2011-07-02 06:06:37 +02:00
|
|
|
|
|
|
|
diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiaf->dwNumActions);
|
|
|
|
_copy_diactionformatAtoW(&diafW, lpdiaf);
|
|
|
|
|
2011-08-24 04:42:53 +02:00
|
|
|
if (lpszUserName != NULL)
|
|
|
|
{
|
|
|
|
username_size = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
|
|
|
|
lpszUserNameW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*username_size);
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, lpszUserNameW, username_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = SysKeyboardWImpl_BuildActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags);
|
2011-07-02 06:06:37 +02:00
|
|
|
|
|
|
|
_copy_diactionformatWtoA(lpdiaf, &diafW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
|
2011-08-24 04:42:53 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, lpszUserNameW);
|
2011-07-02 06:06:37 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-07-02 06:06:54 +02:00
|
|
|
static HRESULT WINAPI SysKeyboardWImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
|
|
|
|
LPDIACTIONFORMATW lpdiaf,
|
|
|
|
LPCWSTR lpszUserName,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
2011-08-24 04:42:50 +02:00
|
|
|
FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
|
2011-07-02 06:06:54 +02:00
|
|
|
|
2011-08-24 04:42:50 +02:00
|
|
|
return _set_action_map(iface, lpdiaf, lpszUserName, dwFlags, &c_dfDIKeyboard);
|
2011-07-02 06:06:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SysKeyboardAImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
|
|
|
|
LPDIACTIONFORMATA lpdiaf,
|
|
|
|
LPCSTR lpszUserName,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
|
|
|
|
DIACTIONFORMATW diafW;
|
|
|
|
HRESULT hr;
|
2011-08-24 04:42:53 +02:00
|
|
|
WCHAR *lpszUserNameW = NULL;
|
|
|
|
int username_size;
|
2011-07-02 06:06:54 +02:00
|
|
|
|
|
|
|
diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiaf->dwNumActions);
|
|
|
|
_copy_diactionformatAtoW(&diafW, lpdiaf);
|
|
|
|
|
2011-08-24 04:42:53 +02:00
|
|
|
if (lpszUserName != NULL)
|
|
|
|
{
|
|
|
|
username_size = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
|
|
|
|
lpszUserNameW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*username_size);
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, lpszUserNameW, username_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = SysKeyboardWImpl_SetActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags);
|
2011-07-02 06:06:54 +02:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
|
2011-08-24 04:42:53 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, lpszUserNameW);
|
2011-07-02 06:06:54 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2005-05-30 12:01:08 +02:00
|
|
|
static const IDirectInputDevice8AVtbl SysKeyboardAvt =
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
2011-01-09 23:43:58 +01:00
|
|
|
IDirectInputDevice2AImpl_QueryInterface,
|
|
|
|
IDirectInputDevice2AImpl_AddRef,
|
|
|
|
IDirectInputDevice2AImpl_Release,
|
|
|
|
SysKeyboardAImpl_GetCapabilities,
|
|
|
|
IDirectInputDevice2AImpl_EnumObjects,
|
|
|
|
SysKeyboardAImpl_GetProperty,
|
|
|
|
IDirectInputDevice2AImpl_SetProperty,
|
2015-04-11 10:06:05 +02:00
|
|
|
SysKeyboardAImpl_Acquire,
|
2011-01-09 23:43:58 +01:00
|
|
|
IDirectInputDevice2AImpl_Unacquire,
|
|
|
|
SysKeyboardAImpl_GetDeviceState,
|
|
|
|
IDirectInputDevice2AImpl_GetDeviceData,
|
|
|
|
IDirectInputDevice2AImpl_SetDataFormat,
|
|
|
|
IDirectInputDevice2AImpl_SetEventNotification,
|
|
|
|
IDirectInputDevice2AImpl_SetCooperativeLevel,
|
|
|
|
SysKeyboardAImpl_GetObjectInfo,
|
|
|
|
SysKeyboardAImpl_GetDeviceInfo,
|
|
|
|
IDirectInputDevice2AImpl_RunControlPanel,
|
|
|
|
IDirectInputDevice2AImpl_Initialize,
|
|
|
|
IDirectInputDevice2AImpl_CreateEffect,
|
|
|
|
IDirectInputDevice2AImpl_EnumEffects,
|
|
|
|
IDirectInputDevice2AImpl_GetEffectInfo,
|
|
|
|
IDirectInputDevice2AImpl_GetForceFeedbackState,
|
|
|
|
IDirectInputDevice2AImpl_SendForceFeedbackCommand,
|
|
|
|
IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
|
|
|
|
IDirectInputDevice2AImpl_Escape,
|
|
|
|
IDirectInputDevice2AImpl_Poll,
|
|
|
|
IDirectInputDevice2AImpl_SendDeviceData,
|
|
|
|
IDirectInputDevice7AImpl_EnumEffectsInFile,
|
|
|
|
IDirectInputDevice7AImpl_WriteEffectToFile,
|
2011-07-02 06:06:37 +02:00
|
|
|
SysKeyboardAImpl_BuildActionMap,
|
2011-07-02 06:06:54 +02:00
|
|
|
SysKeyboardAImpl_SetActionMap,
|
2011-01-09 23:43:58 +01:00
|
|
|
IDirectInputDevice8AImpl_GetImageInfo
|
2000-11-05 21:25:02 +01:00
|
|
|
};
|
2003-06-16 22:22:13 +02:00
|
|
|
|
2005-05-30 12:01:08 +02:00
|
|
|
static const IDirectInputDevice8WVtbl SysKeyboardWvt =
|
2003-06-16 22:22:13 +02:00
|
|
|
{
|
2011-01-09 23:43:55 +01:00
|
|
|
IDirectInputDevice2WImpl_QueryInterface,
|
|
|
|
IDirectInputDevice2WImpl_AddRef,
|
|
|
|
IDirectInputDevice2WImpl_Release,
|
2011-01-09 23:43:58 +01:00
|
|
|
SysKeyboardWImpl_GetCapabilities,
|
2011-01-09 23:43:55 +01:00
|
|
|
IDirectInputDevice2WImpl_EnumObjects,
|
2011-01-09 23:43:58 +01:00
|
|
|
SysKeyboardWImpl_GetProperty,
|
2011-01-09 23:43:55 +01:00
|
|
|
IDirectInputDevice2WImpl_SetProperty,
|
2015-04-11 10:06:05 +02:00
|
|
|
SysKeyboardWImpl_Acquire,
|
2011-01-09 23:43:55 +01:00
|
|
|
IDirectInputDevice2WImpl_Unacquire,
|
2011-01-09 23:43:58 +01:00
|
|
|
SysKeyboardWImpl_GetDeviceState,
|
2011-01-09 23:43:55 +01:00
|
|
|
IDirectInputDevice2WImpl_GetDeviceData,
|
|
|
|
IDirectInputDevice2WImpl_SetDataFormat,
|
|
|
|
IDirectInputDevice2WImpl_SetEventNotification,
|
|
|
|
IDirectInputDevice2WImpl_SetCooperativeLevel,
|
|
|
|
SysKeyboardWImpl_GetObjectInfo,
|
|
|
|
SysKeyboardWImpl_GetDeviceInfo,
|
|
|
|
IDirectInputDevice2WImpl_RunControlPanel,
|
|
|
|
IDirectInputDevice2WImpl_Initialize,
|
|
|
|
IDirectInputDevice2WImpl_CreateEffect,
|
|
|
|
IDirectInputDevice2WImpl_EnumEffects,
|
|
|
|
IDirectInputDevice2WImpl_GetEffectInfo,
|
|
|
|
IDirectInputDevice2WImpl_GetForceFeedbackState,
|
|
|
|
IDirectInputDevice2WImpl_SendForceFeedbackCommand,
|
|
|
|
IDirectInputDevice2WImpl_EnumCreatedEffectObjects,
|
|
|
|
IDirectInputDevice2WImpl_Escape,
|
|
|
|
IDirectInputDevice2WImpl_Poll,
|
|
|
|
IDirectInputDevice2WImpl_SendDeviceData,
|
|
|
|
IDirectInputDevice7WImpl_EnumEffectsInFile,
|
|
|
|
IDirectInputDevice7WImpl_WriteEffectToFile,
|
2011-07-02 06:06:37 +02:00
|
|
|
SysKeyboardWImpl_BuildActionMap,
|
2011-07-02 06:06:54 +02:00
|
|
|
SysKeyboardWImpl_SetActionMap,
|
2011-01-09 23:43:55 +01:00
|
|
|
IDirectInputDevice8WImpl_GetImageInfo
|
2003-06-16 22:22:13 +02:00
|
|
|
};
|