dinput: Move keyboard to using new EnumObjects from base class.
[wine] / dlls / dinput / keyboard.c
1 /*              DirectInput Keyboard device
2  *
3  * Copyright 1998 Marcus Meissner
4  * Copyright 1998,1999 Lionel Ulmer
5  * Copyright 2000-2001 TransGaming Technologies Inc.
6  * Copyright 2005 Raphael Junqueira
7  *
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.
12  *
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.
17  *
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
21  */
22
23 #include "config.h"
24 #include "wine/port.h"
25
26 #include <stdarg.h>
27 #include <string.h>
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winuser.h"
31 #include "winerror.h"
32 #include "dinput.h"
33
34 #include "dinput_private.h"
35 #include "device_private.h"
36 #include "wine/debug.h"
37 #include "wine/unicode.h"
38
39 WINE_DEFAULT_DEBUG_CHANNEL(dinput);
40
41 #define WINE_DINPUT_KEYBOARD_MAX_KEYS 256
42
43 static const IDirectInputDevice8AVtbl SysKeyboardAvt;
44 static const IDirectInputDevice8WVtbl SysKeyboardWvt;
45
46 typedef struct SysKeyboardImpl SysKeyboardImpl;
47 struct SysKeyboardImpl
48 {
49     struct IDirectInputDevice2AImpl base;
50
51     IDirectInputImpl*           dinput;
52 };
53
54 static SysKeyboardImpl* current_lock = NULL; 
55 /* Today's acquired device
56  * FIXME: currently this can be only one.
57  * Maybe this should be a linked list or st.
58  * I don't know what the rules are for multiple acquired keyboards,
59  * but 'DI_LOSTFOCUS' and 'DI_UNACQUIRED' exist for a reason.
60 */
61
62 static BYTE DInputKeyState[WINE_DINPUT_KEYBOARD_MAX_KEYS]; /* array for 'GetDeviceState' */
63
64 LRESULT CALLBACK KeyboardCallback( int code, WPARAM wparam, LPARAM lparam )
65 {
66     SysKeyboardImpl *This = (SysKeyboardImpl *)current_lock;
67     int dik_code;
68     KBDLLHOOKSTRUCT *hook = (KBDLLHOOKSTRUCT *)lparam;
69     BYTE new_diks;
70
71     TRACE("(%d,%d,%ld)\n", code, wparam, lparam);
72
73     /* returns now if not HC_ACTION */
74     if (code != HC_ACTION) return CallNextHookEx(0, code, wparam, lparam);
75   
76     dik_code = hook->scanCode & 0xff;
77     if (hook->flags & LLKHF_EXTENDED) dik_code |= 0x80;
78
79     new_diks = hook->flags & LLKHF_UP ? 0 : 0x80;
80
81     /* returns now if key event already known */
82     if (new_diks == DInputKeyState[dik_code])
83         return CallNextHookEx(0, code, wparam, lparam);
84
85     DInputKeyState[dik_code] = new_diks;
86     TRACE(" setting %02X to %02X\n", dik_code, DInputKeyState[dik_code]);
87       
88     EnterCriticalSection(&This->base.crit);
89     queue_event((LPDIRECTINPUTDEVICE8A)This, dik_code, new_diks, hook->time, This->dinput->evsequence++);
90     LeaveCriticalSection(&This->base.crit);
91
92     if (This->base.hEvent) SetEvent(This->base.hEvent);
93     
94     return CallNextHookEx(0, code, wparam, lparam);
95 }
96
97 static GUID DInput_Wine_Keyboard_GUID = { /* 0ab8648a-7735-11d2-8c73-71df54a96441 */
98   0x0ab8648a,
99   0x7735,
100   0x11d2,
101   {0x8c, 0x73, 0x71, 0xdf, 0x54, 0xa9, 0x64, 0x41}
102 };
103
104 static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version) {
105     DWORD dwSize;
106     DIDEVICEINSTANCEA ddi;
107     
108     dwSize = lpddi->dwSize;
109
110     TRACE("%d %p\n", dwSize, lpddi);
111     
112     memset(lpddi, 0, dwSize);
113     memset(&ddi, 0, sizeof(ddi));
114
115     ddi.dwSize = dwSize;
116     ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
117     ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
118     if (version >= 0x0800)
119         ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
120     else
121         ddi.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
122     strcpy(ddi.tszInstanceName, "Keyboard");
123     strcpy(ddi.tszProductName, "Wine Keyboard");
124
125     memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
126 }
127
128 static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version) {
129     DWORD dwSize;
130     DIDEVICEINSTANCEW ddi;
131     
132     dwSize = lpddi->dwSize;
133
134     TRACE("%d %p\n", dwSize, lpddi);
135     
136     memset(lpddi, 0, dwSize);
137     memset(&ddi, 0, sizeof(ddi));
138  
139     ddi.dwSize = dwSize;
140     ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
141     ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
142     if (version >= 0x0800)
143         ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
144     else
145         ddi.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
146     MultiByteToWideChar(CP_ACP, 0, "Keyboard", -1, ddi.tszInstanceName, MAX_PATH);
147     MultiByteToWideChar(CP_ACP, 0, "Wine Keyboard", -1, ddi.tszProductName, MAX_PATH);
148
149     memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
150 }
151  
152 static BOOL keyboarddev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
153 {
154   if (id != 0)
155     return FALSE;
156
157   if ((dwDevType == 0) ||
158       ((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 0x0800)) ||
159       (((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 0x0800))) {
160     TRACE("Enumerating the Keyboard device\n");
161  
162     fill_keyboard_dideviceinstanceA(lpddi, version);
163     
164     return TRUE;
165   }
166
167   return FALSE;
168 }
169
170 static BOOL keyboarddev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
171 {
172   if (id != 0)
173     return FALSE;
174
175   if ((dwDevType == 0) ||
176       ((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 0x0800)) ||
177       (((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 0x0800))) {
178     TRACE("Enumerating the Keyboard device\n");
179
180     fill_keyboard_dideviceinstanceW(lpddi, version);
181     
182     return TRUE;
183   }
184
185   return FALSE;
186 }
187
188 static SysKeyboardImpl *alloc_device(REFGUID rguid, const void *kvt, IDirectInputImpl *dinput)
189 {
190     SysKeyboardImpl* newDevice;
191     LPDIDATAFORMAT df = NULL;
192     int i, idx = 0;
193
194     newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardImpl));
195     newDevice->base.lpVtbl = kvt;
196     newDevice->base.ref = 1;
197     memcpy(&newDevice->base.guid, rguid, sizeof(*rguid));
198     newDevice->dinput = dinput;
199     InitializeCriticalSection(&newDevice->base.crit);
200
201     /* Create copy of default data format */
202     if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIKeyboard.dwSize))) goto failed;
203     memcpy(df, &c_dfDIKeyboard, c_dfDIKeyboard.dwSize);
204     if (!(df->rgodf = HeapAlloc(GetProcessHeap(), 0, df->dwNumObjs * df->dwObjSize))) goto failed;
205
206     for (i = 0; i < df->dwNumObjs; i++)
207     {
208         char buf[MAX_PATH];
209
210         if (!GetKeyNameTextA(((i & 0x7f) << 16) | ((i & 0x80) << 17), buf, sizeof(buf)))
211             continue;
212
213         memcpy(&df->rgodf[idx], &c_dfDIKeyboard.rgodf[i], df->dwObjSize);
214         df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_PSHBUTTON;
215     }
216     df->dwNumObjs = idx;
217
218     newDevice->base.data_format.wine_df = df;
219     IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->dinput);
220     return newDevice;
221
222 failed:
223     if (df) HeapFree(GetProcessHeap(), 0, df->rgodf);
224     HeapFree(GetProcessHeap(), 0, df);
225     HeapFree(GetProcessHeap(), 0, newDevice);
226     return NULL;
227 }
228
229
230 static HRESULT keyboarddev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
231 {
232   if ((IsEqualGUID(&GUID_SysKeyboard,rguid)) ||          /* Generic Keyboard */
233       (IsEqualGUID(&DInput_Wine_Keyboard_GUID,rguid))) { /* Wine Keyboard */
234     if ((riid == NULL) ||
235         IsEqualGUID(&IID_IDirectInputDeviceA,riid) ||
236         IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
237         IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
238         IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
239       *pdev = (IDirectInputDeviceA*) alloc_device(rguid, &SysKeyboardAvt, dinput);
240       TRACE("Creating a Keyboard device (%p)\n", *pdev);
241       if (!*pdev) return DIERR_OUTOFMEMORY;
242       return DI_OK;
243     } else
244       return DIERR_NOINTERFACE;
245   }
246   return DIERR_DEVICENOTREG;
247 }
248
249 static HRESULT keyboarddev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
250 {
251   if ((IsEqualGUID(&GUID_SysKeyboard,rguid)) ||          /* Generic Keyboard */
252       (IsEqualGUID(&DInput_Wine_Keyboard_GUID,rguid))) { /* Wine Keyboard */
253     if ((riid == NULL) ||
254         IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
255         IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
256         IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
257         IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
258       *pdev = (IDirectInputDeviceW*) alloc_device(rguid, &SysKeyboardWvt, dinput);
259       TRACE("Creating a Keyboard device (%p)\n", *pdev);
260       if (!*pdev) return DIERR_OUTOFMEMORY;
261       return DI_OK;
262     } else
263       return DIERR_NOINTERFACE;
264   }
265   return DIERR_DEVICENOTREG;
266 }
267
268 const struct dinput_device keyboard_device = {
269   "Wine keyboard driver",
270   keyboarddev_enum_deviceA,
271   keyboarddev_enum_deviceW,
272   keyboarddev_create_deviceA,
273   keyboarddev_create_deviceW
274 };
275
276 static ULONG WINAPI SysKeyboardAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
277 {
278     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
279     ULONG ref;
280
281     ref = InterlockedDecrement(&This->base.ref);
282     if (ref) return ref;
283
284     set_dinput_hook(WH_KEYBOARD_LL, NULL);
285
286     HeapFree(GetProcessHeap(), 0, This->base.data_queue);
287
288     /* Free data format */
289     HeapFree(GetProcessHeap(), 0, (LPVOID)This->base.data_format.wine_df);
290     release_DataFormat(&This->base.data_format);
291
292     IDirectInput_Release((LPDIRECTINPUTDEVICE8A)This->dinput);
293     DeleteCriticalSection(&This->base.crit);
294     HeapFree(GetProcessHeap(), 0, This);
295
296     return DI_OK;
297 }
298
299 static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState(
300         LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
301 )
302 {
303     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
304     TRACE("(%p)->(%d,%p)\n", This, len, ptr);
305
306     if (!This->base.acquired) return DIERR_NOTACQUIRED;
307
308     if (len != WINE_DINPUT_KEYBOARD_MAX_KEYS)
309         return DIERR_INVALIDPARAM;
310
311     EnterCriticalSection(&This->base.crit);
312
313     if (TRACE_ON(dinput)) {
314         int i;
315         for (i = 0; i < WINE_DINPUT_KEYBOARD_MAX_KEYS; i++) {
316             if (DInputKeyState[i] != 0x00) {
317                 TRACE(" - %02X: %02x\n", i, DInputKeyState[i]);
318             }
319         }
320     }
321     
322     memcpy(ptr, DInputKeyState, WINE_DINPUT_KEYBOARD_MAX_KEYS);
323     LeaveCriticalSection(&This->base.crit);
324
325     return DI_OK;
326 }
327
328 static HRESULT WINAPI SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface);
329
330 static HRESULT WINAPI SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
331 {
332     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
333     HRESULT res;
334
335     TRACE("(%p)\n",This);
336
337     if ((res = IDirectInputDevice2AImpl_Acquire(iface)) != DI_OK) return res;
338
339     if (current_lock != NULL) {
340         FIXME("Not more than one keyboard can be acquired at the same time.\n");
341         SysKeyboardAImpl_Unacquire((LPDIRECTINPUTDEVICE8A)current_lock);
342     }
343     current_lock = This;
344
345     set_dinput_hook(WH_KEYBOARD_LL, KeyboardCallback);
346
347     return DI_OK;
348 }
349
350 static HRESULT WINAPI SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
351 {
352     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
353     HRESULT res;
354
355     TRACE("(this=%p)\n",This);
356
357     if ((res = IDirectInputDevice2AImpl_Unacquire(iface)) != DI_OK) return res;
358
359     set_dinput_hook(WH_KEYBOARD_LL, NULL);
360
361     /* No more locks */
362     if (current_lock == This)
363         current_lock = NULL;
364     else
365         ERR("this != current_lock\n");
366
367     return DI_OK;
368 }
369
370 /******************************************************************************
371   *     GetCapabilities : get the device capablitites
372   */
373 static HRESULT WINAPI SysKeyboardAImpl_GetCapabilities(
374         LPDIRECTINPUTDEVICE8A iface,
375         LPDIDEVCAPS lpDIDevCaps)
376 {
377     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
378     DIDEVCAPS devcaps;
379
380     TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
381
382     if ((lpDIDevCaps->dwSize != sizeof(DIDEVCAPS)) && (lpDIDevCaps->dwSize != sizeof(DIDEVCAPS_DX3))) {
383         WARN("invalid parameter\n");
384         return DIERR_INVALIDPARAM;
385     }
386     
387     devcaps.dwSize = lpDIDevCaps->dwSize;
388     devcaps.dwFlags = DIDC_ATTACHED;
389     if (This->dinput->dwVersion >= 0x0800)
390         devcaps.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
391     else
392         devcaps.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
393     devcaps.dwAxes = 0;
394     devcaps.dwButtons = This->base.data_format.wine_df->dwNumObjs;
395     devcaps.dwPOVs = 0;
396     devcaps.dwFFSamplePeriod = 0;
397     devcaps.dwFFMinTimeResolution = 0;
398     devcaps.dwFirmwareRevision = 100;
399     devcaps.dwHardwareRevision = 100;
400     devcaps.dwFFDriverVersion = 0;
401
402     memcpy(lpDIDevCaps, &devcaps, lpDIDevCaps->dwSize);
403     
404     return DI_OK;
405 }
406
407 /******************************************************************************
408   *     GetObjectInfo : get information about a device object such as a button
409   *                     or axis
410   */
411 static HRESULT WINAPI
412 SysKeyboardAImpl_GetObjectInfo(
413         LPDIRECTINPUTDEVICE8A iface,
414         LPDIDEVICEOBJECTINSTANCEA pdidoi,
415         DWORD dwObj,
416         DWORD dwHow)
417 {
418     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
419     DIDEVICEOBJECTINSTANCEA ddoi;
420     DWORD dwSize = pdidoi->dwSize;
421     
422     TRACE("(this=%p,%p,%d,0x%08x)\n", This, pdidoi, dwObj, dwHow);
423
424     if (dwHow == DIPH_BYID) {
425         WARN(" querying by id not supported yet...\n");
426         return DI_OK;
427     }
428
429     memset(pdidoi, 0, dwSize);
430     memset(&ddoi, 0, sizeof(ddoi));
431
432     ddoi.dwSize = dwSize;
433     ddoi.guidType = GUID_Key;
434     ddoi.dwOfs = dwObj;
435     ddoi.dwType = DIDFT_MAKEINSTANCE(dwObj) | DIDFT_BUTTON;
436     if (!GetKeyNameTextA(((dwObj & 0x7f) << 16) | ((dwObj & 0x80) << 17), ddoi.tszName, sizeof(ddoi.tszName)))
437         return DIERR_OBJECTNOTFOUND;
438
439     /* And return our just filled device object instance structure */
440     memcpy(pdidoi, &ddoi, (dwSize < sizeof(ddoi) ? dwSize : sizeof(ddoi)));
441     
442     _dump_OBJECTINSTANCEA(pdidoi);
443
444     return DI_OK;
445 }
446
447 static HRESULT WINAPI SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
448                                                      LPDIDEVICEOBJECTINSTANCEW pdidoi,
449                                                      DWORD dwObj,
450                                                      DWORD dwHow)
451 {
452     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
453     DIDEVICEOBJECTINSTANCEW ddoi;
454     DWORD dwSize = pdidoi->dwSize;
455     
456     TRACE("(this=%p,%p,%d,0x%08x)\n", This, pdidoi, dwObj, dwHow);
457
458     if (dwHow == DIPH_BYID) {
459         WARN(" querying by id not supported yet...\n");
460         return DI_OK;
461     }
462
463     memset(pdidoi, 0, dwSize);
464     memset(&ddoi, 0, sizeof(ddoi));
465
466     ddoi.dwSize = dwSize;
467     ddoi.guidType = GUID_Key;
468     ddoi.dwOfs = dwObj;
469     ddoi.dwType = DIDFT_MAKEINSTANCE(dwObj) | DIDFT_BUTTON;
470     if (!GetKeyNameTextW(((dwObj & 0x7f) << 16) | ((dwObj & 0x80) << 17), ddoi.tszName, sizeof(ddoi.tszName)))
471         return DIERR_OBJECTNOTFOUND;
472
473     /* And return our just filled device object instance structure */
474     memcpy(pdidoi, &ddoi, (dwSize < sizeof(ddoi) ? dwSize : sizeof(ddoi)));
475     
476     _dump_OBJECTINSTANCEW(pdidoi);
477
478     return DI_OK;
479 }
480
481 /******************************************************************************
482   *     GetDeviceInfo : get information about a device's identity
483   */
484 static HRESULT WINAPI SysKeyboardAImpl_GetDeviceInfo(
485         LPDIRECTINPUTDEVICE8A iface,
486         LPDIDEVICEINSTANCEA pdidi)
487 {
488     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
489     TRACE("(this=%p,%p)\n", This, pdidi);
490
491     if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA)) {
492         WARN(" dinput3 not supported yet...\n");
493         return DI_OK;
494     }
495
496     fill_keyboard_dideviceinstanceA(pdidi, This->dinput->dwVersion);
497     
498     return DI_OK;
499 }
500
501 static HRESULT WINAPI SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi) 
502 {
503     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
504     TRACE("(this=%p,%p)\n", This, pdidi);
505
506     if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)) {
507         WARN(" dinput3 not supported yet...\n");
508         return DI_OK;
509     }
510
511     fill_keyboard_dideviceinstanceW(pdidi, This->dinput->dwVersion);
512     
513     return DI_OK;
514 }
515
516 static HRESULT WINAPI SysKeyboardAImpl_Poll(LPDIRECTINPUTDEVICE8A iface)
517 {
518     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
519
520     TRACE("(%p)\n",This);
521
522     if (!This->base.acquired) return DIERR_NOTACQUIRED;
523     return DI_NOEFFECT;
524 }
525
526 static const IDirectInputDevice8AVtbl SysKeyboardAvt =
527 {
528         IDirectInputDevice2AImpl_QueryInterface,
529         IDirectInputDevice2AImpl_AddRef,
530         SysKeyboardAImpl_Release,
531         SysKeyboardAImpl_GetCapabilities,
532         IDirectInputDevice2AImpl_EnumObjects,
533         IDirectInputDevice2AImpl_GetProperty,
534         IDirectInputDevice2AImpl_SetProperty,
535         SysKeyboardAImpl_Acquire,
536         SysKeyboardAImpl_Unacquire,
537         SysKeyboardAImpl_GetDeviceState,
538         IDirectInputDevice2AImpl_GetDeviceData,
539         IDirectInputDevice2AImpl_SetDataFormat,
540         IDirectInputDevice2AImpl_SetEventNotification,
541         IDirectInputDevice2AImpl_SetCooperativeLevel,
542         SysKeyboardAImpl_GetObjectInfo,
543         SysKeyboardAImpl_GetDeviceInfo,
544         IDirectInputDevice2AImpl_RunControlPanel,
545         IDirectInputDevice2AImpl_Initialize,
546         IDirectInputDevice2AImpl_CreateEffect,
547         IDirectInputDevice2AImpl_EnumEffects,
548         IDirectInputDevice2AImpl_GetEffectInfo,
549         IDirectInputDevice2AImpl_GetForceFeedbackState,
550         IDirectInputDevice2AImpl_SendForceFeedbackCommand,
551         IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
552         IDirectInputDevice2AImpl_Escape,
553         SysKeyboardAImpl_Poll,
554         IDirectInputDevice2AImpl_SendDeviceData,
555         IDirectInputDevice7AImpl_EnumEffectsInFile,
556         IDirectInputDevice7AImpl_WriteEffectToFile,
557         IDirectInputDevice8AImpl_BuildActionMap,
558         IDirectInputDevice8AImpl_SetActionMap,
559         IDirectInputDevice8AImpl_GetImageInfo
560 };
561
562 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
563 # define XCAST(fun)     (typeof(SysKeyboardWvt.fun))
564 #else
565 # define XCAST(fun)     (void*)
566 #endif
567
568 static const IDirectInputDevice8WVtbl SysKeyboardWvt =
569 {
570         IDirectInputDevice2WImpl_QueryInterface,
571         XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
572         XCAST(Release)SysKeyboardAImpl_Release,
573         XCAST(GetCapabilities)SysKeyboardAImpl_GetCapabilities,
574         IDirectInputDevice2WImpl_EnumObjects,
575         XCAST(GetProperty)IDirectInputDevice2AImpl_GetProperty,
576         XCAST(SetProperty)IDirectInputDevice2AImpl_SetProperty,
577         XCAST(Acquire)SysKeyboardAImpl_Acquire,
578         XCAST(Unacquire)SysKeyboardAImpl_Unacquire,
579         XCAST(GetDeviceState)SysKeyboardAImpl_GetDeviceState,
580         XCAST(GetDeviceData)IDirectInputDevice2AImpl_GetDeviceData,
581         XCAST(SetDataFormat)IDirectInputDevice2AImpl_SetDataFormat,
582         XCAST(SetEventNotification)IDirectInputDevice2AImpl_SetEventNotification,
583         XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
584         SysKeyboardWImpl_GetObjectInfo,
585         SysKeyboardWImpl_GetDeviceInfo,
586         XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
587         XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
588         XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,
589         IDirectInputDevice2WImpl_EnumEffects,
590         IDirectInputDevice2WImpl_GetEffectInfo,
591         XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,
592         XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,
593         XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
594         XCAST(Escape)IDirectInputDevice2AImpl_Escape,
595         XCAST(Poll)SysKeyboardAImpl_Poll,
596         XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
597         IDirectInputDevice7WImpl_EnumEffectsInFile,
598         IDirectInputDevice7WImpl_WriteEffectToFile,
599         IDirectInputDevice8WImpl_BuildActionMap,
600         IDirectInputDevice8WImpl_SetActionMap,
601         IDirectInputDevice8WImpl_GetImageInfo
602 };
603 #undef XCAST