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
];
53 static inline SysKeyboardImpl
*impl_from_IDirectInputDevice8A(IDirectInputDevice8A
*iface
)
55 return CONTAINING_RECORD(CONTAINING_RECORD(iface
, IDirectInputDeviceImpl
, IDirectInputDevice8A_iface
), SysKeyboardImpl
, base
);
57 static inline SysKeyboardImpl
*impl_from_IDirectInputDevice8W(IDirectInputDevice8W
*iface
)
59 return CONTAINING_RECORD(CONTAINING_RECORD(iface
, IDirectInputDeviceImpl
, IDirectInputDevice8W_iface
), SysKeyboardImpl
, base
);
61 static inline IDirectInputDevice8A
*IDirectInputDevice8A_from_impl(SysKeyboardImpl
*This
)
63 return &This
->base
.IDirectInputDevice8A_iface
;
65 static inline IDirectInputDevice8W
*IDirectInputDevice8W_from_impl(SysKeyboardImpl
*This
)
67 return &This
->base
.IDirectInputDevice8W_iface
;
70 static BYTE
map_dik_code(DWORD scanCode
, DWORD vkCode
)
72 static const BYTE asciiCodes
[] =
73 {/*32*/ DIK_SPACE
,0,0,0,0,0,0,DIK_APOSTROPHE
,
74 /*40*/ 0,0,0,0,DIK_COMMA
,DIK_MINUS
,DIK_PERIOD
,DIK_SLASH
,
75 /*48*/ DIK_0
,DIK_1
,DIK_2
,DIK_3
,DIK_4
,DIK_5
,DIK_6
,DIK_7
,
76 /*56*/ DIK_8
,DIK_9
,DIK_COLON
,DIK_SEMICOLON
,0,DIK_EQUALS
,0,0,
77 /*64*/ DIK_AT
,DIK_A
,DIK_B
,DIK_C
,DIK_D
,DIK_E
,DIK_F
,DIK_G
,
78 /*72*/ DIK_H
,DIK_I
,DIK_J
,DIK_K
,DIK_L
,DIK_M
,DIK_N
,DIK_O
,
79 /*80*/ DIK_P
,DIK_Q
,DIK_R
,DIK_S
,DIK_T
,DIK_U
,DIK_V
,DIK_W
,
80 /*88*/ DIK_X
,DIK_Y
,DIK_Z
,DIK_LBRACKET
,0,DIK_RBRACKET
,DIK_CIRCUMFLEX
,DIK_UNDERLINE
} /*95*/ ;
83 WCHAR c
= MapVirtualKeyW(vkCode
,MAPVK_VK_TO_CHAR
);
86 out_code
= asciiCodes
[c
- 32];
94 static int KeyboardCallback( LPDIRECTINPUTDEVICE8A iface
, WPARAM wparam
, LPARAM lparam
)
96 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
97 int dik_code
, ret
= This
->base
.dwCoopLevel
& DISCL_EXCLUSIVE
;
98 KBDLLHOOKSTRUCT
*hook
= (KBDLLHOOKSTRUCT
*)lparam
;
101 if (wparam
!= WM_KEYDOWN
&& wparam
!= WM_KEYUP
&&
102 wparam
!= WM_SYSKEYDOWN
&& wparam
!= WM_SYSKEYUP
)
105 TRACE("(%p) %ld,%ld\n", iface
, wparam
, lparam
);
107 switch (hook
->vkCode
)
109 /* R-Shift is special - it is an extended key with separate scan code */
110 case VK_RSHIFT
: dik_code
= DIK_RSHIFT
; break;
111 case VK_PAUSE
: dik_code
= DIK_PAUSE
; break;
112 case VK_NUMLOCK
: dik_code
= DIK_NUMLOCK
; break;
113 case VK_SUBTRACT
: dik_code
= DIK_SUBTRACT
; break;
115 dik_code
= map_dik_code(hook
->scanCode
& 0xff, hook
->vkCode
);
116 if (hook
->flags
& LLKHF_EXTENDED
) dik_code
|= 0x80;
118 new_diks
= hook
->flags
& LLKHF_UP
? 0 : 0x80;
120 /* returns now if key event already known */
121 if (new_diks
== This
->DInputKeyState
[dik_code
])
124 This
->DInputKeyState
[dik_code
] = new_diks
;
125 TRACE(" setting %02X to %02X\n", dik_code
, This
->DInputKeyState
[dik_code
]);
127 EnterCriticalSection(&This
->base
.crit
);
128 queue_event(iface
, DIDFT_MAKEINSTANCE(dik_code
) | DIDFT_PSHBUTTON
,
129 new_diks
, GetCurrentTime(), This
->base
.dinput
->evsequence
++);
130 LeaveCriticalSection(&This
->base
.crit
);
135 const GUID DInput_Wine_Keyboard_GUID
= { /* 0ab8648a-7735-11d2-8c73-71df54a96441 */
136 0x0ab8648a, 0x7735, 0x11d2, {0x8c, 0x73, 0x71, 0xdf, 0x54, 0xa9, 0x64, 0x41}
139 static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi
, DWORD version
) {
141 DIDEVICEINSTANCEA ddi
;
143 dwSize
= lpddi
->dwSize
;
145 TRACE("%d %p\n", dwSize
, lpddi
);
147 memset(lpddi
, 0, dwSize
);
148 memset(&ddi
, 0, sizeof(ddi
));
151 ddi
.guidInstance
= GUID_SysKeyboard
;/* DInput's GUID */
152 ddi
.guidProduct
= DInput_Wine_Keyboard_GUID
; /* Vendor's GUID */
153 if (version
>= 0x0800)
154 ddi
.dwDevType
= DI8DEVTYPE_KEYBOARD
| (DI8DEVTYPEKEYBOARD_UNKNOWN
<< 8);
156 ddi
.dwDevType
= DIDEVTYPE_KEYBOARD
| (DIDEVTYPEKEYBOARD_UNKNOWN
<< 8);
157 strcpy(ddi
.tszInstanceName
, "Keyboard");
158 strcpy(ddi
.tszProductName
, "Wine Keyboard");
160 memcpy(lpddi
, &ddi
, (dwSize
< sizeof(ddi
) ? dwSize
: sizeof(ddi
)));
163 static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi
, DWORD version
) {
165 DIDEVICEINSTANCEW ddi
;
167 dwSize
= lpddi
->dwSize
;
169 TRACE("%d %p\n", dwSize
, lpddi
);
171 memset(lpddi
, 0, dwSize
);
172 memset(&ddi
, 0, sizeof(ddi
));
175 ddi
.guidInstance
= GUID_SysKeyboard
;/* DInput's GUID */
176 ddi
.guidProduct
= DInput_Wine_Keyboard_GUID
; /* Vendor's GUID */
177 if (version
>= 0x0800)
178 ddi
.dwDevType
= DI8DEVTYPE_KEYBOARD
| (DI8DEVTYPEKEYBOARD_UNKNOWN
<< 8);
180 ddi
.dwDevType
= DIDEVTYPE_KEYBOARD
| (DIDEVTYPEKEYBOARD_UNKNOWN
<< 8);
181 MultiByteToWideChar(CP_ACP
, 0, "Keyboard", -1, ddi
.tszInstanceName
, MAX_PATH
);
182 MultiByteToWideChar(CP_ACP
, 0, "Wine Keyboard", -1, ddi
.tszProductName
, MAX_PATH
);
184 memcpy(lpddi
, &ddi
, (dwSize
< sizeof(ddi
) ? dwSize
: sizeof(ddi
)));
187 static HRESULT
keyboarddev_enum_deviceA(DWORD dwDevType
, DWORD dwFlags
, LPDIDEVICEINSTANCEA lpddi
, DWORD version
, int id
)
192 if ((dwDevType
== 0) ||
193 ((dwDevType
== DIDEVTYPE_KEYBOARD
) && (version
< 0x0800)) ||
194 (((dwDevType
== DI8DEVCLASS_KEYBOARD
) || (dwDevType
== DI8DEVTYPE_KEYBOARD
)) && (version
>= 0x0800))) {
195 TRACE("Enumerating the Keyboard device\n");
197 fill_keyboard_dideviceinstanceA(lpddi
, version
);
205 static HRESULT
keyboarddev_enum_deviceW(DWORD dwDevType
, DWORD dwFlags
, LPDIDEVICEINSTANCEW lpddi
, DWORD version
, int id
)
210 if ((dwDevType
== 0) ||
211 ((dwDevType
== DIDEVTYPE_KEYBOARD
) && (version
< 0x0800)) ||
212 (((dwDevType
== DI8DEVCLASS_KEYBOARD
) || (dwDevType
== DI8DEVTYPE_KEYBOARD
)) && (version
>= 0x0800))) {
213 TRACE("Enumerating the Keyboard device\n");
215 fill_keyboard_dideviceinstanceW(lpddi
, version
);
223 static SysKeyboardImpl
*alloc_device(REFGUID rguid
, IDirectInputImpl
*dinput
)
225 SysKeyboardImpl
* newDevice
;
226 LPDIDATAFORMAT df
= NULL
;
229 newDevice
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(SysKeyboardImpl
));
230 newDevice
->base
.IDirectInputDevice8A_iface
.lpVtbl
= &SysKeyboardAvt
;
231 newDevice
->base
.IDirectInputDevice8W_iface
.lpVtbl
= &SysKeyboardWvt
;
232 newDevice
->base
.ref
= 1;
233 memcpy(&newDevice
->base
.guid
, rguid
, sizeof(*rguid
));
234 newDevice
->base
.dinput
= dinput
;
235 newDevice
->base
.event_proc
= KeyboardCallback
;
236 InitializeCriticalSection(&newDevice
->base
.crit
);
237 newDevice
->base
.crit
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": SysKeyboardImpl*->base.crit");
239 /* Create copy of default data format */
240 if (!(df
= HeapAlloc(GetProcessHeap(), 0, c_dfDIKeyboard
.dwSize
))) goto failed
;
241 memcpy(df
, &c_dfDIKeyboard
, c_dfDIKeyboard
.dwSize
);
242 if (!(df
->rgodf
= HeapAlloc(GetProcessHeap(), 0, df
->dwNumObjs
* df
->dwObjSize
))) goto failed
;
244 for (i
= 0; i
< df
->dwNumObjs
; i
++)
248 if (!GetKeyNameTextA(((i
& 0x7f) << 16) | ((i
& 0x80) << 17), buf
, sizeof(buf
)))
251 memcpy(&df
->rgodf
[idx
], &c_dfDIKeyboard
.rgodf
[i
], df
->dwObjSize
);
252 df
->rgodf
[idx
++].dwType
= DIDFT_MAKEINSTANCE(i
) | DIDFT_PSHBUTTON
;
256 newDevice
->base
.data_format
.wine_df
= df
;
257 IDirectInput_AddRef(&newDevice
->base
.dinput
->IDirectInput7A_iface
);
259 EnterCriticalSection(&dinput
->crit
);
260 list_add_tail(&dinput
->devices_list
, &newDevice
->base
.entry
);
261 LeaveCriticalSection(&dinput
->crit
);
266 if (df
) HeapFree(GetProcessHeap(), 0, df
->rgodf
);
267 HeapFree(GetProcessHeap(), 0, df
);
268 HeapFree(GetProcessHeap(), 0, newDevice
);
273 static HRESULT
keyboarddev_create_device(IDirectInputImpl
*dinput
, REFGUID rguid
, REFIID riid
, LPVOID
*pdev
, int unicode
)
275 TRACE("%p %s %s %p %i\n", dinput
, debugstr_guid(rguid
), debugstr_guid(riid
), pdev
, unicode
);
278 if (IsEqualGUID(&GUID_SysKeyboard
, rguid
) || /* Generic Keyboard */
279 IsEqualGUID(&DInput_Wine_Keyboard_GUID
, rguid
)) /* Wine Keyboard */
281 SysKeyboardImpl
*This
;
285 else if (IsEqualGUID(&IID_IDirectInputDeviceA
, riid
) ||
286 IsEqualGUID(&IID_IDirectInputDevice2A
, riid
) ||
287 IsEqualGUID(&IID_IDirectInputDevice7A
, riid
) ||
288 IsEqualGUID(&IID_IDirectInputDevice8A
, riid
))
292 else if (IsEqualGUID(&IID_IDirectInputDeviceW
, riid
) ||
293 IsEqualGUID(&IID_IDirectInputDevice2W
, riid
) ||
294 IsEqualGUID(&IID_IDirectInputDevice7W
, riid
) ||
295 IsEqualGUID(&IID_IDirectInputDevice8W
, riid
))
301 WARN("no interface\n");
302 return DIERR_NOINTERFACE
;
305 This
= alloc_device(rguid
, dinput
);
306 TRACE("Created a Keyboard device (%p)\n", This
);
308 if (!This
) return DIERR_OUTOFMEMORY
;
311 *pdev
= &This
->base
.IDirectInputDevice8W_iface
;
313 *pdev
= &This
->base
.IDirectInputDevice8A_iface
;
318 return DIERR_DEVICENOTREG
;
321 const struct dinput_device keyboard_device
= {
322 "Wine keyboard driver",
323 keyboarddev_enum_deviceA
,
324 keyboarddev_enum_deviceW
,
325 keyboarddev_create_device
328 static HRESULT WINAPI
SysKeyboardWImpl_GetDeviceState(LPDIRECTINPUTDEVICE8W iface
, DWORD len
, LPVOID ptr
)
330 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
331 TRACE("(%p)->(%d,%p)\n", This
, len
, ptr
);
333 if (!This
->base
.acquired
) return DIERR_NOTACQUIRED
;
335 if (len
!= This
->base
.data_format
.user_df
->dwDataSize
)
336 return DIERR_INVALIDPARAM
;
338 check_dinput_events();
340 EnterCriticalSection(&This
->base
.crit
);
342 if (TRACE_ON(dinput
)) {
344 for (i
= 0; i
< WINE_DINPUT_KEYBOARD_MAX_KEYS
; i
++) {
345 if (This
->DInputKeyState
[i
] != 0x00)
346 TRACE(" - %02X: %02x\n", i
, This
->DInputKeyState
[i
]);
350 fill_DataFormat(ptr
, len
, This
->DInputKeyState
, &This
->base
.data_format
);
351 LeaveCriticalSection(&This
->base
.crit
);
356 static HRESULT WINAPI
SysKeyboardAImpl_GetDeviceState(LPDIRECTINPUTDEVICE8A iface
, DWORD len
, LPVOID ptr
)
358 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
359 return SysKeyboardWImpl_GetDeviceState(IDirectInputDevice8W_from_impl(This
), len
, ptr
);
362 /******************************************************************************
363 * GetCapabilities : get the device capabilities
365 static HRESULT WINAPI
SysKeyboardWImpl_GetCapabilities(LPDIRECTINPUTDEVICE8W iface
, LPDIDEVCAPS lpDIDevCaps
)
367 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
370 TRACE("(this=%p,%p)\n",This
,lpDIDevCaps
);
372 if ((lpDIDevCaps
->dwSize
!= sizeof(DIDEVCAPS
)) && (lpDIDevCaps
->dwSize
!= sizeof(DIDEVCAPS_DX3
))) {
373 WARN("invalid parameter\n");
374 return DIERR_INVALIDPARAM
;
377 devcaps
.dwSize
= lpDIDevCaps
->dwSize
;
378 devcaps
.dwFlags
= DIDC_ATTACHED
| DIDC_EMULATED
;
379 if (This
->base
.dinput
->dwVersion
>= 0x0800)
380 devcaps
.dwDevType
= DI8DEVTYPE_KEYBOARD
| (DI8DEVTYPEKEYBOARD_PCENH
<< 8);
382 devcaps
.dwDevType
= DIDEVTYPE_KEYBOARD
| (DIDEVTYPEKEYBOARD_PCENH
<< 8);
384 devcaps
.dwButtons
= This
->base
.data_format
.wine_df
->dwNumObjs
;
386 devcaps
.dwFFSamplePeriod
= 0;
387 devcaps
.dwFFMinTimeResolution
= 0;
388 devcaps
.dwFirmwareRevision
= 100;
389 devcaps
.dwHardwareRevision
= 100;
390 devcaps
.dwFFDriverVersion
= 0;
392 memcpy(lpDIDevCaps
, &devcaps
, lpDIDevCaps
->dwSize
);
397 static HRESULT WINAPI
SysKeyboardAImpl_GetCapabilities(LPDIRECTINPUTDEVICE8A iface
, LPDIDEVCAPS lpDIDevCaps
)
399 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
400 return SysKeyboardWImpl_GetCapabilities(IDirectInputDevice8W_from_impl(This
), lpDIDevCaps
);
403 /******************************************************************************
404 * GetObjectInfo : get information about a device object such as a button
407 static HRESULT WINAPI
408 SysKeyboardAImpl_GetObjectInfo(
409 LPDIRECTINPUTDEVICE8A iface
,
410 LPDIDEVICEOBJECTINSTANCEA pdidoi
,
417 res
= IDirectInputDevice2AImpl_GetObjectInfo(iface
, pdidoi
, dwObj
, dwHow
);
418 if (res
!= DI_OK
) return res
;
420 scan
= DIDFT_GETINSTANCE(pdidoi
->dwType
);
421 if (scan
== DIK_PAUSE
|| scan
== DIK_NUMLOCK
) scan
^= 0x80;
422 if (!GetKeyNameTextA((scan
& 0x80) << 17 | (scan
& 0x7f) << 16,
423 pdidoi
->tszName
, sizeof(pdidoi
->tszName
)))
424 return DIERR_OBJECTNOTFOUND
;
426 _dump_OBJECTINSTANCEA(pdidoi
);
430 static HRESULT WINAPI
SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface
,
431 LPDIDEVICEOBJECTINSTANCEW pdidoi
,
438 res
= IDirectInputDevice2WImpl_GetObjectInfo(iface
, pdidoi
, dwObj
, dwHow
);
439 if (res
!= DI_OK
) return res
;
441 scan
= DIDFT_GETINSTANCE(pdidoi
->dwType
);
442 if (scan
== DIK_PAUSE
|| scan
== DIK_NUMLOCK
) scan
^= 0x80;
443 if (!GetKeyNameTextW((scan
& 0x80) << 17 | (scan
& 0x7f) << 16,
444 pdidoi
->tszName
, sizeof(pdidoi
->tszName
)/sizeof(pdidoi
->tszName
[0])))
445 return DIERR_OBJECTNOTFOUND
;
447 _dump_OBJECTINSTANCEW(pdidoi
);
451 /******************************************************************************
452 * GetDeviceInfo : get information about a device's identity
454 static HRESULT WINAPI
SysKeyboardAImpl_GetDeviceInfo(
455 LPDIRECTINPUTDEVICE8A iface
,
456 LPDIDEVICEINSTANCEA pdidi
)
458 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
459 TRACE("(this=%p,%p)\n", This
, pdidi
);
461 if (pdidi
->dwSize
!= sizeof(DIDEVICEINSTANCEA
)) {
462 WARN(" dinput3 not supported yet...\n");
466 fill_keyboard_dideviceinstanceA(pdidi
, This
->base
.dinput
->dwVersion
);
471 static HRESULT WINAPI
SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface
, LPDIDEVICEINSTANCEW pdidi
)
473 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
474 TRACE("(this=%p,%p)\n", This
, pdidi
);
476 if (pdidi
->dwSize
!= sizeof(DIDEVICEINSTANCEW
)) {
477 WARN(" dinput3 not supported yet...\n");
481 fill_keyboard_dideviceinstanceW(pdidi
, This
->base
.dinput
->dwVersion
);
486 /******************************************************************************
487 * GetProperty : Retrieves information about the input device.
489 static HRESULT WINAPI
SysKeyboardWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface
,
490 REFGUID rguid
, LPDIPROPHEADER pdiph
)
492 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
494 TRACE("(%p) %s,%p\n", iface
, debugstr_guid(rguid
), pdiph
);
495 _dump_DIPROPHEADER(pdiph
);
497 if (!IS_DIPROP(rguid
)) return DI_OK
;
499 switch (LOWORD(rguid
))
501 case (DWORD_PTR
)DIPROP_KEYNAME
:
504 LPDIPROPSTRING ps
= (LPDIPROPSTRING
)pdiph
;
505 DIDEVICEOBJECTINSTANCEW didoi
;
507 if (pdiph
->dwSize
!= sizeof(DIPROPSTRING
))
508 return DIERR_INVALIDPARAM
;
510 didoi
.dwSize
= sizeof(DIDEVICEOBJECTINSTANCEW
);
512 hr
= SysKeyboardWImpl_GetObjectInfo(iface
, &didoi
, ps
->diph
.dwObj
, ps
->diph
.dwHow
);
514 memcpy(ps
->wsz
, didoi
.tszName
, sizeof(ps
->wsz
));
517 case (DWORD_PTR
) DIPROP_RANGE
:
518 return DIERR_UNSUPPORTED
;
520 return IDirectInputDevice2AImpl_GetProperty( IDirectInputDevice8A_from_impl(This
), rguid
, pdiph
);
525 static HRESULT WINAPI
SysKeyboardAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface
,
526 REFGUID rguid
, LPDIPROPHEADER pdiph
)
528 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
529 return SysKeyboardWImpl_GetProperty(IDirectInputDevice8W_from_impl(This
), rguid
, pdiph
);
532 static HRESULT WINAPI
SysKeyboardWImpl_Acquire(LPDIRECTINPUTDEVICE8W iface
)
534 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
537 TRACE("(%p)\n", This
);
539 res
= IDirectInputDevice2WImpl_Acquire(iface
);
542 TRACE("clearing keystate\n");
543 memset(This
->DInputKeyState
, 0, sizeof(This
->DInputKeyState
));
549 static HRESULT WINAPI
SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface
)
551 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
552 return SysKeyboardWImpl_Acquire(IDirectInputDevice8W_from_impl(This
));
555 static HRESULT WINAPI
SysKeyboardWImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface
,
556 LPDIACTIONFORMATW lpdiaf
,
557 LPCWSTR lpszUserName
,
560 FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface
, lpdiaf
, debugstr_w(lpszUserName
), dwFlags
);
562 return _build_action_map(iface
, lpdiaf
, lpszUserName
, dwFlags
, DIKEYBOARD_MASK
, &c_dfDIKeyboard
);
565 static HRESULT WINAPI
SysKeyboardAImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface
,
566 LPDIACTIONFORMATA lpdiaf
,
570 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
571 DIACTIONFORMATW diafW
;
573 WCHAR
*lpszUserNameW
= NULL
;
576 diafW
.rgoAction
= HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW
)*lpdiaf
->dwNumActions
);
577 _copy_diactionformatAtoW(&diafW
, lpdiaf
);
579 if (lpszUserName
!= NULL
)
581 username_size
= MultiByteToWideChar(CP_ACP
, 0, lpszUserName
, -1, NULL
, 0);
582 lpszUserNameW
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
)*username_size
);
583 MultiByteToWideChar(CP_ACP
, 0, lpszUserName
, -1, lpszUserNameW
, username_size
);
586 hr
= SysKeyboardWImpl_BuildActionMap(&This
->base
.IDirectInputDevice8W_iface
, &diafW
, lpszUserNameW
, dwFlags
);
588 _copy_diactionformatWtoA(lpdiaf
, &diafW
);
589 HeapFree(GetProcessHeap(), 0, diafW
.rgoAction
);
590 HeapFree(GetProcessHeap(), 0, lpszUserNameW
);
595 static HRESULT WINAPI
SysKeyboardWImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface
,
596 LPDIACTIONFORMATW lpdiaf
,
597 LPCWSTR lpszUserName
,
600 FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface
, lpdiaf
, debugstr_w(lpszUserName
), dwFlags
);
602 return _set_action_map(iface
, lpdiaf
, lpszUserName
, dwFlags
, &c_dfDIKeyboard
);
605 static HRESULT WINAPI
SysKeyboardAImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface
,
606 LPDIACTIONFORMATA lpdiaf
,
610 SysKeyboardImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
611 DIACTIONFORMATW diafW
;
613 WCHAR
*lpszUserNameW
= NULL
;
616 diafW
.rgoAction
= HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW
)*lpdiaf
->dwNumActions
);
617 _copy_diactionformatAtoW(&diafW
, lpdiaf
);
619 if (lpszUserName
!= NULL
)
621 username_size
= MultiByteToWideChar(CP_ACP
, 0, lpszUserName
, -1, NULL
, 0);
622 lpszUserNameW
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
)*username_size
);
623 MultiByteToWideChar(CP_ACP
, 0, lpszUserName
, -1, lpszUserNameW
, username_size
);
626 hr
= SysKeyboardWImpl_SetActionMap(&This
->base
.IDirectInputDevice8W_iface
, &diafW
, lpszUserNameW
, dwFlags
);
628 HeapFree(GetProcessHeap(), 0, diafW
.rgoAction
);
629 HeapFree(GetProcessHeap(), 0, lpszUserNameW
);
634 static const IDirectInputDevice8AVtbl SysKeyboardAvt
=
636 IDirectInputDevice2AImpl_QueryInterface
,
637 IDirectInputDevice2AImpl_AddRef
,
638 IDirectInputDevice2AImpl_Release
,
639 SysKeyboardAImpl_GetCapabilities
,
640 IDirectInputDevice2AImpl_EnumObjects
,
641 SysKeyboardAImpl_GetProperty
,
642 IDirectInputDevice2AImpl_SetProperty
,
643 SysKeyboardAImpl_Acquire
,
644 IDirectInputDevice2AImpl_Unacquire
,
645 SysKeyboardAImpl_GetDeviceState
,
646 IDirectInputDevice2AImpl_GetDeviceData
,
647 IDirectInputDevice2AImpl_SetDataFormat
,
648 IDirectInputDevice2AImpl_SetEventNotification
,
649 IDirectInputDevice2AImpl_SetCooperativeLevel
,
650 SysKeyboardAImpl_GetObjectInfo
,
651 SysKeyboardAImpl_GetDeviceInfo
,
652 IDirectInputDevice2AImpl_RunControlPanel
,
653 IDirectInputDevice2AImpl_Initialize
,
654 IDirectInputDevice2AImpl_CreateEffect
,
655 IDirectInputDevice2AImpl_EnumEffects
,
656 IDirectInputDevice2AImpl_GetEffectInfo
,
657 IDirectInputDevice2AImpl_GetForceFeedbackState
,
658 IDirectInputDevice2AImpl_SendForceFeedbackCommand
,
659 IDirectInputDevice2AImpl_EnumCreatedEffectObjects
,
660 IDirectInputDevice2AImpl_Escape
,
661 IDirectInputDevice2AImpl_Poll
,
662 IDirectInputDevice2AImpl_SendDeviceData
,
663 IDirectInputDevice7AImpl_EnumEffectsInFile
,
664 IDirectInputDevice7AImpl_WriteEffectToFile
,
665 SysKeyboardAImpl_BuildActionMap
,
666 SysKeyboardAImpl_SetActionMap
,
667 IDirectInputDevice8AImpl_GetImageInfo
670 static const IDirectInputDevice8WVtbl SysKeyboardWvt
=
672 IDirectInputDevice2WImpl_QueryInterface
,
673 IDirectInputDevice2WImpl_AddRef
,
674 IDirectInputDevice2WImpl_Release
,
675 SysKeyboardWImpl_GetCapabilities
,
676 IDirectInputDevice2WImpl_EnumObjects
,
677 SysKeyboardWImpl_GetProperty
,
678 IDirectInputDevice2WImpl_SetProperty
,
679 SysKeyboardWImpl_Acquire
,
680 IDirectInputDevice2WImpl_Unacquire
,
681 SysKeyboardWImpl_GetDeviceState
,
682 IDirectInputDevice2WImpl_GetDeviceData
,
683 IDirectInputDevice2WImpl_SetDataFormat
,
684 IDirectInputDevice2WImpl_SetEventNotification
,
685 IDirectInputDevice2WImpl_SetCooperativeLevel
,
686 SysKeyboardWImpl_GetObjectInfo
,
687 SysKeyboardWImpl_GetDeviceInfo
,
688 IDirectInputDevice2WImpl_RunControlPanel
,
689 IDirectInputDevice2WImpl_Initialize
,
690 IDirectInputDevice2WImpl_CreateEffect
,
691 IDirectInputDevice2WImpl_EnumEffects
,
692 IDirectInputDevice2WImpl_GetEffectInfo
,
693 IDirectInputDevice2WImpl_GetForceFeedbackState
,
694 IDirectInputDevice2WImpl_SendForceFeedbackCommand
,
695 IDirectInputDevice2WImpl_EnumCreatedEffectObjects
,
696 IDirectInputDevice2WImpl_Escape
,
697 IDirectInputDevice2WImpl_Poll
,
698 IDirectInputDevice2WImpl_SendDeviceData
,
699 IDirectInputDevice7WImpl_EnumEffectsInFile
,
700 IDirectInputDevice7WImpl_WriteEffectToFile
,
701 SysKeyboardWImpl_BuildActionMap
,
702 SysKeyboardWImpl_SetActionMap
,
703 IDirectInputDevice8WImpl_GetImageInfo