1 /* DirectInput Keyboard device
3 * Copyright 1998 Marcus Meissner
4 * Copyright 1998,1999 Lionel Ulmer
5 * Copyright 2000-2001 TransGaming Technologies Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "wine/port.h"
33 #include "dinput_private.h"
34 #include "device_private.h"
35 #include "wine/debug.h"
36 #include "wine/unicode.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(dinput
);
40 static IDirectInputDevice8AVtbl SysKeyboardAvt
;
41 static IDirectInputDevice8WVtbl SysKeyboardWvt
;
43 typedef struct SysKeyboardImpl SysKeyboardImpl
;
44 struct SysKeyboardImpl
50 IDirectInputImpl
* dinput
;
53 /* SysKeyboardAImpl */
55 int buffersize
; /* set in 'SetProperty' */
56 LPDIDEVICEOBJECTDATA buffer
; /* buffer for 'GetDeviceData'.
57 Alloc at 'Acquire', Free at
59 int count
; /* number of objects in use in
61 int start
; /* 'buffer' rotates. This is the
62 first in use (if count > 0) */
63 BOOL overflow
; /* return DI_BUFFEROVERFLOW in
65 CRITICAL_SECTION crit
;
68 SysKeyboardImpl
*current
; /* Today's acquired device
69 FIXME: currently this can be only one.
70 Maybe this should be a linked list or st.
71 I don't know what the rules are for multiple acquired keyboards,
72 but 'DI_LOSTFOCUS' and 'DI_UNACQUIRED' exist for a reason.
75 static BYTE DInputKeyState
[256]; /* array for 'GetDeviceState' */
77 static CRITICAL_SECTION keyboard_crit
;
78 static CRITICAL_SECTION_DEBUG critsect_debug
=
81 { &critsect_debug
.ProcessLocksList
, &critsect_debug
.ProcessLocksList
},
82 0, 0, { 0, (DWORD
)(__FILE__
": keyboard_crit") }
84 static CRITICAL_SECTION keyboard_crit
= { &critsect_debug
, -1, 0, 0, 0, 0 };
86 static DWORD keyboard_users
;
87 static HHOOK keyboard_hook
;
89 LRESULT CALLBACK
KeyboardCallback( int code
, WPARAM wparam
, LPARAM lparam
)
91 TRACE("(%d,%d,%ld)\n", code
, wparam
, lparam
);
93 if (code
== HC_ACTION
)
100 KBDLLHOOKSTRUCT
*hook
= (KBDLLHOOKSTRUCT
*)lparam
;
101 dik_code
= hook
->scanCode
;
102 if (hook
->flags
& LLKHF_EXTENDED
) dik_code
|= 0x80;
103 down
= !(hook
->flags
& LLKHF_UP
);
104 timestamp
= hook
->time
;
107 DInputKeyState
[dik_code
] = (down
? 0x80 : 0);
108 TRACE(" setting %02X to %02X\n", dik_code
, DInputKeyState
[dik_code
]);
113 SetEvent(current
->hEvent
);
115 if (current
->buffer
!= NULL
)
119 EnterCriticalSection(&(current
->crit
));
121 n
= (current
->start
+ current
->count
) % current
->buffersize
;
123 current
->buffer
[n
].dwOfs
= dik_code
;
124 current
->buffer
[n
].dwData
= down
? 0x80 : 0;
125 current
->buffer
[n
].dwTimeStamp
= timestamp
;
126 current
->buffer
[n
].dwSequence
= current
->dinput
->evsequence
++;
128 TRACE("Adding event at offset %d : %ld - %ld - %ld - %ld\n", n
,
129 current
->buffer
[n
].dwOfs
, current
->buffer
[n
].dwData
, current
->buffer
[n
].dwTimeStamp
, current
->buffer
[n
].dwSequence
);
131 if (current
->count
== current
->buffersize
)
133 current
->start
= ++current
->start
% current
->buffersize
;
134 current
->overflow
= TRUE
;
139 LeaveCriticalSection(&(current
->crit
));
144 return CallNextHookEx(keyboard_hook
, code
, wparam
, lparam
);
147 static GUID DInput_Wine_Keyboard_GUID
= { /* 0ab8648a-7735-11d2-8c73-71df54a96441 */
151 {0x8c, 0x73, 0x71, 0xdf, 0x54, 0xa9, 0x64, 0x41}
154 static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi
, int version
) {
156 DIDEVICEINSTANCEA ddi
;
158 dwSize
= lpddi
->dwSize
;
160 TRACE("%ld %p\n", dwSize
, lpddi
);
162 memset(lpddi
, 0, dwSize
);
163 memset(&ddi
, 0, sizeof(ddi
));
166 ddi
.guidInstance
= GUID_SysKeyboard
;/* DInput's GUID */
167 ddi
.guidProduct
= DInput_Wine_Keyboard_GUID
; /* Vendor's GUID */
169 ddi
.dwDevType
= DI8DEVTYPE_KEYBOARD
| (DI8DEVTYPEKEYBOARD_UNKNOWN
<< 8);
171 ddi
.dwDevType
= DIDEVTYPE_KEYBOARD
| (DIDEVTYPEKEYBOARD_UNKNOWN
<< 8);
172 strcpy(ddi
.tszInstanceName
, "Keyboard");
173 strcpy(ddi
.tszProductName
, "Wine Keyboard");
175 memcpy(lpddi
, &ddi
, (dwSize
< sizeof(ddi
) ? dwSize
: sizeof(ddi
)));
178 static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi
, int version
) {
180 DIDEVICEINSTANCEW ddi
;
182 dwSize
= lpddi
->dwSize
;
184 TRACE("%ld %p\n", dwSize
, lpddi
);
186 memset(lpddi
, 0, dwSize
);
187 memset(&ddi
, 0, sizeof(ddi
));
190 ddi
.guidInstance
= GUID_SysKeyboard
;/* DInput's GUID */
191 ddi
.guidProduct
= DInput_Wine_Keyboard_GUID
; /* Vendor's GUID */
193 ddi
.dwDevType
= DI8DEVTYPE_KEYBOARD
| (DI8DEVTYPEKEYBOARD_UNKNOWN
<< 8);
195 ddi
.dwDevType
= DIDEVTYPE_KEYBOARD
| (DIDEVTYPEKEYBOARD_UNKNOWN
<< 8);
196 MultiByteToWideChar(CP_ACP
, 0, "Keyboard", -1, ddi
.tszInstanceName
, MAX_PATH
);
197 MultiByteToWideChar(CP_ACP
, 0, "Wine Keyboard", -1, ddi
.tszProductName
, MAX_PATH
);
199 memcpy(lpddi
, &ddi
, (dwSize
< sizeof(ddi
) ? dwSize
: sizeof(ddi
)));
202 static BOOL
keyboarddev_enum_deviceA(DWORD dwDevType
, DWORD dwFlags
, LPDIDEVICEINSTANCEA lpddi
, int version
, int id
)
207 if ((dwDevType
== 0) ||
208 ((dwDevType
== DIDEVTYPE_KEYBOARD
) && (version
< 8)) ||
209 ((dwDevType
== DI8DEVTYPE_KEYBOARD
) && (version
>= 8))) {
210 TRACE("Enumerating the Keyboard device\n");
212 fill_keyboard_dideviceinstanceA(lpddi
, version
);
220 static BOOL
keyboarddev_enum_deviceW(DWORD dwDevType
, DWORD dwFlags
, LPDIDEVICEINSTANCEW lpddi
, int version
, int id
)
225 if ((dwDevType
== 0) ||
226 ((dwDevType
== DIDEVTYPE_KEYBOARD
) && (version
< 8)) ||
227 ((dwDevType
== DI8DEVTYPE_KEYBOARD
) && (version
>= 8))) {
228 TRACE("Enumerating the Keyboard device\n");
230 fill_keyboard_dideviceinstanceW(lpddi
, version
);
238 static SysKeyboardImpl
*alloc_device(REFGUID rguid
, LPVOID kvt
, IDirectInputImpl
*dinput
)
240 SysKeyboardImpl
* newDevice
;
241 newDevice
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(SysKeyboardImpl
));
242 newDevice
->lpVtbl
= kvt
;
244 memcpy(&(newDevice
->guid
),rguid
,sizeof(*rguid
));
245 newDevice
->dinput
= dinput
;
247 EnterCriticalSection(&keyboard_crit
);
248 if (!keyboard_users
++)
249 keyboard_hook
= SetWindowsHookExW( WH_KEYBOARD_LL
, KeyboardCallback
, DINPUT_instance
, 0 );
250 LeaveCriticalSection(&keyboard_crit
);
256 static HRESULT
keyboarddev_create_deviceA(IDirectInputImpl
*dinput
, REFGUID rguid
, REFIID riid
, LPDIRECTINPUTDEVICEA
* pdev
)
258 if ((IsEqualGUID(&GUID_SysKeyboard
,rguid
)) || /* Generic Keyboard */
259 (IsEqualGUID(&DInput_Wine_Keyboard_GUID
,rguid
))) { /* Wine Keyboard */
260 if ((riid
== NULL
) ||
261 IsEqualGUID(&IID_IDirectInputDeviceA
,riid
) ||
262 IsEqualGUID(&IID_IDirectInputDevice2A
,riid
) ||
263 IsEqualGUID(&IID_IDirectInputDevice7A
,riid
) ||
264 IsEqualGUID(&IID_IDirectInputDevice8A
,riid
)) {
265 *pdev
= (IDirectInputDeviceA
*) alloc_device(rguid
, &SysKeyboardAvt
, dinput
);
266 TRACE("Creating a Keyboard device (%p)\n", *pdev
);
269 return DIERR_NOINTERFACE
;
271 return DIERR_DEVICENOTREG
;
274 static HRESULT
keyboarddev_create_deviceW(IDirectInputImpl
*dinput
, REFGUID rguid
, REFIID riid
, LPDIRECTINPUTDEVICEW
* pdev
)
276 if ((IsEqualGUID(&GUID_SysKeyboard
,rguid
)) || /* Generic Keyboard */
277 (IsEqualGUID(&DInput_Wine_Keyboard_GUID
,rguid
))) { /* Wine Keyboard */
278 if ((riid
== NULL
) ||
279 IsEqualGUID(&IID_IDirectInputDeviceW
,riid
) ||
280 IsEqualGUID(&IID_IDirectInputDevice2W
,riid
) ||
281 IsEqualGUID(&IID_IDirectInputDevice7W
,riid
) ||
282 IsEqualGUID(&IID_IDirectInputDevice8W
,riid
)) {
283 *pdev
= (IDirectInputDeviceW
*) alloc_device(rguid
, &SysKeyboardWvt
, dinput
);
284 TRACE("Creating a Keyboard device (%p)\n", *pdev
);
287 return DIERR_NOINTERFACE
;
289 return DIERR_DEVICENOTREG
;
292 static dinput_device keyboarddev
= {
294 "Wine keyboard driver",
295 keyboarddev_enum_deviceA
,
296 keyboarddev_enum_deviceW
,
297 keyboarddev_create_deviceA
,
298 keyboarddev_create_deviceW
301 DECL_GLOBAL_CONSTRUCTOR(keyboarddev_register
) { dinput_register_device(&keyboarddev
); }
303 static ULONG WINAPI
SysKeyboardAImpl_Release(LPDIRECTINPUTDEVICE8A iface
)
305 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
308 ref
= InterlockedDecrement(&(This
->ref
));
312 EnterCriticalSection(&keyboard_crit
);
313 if (!--keyboard_users
) {
314 UnhookWindowsHookEx( keyboard_hook
);
317 LeaveCriticalSection(&keyboard_crit
);
319 /* Free the data queue */
320 if (This
->buffer
!= NULL
)
321 HeapFree(GetProcessHeap(),0,This
->buffer
);
323 DeleteCriticalSection(&(This
->crit
));
325 HeapFree(GetProcessHeap(),0,This
);
329 static HRESULT WINAPI
SysKeyboardAImpl_SetProperty(
330 LPDIRECTINPUTDEVICE8A iface
,REFGUID rguid
,LPCDIPROPHEADER ph
333 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
335 TRACE("(this=%p,%s,%p)\n",This
,debugstr_guid(rguid
),ph
);
336 TRACE("(size=%ld,headersize=%ld,obj=%ld,how=%ld\n",
337 ph
->dwSize
,ph
->dwHeaderSize
,ph
->dwObj
,ph
->dwHow
);
338 if (!HIWORD(rguid
)) {
339 switch ((DWORD
)rguid
) {
340 case (DWORD
) DIPROP_BUFFERSIZE
: {
341 LPCDIPROPDWORD pd
= (LPCDIPROPDWORD
)ph
;
343 TRACE("(buffersize=%ld)\n",pd
->dwData
);
346 return DIERR_INVALIDPARAM
;
348 This
->buffersize
= pd
->dwData
;
353 WARN("Unknown type %ld\n",(DWORD
)rguid
);
360 static HRESULT WINAPI
SysKeyboardAImpl_GetDeviceState(
361 LPDIRECTINPUTDEVICE8A iface
,DWORD len
,LPVOID ptr
364 TRACE("(%p)->(%ld,%p)\n", iface
, len
, ptr
);
366 /* Note: device does not need to be acquired */
368 return DIERR_INVALIDPARAM
;
370 MsgWaitForMultipleObjectsEx(0, NULL
, 0, 0, 0);
372 if (TRACE_ON(dinput
)) {
374 for (i
= 0; i
< 256; i
++) {
375 if (DInputKeyState
[i
] != 0x00) {
376 TRACE(" - %02X: %02x\n", i
, DInputKeyState
[i
]);
381 memcpy(ptr
, DInputKeyState
, 256);
385 static HRESULT WINAPI
SysKeyboardAImpl_GetDeviceData(
386 LPDIRECTINPUTDEVICE8A iface
,DWORD dodsize
,LPDIDEVICEOBJECTDATA dod
,
387 LPDWORD entries
,DWORD flags
390 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
391 int ret
= DI_OK
, i
= 0;
393 TRACE("(this=%p,%ld,%p,%p(%ld)),0x%08lx)\n",
394 This
,dodsize
,dod
,entries
,entries
?*entries
:0,flags
);
396 if (This
->acquired
== 0)
397 return DIERR_NOTACQUIRED
;
399 if (This
->buffer
== NULL
)
400 return DIERR_NOTBUFFERED
;
402 if (dodsize
< sizeof(*dod
))
403 return DIERR_INVALIDPARAM
;
405 MsgWaitForMultipleObjectsEx(0, NULL
, 0, 0, 0);
407 EnterCriticalSection(&(This
->crit
));
409 /* Copy item at a time for the case dodsize > sizeof(buffer[n]) */
410 while ((i
< *entries
|| *entries
== INFINITE
) && i
< This
->count
)
414 int n
= (This
->start
+ i
) % This
->buffersize
;
415 LPDIDEVICEOBJECTDATA pd
416 = (LPDIDEVICEOBJECTDATA
)((BYTE
*)dod
+ dodsize
* i
);
417 pd
->dwOfs
= This
->buffer
[n
].dwOfs
;
418 pd
->dwData
= This
->buffer
[n
].dwData
;
419 pd
->dwTimeStamp
= This
->buffer
[n
].dwTimeStamp
;
420 pd
->dwSequence
= This
->buffer
[n
].dwSequence
;
428 ret
= DI_BUFFEROVERFLOW
;
430 if (!(flags
& DIGDD_PEEK
))
434 This
->start
= (This
->start
+ i
) % This
->buffersize
;
435 This
->overflow
= FALSE
;
438 LeaveCriticalSection(&(This
->crit
));
440 TRACE("Returning %ld events queued\n", *entries
);
445 static HRESULT WINAPI
SysKeyboardAImpl_EnumObjects(
446 LPDIRECTINPUTDEVICE8A iface
,
447 LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback
,
451 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
452 DIDEVICEOBJECTINSTANCEA ddoi
;
455 TRACE("(this=%p,%p,%p,%08lx)\n", This
, lpCallback
, lpvRef
, dwFlags
);
456 if (TRACE_ON(dinput
)) {
457 TRACE(" - flags = ");
458 _dump_EnumObjects_flags(dwFlags
);
462 /* Only the fields till dwFFMaxForce are relevant */
463 memset(&ddoi
, 0, sizeof(ddoi
));
464 ddoi
.dwSize
= FIELD_OFFSET(DIDEVICEOBJECTINSTANCEA
, dwFFMaxForce
);
466 for (i
= 0; i
< 256; i
++) {
467 /* Report 255 keys :-) */
468 ddoi
.guidType
= GUID_Key
;
470 ddoi
.dwType
= DIDFT_MAKEINSTANCE(i
) | DIDFT_BUTTON
;
471 GetKeyNameTextA(((i
& 0x7f) << 16) | ((i
& 0x80) << 17), ddoi
.tszName
, sizeof(ddoi
.tszName
));
472 _dump_OBJECTINSTANCEA(&ddoi
);
473 if (lpCallback(&ddoi
, lpvRef
) != DIENUM_CONTINUE
) return DI_OK
;
479 static HRESULT WINAPI
SysKeyboardWImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface
,
480 LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback
,
484 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
486 device_enumobjects_AtoWcb_data data
;
488 data
.lpCallBack
= lpCallback
;
489 data
.lpvRef
= lpvRef
;
491 return SysKeyboardAImpl_EnumObjects((LPDIRECTINPUTDEVICE8A
) This
, (LPDIENUMDEVICEOBJECTSCALLBACKA
) DIEnumDevicesCallbackAtoW
, (LPVOID
) &data
, dwFlags
);
494 static HRESULT WINAPI
SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface
);
496 static HRESULT WINAPI
SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface
)
498 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
500 TRACE("(this=%p)\n",This
);
509 FIXME("Not more than one keyboard can be acquired at the same time.\n");
510 SysKeyboardAImpl_Unacquire(iface
);
515 if (This
->buffersize
> 0)
517 This
->buffer
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
518 This
->buffersize
* sizeof(*(This
->buffer
)));
521 This
->overflow
= FALSE
;
522 InitializeCriticalSection(&(This
->crit
));
530 static HRESULT WINAPI
SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface
)
532 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
533 TRACE("(this=%p)\n",This
);
535 if (This
->acquired
== 0)
541 ERR("this != current\n");
545 if (This
->buffersize
>= 0)
547 HeapFree(GetProcessHeap(), 0, This
->buffer
);
549 DeleteCriticalSection(&(This
->crit
));
555 static HRESULT WINAPI
SysKeyboardAImpl_SetEventNotification(LPDIRECTINPUTDEVICE8A iface
,
557 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
559 TRACE("(this=%p,0x%08lx)\n",This
,(DWORD
)hnd
);
565 /******************************************************************************
566 * GetCapabilities : get the device capablitites
568 static HRESULT WINAPI
SysKeyboardAImpl_GetCapabilities(
569 LPDIRECTINPUTDEVICE8A iface
,
570 LPDIDEVCAPS lpDIDevCaps
)
572 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
574 TRACE("(this=%p,%p)\n",This
,lpDIDevCaps
);
576 if (lpDIDevCaps
->dwSize
== sizeof(DIDEVCAPS
)) {
577 lpDIDevCaps
->dwFlags
= DIDC_ATTACHED
;
578 if (This
->dinput
->version
>= 8)
579 lpDIDevCaps
->dwDevType
= DI8DEVTYPE_KEYBOARD
| (DI8DEVTYPEKEYBOARD_UNKNOWN
<< 8);
581 lpDIDevCaps
->dwDevType
= DIDEVTYPE_KEYBOARD
| (DIDEVTYPEKEYBOARD_UNKNOWN
<< 8);
582 lpDIDevCaps
->dwAxes
= 0;
583 lpDIDevCaps
->dwButtons
= 256;
584 lpDIDevCaps
->dwPOVs
= 0;
585 lpDIDevCaps
->dwFFSamplePeriod
= 0;
586 lpDIDevCaps
->dwFFMinTimeResolution
= 0;
587 lpDIDevCaps
->dwFirmwareRevision
= 100;
588 lpDIDevCaps
->dwHardwareRevision
= 100;
589 lpDIDevCaps
->dwFFDriverVersion
= 0;
590 } else if (lpDIDevCaps
->dwSize
== sizeof(DIDEVCAPS_DX3
)) {
591 lpDIDevCaps
->dwFlags
= DIDC_ATTACHED
;
592 lpDIDevCaps
->dwDevType
= DIDEVTYPE_KEYBOARD
| (DIDEVTYPEKEYBOARD_UNKNOWN
<< 8);
593 lpDIDevCaps
->dwAxes
= 0;
594 lpDIDevCaps
->dwButtons
= 256;
595 lpDIDevCaps
->dwPOVs
= 0;
597 WARN("invalid parameter\n");
598 return DIERR_INVALIDPARAM
;
604 /******************************************************************************
605 * GetObjectInfo : get information about a device object such as a button
608 static HRESULT WINAPI
609 SysKeyboardAImpl_GetObjectInfo(
610 LPDIRECTINPUTDEVICE8A iface
,
611 LPDIDEVICEOBJECTINSTANCEA pdidoi
,
615 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
616 DIDEVICEOBJECTINSTANCEA ddoi
;
617 DWORD dwSize
= pdidoi
->dwSize
;
619 TRACE("(this=%p,%p,%ld,0x%08lx)\n", This
, pdidoi
, dwObj
, dwHow
);
621 if (dwHow
== DIPH_BYID
) {
622 WARN(" querying by id not supported yet...\n");
626 memset(pdidoi
, 0, dwSize
);
627 memset(&ddoi
, 0, sizeof(ddoi
));
629 ddoi
.dwSize
= dwSize
;
630 ddoi
.guidType
= GUID_Key
;
632 ddoi
.dwType
= DIDFT_MAKEINSTANCE(dwObj
) | DIDFT_BUTTON
;
633 GetKeyNameTextA(((dwObj
& 0x7f) << 16) | ((dwObj
& 0x80) << 17), ddoi
.tszName
, sizeof(ddoi
.tszName
));
635 /* And return our just filled device object instance structure */
636 memcpy(pdidoi
, &ddoi
, (dwSize
< sizeof(ddoi
) ? dwSize
: sizeof(ddoi
)));
638 _dump_OBJECTINSTANCEA(pdidoi
);
643 static HRESULT WINAPI
SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface
,
644 LPDIDEVICEOBJECTINSTANCEW pdidoi
,
648 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
649 DIDEVICEOBJECTINSTANCEW ddoi
;
650 DWORD dwSize
= pdidoi
->dwSize
;
652 TRACE("(this=%p,%p,%ld,0x%08lx)\n", This
, pdidoi
, dwObj
, dwHow
);
654 if (dwHow
== DIPH_BYID
) {
655 WARN(" querying by id not supported yet...\n");
659 memset(pdidoi
, 0, dwSize
);
660 memset(&ddoi
, 0, sizeof(ddoi
));
662 ddoi
.dwSize
= dwSize
;
663 ddoi
.guidType
= GUID_Key
;
665 ddoi
.dwType
= DIDFT_MAKEINSTANCE(dwObj
) | DIDFT_BUTTON
;
666 GetKeyNameTextW(((dwObj
& 0x7f) << 16) | ((dwObj
& 0x80) << 17), ddoi
.tszName
, sizeof(ddoi
.tszName
));
668 /* And return our just filled device object instance structure */
669 memcpy(pdidoi
, &ddoi
, (dwSize
< sizeof(ddoi
) ? dwSize
: sizeof(ddoi
)));
671 _dump_OBJECTINSTANCEW(pdidoi
);
676 /******************************************************************************
677 * GetDeviceInfo : get information about a device's identity
679 static HRESULT WINAPI
SysKeyboardAImpl_GetDeviceInfo(
680 LPDIRECTINPUTDEVICE8A iface
,
681 LPDIDEVICEINSTANCEA pdidi
)
683 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
684 TRACE("(this=%p,%p)\n", This
, pdidi
);
686 if (pdidi
->dwSize
!= sizeof(DIDEVICEINSTANCEA
)) {
687 WARN(" dinput3 not supporte yet...\n");
691 fill_keyboard_dideviceinstanceA(pdidi
, This
->dinput
->version
);
696 static HRESULT WINAPI
SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface
, LPDIDEVICEINSTANCEW pdidi
)
698 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
699 TRACE("(this=%p,%p)\n", This
, pdidi
);
701 if (pdidi
->dwSize
!= sizeof(DIDEVICEINSTANCEW
)) {
702 WARN(" dinput3 not supporte yet...\n");
706 fill_keyboard_dideviceinstanceW(pdidi
, This
->dinput
->version
);
711 static IDirectInputDevice8AVtbl SysKeyboardAvt
=
713 IDirectInputDevice2AImpl_QueryInterface
,
714 IDirectInputDevice2AImpl_AddRef
,
715 SysKeyboardAImpl_Release
,
716 SysKeyboardAImpl_GetCapabilities
,
717 SysKeyboardAImpl_EnumObjects
,
718 IDirectInputDevice2AImpl_GetProperty
,
719 SysKeyboardAImpl_SetProperty
,
720 SysKeyboardAImpl_Acquire
,
721 SysKeyboardAImpl_Unacquire
,
722 SysKeyboardAImpl_GetDeviceState
,
723 SysKeyboardAImpl_GetDeviceData
,
724 IDirectInputDevice2AImpl_SetDataFormat
,
725 SysKeyboardAImpl_SetEventNotification
,
726 IDirectInputDevice2AImpl_SetCooperativeLevel
,
727 SysKeyboardAImpl_GetObjectInfo
,
728 SysKeyboardAImpl_GetDeviceInfo
,
729 IDirectInputDevice2AImpl_RunControlPanel
,
730 IDirectInputDevice2AImpl_Initialize
,
731 IDirectInputDevice2AImpl_CreateEffect
,
732 IDirectInputDevice2AImpl_EnumEffects
,
733 IDirectInputDevice2AImpl_GetEffectInfo
,
734 IDirectInputDevice2AImpl_GetForceFeedbackState
,
735 IDirectInputDevice2AImpl_SendForceFeedbackCommand
,
736 IDirectInputDevice2AImpl_EnumCreatedEffectObjects
,
737 IDirectInputDevice2AImpl_Escape
,
738 IDirectInputDevice2AImpl_Poll
,
739 IDirectInputDevice2AImpl_SendDeviceData
,
740 IDirectInputDevice7AImpl_EnumEffectsInFile
,
741 IDirectInputDevice7AImpl_WriteEffectToFile
,
742 IDirectInputDevice8AImpl_BuildActionMap
,
743 IDirectInputDevice8AImpl_SetActionMap
,
744 IDirectInputDevice8AImpl_GetImageInfo
747 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
748 # define XCAST(fun) (typeof(SysKeyboardWvt.fun))
750 # define XCAST(fun) (void*)
753 static IDirectInputDevice8WVtbl SysKeyboardWvt
=
755 IDirectInputDevice2WImpl_QueryInterface
,
756 XCAST(AddRef
)IDirectInputDevice2AImpl_AddRef
,
757 XCAST(Release
)SysKeyboardAImpl_Release
,
758 XCAST(GetCapabilities
)SysKeyboardAImpl_GetCapabilities
,
759 SysKeyboardWImpl_EnumObjects
,
760 XCAST(GetProperty
)IDirectInputDevice2AImpl_GetProperty
,
761 XCAST(SetProperty
)SysKeyboardAImpl_SetProperty
,
762 XCAST(Acquire
)SysKeyboardAImpl_Acquire
,
763 XCAST(Unacquire
)SysKeyboardAImpl_Unacquire
,
764 XCAST(GetDeviceState
)SysKeyboardAImpl_GetDeviceState
,
765 XCAST(GetDeviceData
)SysKeyboardAImpl_GetDeviceData
,
766 XCAST(SetDataFormat
)IDirectInputDevice2AImpl_SetDataFormat
,
767 XCAST(SetEventNotification
)SysKeyboardAImpl_SetEventNotification
,
768 XCAST(SetCooperativeLevel
)IDirectInputDevice2AImpl_SetCooperativeLevel
,
769 SysKeyboardWImpl_GetObjectInfo
,
770 SysKeyboardWImpl_GetDeviceInfo
,
771 XCAST(RunControlPanel
)IDirectInputDevice2AImpl_RunControlPanel
,
772 XCAST(Initialize
)IDirectInputDevice2AImpl_Initialize
,
773 XCAST(CreateEffect
)IDirectInputDevice2AImpl_CreateEffect
,
774 IDirectInputDevice2WImpl_EnumEffects
,
775 IDirectInputDevice2WImpl_GetEffectInfo
,
776 XCAST(GetForceFeedbackState
)IDirectInputDevice2AImpl_GetForceFeedbackState
,
777 XCAST(SendForceFeedbackCommand
)IDirectInputDevice2AImpl_SendForceFeedbackCommand
,
778 XCAST(EnumCreatedEffectObjects
)IDirectInputDevice2AImpl_EnumCreatedEffectObjects
,
779 XCAST(Escape
)IDirectInputDevice2AImpl_Escape
,
780 XCAST(Poll
)IDirectInputDevice2AImpl_Poll
,
781 XCAST(SendDeviceData
)IDirectInputDevice2AImpl_SendDeviceData
,
782 IDirectInputDevice7WImpl_EnumEffectsInFile
,
783 IDirectInputDevice7WImpl_WriteEffectToFile
,
784 IDirectInputDevice8WImpl_BuildActionMap
,
785 IDirectInputDevice8WImpl_SetActionMap
,
786 IDirectInputDevice8WImpl_GetImageInfo