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
53 IDirectInputImpl
* dinput
;
56 /* SysKeyboardAImpl */
58 int buffersize
; /* set in 'SetProperty' */
59 LPDIDEVICEOBJECTDATA buffer
; /* buffer for 'GetDeviceData'.
60 Alloc at 'Acquire', Free at
62 int count
; /* number of objects in use in
64 int start
; /* 'buffer' rotates. This is the
65 first in use (if count > 0) */
66 BOOL overflow
; /* return DI_BUFFEROVERFLOW in
68 CRITICAL_SECTION crit
;
71 static SysKeyboardImpl
* current_lock
= NULL
;
72 /* Today's acquired device
73 * FIXME: currently this can be only one.
74 * Maybe this should be a linked list or st.
75 * I don't know what the rules are for multiple acquired keyboards,
76 * but 'DI_LOSTFOCUS' and 'DI_UNACQUIRED' exist for a reason.
79 static BYTE DInputKeyState
[WINE_DINPUT_KEYBOARD_MAX_KEYS
]; /* array for 'GetDeviceState' */
81 LRESULT CALLBACK
KeyboardCallback( int code
, WPARAM wparam
, LPARAM lparam
)
83 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)current_lock
;
86 KBDLLHOOKSTRUCT
*hook
= (KBDLLHOOKSTRUCT
*)lparam
;
89 TRACE("(%d,%d,%ld)\n", code
, wparam
, lparam
);
91 /* returns now if not HC_ACTION */
92 if (code
!= HC_ACTION
) return CallNextHookEx(0, code
, wparam
, lparam
);
94 dik_code
= hook
->scanCode
;
95 if (hook
->flags
& LLKHF_EXTENDED
) dik_code
|= 0x80;
96 down
= !(hook
->flags
& LLKHF_UP
);
98 /** returns now if key event already known */
99 new_diks
= (down
? 0x80 : 0);
100 /*if (new_diks != DInputKeyState[dik_code]) return CallNextHookEx(keyboard_hook, code, wparam, lparam); TO BE FIXED */
102 DInputKeyState
[dik_code
] = new_diks
;
103 TRACE(" setting %02X to %02X\n", dik_code
, DInputKeyState
[dik_code
]);
105 if (This
->hEvent
) SetEvent(This
->hEvent
);
107 if (This
->buffer
!= NULL
)
111 EnterCriticalSection(&(This
->crit
));
113 n
= (This
->start
+ This
->count
) % This
->buffersize
;
115 This
->buffer
[n
].dwOfs
= dik_code
;
116 This
->buffer
[n
].dwData
= down
? 0x80 : 0;
117 This
->buffer
[n
].dwTimeStamp
= hook
->time
;
118 This
->buffer
[n
].dwSequence
= This
->dinput
->evsequence
++;
120 TRACE("Adding event at offset %d : %ld - %ld - %ld - %ld\n", n
,
121 This
->buffer
[n
].dwOfs
, This
->buffer
[n
].dwData
, This
->buffer
[n
].dwTimeStamp
, This
->buffer
[n
].dwSequence
);
123 if (This
->count
== This
->buffersize
) {
124 This
->start
= ++This
->start
% This
->buffersize
;
125 This
->overflow
= TRUE
;
129 LeaveCriticalSection(&(This
->crit
));
131 return CallNextHookEx(0, code
, wparam
, lparam
);
134 static GUID DInput_Wine_Keyboard_GUID
= { /* 0ab8648a-7735-11d2-8c73-71df54a96441 */
138 {0x8c, 0x73, 0x71, 0xdf, 0x54, 0xa9, 0x64, 0x41}
141 static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi
, DWORD version
) {
143 DIDEVICEINSTANCEA ddi
;
145 dwSize
= lpddi
->dwSize
;
147 TRACE("%ld %p\n", dwSize
, lpddi
);
149 memset(lpddi
, 0, dwSize
);
150 memset(&ddi
, 0, sizeof(ddi
));
153 ddi
.guidInstance
= GUID_SysKeyboard
;/* DInput's GUID */
154 ddi
.guidProduct
= DInput_Wine_Keyboard_GUID
; /* Vendor's GUID */
155 if (version
>= 0x0800)
156 ddi
.dwDevType
= DI8DEVTYPE_KEYBOARD
| (DI8DEVTYPEKEYBOARD_UNKNOWN
<< 8);
158 ddi
.dwDevType
= DIDEVTYPE_KEYBOARD
| (DIDEVTYPEKEYBOARD_UNKNOWN
<< 8);
159 strcpy(ddi
.tszInstanceName
, "Keyboard");
160 strcpy(ddi
.tszProductName
, "Wine Keyboard");
162 memcpy(lpddi
, &ddi
, (dwSize
< sizeof(ddi
) ? dwSize
: sizeof(ddi
)));
165 static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi
, DWORD version
) {
167 DIDEVICEINSTANCEW ddi
;
169 dwSize
= lpddi
->dwSize
;
171 TRACE("%ld %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
= DInput_Wine_Keyboard_GUID
; /* Vendor's GUID */
179 if (version
>= 0x0800)
180 ddi
.dwDevType
= DI8DEVTYPE_KEYBOARD
| (DI8DEVTYPEKEYBOARD_UNKNOWN
<< 8);
182 ddi
.dwDevType
= DIDEVTYPE_KEYBOARD
| (DIDEVTYPEKEYBOARD_UNKNOWN
<< 8);
183 MultiByteToWideChar(CP_ACP
, 0, "Keyboard", -1, ddi
.tszInstanceName
, MAX_PATH
);
184 MultiByteToWideChar(CP_ACP
, 0, "Wine Keyboard", -1, ddi
.tszProductName
, MAX_PATH
);
186 memcpy(lpddi
, &ddi
, (dwSize
< sizeof(ddi
) ? dwSize
: sizeof(ddi
)));
189 static BOOL
keyboarddev_enum_deviceA(DWORD dwDevType
, DWORD dwFlags
, LPDIDEVICEINSTANCEA lpddi
, DWORD version
, int id
)
194 if ((dwDevType
== 0) ||
195 ((dwDevType
== DIDEVTYPE_KEYBOARD
) && (version
< 0x0800)) ||
196 (((dwDevType
== DI8DEVCLASS_KEYBOARD
) || (dwDevType
== DI8DEVTYPE_KEYBOARD
)) && (version
>= 0x0800))) {
197 TRACE("Enumerating the Keyboard device\n");
199 fill_keyboard_dideviceinstanceA(lpddi
, version
);
207 static BOOL
keyboarddev_enum_deviceW(DWORD dwDevType
, DWORD dwFlags
, LPDIDEVICEINSTANCEW lpddi
, DWORD version
, int id
)
212 if ((dwDevType
== 0) ||
213 ((dwDevType
== DIDEVTYPE_KEYBOARD
) && (version
< 0x0800)) ||
214 (((dwDevType
== DI8DEVCLASS_KEYBOARD
) || (dwDevType
== DI8DEVTYPE_KEYBOARD
)) && (version
>= 0x0800))) {
215 TRACE("Enumerating the Keyboard device\n");
217 fill_keyboard_dideviceinstanceW(lpddi
, version
);
225 static SysKeyboardImpl
*alloc_device(REFGUID rguid
, const void *kvt
, IDirectInputImpl
*dinput
)
227 SysKeyboardImpl
* newDevice
;
229 newDevice
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(SysKeyboardImpl
));
230 newDevice
->lpVtbl
= kvt
;
232 memcpy(&(newDevice
->guid
),rguid
,sizeof(*rguid
));
233 newDevice
->dinput
= dinput
;
234 InitializeCriticalSection(&(newDevice
->crit
));
240 static HRESULT
keyboarddev_create_deviceA(IDirectInputImpl
*dinput
, REFGUID rguid
, REFIID riid
, LPDIRECTINPUTDEVICEA
* pdev
)
242 if ((IsEqualGUID(&GUID_SysKeyboard
,rguid
)) || /* Generic Keyboard */
243 (IsEqualGUID(&DInput_Wine_Keyboard_GUID
,rguid
))) { /* Wine Keyboard */
244 if ((riid
== NULL
) ||
245 IsEqualGUID(&IID_IDirectInputDeviceA
,riid
) ||
246 IsEqualGUID(&IID_IDirectInputDevice2A
,riid
) ||
247 IsEqualGUID(&IID_IDirectInputDevice7A
,riid
) ||
248 IsEqualGUID(&IID_IDirectInputDevice8A
,riid
)) {
249 *pdev
= (IDirectInputDeviceA
*) alloc_device(rguid
, &SysKeyboardAvt
, dinput
);
250 TRACE("Creating a Keyboard device (%p)\n", *pdev
);
253 return DIERR_NOINTERFACE
;
255 return DIERR_DEVICENOTREG
;
258 static HRESULT
keyboarddev_create_deviceW(IDirectInputImpl
*dinput
, REFGUID rguid
, REFIID riid
, LPDIRECTINPUTDEVICEW
* pdev
)
260 if ((IsEqualGUID(&GUID_SysKeyboard
,rguid
)) || /* Generic Keyboard */
261 (IsEqualGUID(&DInput_Wine_Keyboard_GUID
,rguid
))) { /* Wine Keyboard */
262 if ((riid
== NULL
) ||
263 IsEqualGUID(&IID_IDirectInputDeviceW
,riid
) ||
264 IsEqualGUID(&IID_IDirectInputDevice2W
,riid
) ||
265 IsEqualGUID(&IID_IDirectInputDevice7W
,riid
) ||
266 IsEqualGUID(&IID_IDirectInputDevice8W
,riid
)) {
267 *pdev
= (IDirectInputDeviceW
*) alloc_device(rguid
, &SysKeyboardWvt
, dinput
);
268 TRACE("Creating a Keyboard device (%p)\n", *pdev
);
271 return DIERR_NOINTERFACE
;
273 return DIERR_DEVICENOTREG
;
276 const struct dinput_device keyboard_device
= {
277 "Wine keyboard driver",
278 keyboarddev_enum_deviceA
,
279 keyboarddev_enum_deviceW
,
280 keyboarddev_create_deviceA
,
281 keyboarddev_create_deviceW
284 static ULONG WINAPI
SysKeyboardAImpl_Release(LPDIRECTINPUTDEVICE8A iface
)
286 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
289 ref
= InterlockedDecrement(&(This
->ref
));
292 set_dinput_hook(WH_KEYBOARD_LL
, NULL
);
294 /* Free the data queue */
295 HeapFree(GetProcessHeap(),0,This
->buffer
);
297 DeleteCriticalSection(&(This
->crit
));
299 HeapFree(GetProcessHeap(),0,This
);
303 static HRESULT WINAPI
SysKeyboardAImpl_SetProperty(
304 LPDIRECTINPUTDEVICE8A iface
,REFGUID rguid
,LPCDIPROPHEADER ph
307 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
309 TRACE("(this=%p,%s,%p)\n",This
,debugstr_guid(rguid
),ph
);
310 TRACE("(size=%ld,headersize=%ld,obj=%ld,how=%ld\n",
311 ph
->dwSize
,ph
->dwHeaderSize
,ph
->dwObj
,ph
->dwHow
);
312 if (!HIWORD(rguid
)) {
313 switch (LOWORD(rguid
)) {
314 case (DWORD
) DIPROP_BUFFERSIZE
: {
315 LPCDIPROPDWORD pd
= (LPCDIPROPDWORD
)ph
;
317 TRACE("(buffersize=%ld)\n",pd
->dwData
);
320 return DIERR_INVALIDPARAM
;
322 This
->buffersize
= pd
->dwData
;
327 WARN("Unknown type %p\n",rguid
);
334 static HRESULT WINAPI
SysKeyboardAImpl_GetProperty(
335 LPDIRECTINPUTDEVICE8A iface
,REFGUID rguid
,LPDIPROPHEADER ph
338 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
340 TRACE("(this=%p,%s,%p)\n",This
,debugstr_guid(rguid
),ph
);
341 TRACE("(size=%ld,headersize=%ld,obj=%ld,how=%ld\n",
342 ph
->dwSize
,ph
->dwHeaderSize
,ph
->dwObj
,ph
->dwHow
);
343 if (!HIWORD(rguid
)) {
344 switch (LOWORD(rguid
)) {
345 case (DWORD
) DIPROP_BUFFERSIZE
: {
346 LPDIPROPDWORD pd
= (LPDIPROPDWORD
)ph
;
348 TRACE("(buffersize=%ld)\n",pd
->dwData
);
351 return DIERR_INVALIDPARAM
;
353 pd
->dwData
= This
->buffersize
;
358 WARN("Unknown type %p\n",rguid
);
365 static HRESULT WINAPI
SysKeyboardAImpl_GetDeviceState(
366 LPDIRECTINPUTDEVICE8A iface
,DWORD len
,LPVOID ptr
369 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
370 TRACE("(%p)->(%ld,%p)\n", This
, len
, ptr
);
372 if (This
->acquired
== 0) return DIERR_NOTACQUIRED
;
374 if (len
!= WINE_DINPUT_KEYBOARD_MAX_KEYS
)
375 return DIERR_INVALIDPARAM
;
377 MsgWaitForMultipleObjectsEx(0, NULL
, 0, QS_ALLINPUT
, 0);
379 EnterCriticalSection(&(This
->crit
));
381 if (TRACE_ON(dinput
)) {
383 for (i
= 0; i
< WINE_DINPUT_KEYBOARD_MAX_KEYS
; i
++) {
384 if (DInputKeyState
[i
] != 0x00) {
385 TRACE(" - %02X: %02x\n", i
, DInputKeyState
[i
]);
390 memcpy(ptr
, DInputKeyState
, WINE_DINPUT_KEYBOARD_MAX_KEYS
);
391 LeaveCriticalSection(&(This
->crit
));
396 static HRESULT WINAPI
SysKeyboardAImpl_GetDeviceData(
397 LPDIRECTINPUTDEVICE8A iface
,DWORD dodsize
,LPDIDEVICEOBJECTDATA dod
,
398 LPDWORD entries
,DWORD flags
401 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
402 int ret
= DI_OK
, i
= 0;
404 TRACE("(this=%p,%ld,%p,%p(%ld)),0x%08lx)\n",
405 This
,dodsize
,dod
,entries
,entries
?*entries
:0,flags
);
407 if (This
->acquired
== 0)
408 return DIERR_NOTACQUIRED
;
410 if (This
->buffer
== NULL
)
411 return DIERR_NOTBUFFERED
;
413 if (dodsize
< sizeof(DIDEVICEOBJECTDATA_DX3
))
414 return DIERR_INVALIDPARAM
;
416 MsgWaitForMultipleObjectsEx(0, NULL
, 0, QS_ALLINPUT
, 0);
418 EnterCriticalSection(&(This
->crit
));
420 /* Copy item at a time for the case dodsize > sizeof(buffer[n]) */
421 while ((i
< *entries
|| *entries
== INFINITE
) && i
< This
->count
)
425 int n
= (This
->start
+ i
) % This
->buffersize
;
426 LPDIDEVICEOBJECTDATA pd
427 = (LPDIDEVICEOBJECTDATA
)((BYTE
*)dod
+ dodsize
* i
);
428 pd
->dwOfs
= This
->buffer
[n
].dwOfs
;
429 pd
->dwData
= This
->buffer
[n
].dwData
;
430 pd
->dwTimeStamp
= This
->buffer
[n
].dwTimeStamp
;
431 pd
->dwSequence
= This
->buffer
[n
].dwSequence
;
439 ret
= DI_BUFFEROVERFLOW
;
441 if (!(flags
& DIGDD_PEEK
))
445 This
->start
= (This
->start
+ i
) % This
->buffersize
;
446 This
->overflow
= FALSE
;
449 LeaveCriticalSection(&(This
->crit
));
451 TRACE("Returning %ld events queued\n", *entries
);
456 static HRESULT WINAPI
SysKeyboardAImpl_EnumObjects(
457 LPDIRECTINPUTDEVICE8A iface
,
458 LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback
,
462 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
463 DIDEVICEOBJECTINSTANCEA ddoi
;
466 TRACE("(this=%p,%p,%p,%08lx)\n", This
, lpCallback
, lpvRef
, dwFlags
);
467 if (TRACE_ON(dinput
)) {
468 TRACE(" - flags = ");
469 _dump_EnumObjects_flags(dwFlags
);
473 /* Only the fields till dwFFMaxForce are relevant */
474 memset(&ddoi
, 0, sizeof(ddoi
));
475 ddoi
.dwSize
= FIELD_OFFSET(DIDEVICEOBJECTINSTANCEA
, dwFFMaxForce
);
477 for (i
= 0; i
< WINE_DINPUT_KEYBOARD_MAX_KEYS
; i
++) {
478 /* Report 255 keys :-) */
479 ddoi
.guidType
= GUID_Key
;
481 ddoi
.dwType
= DIDFT_MAKEINSTANCE(i
) | DIDFT_BUTTON
;
482 GetKeyNameTextA(((i
& 0x7f) << 16) | ((i
& 0x80) << 17), ddoi
.tszName
, sizeof(ddoi
.tszName
));
483 _dump_OBJECTINSTANCEA(&ddoi
);
484 if (lpCallback(&ddoi
, lpvRef
) != DIENUM_CONTINUE
) return DI_OK
;
490 static HRESULT WINAPI
SysKeyboardWImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface
,
491 LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback
,
495 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
497 device_enumobjects_AtoWcb_data data
;
499 data
.lpCallBack
= lpCallback
;
500 data
.lpvRef
= lpvRef
;
502 return SysKeyboardAImpl_EnumObjects((LPDIRECTINPUTDEVICE8A
) This
, (LPDIENUMDEVICEOBJECTSCALLBACKA
) DIEnumDevicesCallbackAtoW
, (LPVOID
) &data
, dwFlags
);
505 static HRESULT WINAPI
SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface
);
507 static HRESULT WINAPI
SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface
)
509 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
511 TRACE("(this=%p)\n",This
);
518 if (current_lock
!= NULL
) {
519 FIXME("Not more than one keyboard can be acquired at the same time.\n");
520 SysKeyboardAImpl_Unacquire(iface
);
525 if (This
->buffersize
> 0) {
526 This
->buffer
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
527 This
->buffersize
* sizeof(*(This
->buffer
)));
530 This
->overflow
= FALSE
;
535 set_dinput_hook(WH_KEYBOARD_LL
, KeyboardCallback
);
540 static HRESULT WINAPI
SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface
)
542 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
543 TRACE("(this=%p)\n",This
);
545 if (This
->acquired
== 0)
548 set_dinput_hook(WH_KEYBOARD_LL
, NULL
);
551 if (current_lock
== This
)
554 ERR("this != current_lock\n");
556 /* Unacquire device */
559 if (This
->buffersize
>= 0) {
560 HeapFree(GetProcessHeap(), 0, This
->buffer
);
567 static HRESULT WINAPI
SysKeyboardAImpl_SetEventNotification(LPDIRECTINPUTDEVICE8A iface
,
569 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
571 TRACE("(this=%p,%p)\n",This
,hnd
);
577 /******************************************************************************
578 * GetCapabilities : get the device capablitites
580 static HRESULT WINAPI
SysKeyboardAImpl_GetCapabilities(
581 LPDIRECTINPUTDEVICE8A iface
,
582 LPDIDEVCAPS lpDIDevCaps
)
584 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
587 TRACE("(this=%p,%p)\n",This
,lpDIDevCaps
);
589 if ((lpDIDevCaps
->dwSize
!= sizeof(DIDEVCAPS
)) && (lpDIDevCaps
->dwSize
!= sizeof(DIDEVCAPS_DX3
))) {
590 WARN("invalid parameter\n");
591 return DIERR_INVALIDPARAM
;
594 devcaps
.dwSize
= lpDIDevCaps
->dwSize
;
595 devcaps
.dwFlags
= DIDC_ATTACHED
;
596 if (This
->dinput
->dwVersion
>= 0x0800)
597 devcaps
.dwDevType
= DI8DEVTYPE_KEYBOARD
| (DI8DEVTYPEKEYBOARD_UNKNOWN
<< 8);
599 devcaps
.dwDevType
= DIDEVTYPE_KEYBOARD
| (DIDEVTYPEKEYBOARD_UNKNOWN
<< 8);
601 devcaps
.dwButtons
= WINE_DINPUT_KEYBOARD_MAX_KEYS
;
603 devcaps
.dwFFSamplePeriod
= 0;
604 devcaps
.dwFFMinTimeResolution
= 0;
605 devcaps
.dwFirmwareRevision
= 100;
606 devcaps
.dwHardwareRevision
= 100;
607 devcaps
.dwFFDriverVersion
= 0;
609 memcpy(lpDIDevCaps
, &devcaps
, lpDIDevCaps
->dwSize
);
614 /******************************************************************************
615 * GetObjectInfo : get information about a device object such as a button
618 static HRESULT WINAPI
619 SysKeyboardAImpl_GetObjectInfo(
620 LPDIRECTINPUTDEVICE8A iface
,
621 LPDIDEVICEOBJECTINSTANCEA pdidoi
,
625 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
626 DIDEVICEOBJECTINSTANCEA ddoi
;
627 DWORD dwSize
= pdidoi
->dwSize
;
629 TRACE("(this=%p,%p,%ld,0x%08lx)\n", This
, pdidoi
, dwObj
, dwHow
);
631 if (dwHow
== DIPH_BYID
) {
632 WARN(" querying by id not supported yet...\n");
636 memset(pdidoi
, 0, dwSize
);
637 memset(&ddoi
, 0, sizeof(ddoi
));
639 ddoi
.dwSize
= dwSize
;
640 ddoi
.guidType
= GUID_Key
;
642 ddoi
.dwType
= DIDFT_MAKEINSTANCE(dwObj
) | DIDFT_BUTTON
;
643 GetKeyNameTextA(((dwObj
& 0x7f) << 16) | ((dwObj
& 0x80) << 17), ddoi
.tszName
, sizeof(ddoi
.tszName
));
645 /* And return our just filled device object instance structure */
646 memcpy(pdidoi
, &ddoi
, (dwSize
< sizeof(ddoi
) ? dwSize
: sizeof(ddoi
)));
648 _dump_OBJECTINSTANCEA(pdidoi
);
653 static HRESULT WINAPI
SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface
,
654 LPDIDEVICEOBJECTINSTANCEW pdidoi
,
658 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
659 DIDEVICEOBJECTINSTANCEW ddoi
;
660 DWORD dwSize
= pdidoi
->dwSize
;
662 TRACE("(this=%p,%p,%ld,0x%08lx)\n", This
, pdidoi
, dwObj
, dwHow
);
664 if (dwHow
== DIPH_BYID
) {
665 WARN(" querying by id not supported yet...\n");
669 memset(pdidoi
, 0, dwSize
);
670 memset(&ddoi
, 0, sizeof(ddoi
));
672 ddoi
.dwSize
= dwSize
;
673 ddoi
.guidType
= GUID_Key
;
675 ddoi
.dwType
= DIDFT_MAKEINSTANCE(dwObj
) | DIDFT_BUTTON
;
676 GetKeyNameTextW(((dwObj
& 0x7f) << 16) | ((dwObj
& 0x80) << 17), ddoi
.tszName
, sizeof(ddoi
.tszName
));
678 /* And return our just filled device object instance structure */
679 memcpy(pdidoi
, &ddoi
, (dwSize
< sizeof(ddoi
) ? dwSize
: sizeof(ddoi
)));
681 _dump_OBJECTINSTANCEW(pdidoi
);
686 /******************************************************************************
687 * GetDeviceInfo : get information about a device's identity
689 static HRESULT WINAPI
SysKeyboardAImpl_GetDeviceInfo(
690 LPDIRECTINPUTDEVICE8A iface
,
691 LPDIDEVICEINSTANCEA pdidi
)
693 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
694 TRACE("(this=%p,%p)\n", This
, pdidi
);
696 if (pdidi
->dwSize
!= sizeof(DIDEVICEINSTANCEA
)) {
697 WARN(" dinput3 not supported yet...\n");
701 fill_keyboard_dideviceinstanceA(pdidi
, This
->dinput
->dwVersion
);
706 static HRESULT WINAPI
SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface
, LPDIDEVICEINSTANCEW pdidi
)
708 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
709 TRACE("(this=%p,%p)\n", This
, pdidi
);
711 if (pdidi
->dwSize
!= sizeof(DIDEVICEINSTANCEW
)) {
712 WARN(" dinput3 not supported yet...\n");
716 fill_keyboard_dideviceinstanceW(pdidi
, This
->dinput
->dwVersion
);
721 static const IDirectInputDevice8AVtbl SysKeyboardAvt
=
723 IDirectInputDevice2AImpl_QueryInterface
,
724 IDirectInputDevice2AImpl_AddRef
,
725 SysKeyboardAImpl_Release
,
726 SysKeyboardAImpl_GetCapabilities
,
727 SysKeyboardAImpl_EnumObjects
,
728 SysKeyboardAImpl_GetProperty
,
729 SysKeyboardAImpl_SetProperty
,
730 SysKeyboardAImpl_Acquire
,
731 SysKeyboardAImpl_Unacquire
,
732 SysKeyboardAImpl_GetDeviceState
,
733 SysKeyboardAImpl_GetDeviceData
,
734 IDirectInputDevice2AImpl_SetDataFormat
,
735 SysKeyboardAImpl_SetEventNotification
,
736 IDirectInputDevice2AImpl_SetCooperativeLevel
,
737 SysKeyboardAImpl_GetObjectInfo
,
738 SysKeyboardAImpl_GetDeviceInfo
,
739 IDirectInputDevice2AImpl_RunControlPanel
,
740 IDirectInputDevice2AImpl_Initialize
,
741 IDirectInputDevice2AImpl_CreateEffect
,
742 IDirectInputDevice2AImpl_EnumEffects
,
743 IDirectInputDevice2AImpl_GetEffectInfo
,
744 IDirectInputDevice2AImpl_GetForceFeedbackState
,
745 IDirectInputDevice2AImpl_SendForceFeedbackCommand
,
746 IDirectInputDevice2AImpl_EnumCreatedEffectObjects
,
747 IDirectInputDevice2AImpl_Escape
,
748 IDirectInputDevice2AImpl_Poll
,
749 IDirectInputDevice2AImpl_SendDeviceData
,
750 IDirectInputDevice7AImpl_EnumEffectsInFile
,
751 IDirectInputDevice7AImpl_WriteEffectToFile
,
752 IDirectInputDevice8AImpl_BuildActionMap
,
753 IDirectInputDevice8AImpl_SetActionMap
,
754 IDirectInputDevice8AImpl_GetImageInfo
757 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
758 # define XCAST(fun) (typeof(SysKeyboardWvt.fun))
760 # define XCAST(fun) (void*)
763 static const IDirectInputDevice8WVtbl SysKeyboardWvt
=
765 IDirectInputDevice2WImpl_QueryInterface
,
766 XCAST(AddRef
)IDirectInputDevice2AImpl_AddRef
,
767 XCAST(Release
)SysKeyboardAImpl_Release
,
768 XCAST(GetCapabilities
)SysKeyboardAImpl_GetCapabilities
,
769 SysKeyboardWImpl_EnumObjects
,
770 XCAST(GetProperty
)SysKeyboardAImpl_GetProperty
,
771 XCAST(SetProperty
)SysKeyboardAImpl_SetProperty
,
772 XCAST(Acquire
)SysKeyboardAImpl_Acquire
,
773 XCAST(Unacquire
)SysKeyboardAImpl_Unacquire
,
774 XCAST(GetDeviceState
)SysKeyboardAImpl_GetDeviceState
,
775 XCAST(GetDeviceData
)SysKeyboardAImpl_GetDeviceData
,
776 XCAST(SetDataFormat
)IDirectInputDevice2AImpl_SetDataFormat
,
777 XCAST(SetEventNotification
)SysKeyboardAImpl_SetEventNotification
,
778 XCAST(SetCooperativeLevel
)IDirectInputDevice2AImpl_SetCooperativeLevel
,
779 SysKeyboardWImpl_GetObjectInfo
,
780 SysKeyboardWImpl_GetDeviceInfo
,
781 XCAST(RunControlPanel
)IDirectInputDevice2AImpl_RunControlPanel
,
782 XCAST(Initialize
)IDirectInputDevice2AImpl_Initialize
,
783 XCAST(CreateEffect
)IDirectInputDevice2AImpl_CreateEffect
,
784 IDirectInputDevice2WImpl_EnumEffects
,
785 IDirectInputDevice2WImpl_GetEffectInfo
,
786 XCAST(GetForceFeedbackState
)IDirectInputDevice2AImpl_GetForceFeedbackState
,
787 XCAST(SendForceFeedbackCommand
)IDirectInputDevice2AImpl_SendForceFeedbackCommand
,
788 XCAST(EnumCreatedEffectObjects
)IDirectInputDevice2AImpl_EnumCreatedEffectObjects
,
789 XCAST(Escape
)IDirectInputDevice2AImpl_Escape
,
790 XCAST(Poll
)IDirectInputDevice2AImpl_Poll
,
791 XCAST(SendDeviceData
)IDirectInputDevice2AImpl_SendDeviceData
,
792 IDirectInputDevice7WImpl_EnumEffectsInFile
,
793 IDirectInputDevice7WImpl_WriteEffectToFile
,
794 IDirectInputDevice8WImpl_BuildActionMap
,
795 IDirectInputDevice8WImpl_SetActionMap
,
796 IDirectInputDevice8WImpl_GetImageInfo