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
)
204 if ((dwDevType
== 0) ||
205 ((dwDevType
== DIDEVTYPE_KEYBOARD
) && (version
< 8)) ||
206 ((dwDevType
== DI8DEVTYPE_KEYBOARD
) && (version
>= 8))) {
207 TRACE("Enumerating the Keyboard device\n");
209 fill_keyboard_dideviceinstanceA(lpddi
, version
);
217 static BOOL
keyboarddev_enum_deviceW(DWORD dwDevType
, DWORD dwFlags
, LPDIDEVICEINSTANCEW lpddi
, int version
)
219 if ((dwDevType
== 0) ||
220 ((dwDevType
== DIDEVTYPE_KEYBOARD
) && (version
< 8)) ||
221 ((dwDevType
== DI8DEVTYPE_KEYBOARD
) && (version
>= 8))) {
222 TRACE("Enumerating the Keyboard device\n");
224 fill_keyboard_dideviceinstanceW(lpddi
, version
);
232 static SysKeyboardImpl
*alloc_device(REFGUID rguid
, LPVOID kvt
, IDirectInputImpl
*dinput
)
234 SysKeyboardImpl
* newDevice
;
235 newDevice
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(SysKeyboardImpl
));
236 newDevice
->lpVtbl
= kvt
;
238 memcpy(&(newDevice
->guid
),rguid
,sizeof(*rguid
));
239 newDevice
->dinput
= dinput
;
241 EnterCriticalSection(&keyboard_crit
);
242 if (!keyboard_users
++)
243 keyboard_hook
= SetWindowsHookExW( WH_KEYBOARD_LL
, KeyboardCallback
, DINPUT_instance
, 0 );
244 LeaveCriticalSection(&keyboard_crit
);
250 static HRESULT
keyboarddev_create_deviceA(IDirectInputImpl
*dinput
, REFGUID rguid
, REFIID riid
, LPDIRECTINPUTDEVICEA
* pdev
)
252 if ((IsEqualGUID(&GUID_SysKeyboard
,rguid
)) || /* Generic Keyboard */
253 (IsEqualGUID(&DInput_Wine_Keyboard_GUID
,rguid
))) { /* Wine Keyboard */
254 if ((riid
== NULL
) ||
255 IsEqualGUID(&IID_IDirectInputDeviceA
,riid
) ||
256 IsEqualGUID(&IID_IDirectInputDevice2A
,riid
) ||
257 IsEqualGUID(&IID_IDirectInputDevice7A
,riid
) ||
258 IsEqualGUID(&IID_IDirectInputDevice8A
,riid
)) {
259 *pdev
= (IDirectInputDeviceA
*) alloc_device(rguid
, &SysKeyboardAvt
, dinput
);
260 TRACE("Creating a Keyboard device (%p)\n", *pdev
);
263 return DIERR_NOINTERFACE
;
265 return DIERR_DEVICENOTREG
;
268 static HRESULT
keyboarddev_create_deviceW(IDirectInputImpl
*dinput
, REFGUID rguid
, REFIID riid
, LPDIRECTINPUTDEVICEW
* pdev
)
270 if ((IsEqualGUID(&GUID_SysKeyboard
,rguid
)) || /* Generic Keyboard */
271 (IsEqualGUID(&DInput_Wine_Keyboard_GUID
,rguid
))) { /* Wine Keyboard */
272 if ((riid
== NULL
) ||
273 IsEqualGUID(&IID_IDirectInputDeviceW
,riid
) ||
274 IsEqualGUID(&IID_IDirectInputDevice2W
,riid
) ||
275 IsEqualGUID(&IID_IDirectInputDevice7W
,riid
) ||
276 IsEqualGUID(&IID_IDirectInputDevice8W
,riid
)) {
277 *pdev
= (IDirectInputDeviceW
*) alloc_device(rguid
, &SysKeyboardWvt
, dinput
);
278 TRACE("Creating a Keyboard device (%p)\n", *pdev
);
281 return DIERR_NOINTERFACE
;
283 return DIERR_DEVICENOTREG
;
286 static dinput_device keyboarddev
= {
288 "Wine keyboard driver",
289 keyboarddev_enum_deviceA
,
290 keyboarddev_enum_deviceW
,
291 keyboarddev_create_deviceA
,
292 keyboarddev_create_deviceW
295 DECL_GLOBAL_CONSTRUCTOR(keyboarddev_register
) { dinput_register_device(&keyboarddev
); }
297 static ULONG WINAPI
SysKeyboardAImpl_Release(LPDIRECTINPUTDEVICE8A iface
)
299 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
305 EnterCriticalSection(&keyboard_crit
);
306 if (!--keyboard_users
) {
307 UnhookWindowsHookEx( keyboard_hook
);
310 LeaveCriticalSection(&keyboard_crit
);
312 /* Free the data queue */
313 if (This
->buffer
!= NULL
)
314 HeapFree(GetProcessHeap(),0,This
->buffer
);
316 DeleteCriticalSection(&(This
->crit
));
318 HeapFree(GetProcessHeap(),0,This
);
322 static HRESULT WINAPI
SysKeyboardAImpl_SetProperty(
323 LPDIRECTINPUTDEVICE8A iface
,REFGUID rguid
,LPCDIPROPHEADER ph
326 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
328 TRACE("(this=%p,%s,%p)\n",This
,debugstr_guid(rguid
),ph
);
329 TRACE("(size=%ld,headersize=%ld,obj=%ld,how=%ld\n",
330 ph
->dwSize
,ph
->dwHeaderSize
,ph
->dwObj
,ph
->dwHow
);
331 if (!HIWORD(rguid
)) {
332 switch ((DWORD
)rguid
) {
333 case (DWORD
) DIPROP_BUFFERSIZE
: {
334 LPCDIPROPDWORD pd
= (LPCDIPROPDWORD
)ph
;
336 TRACE("(buffersize=%ld)\n",pd
->dwData
);
339 return DIERR_INVALIDPARAM
;
341 This
->buffersize
= pd
->dwData
;
346 WARN("Unknown type %ld\n",(DWORD
)rguid
);
353 static HRESULT WINAPI
SysKeyboardAImpl_GetDeviceState(
354 LPDIRECTINPUTDEVICE8A iface
,DWORD len
,LPVOID ptr
357 TRACE("(%p)->(%ld,%p)\n", iface
, len
, ptr
);
359 /* Note: device does not need to be acquired */
361 return DIERR_INVALIDPARAM
;
363 MsgWaitForMultipleObjectsEx(0, NULL
, 0, 0, 0);
365 if (TRACE_ON(dinput
)) {
367 for (i
= 0; i
< 256; i
++) {
368 if (DInputKeyState
[i
] != 0x00) {
369 TRACE(" - %02X: %02x\n", i
, DInputKeyState
[i
]);
374 memcpy(ptr
, DInputKeyState
, 256);
378 static HRESULT WINAPI
SysKeyboardAImpl_GetDeviceData(
379 LPDIRECTINPUTDEVICE8A iface
,DWORD dodsize
,LPDIDEVICEOBJECTDATA dod
,
380 LPDWORD entries
,DWORD flags
383 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
384 int ret
= DI_OK
, i
= 0;
386 TRACE("(this=%p,%ld,%p,%p(%ld)),0x%08lx)\n",
387 This
,dodsize
,dod
,entries
,entries
?*entries
:0,flags
);
389 if (This
->acquired
== 0)
390 return DIERR_NOTACQUIRED
;
392 if (This
->buffer
== NULL
)
393 return DIERR_NOTBUFFERED
;
395 if (dodsize
< sizeof(*dod
))
396 return DIERR_INVALIDPARAM
;
398 MsgWaitForMultipleObjectsEx(0, NULL
, 0, 0, 0);
400 EnterCriticalSection(&(This
->crit
));
402 /* Copy item at a time for the case dodsize > sizeof(buffer[n]) */
403 while ((i
< *entries
|| *entries
== INFINITE
) && i
< This
->count
)
407 int n
= (This
->start
+ i
) % This
->buffersize
;
408 LPDIDEVICEOBJECTDATA pd
409 = (LPDIDEVICEOBJECTDATA
)((BYTE
*)dod
+ dodsize
* i
);
410 pd
->dwOfs
= This
->buffer
[n
].dwOfs
;
411 pd
->dwData
= This
->buffer
[n
].dwData
;
412 pd
->dwTimeStamp
= This
->buffer
[n
].dwTimeStamp
;
413 pd
->dwSequence
= This
->buffer
[n
].dwSequence
;
421 ret
= DI_BUFFEROVERFLOW
;
423 if (!(flags
& DIGDD_PEEK
))
427 This
->start
= (This
->start
+ i
) % This
->buffersize
;
428 This
->overflow
= FALSE
;
431 LeaveCriticalSection(&(This
->crit
));
433 TRACE("Returning %ld events queued\n", *entries
);
438 static HRESULT WINAPI
SysKeyboardAImpl_EnumObjects(
439 LPDIRECTINPUTDEVICE8A iface
,
440 LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback
,
444 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
445 DIDEVICEOBJECTINSTANCEA ddoi
;
448 TRACE("(this=%p,%p,%p,%08lx)\n", This
, lpCallback
, lpvRef
, dwFlags
);
449 if (TRACE_ON(dinput
)) {
450 TRACE(" - flags = ");
451 _dump_EnumObjects_flags(dwFlags
);
455 /* Only the fields till dwFFMaxForce are relevant */
456 memset(&ddoi
, 0, sizeof(ddoi
));
457 ddoi
.dwSize
= FIELD_OFFSET(DIDEVICEOBJECTINSTANCEA
, dwFFMaxForce
);
459 for (i
= 0; i
< 256; i
++) {
460 /* Report 255 keys :-) */
461 ddoi
.guidType
= GUID_Key
;
463 ddoi
.dwType
= DIDFT_MAKEINSTANCE(i
) | DIDFT_BUTTON
;
464 GetKeyNameTextA(((i
& 0x7f) << 16) | ((i
& 0x80) << 17), ddoi
.tszName
, sizeof(ddoi
.tszName
));
465 _dump_OBJECTINSTANCEA(&ddoi
);
466 if (lpCallback(&ddoi
, lpvRef
) != DIENUM_CONTINUE
) return DI_OK
;
472 static HRESULT WINAPI
SysKeyboardWImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface
,
473 LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback
,
477 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
479 device_enumobjects_AtoWcb_data data
;
481 data
.lpCallBack
= lpCallback
;
482 data
.lpvRef
= lpvRef
;
484 return SysKeyboardAImpl_EnumObjects((LPDIRECTINPUTDEVICE8A
) This
, (LPDIENUMDEVICEOBJECTSCALLBACKA
) DIEnumDevicesCallbackAtoW
, (LPVOID
) &data
, dwFlags
);
487 static HRESULT WINAPI
SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface
);
489 static HRESULT WINAPI
SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface
)
491 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
493 TRACE("(this=%p)\n",This
);
502 FIXME("Not more than one keyboard can be acquired at the same time.\n");
503 SysKeyboardAImpl_Unacquire(iface
);
508 if (This
->buffersize
> 0)
510 This
->buffer
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
511 This
->buffersize
* sizeof(*(This
->buffer
)));
514 This
->overflow
= FALSE
;
515 InitializeCriticalSection(&(This
->crit
));
523 static HRESULT WINAPI
SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface
)
525 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
526 TRACE("(this=%p)\n",This
);
528 if (This
->acquired
== 0)
534 ERR("this != current\n");
538 if (This
->buffersize
>= 0)
540 HeapFree(GetProcessHeap(), 0, This
->buffer
);
542 DeleteCriticalSection(&(This
->crit
));
548 static HRESULT WINAPI
SysKeyboardAImpl_SetEventNotification(LPDIRECTINPUTDEVICE8A iface
,
550 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
552 TRACE("(this=%p,0x%08lx)\n",This
,(DWORD
)hnd
);
558 /******************************************************************************
559 * GetCapabilities : get the device capablitites
561 static HRESULT WINAPI
SysKeyboardAImpl_GetCapabilities(
562 LPDIRECTINPUTDEVICE8A iface
,
563 LPDIDEVCAPS lpDIDevCaps
)
565 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
567 TRACE("(this=%p,%p)\n",This
,lpDIDevCaps
);
569 if (lpDIDevCaps
->dwSize
== sizeof(DIDEVCAPS
)) {
570 lpDIDevCaps
->dwFlags
= DIDC_ATTACHED
;
571 if (This
->dinput
->version
>= 8)
572 lpDIDevCaps
->dwDevType
= DI8DEVTYPE_KEYBOARD
| (DI8DEVTYPEKEYBOARD_UNKNOWN
<< 8);
574 lpDIDevCaps
->dwDevType
= DIDEVTYPE_KEYBOARD
| (DIDEVTYPEKEYBOARD_UNKNOWN
<< 8);
575 lpDIDevCaps
->dwAxes
= 0;
576 lpDIDevCaps
->dwButtons
= 256;
577 lpDIDevCaps
->dwPOVs
= 0;
578 lpDIDevCaps
->dwFFSamplePeriod
= 0;
579 lpDIDevCaps
->dwFFMinTimeResolution
= 0;
580 lpDIDevCaps
->dwFirmwareRevision
= 100;
581 lpDIDevCaps
->dwHardwareRevision
= 100;
582 lpDIDevCaps
->dwFFDriverVersion
= 0;
585 FIXME("DirectX 3.0 not supported....\n");
591 /******************************************************************************
592 * GetObjectInfo : get information about a device object such as a button
595 static HRESULT WINAPI
596 SysKeyboardAImpl_GetObjectInfo(
597 LPDIRECTINPUTDEVICE8A iface
,
598 LPDIDEVICEOBJECTINSTANCEA pdidoi
,
602 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
603 DIDEVICEOBJECTINSTANCEA ddoi
;
604 DWORD dwSize
= pdidoi
->dwSize
;
606 TRACE("(this=%p,%p,%ld,0x%08lx)\n", This
, pdidoi
, dwObj
, dwHow
);
608 if (dwHow
== DIPH_BYID
) {
609 WARN(" querying by id not supported yet...\n");
613 memset(pdidoi
, 0, dwSize
);
614 memset(&ddoi
, 0, sizeof(ddoi
));
616 ddoi
.dwSize
= dwSize
;
617 ddoi
.guidType
= GUID_Key
;
619 ddoi
.dwType
= DIDFT_MAKEINSTANCE(dwObj
) | DIDFT_BUTTON
;
620 GetKeyNameTextA(((dwObj
& 0x7f) << 16) | ((dwObj
& 0x80) << 17), ddoi
.tszName
, sizeof(ddoi
.tszName
));
622 /* And return our just filled device object instance structure */
623 memcpy(pdidoi
, &ddoi
, (dwSize
< sizeof(ddoi
) ? dwSize
: sizeof(ddoi
)));
625 _dump_OBJECTINSTANCEA(pdidoi
);
630 static HRESULT WINAPI
SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface
,
631 LPDIDEVICEOBJECTINSTANCEW pdidoi
,
635 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
636 DIDEVICEOBJECTINSTANCEW ddoi
;
637 DWORD dwSize
= pdidoi
->dwSize
;
639 TRACE("(this=%p,%p,%ld,0x%08lx)\n", This
, pdidoi
, dwObj
, dwHow
);
641 if (dwHow
== DIPH_BYID
) {
642 WARN(" querying by id not supported yet...\n");
646 memset(pdidoi
, 0, dwSize
);
647 memset(&ddoi
, 0, sizeof(ddoi
));
649 ddoi
.dwSize
= dwSize
;
650 ddoi
.guidType
= GUID_Key
;
652 ddoi
.dwType
= DIDFT_MAKEINSTANCE(dwObj
) | DIDFT_BUTTON
;
653 GetKeyNameTextW(((dwObj
& 0x7f) << 16) | ((dwObj
& 0x80) << 17), ddoi
.tszName
, sizeof(ddoi
.tszName
));
655 /* And return our just filled device object instance structure */
656 memcpy(pdidoi
, &ddoi
, (dwSize
< sizeof(ddoi
) ? dwSize
: sizeof(ddoi
)));
658 _dump_OBJECTINSTANCEW(pdidoi
);
663 /******************************************************************************
664 * GetDeviceInfo : get information about a device's identity
666 static HRESULT WINAPI
SysKeyboardAImpl_GetDeviceInfo(
667 LPDIRECTINPUTDEVICE8A iface
,
668 LPDIDEVICEINSTANCEA pdidi
)
670 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
671 TRACE("(this=%p,%p)\n", This
, pdidi
);
673 if (pdidi
->dwSize
!= sizeof(DIDEVICEINSTANCEA
)) {
674 WARN(" dinput3 not supporte yet...\n");
678 fill_keyboard_dideviceinstanceA(pdidi
, This
->dinput
->version
);
683 static HRESULT WINAPI
SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface
, LPDIDEVICEINSTANCEW pdidi
)
685 SysKeyboardImpl
*This
= (SysKeyboardImpl
*)iface
;
686 TRACE("(this=%p,%p)\n", This
, pdidi
);
688 if (pdidi
->dwSize
!= sizeof(DIDEVICEINSTANCEW
)) {
689 WARN(" dinput3 not supporte yet...\n");
693 fill_keyboard_dideviceinstanceW(pdidi
, This
->dinput
->version
);
698 static IDirectInputDevice8AVtbl SysKeyboardAvt
=
700 IDirectInputDevice2AImpl_QueryInterface
,
701 IDirectInputDevice2AImpl_AddRef
,
702 SysKeyboardAImpl_Release
,
703 SysKeyboardAImpl_GetCapabilities
,
704 SysKeyboardAImpl_EnumObjects
,
705 IDirectInputDevice2AImpl_GetProperty
,
706 SysKeyboardAImpl_SetProperty
,
707 SysKeyboardAImpl_Acquire
,
708 SysKeyboardAImpl_Unacquire
,
709 SysKeyboardAImpl_GetDeviceState
,
710 SysKeyboardAImpl_GetDeviceData
,
711 IDirectInputDevice2AImpl_SetDataFormat
,
712 SysKeyboardAImpl_SetEventNotification
,
713 IDirectInputDevice2AImpl_SetCooperativeLevel
,
714 SysKeyboardAImpl_GetObjectInfo
,
715 SysKeyboardAImpl_GetDeviceInfo
,
716 IDirectInputDevice2AImpl_RunControlPanel
,
717 IDirectInputDevice2AImpl_Initialize
,
718 IDirectInputDevice2AImpl_CreateEffect
,
719 IDirectInputDevice2AImpl_EnumEffects
,
720 IDirectInputDevice2AImpl_GetEffectInfo
,
721 IDirectInputDevice2AImpl_GetForceFeedbackState
,
722 IDirectInputDevice2AImpl_SendForceFeedbackCommand
,
723 IDirectInputDevice2AImpl_EnumCreatedEffectObjects
,
724 IDirectInputDevice2AImpl_Escape
,
725 IDirectInputDevice2AImpl_Poll
,
726 IDirectInputDevice2AImpl_SendDeviceData
,
727 IDirectInputDevice7AImpl_EnumEffectsInFile
,
728 IDirectInputDevice7AImpl_WriteEffectToFile
,
729 IDirectInputDevice8AImpl_BuildActionMap
,
730 IDirectInputDevice8AImpl_SetActionMap
,
731 IDirectInputDevice8AImpl_GetImageInfo
734 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
735 # define XCAST(fun) (typeof(SysKeyboardWvt.fun))
737 # define XCAST(fun) (void*)
740 static IDirectInputDevice8WVtbl SysKeyboardWvt
=
742 IDirectInputDevice2WImpl_QueryInterface
,
743 XCAST(AddRef
)IDirectInputDevice2AImpl_AddRef
,
744 XCAST(Release
)SysKeyboardAImpl_Release
,
745 XCAST(GetCapabilities
)SysKeyboardAImpl_GetCapabilities
,
746 SysKeyboardWImpl_EnumObjects
,
747 XCAST(GetProperty
)IDirectInputDevice2AImpl_GetProperty
,
748 XCAST(SetProperty
)SysKeyboardAImpl_SetProperty
,
749 XCAST(Acquire
)SysKeyboardAImpl_Acquire
,
750 XCAST(Unacquire
)SysKeyboardAImpl_Unacquire
,
751 XCAST(GetDeviceState
)SysKeyboardAImpl_GetDeviceState
,
752 XCAST(GetDeviceData
)SysKeyboardAImpl_GetDeviceData
,
753 XCAST(SetDataFormat
)IDirectInputDevice2AImpl_SetDataFormat
,
754 XCAST(SetEventNotification
)SysKeyboardAImpl_SetEventNotification
,
755 XCAST(SetCooperativeLevel
)IDirectInputDevice2AImpl_SetCooperativeLevel
,
756 SysKeyboardWImpl_GetObjectInfo
,
757 SysKeyboardWImpl_GetDeviceInfo
,
758 XCAST(RunControlPanel
)IDirectInputDevice2AImpl_RunControlPanel
,
759 XCAST(Initialize
)IDirectInputDevice2AImpl_Initialize
,
760 XCAST(CreateEffect
)IDirectInputDevice2AImpl_CreateEffect
,
761 IDirectInputDevice2WImpl_EnumEffects
,
762 IDirectInputDevice2WImpl_GetEffectInfo
,
763 XCAST(GetForceFeedbackState
)IDirectInputDevice2AImpl_GetForceFeedbackState
,
764 XCAST(SendForceFeedbackCommand
)IDirectInputDevice2AImpl_SendForceFeedbackCommand
,
765 XCAST(EnumCreatedEffectObjects
)IDirectInputDevice2AImpl_EnumCreatedEffectObjects
,
766 XCAST(Escape
)IDirectInputDevice2AImpl_Escape
,
767 XCAST(Poll
)IDirectInputDevice2AImpl_Poll
,
768 XCAST(SendDeviceData
)IDirectInputDevice2AImpl_SendDeviceData
,
769 IDirectInputDevice7WImpl_EnumEffectsInFile
,
770 IDirectInputDevice7WImpl_WriteEffectToFile
,
771 IDirectInputDevice8WImpl_BuildActionMap
,
772 IDirectInputDevice8WImpl_SetActionMap
,
773 IDirectInputDevice8WImpl_GetImageInfo