1 /* DirectInput Keyboard device
3 * Copyright 1998 Marcus Meissner
4 * Copyright 1998,1999 Lionel Ulmer
5 * Copyright 2000-2001 TransGaming Technologies Inc.
6 * Copyright 2005 Raphael Junqueira
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/port.h"
34 #include "dinput_private.h"
35 #include "device_private.h"
36 #include "wine/debug.h"
37 #include "wine/unicode.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(dinput
);
41 #define WINE_DINPUT_KEYBOARD_MAX_KEYS 256
43 static const IDirectInputDevice8AVtbl SysKeyboardAvt
;
44 static const IDirectInputDevice8WVtbl SysKeyboardWvt
;
46 typedef struct SysKeyboardImpl SysKeyboardImpl
;
47 struct SysKeyboardImpl
49 struct IDirectInputDeviceImpl base
;
50 BYTE DInputKeyState
[WINE_DINPUT_KEYBOARD_MAX_KEYS
];
54 static inline SysKeyboardImpl
*impl_from_IDirectInputDevice8A(IDirectInputDevice8A
*iface
)
56 return CONTAINING_RECORD(CONTAINING_RECORD(iface
, IDirectInputDeviceImpl
, IDirectInputDevice8A_iface
), SysKeyboardImpl
, base
);
58 static inline SysKeyboardImpl
*impl_from_IDirectInputDevice8W(IDirectInputDevice8W
*iface
)
60 return CONTAINING_RECORD(CONTAINING_RECORD(iface
, IDirectInputDeviceImpl
, IDirectInputDevice8W_iface
), SysKeyboardImpl
, base
);
62 static inline IDirectInputDevice8A
*IDirectInputDevice8A_from_impl(SysKeyboardImpl
*This
)
64 return &This
->base
.IDirectInputDevice8A_iface
;
66 static inline IDirectInputDevice8W
*IDirectInputDevice8W_from_impl(SysKeyboardImpl
*This
)
68 return &This
->base
.IDirectInputDevice8W_iface
;
71 static BYTE
map_dik_code(DWORD scanCode
, DWORD vkCode
, DWORD subType
, DWORD version
)
73 if (!scanCode
&& version
< 0x0800)
74 scanCode
= MapVirtualKeyW(vkCode
, MAPVK_VK_TO_VSC
);
76 if (subType
== DIDEVTYPEKEYBOARD_JAPAN106
)
81 scanCode
= DIK_CIRCUMFLEX
;
87 scanCode
= DIK_LBRACKET
;
92 case 0x29: /* Hankaku/Zenkaku */
96 scanCode
= DIK_RBRACKET
;
99 scanCode
= DIK_BACKSLASH
;
106 int dinput_keyboard_hook( LPDIRECTINPUTDEVICE8A iface
, WPARAM wparam
, LPARAM lparam
)
108 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
109 int dik_code
, ret
= This
->base
.dwCoopLevel
& DISCL_EXCLUSIVE
;
110 KBDLLHOOKSTRUCT
*hook
= (KBDLLHOOKSTRUCT
*)lparam
;
113 if (wparam
!= WM_KEYDOWN
&& wparam
!= WM_KEYUP
&&
114 wparam
!= WM_SYSKEYDOWN
&& wparam
!= WM_SYSKEYUP
)
117 TRACE("(%p) wp %08lx, lp %08lx, vk %02x, scan %02x\n",
118 iface
, wparam
, lparam
, hook
->vkCode
, hook
->scanCode
);
120 switch (hook
->vkCode
)
122 /* R-Shift is special - it is an extended key with separate scan code */
123 case VK_RSHIFT
: dik_code
= DIK_RSHIFT
; break;
124 case VK_PAUSE
: dik_code
= DIK_PAUSE
; break;
125 case VK_NUMLOCK
: dik_code
= DIK_NUMLOCK
; break;
126 case VK_SUBTRACT
: dik_code
= DIK_SUBTRACT
; break;
128 dik_code
= map_dik_code(hook
->scanCode
& 0xff, hook
->vkCode
, This
->subtype
, This
->base
.dinput
->dwVersion
);
129 if (hook
->flags
& LLKHF_EXTENDED
) dik_code
|= 0x80;
131 new_diks
= hook
->flags
& LLKHF_UP
? 0 : 0x80;
133 /* returns now if key event already known */
134 if (new_diks
== This
->DInputKeyState
[dik_code
])
137 This
->DInputKeyState
[dik_code
] = new_diks
;
138 TRACE(" setting %02X to %02X\n", dik_code
, This
->DInputKeyState
[dik_code
]);
140 EnterCriticalSection(&This
->base
.crit
);
141 queue_event(iface
, DIDFT_MAKEINSTANCE(dik_code
) | DIDFT_PSHBUTTON
,
142 new_diks
, GetCurrentTime(), This
->base
.dinput
->evsequence
++);
143 LeaveCriticalSection(&This
->base
.crit
);
148 static DWORD
get_keyboard_subtype(void)
150 DWORD kbd_type
, kbd_subtype
, dev_subtype
;
151 kbd_type
= GetKeyboardType(0);
152 kbd_subtype
= GetKeyboardType(1);
154 if (kbd_type
== 4 || (kbd_type
== 7 && kbd_subtype
== 0))
155 dev_subtype
= DIDEVTYPEKEYBOARD_PCENH
;
156 else if (kbd_type
== 7 && kbd_subtype
== 2)
157 dev_subtype
= DIDEVTYPEKEYBOARD_JAPAN106
;
159 FIXME("Unknown keyboard type=%u, subtype=%u\n", kbd_type
, kbd_subtype
);
160 dev_subtype
= DIDEVTYPEKEYBOARD_PCENH
;
165 static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi
, DWORD version
, DWORD subtype
) {
167 DIDEVICEINSTANCEA ddi
;
169 dwSize
= lpddi
->dwSize
;
171 TRACE("%d %p\n", dwSize
, lpddi
);
173 memset(lpddi
, 0, dwSize
);
174 memset(&ddi
, 0, sizeof(ddi
));
177 ddi
.guidInstance
= GUID_SysKeyboard
;/* DInput's GUID */
178 ddi
.guidProduct
= GUID_SysKeyboard
;
179 if (version
>= 0x0800)
180 ddi
.dwDevType
= DI8DEVTYPE_KEYBOARD
| (subtype
<< 8);
182 ddi
.dwDevType
= DIDEVTYPE_KEYBOARD
| (subtype
<< 8);
183 strcpy(ddi
.tszInstanceName
, "Keyboard");
184 strcpy(ddi
.tszProductName
, "Wine Keyboard");
186 memcpy(lpddi
, &ddi
, (dwSize
< sizeof(ddi
) ? dwSize
: sizeof(ddi
)));
189 static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi
, DWORD version
, DWORD subtype
) {
191 DIDEVICEINSTANCEW ddi
;
193 dwSize
= lpddi
->dwSize
;
195 TRACE("%d %p\n", dwSize
, lpddi
);
197 memset(lpddi
, 0, dwSize
);
198 memset(&ddi
, 0, sizeof(ddi
));
201 ddi
.guidInstance
= GUID_SysKeyboard
;/* DInput's GUID */
202 ddi
.guidProduct
= GUID_SysKeyboard
;
203 if (version
>= 0x0800)
204 ddi
.dwDevType
= DI8DEVTYPE_KEYBOARD
| (subtype
<< 8);
206 ddi
.dwDevType
= DIDEVTYPE_KEYBOARD
| (subtype
<< 8);
207 MultiByteToWideChar(CP_ACP
, 0, "Keyboard", -1, ddi
.tszInstanceName
, MAX_PATH
);
208 MultiByteToWideChar(CP_ACP
, 0, "Wine Keyboard", -1, ddi
.tszProductName
, MAX_PATH
);
210 memcpy(lpddi
, &ddi
, (dwSize
< sizeof(ddi
) ? dwSize
: sizeof(ddi
)));
213 static HRESULT
keyboarddev_enum_deviceA(DWORD dwDevType
, DWORD dwFlags
, LPDIDEVICEINSTANCEA lpddi
, DWORD version
, int id
)
218 if (dwFlags
& DIEDFL_FORCEFEEDBACK
)
221 if ((dwDevType
== 0) ||
222 ((dwDevType
== DIDEVTYPE_KEYBOARD
) && (version
< 0x0800)) ||
223 (((dwDevType
== DI8DEVCLASS_KEYBOARD
) || (dwDevType
== DI8DEVTYPE_KEYBOARD
)) && (version
>= 0x0800))) {
224 TRACE("Enumerating the Keyboard device\n");
226 fill_keyboard_dideviceinstanceA(lpddi
, version
, get_keyboard_subtype());
234 static HRESULT
keyboarddev_enum_deviceW(DWORD dwDevType
, DWORD dwFlags
, LPDIDEVICEINSTANCEW lpddi
, DWORD version
, int id
)
239 if (dwFlags
& DIEDFL_FORCEFEEDBACK
)
242 if ((dwDevType
== 0) ||
243 ((dwDevType
== DIDEVTYPE_KEYBOARD
) && (version
< 0x0800)) ||
244 (((dwDevType
== DI8DEVCLASS_KEYBOARD
) || (dwDevType
== DI8DEVTYPE_KEYBOARD
)) && (version
>= 0x0800))) {
245 TRACE("Enumerating the Keyboard device\n");
247 fill_keyboard_dideviceinstanceW(lpddi
, version
, get_keyboard_subtype());
255 static SysKeyboardImpl
*alloc_device(REFGUID rguid
, IDirectInputImpl
*dinput
)
257 SysKeyboardImpl
* newDevice
;
258 LPDIDATAFORMAT df
= NULL
;
261 newDevice
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(SysKeyboardImpl
));
262 newDevice
->base
.IDirectInputDevice8A_iface
.lpVtbl
= &SysKeyboardAvt
;
263 newDevice
->base
.IDirectInputDevice8W_iface
.lpVtbl
= &SysKeyboardWvt
;
264 newDevice
->base
.ref
= 1;
265 memcpy(&newDevice
->base
.guid
, rguid
, sizeof(*rguid
));
266 newDevice
->base
.dinput
= dinput
;
267 InitializeCriticalSection(&newDevice
->base
.crit
);
268 newDevice
->base
.crit
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": SysKeyboardImpl*->base.crit");
269 newDevice
->subtype
= get_keyboard_subtype();
271 /* Create copy of default data format */
272 if (!(df
= HeapAlloc(GetProcessHeap(), 0, c_dfDIKeyboard
.dwSize
))) goto failed
;
273 memcpy(df
, &c_dfDIKeyboard
, c_dfDIKeyboard
.dwSize
);
274 if (!(df
->rgodf
= HeapAlloc(GetProcessHeap(), 0, df
->dwNumObjs
* df
->dwObjSize
))) goto failed
;
276 for (i
= 0; i
< df
->dwNumObjs
; i
++)
281 if (!GetKeyNameTextA(((i
& 0x7f) << 16) | ((i
& 0x80) << 17), buf
, sizeof(buf
)))
284 dik_code
= map_dik_code(i
, 0, newDevice
->subtype
, dinput
->dwVersion
);
285 memcpy(&df
->rgodf
[idx
], &c_dfDIKeyboard
.rgodf
[dik_code
], df
->dwObjSize
);
286 df
->rgodf
[idx
++].dwType
= DIDFT_MAKEINSTANCE(dik_code
) | DIDFT_PSHBUTTON
;
290 newDevice
->base
.data_format
.wine_df
= df
;
291 IDirectInput_AddRef(&newDevice
->base
.dinput
->IDirectInput7A_iface
);
296 if (df
) HeapFree(GetProcessHeap(), 0, df
->rgodf
);
297 HeapFree(GetProcessHeap(), 0, df
);
298 HeapFree(GetProcessHeap(), 0, newDevice
);
303 static HRESULT
keyboarddev_create_device(IDirectInputImpl
*dinput
, REFGUID rguid
, REFIID riid
, LPVOID
*pdev
, int unicode
)
305 TRACE("%p %s %s %p %i\n", dinput
, debugstr_guid(rguid
), debugstr_guid(riid
), pdev
, unicode
);
308 if (IsEqualGUID(&GUID_SysKeyboard
, rguid
)) /* Wine Keyboard */
310 SysKeyboardImpl
*This
;
314 else if (IsEqualGUID(&IID_IDirectInputDeviceA
, riid
) ||
315 IsEqualGUID(&IID_IDirectInputDevice2A
, riid
) ||
316 IsEqualGUID(&IID_IDirectInputDevice7A
, riid
) ||
317 IsEqualGUID(&IID_IDirectInputDevice8A
, riid
))
321 else if (IsEqualGUID(&IID_IDirectInputDeviceW
, riid
) ||
322 IsEqualGUID(&IID_IDirectInputDevice2W
, riid
) ||
323 IsEqualGUID(&IID_IDirectInputDevice7W
, riid
) ||
324 IsEqualGUID(&IID_IDirectInputDevice8W
, riid
))
330 WARN("no interface\n");
331 return DIERR_NOINTERFACE
;
334 This
= alloc_device(rguid
, dinput
);
335 TRACE("Created a Keyboard device (%p)\n", This
);
337 if (!This
) return DIERR_OUTOFMEMORY
;
340 *pdev
= &This
->base
.IDirectInputDevice8W_iface
;
342 *pdev
= &This
->base
.IDirectInputDevice8A_iface
;
347 return DIERR_DEVICENOTREG
;
350 const struct dinput_device keyboard_device
= {
351 "Wine keyboard driver",
352 keyboarddev_enum_deviceA
,
353 keyboarddev_enum_deviceW
,
354 keyboarddev_create_device
357 static HRESULT WINAPI
SysKeyboardWImpl_GetDeviceState(LPDIRECTINPUTDEVICE8W iface
, DWORD len
, LPVOID ptr
)
359 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
360 TRACE("(%p)->(%d,%p)\n", This
, len
, ptr
);
362 if (!This
->base
.acquired
) return DIERR_NOTACQUIRED
;
364 if (len
!= This
->base
.data_format
.user_df
->dwDataSize
)
365 return DIERR_INVALIDPARAM
;
367 check_dinput_events();
369 EnterCriticalSection(&This
->base
.crit
);
371 if (TRACE_ON(dinput
)) {
373 for (i
= 0; i
< WINE_DINPUT_KEYBOARD_MAX_KEYS
; i
++) {
374 if (This
->DInputKeyState
[i
] != 0x00)
375 TRACE(" - %02X: %02x\n", i
, This
->DInputKeyState
[i
]);
379 fill_DataFormat(ptr
, len
, This
->DInputKeyState
, &This
->base
.data_format
);
380 LeaveCriticalSection(&This
->base
.crit
);
385 static HRESULT WINAPI
SysKeyboardAImpl_GetDeviceState(LPDIRECTINPUTDEVICE8A iface
, DWORD len
, LPVOID ptr
)
387 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
388 return SysKeyboardWImpl_GetDeviceState(IDirectInputDevice8W_from_impl(This
), len
, ptr
);
391 /******************************************************************************
392 * GetCapabilities : get the device capabilities
394 static HRESULT WINAPI
SysKeyboardWImpl_GetCapabilities(LPDIRECTINPUTDEVICE8W iface
, LPDIDEVCAPS lpDIDevCaps
)
396 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
399 TRACE("(this=%p,%p)\n",This
,lpDIDevCaps
);
401 if ((lpDIDevCaps
->dwSize
!= sizeof(DIDEVCAPS
)) && (lpDIDevCaps
->dwSize
!= sizeof(DIDEVCAPS_DX3
))) {
402 WARN("invalid parameter\n");
403 return DIERR_INVALIDPARAM
;
406 devcaps
.dwSize
= lpDIDevCaps
->dwSize
;
407 devcaps
.dwFlags
= DIDC_ATTACHED
| DIDC_EMULATED
;
408 if (This
->base
.dinput
->dwVersion
>= 0x0800)
409 devcaps
.dwDevType
= DI8DEVTYPE_KEYBOARD
| (This
->subtype
<< 8);
411 devcaps
.dwDevType
= DIDEVTYPE_KEYBOARD
| (This
->subtype
<< 8);
413 devcaps
.dwButtons
= This
->base
.data_format
.wine_df
->dwNumObjs
;
415 devcaps
.dwFFSamplePeriod
= 0;
416 devcaps
.dwFFMinTimeResolution
= 0;
417 devcaps
.dwFirmwareRevision
= 100;
418 devcaps
.dwHardwareRevision
= 100;
419 devcaps
.dwFFDriverVersion
= 0;
421 memcpy(lpDIDevCaps
, &devcaps
, lpDIDevCaps
->dwSize
);
426 static HRESULT WINAPI
SysKeyboardAImpl_GetCapabilities(LPDIRECTINPUTDEVICE8A iface
, LPDIDEVCAPS lpDIDevCaps
)
428 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
429 return SysKeyboardWImpl_GetCapabilities(IDirectInputDevice8W_from_impl(This
), lpDIDevCaps
);
432 static DWORD
map_dik_to_scan(DWORD dik_code
, DWORD subtype
)
434 if (dik_code
== DIK_PAUSE
|| dik_code
== DIK_NUMLOCK
) dik_code
^= 0x80;
435 if (subtype
== DIDEVTYPEKEYBOARD_JAPAN106
)
466 /******************************************************************************
467 * GetObjectInfo : get information about a device object such as a button
470 static HRESULT WINAPI
471 SysKeyboardAImpl_GetObjectInfo(
472 LPDIRECTINPUTDEVICE8A iface
,
473 LPDIDEVICEOBJECTINSTANCEA pdidoi
,
477 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
481 res
= IDirectInputDevice2AImpl_GetObjectInfo(iface
, pdidoi
, dwObj
, dwHow
);
482 if (res
!= DI_OK
) return res
;
484 scan
= map_dik_to_scan(DIDFT_GETINSTANCE(pdidoi
->dwType
), This
->subtype
);
485 if (!GetKeyNameTextA((scan
& 0x80) << 17 | (scan
& 0x7f) << 16,
486 pdidoi
->tszName
, sizeof(pdidoi
->tszName
)))
487 return DIERR_OBJECTNOTFOUND
;
489 _dump_OBJECTINSTANCEA(pdidoi
);
493 static HRESULT WINAPI
SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface
,
494 LPDIDEVICEOBJECTINSTANCEW pdidoi
,
498 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
502 res
= IDirectInputDevice2WImpl_GetObjectInfo(iface
, pdidoi
, dwObj
, dwHow
);
503 if (res
!= DI_OK
) return res
;
505 scan
= map_dik_to_scan(DIDFT_GETINSTANCE(pdidoi
->dwType
), This
->subtype
);
506 if (!GetKeyNameTextW((scan
& 0x80) << 17 | (scan
& 0x7f) << 16,
507 pdidoi
->tszName
, ARRAY_SIZE(pdidoi
->tszName
)))
508 return DIERR_OBJECTNOTFOUND
;
510 _dump_OBJECTINSTANCEW(pdidoi
);
514 /******************************************************************************
515 * GetDeviceInfo : get information about a device's identity
517 static HRESULT WINAPI
SysKeyboardAImpl_GetDeviceInfo(
518 LPDIRECTINPUTDEVICE8A iface
,
519 LPDIDEVICEINSTANCEA pdidi
)
521 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
522 TRACE("(this=%p,%p)\n", This
, pdidi
);
524 fill_keyboard_dideviceinstanceA(pdidi
, This
->base
.dinput
->dwVersion
, This
->subtype
);
529 static HRESULT WINAPI
SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface
, LPDIDEVICEINSTANCEW pdidi
)
531 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
532 TRACE("(this=%p,%p)\n", This
, pdidi
);
534 if (pdidi
->dwSize
!= sizeof(DIDEVICEINSTANCEW
)) {
535 WARN(" dinput3 not supported yet...\n");
539 fill_keyboard_dideviceinstanceW(pdidi
, This
->base
.dinput
->dwVersion
, This
->subtype
);
544 /******************************************************************************
545 * GetProperty : Retrieves information about the input device.
547 static HRESULT WINAPI
SysKeyboardWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface
,
548 REFGUID rguid
, LPDIPROPHEADER pdiph
)
550 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
552 TRACE("(%p)->(%s,%p)\n", This
, debugstr_guid(rguid
), pdiph
);
553 _dump_DIPROPHEADER(pdiph
);
555 if (!IS_DIPROP(rguid
)) return DI_OK
;
557 switch (LOWORD(rguid
))
559 case (DWORD_PTR
)DIPROP_KEYNAME
:
562 LPDIPROPSTRING ps
= (LPDIPROPSTRING
)pdiph
;
563 DIDEVICEOBJECTINSTANCEW didoi
;
565 if (pdiph
->dwSize
!= sizeof(DIPROPSTRING
))
566 return DIERR_INVALIDPARAM
;
568 didoi
.dwSize
= sizeof(DIDEVICEOBJECTINSTANCEW
);
570 hr
= SysKeyboardWImpl_GetObjectInfo(iface
, &didoi
, ps
->diph
.dwObj
, ps
->diph
.dwHow
);
572 memcpy(ps
->wsz
, didoi
.tszName
, sizeof(ps
->wsz
));
575 case (DWORD_PTR
) DIPROP_VIDPID
:
576 case (DWORD_PTR
) DIPROP_RANGE
:
577 return DIERR_UNSUPPORTED
;
579 return IDirectInputDevice2AImpl_GetProperty( IDirectInputDevice8A_from_impl(This
), rguid
, pdiph
);
584 static HRESULT WINAPI
SysKeyboardAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface
,
585 REFGUID rguid
, LPDIPROPHEADER pdiph
)
587 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
588 return SysKeyboardWImpl_GetProperty(IDirectInputDevice8W_from_impl(This
), rguid
, pdiph
);
591 static HRESULT WINAPI
SysKeyboardWImpl_Acquire(LPDIRECTINPUTDEVICE8W iface
)
593 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
596 TRACE("(%p)\n", This
);
598 res
= IDirectInputDevice2WImpl_Acquire(iface
);
601 TRACE("clearing keystate\n");
602 memset(This
->DInputKeyState
, 0, sizeof(This
->DInputKeyState
));
608 static HRESULT WINAPI
SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface
)
610 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
611 return SysKeyboardWImpl_Acquire(IDirectInputDevice8W_from_impl(This
));
614 static HRESULT WINAPI
SysKeyboardWImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface
,
615 LPDIACTIONFORMATW lpdiaf
,
616 LPCWSTR lpszUserName
,
619 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
620 FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", This
, lpdiaf
, debugstr_w(lpszUserName
), dwFlags
);
622 return _build_action_map(iface
, lpdiaf
, lpszUserName
, dwFlags
, DIKEYBOARD_MASK
, &c_dfDIKeyboard
);
625 static HRESULT WINAPI
SysKeyboardAImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface
,
626 LPDIACTIONFORMATA lpdiaf
,
630 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
631 DIACTIONFORMATW diafW
;
633 WCHAR
*lpszUserNameW
= NULL
;
636 diafW
.rgoAction
= HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW
)*lpdiaf
->dwNumActions
);
637 _copy_diactionformatAtoW(&diafW
, lpdiaf
);
639 if (lpszUserName
!= NULL
)
641 username_size
= MultiByteToWideChar(CP_ACP
, 0, lpszUserName
, -1, NULL
, 0);
642 lpszUserNameW
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
)*username_size
);
643 MultiByteToWideChar(CP_ACP
, 0, lpszUserName
, -1, lpszUserNameW
, username_size
);
646 hr
= SysKeyboardWImpl_BuildActionMap(&This
->base
.IDirectInputDevice8W_iface
, &diafW
, lpszUserNameW
, dwFlags
);
648 _copy_diactionformatWtoA(lpdiaf
, &diafW
);
649 HeapFree(GetProcessHeap(), 0, diafW
.rgoAction
);
650 HeapFree(GetProcessHeap(), 0, lpszUserNameW
);
655 static HRESULT WINAPI
SysKeyboardWImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface
,
656 LPDIACTIONFORMATW lpdiaf
,
657 LPCWSTR lpszUserName
,
660 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
661 FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", This
, lpdiaf
, debugstr_w(lpszUserName
), dwFlags
);
663 return _set_action_map(iface
, lpdiaf
, lpszUserName
, dwFlags
, &c_dfDIKeyboard
);
666 static HRESULT WINAPI
SysKeyboardAImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface
,
667 LPDIACTIONFORMATA lpdiaf
,
671 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
672 DIACTIONFORMATW diafW
;
674 WCHAR
*lpszUserNameW
= NULL
;
677 diafW
.rgoAction
= HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW
)*lpdiaf
->dwNumActions
);
678 _copy_diactionformatAtoW(&diafW
, lpdiaf
);
680 if (lpszUserName
!= NULL
)
682 username_size
= MultiByteToWideChar(CP_ACP
, 0, lpszUserName
, -1, NULL
, 0);
683 lpszUserNameW
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
)*username_size
);
684 MultiByteToWideChar(CP_ACP
, 0, lpszUserName
, -1, lpszUserNameW
, username_size
);
687 hr
= SysKeyboardWImpl_SetActionMap(&This
->base
.IDirectInputDevice8W_iface
, &diafW
, lpszUserNameW
, dwFlags
);
689 HeapFree(GetProcessHeap(), 0, diafW
.rgoAction
);
690 HeapFree(GetProcessHeap(), 0, lpszUserNameW
);
695 static const IDirectInputDevice8AVtbl SysKeyboardAvt
=
697 IDirectInputDevice2AImpl_QueryInterface
,
698 IDirectInputDevice2AImpl_AddRef
,
699 IDirectInputDevice2AImpl_Release
,
700 SysKeyboardAImpl_GetCapabilities
,
701 IDirectInputDevice2AImpl_EnumObjects
,
702 SysKeyboardAImpl_GetProperty
,
703 IDirectInputDevice2AImpl_SetProperty
,
704 SysKeyboardAImpl_Acquire
,
705 IDirectInputDevice2AImpl_Unacquire
,
706 SysKeyboardAImpl_GetDeviceState
,
707 IDirectInputDevice2AImpl_GetDeviceData
,
708 IDirectInputDevice2AImpl_SetDataFormat
,
709 IDirectInputDevice2AImpl_SetEventNotification
,
710 IDirectInputDevice2AImpl_SetCooperativeLevel
,
711 SysKeyboardAImpl_GetObjectInfo
,
712 SysKeyboardAImpl_GetDeviceInfo
,
713 IDirectInputDevice2AImpl_RunControlPanel
,
714 IDirectInputDevice2AImpl_Initialize
,
715 IDirectInputDevice2AImpl_CreateEffect
,
716 IDirectInputDevice2AImpl_EnumEffects
,
717 IDirectInputDevice2AImpl_GetEffectInfo
,
718 IDirectInputDevice2AImpl_GetForceFeedbackState
,
719 IDirectInputDevice2AImpl_SendForceFeedbackCommand
,
720 IDirectInputDevice2AImpl_EnumCreatedEffectObjects
,
721 IDirectInputDevice2AImpl_Escape
,
722 IDirectInputDevice2AImpl_Poll
,
723 IDirectInputDevice2AImpl_SendDeviceData
,
724 IDirectInputDevice7AImpl_EnumEffectsInFile
,
725 IDirectInputDevice7AImpl_WriteEffectToFile
,
726 SysKeyboardAImpl_BuildActionMap
,
727 SysKeyboardAImpl_SetActionMap
,
728 IDirectInputDevice8AImpl_GetImageInfo
731 static const IDirectInputDevice8WVtbl SysKeyboardWvt
=
733 IDirectInputDevice2WImpl_QueryInterface
,
734 IDirectInputDevice2WImpl_AddRef
,
735 IDirectInputDevice2WImpl_Release
,
736 SysKeyboardWImpl_GetCapabilities
,
737 IDirectInputDevice2WImpl_EnumObjects
,
738 SysKeyboardWImpl_GetProperty
,
739 IDirectInputDevice2WImpl_SetProperty
,
740 SysKeyboardWImpl_Acquire
,
741 IDirectInputDevice2WImpl_Unacquire
,
742 SysKeyboardWImpl_GetDeviceState
,
743 IDirectInputDevice2WImpl_GetDeviceData
,
744 IDirectInputDevice2WImpl_SetDataFormat
,
745 IDirectInputDevice2WImpl_SetEventNotification
,
746 IDirectInputDevice2WImpl_SetCooperativeLevel
,
747 SysKeyboardWImpl_GetObjectInfo
,
748 SysKeyboardWImpl_GetDeviceInfo
,
749 IDirectInputDevice2WImpl_RunControlPanel
,
750 IDirectInputDevice2WImpl_Initialize
,
751 IDirectInputDevice2WImpl_CreateEffect
,
752 IDirectInputDevice2WImpl_EnumEffects
,
753 IDirectInputDevice2WImpl_GetEffectInfo
,
754 IDirectInputDevice2WImpl_GetForceFeedbackState
,
755 IDirectInputDevice2WImpl_SendForceFeedbackCommand
,
756 IDirectInputDevice2WImpl_EnumCreatedEffectObjects
,
757 IDirectInputDevice2WImpl_Escape
,
758 IDirectInputDevice2WImpl_Poll
,
759 IDirectInputDevice2WImpl_SendDeviceData
,
760 IDirectInputDevice7WImpl_EnumEffectsInFile
,
761 IDirectInputDevice7WImpl_WriteEffectToFile
,
762 SysKeyboardWImpl_BuildActionMap
,
763 SysKeyboardWImpl_SetActionMap
,
764 IDirectInputDevice8WImpl_GetImageInfo