winecrt0: Add entry point code for stand-alone 16-bit executables.
[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     BYTE DInputKeyState[WINE_DINPUT_KEYBOARD_MAX_KEYS];
51 };
52
53 static BYTE map_dik_code(DWORD scanCode, DWORD vkCode)
54 {
55     static const BYTE asciiCodes[] =
56      {/*32*/  DIK_SPACE,0,0,0,0,0,0,DIK_APOSTROPHE,
57       /*40*/  0,0,0,0,DIK_COMMA,DIK_MINUS,DIK_PERIOD,DIK_SLASH,
58       /*48*/  DIK_0,DIK_1,DIK_2,DIK_3,DIK_4,DIK_5,DIK_6,DIK_7,
59       /*56*/  DIK_8,DIK_9,DIK_COLON,DIK_SEMICOLON,0,DIK_EQUALS,0,0,
60       /*64*/  DIK_AT,DIK_A,DIK_B,DIK_C,DIK_D,DIK_E,DIK_F,DIK_G,
61       /*72*/  DIK_H,DIK_I,DIK_J,DIK_K,DIK_L,DIK_M,DIK_N,DIK_O,
62       /*80*/  DIK_P,DIK_Q,DIK_R,DIK_S,DIK_T,DIK_U,DIK_V,DIK_W,
63       /*88*/  DIK_X,DIK_Y,DIK_Z,DIK_LBRACKET,0,DIK_RBRACKET,DIK_CIRCUMFLEX,DIK_UNDERLINE}      /*95*/ ;
64
65     BYTE out_code = 0;
66     WCHAR c = MapVirtualKeyW(vkCode,MAPVK_VK_TO_CHAR);
67
68     if (c > 31 && c < 96)
69         out_code = asciiCodes[c - 32];
70
71     if (out_code == 0)
72         out_code = scanCode;
73
74     return out_code;
75 }
76
77 static int KeyboardCallback( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam )
78 {
79     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
80     int dik_code, ret = This->base.dwCoopLevel & DISCL_EXCLUSIVE;
81     KBDLLHOOKSTRUCT *hook = (KBDLLHOOKSTRUCT *)lparam;
82     BYTE new_diks;
83
84     if (wparam != WM_KEYDOWN && wparam != WM_KEYUP &&
85         wparam != WM_SYSKEYDOWN && wparam != WM_SYSKEYUP)
86         return 0;
87
88     TRACE("(%p) %ld,%ld\n", iface, wparam, lparam);
89
90     dik_code = map_dik_code(hook->scanCode & 0xff,hook->vkCode);
91     /* R-Shift is special - it is an extended key with separate scan code */
92     if (hook->flags & LLKHF_EXTENDED && dik_code != 0x36)
93         dik_code |= 0x80;
94
95     new_diks = hook->flags & LLKHF_UP ? 0 : 0x80;
96
97     /* returns now if key event already known */
98     if (new_diks == This->DInputKeyState[dik_code])
99         return ret;
100
101     This->DInputKeyState[dik_code] = new_diks;
102     TRACE(" setting %02X to %02X\n", dik_code, This->DInputKeyState[dik_code]);
103
104     dik_code = id_to_offset(&This->base.data_format, DIDFT_MAKEINSTANCE(dik_code) | DIDFT_PSHBUTTON);
105     EnterCriticalSection(&This->base.crit);
106     queue_event((LPDIRECTINPUTDEVICE8A)This, dik_code, new_diks, hook->time, This->base.dinput->evsequence++);
107     LeaveCriticalSection(&This->base.crit);
108
109     return ret;
110 }
111
112 const GUID DInput_Wine_Keyboard_GUID = { /* 0ab8648a-7735-11d2-8c73-71df54a96441 */
113     0x0ab8648a, 0x7735, 0x11d2, {0x8c, 0x73, 0x71, 0xdf, 0x54, 0xa9, 0x64, 0x41}
114 };
115
116 static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version) {
117     DWORD dwSize;
118     DIDEVICEINSTANCEA ddi;
119     
120     dwSize = lpddi->dwSize;
121
122     TRACE("%d %p\n", dwSize, lpddi);
123     
124     memset(lpddi, 0, dwSize);
125     memset(&ddi, 0, sizeof(ddi));
126
127     ddi.dwSize = dwSize;
128     ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
129     ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
130     if (version >= 0x0800)
131         ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
132     else
133         ddi.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
134     strcpy(ddi.tszInstanceName, "Keyboard");
135     strcpy(ddi.tszProductName, "Wine Keyboard");
136
137     memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
138 }
139
140 static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version) {
141     DWORD dwSize;
142     DIDEVICEINSTANCEW ddi;
143     
144     dwSize = lpddi->dwSize;
145
146     TRACE("%d %p\n", dwSize, lpddi);
147     
148     memset(lpddi, 0, dwSize);
149     memset(&ddi, 0, sizeof(ddi));
150  
151     ddi.dwSize = dwSize;
152     ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
153     ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
154     if (version >= 0x0800)
155         ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
156     else
157         ddi.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
158     MultiByteToWideChar(CP_ACP, 0, "Keyboard", -1, ddi.tszInstanceName, MAX_PATH);
159     MultiByteToWideChar(CP_ACP, 0, "Wine Keyboard", -1, ddi.tszProductName, MAX_PATH);
160
161     memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
162 }
163  
164 static BOOL keyboarddev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
165 {
166   if (id != 0)
167     return FALSE;
168
169   if ((dwDevType == 0) ||
170       ((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 0x0800)) ||
171       (((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 0x0800))) {
172     TRACE("Enumerating the Keyboard device\n");
173  
174     fill_keyboard_dideviceinstanceA(lpddi, version);
175     
176     return TRUE;
177   }
178
179   return FALSE;
180 }
181
182 static BOOL keyboarddev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
183 {
184   if (id != 0)
185     return FALSE;
186
187   if ((dwDevType == 0) ||
188       ((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 0x0800)) ||
189       (((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 0x0800))) {
190     TRACE("Enumerating the Keyboard device\n");
191
192     fill_keyboard_dideviceinstanceW(lpddi, version);
193     
194     return TRUE;
195   }
196
197   return FALSE;
198 }
199
200 static SysKeyboardImpl *alloc_device(REFGUID rguid, const void *kvt, IDirectInputImpl *dinput)
201 {
202     SysKeyboardImpl* newDevice;
203     LPDIDATAFORMAT df = NULL;
204     int i, idx = 0;
205
206     newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardImpl));
207     newDevice->base.lpVtbl = kvt;
208     newDevice->base.ref = 1;
209     memcpy(&newDevice->base.guid, rguid, sizeof(*rguid));
210     newDevice->base.dinput = dinput;
211     newDevice->base.event_proc = KeyboardCallback;
212     InitializeCriticalSection(&newDevice->base.crit);
213     newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SysKeyboardImpl*->base.crit");
214
215     /* Create copy of default data format */
216     if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIKeyboard.dwSize))) goto failed;
217     memcpy(df, &c_dfDIKeyboard, c_dfDIKeyboard.dwSize);
218     if (!(df->rgodf = HeapAlloc(GetProcessHeap(), 0, df->dwNumObjs * df->dwObjSize))) goto failed;
219
220     for (i = 0; i < df->dwNumObjs; i++)
221     {
222         char buf[MAX_PATH];
223
224         if (!GetKeyNameTextA(((i & 0x7f) << 16) | ((i & 0x80) << 17), buf, sizeof(buf)))
225             continue;
226
227         memcpy(&df->rgodf[idx], &c_dfDIKeyboard.rgodf[i], df->dwObjSize);
228         df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_PSHBUTTON;
229     }
230     df->dwNumObjs = idx;
231
232     newDevice->base.data_format.wine_df = df;
233     IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->base.dinput);
234     return newDevice;
235
236 failed:
237     if (df) HeapFree(GetProcessHeap(), 0, df->rgodf);
238     HeapFree(GetProcessHeap(), 0, df);
239     HeapFree(GetProcessHeap(), 0, newDevice);
240     return NULL;
241 }
242
243
244 static HRESULT keyboarddev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
245 {
246   if ((IsEqualGUID(&GUID_SysKeyboard,rguid)) ||          /* Generic Keyboard */
247       (IsEqualGUID(&DInput_Wine_Keyboard_GUID,rguid))) { /* Wine Keyboard */
248     if ((riid == NULL) ||
249         IsEqualGUID(&IID_IDirectInputDeviceA,riid) ||
250         IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
251         IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
252         IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
253       *pdev = (IDirectInputDeviceA*) alloc_device(rguid, &SysKeyboardAvt, dinput);
254       TRACE("Creating a Keyboard device (%p)\n", *pdev);
255       if (!*pdev) return DIERR_OUTOFMEMORY;
256       return DI_OK;
257     } else
258       return DIERR_NOINTERFACE;
259   }
260   return DIERR_DEVICENOTREG;
261 }
262
263 static HRESULT keyboarddev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
264 {
265   if ((IsEqualGUID(&GUID_SysKeyboard,rguid)) ||          /* Generic Keyboard */
266       (IsEqualGUID(&DInput_Wine_Keyboard_GUID,rguid))) { /* Wine Keyboard */
267     if ((riid == NULL) ||
268         IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
269         IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
270         IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
271         IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
272       *pdev = (IDirectInputDeviceW*) alloc_device(rguid, &SysKeyboardWvt, dinput);
273       TRACE("Creating a Keyboard device (%p)\n", *pdev);
274       if (!*pdev) return DIERR_OUTOFMEMORY;
275       return DI_OK;
276     } else
277       return DIERR_NOINTERFACE;
278   }
279   return DIERR_DEVICENOTREG;
280 }
281
282 const struct dinput_device keyboard_device = {
283   "Wine keyboard driver",
284   keyboarddev_enum_deviceA,
285   keyboarddev_enum_deviceW,
286   keyboarddev_create_deviceA,
287   keyboarddev_create_deviceW
288 };
289
290 static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState(
291         LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
292 )
293 {
294     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
295     TRACE("(%p)->(%d,%p)\n", This, len, ptr);
296
297     if (!This->base.acquired) return DIERR_NOTACQUIRED;
298
299     if (len != This->base.data_format.user_df->dwDataSize )
300         return DIERR_INVALIDPARAM;
301
302     EnterCriticalSection(&This->base.crit);
303
304     if (TRACE_ON(dinput)) {
305         int i;
306         for (i = 0; i < WINE_DINPUT_KEYBOARD_MAX_KEYS; i++) {
307             if (This->DInputKeyState[i] != 0x00)
308                 TRACE(" - %02X: %02x\n", i, This->DInputKeyState[i]);
309         }
310     }
311
312     fill_DataFormat(ptr, len, This->DInputKeyState, &This->base.data_format);
313     LeaveCriticalSection(&This->base.crit);
314
315     return DI_OK;
316 }
317
318 /******************************************************************************
319   *     GetCapabilities : get the device capabilities
320   */
321 static HRESULT WINAPI SysKeyboardAImpl_GetCapabilities(
322         LPDIRECTINPUTDEVICE8A iface,
323         LPDIDEVCAPS lpDIDevCaps)
324 {
325     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
326     DIDEVCAPS devcaps;
327
328     TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
329
330     if ((lpDIDevCaps->dwSize != sizeof(DIDEVCAPS)) && (lpDIDevCaps->dwSize != sizeof(DIDEVCAPS_DX3))) {
331         WARN("invalid parameter\n");
332         return DIERR_INVALIDPARAM;
333     }
334     
335     devcaps.dwSize = lpDIDevCaps->dwSize;
336     devcaps.dwFlags = DIDC_ATTACHED;
337     if (This->base.dinput->dwVersion >= 0x0800)
338         devcaps.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
339     else
340         devcaps.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
341     devcaps.dwAxes = 0;
342     devcaps.dwButtons = This->base.data_format.wine_df->dwNumObjs;
343     devcaps.dwPOVs = 0;
344     devcaps.dwFFSamplePeriod = 0;
345     devcaps.dwFFMinTimeResolution = 0;
346     devcaps.dwFirmwareRevision = 100;
347     devcaps.dwHardwareRevision = 100;
348     devcaps.dwFFDriverVersion = 0;
349
350     memcpy(lpDIDevCaps, &devcaps, lpDIDevCaps->dwSize);
351     
352     return DI_OK;
353 }
354
355 /******************************************************************************
356   *     GetObjectInfo : get information about a device object such as a button
357   *                     or axis
358   */
359 static HRESULT WINAPI
360 SysKeyboardAImpl_GetObjectInfo(
361         LPDIRECTINPUTDEVICE8A iface,
362         LPDIDEVICEOBJECTINSTANCEA pdidoi,
363         DWORD dwObj,
364         DWORD dwHow)
365 {
366     HRESULT res;
367
368     res = IDirectInputDevice2AImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
369     if (res != DI_OK) return res;
370
371     if (!GetKeyNameTextA((DIDFT_GETINSTANCE(pdidoi->dwType) & 0x80) << 17 |
372                          (DIDFT_GETINSTANCE(pdidoi->dwType) & 0x7f) << 16,
373                          pdidoi->tszName, sizeof(pdidoi->tszName)))
374         return DIERR_OBJECTNOTFOUND;
375
376     _dump_OBJECTINSTANCEA(pdidoi);
377     return res;
378 }
379
380 static HRESULT WINAPI SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
381                                                      LPDIDEVICEOBJECTINSTANCEW pdidoi,
382                                                      DWORD dwObj,
383                                                      DWORD dwHow)
384 {
385     HRESULT res;
386
387     res = IDirectInputDevice2WImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
388     if (res != DI_OK) return res;
389
390     if (!GetKeyNameTextW((DIDFT_GETINSTANCE(pdidoi->dwType) & 0x80) << 17 |
391                          (DIDFT_GETINSTANCE(pdidoi->dwType) & 0x7f) << 16,
392                          pdidoi->tszName,
393                          sizeof(pdidoi->tszName)/sizeof(pdidoi->tszName[0])))
394         return DIERR_OBJECTNOTFOUND;
395
396     _dump_OBJECTINSTANCEW(pdidoi);
397     return res;
398 }
399
400 /******************************************************************************
401   *     GetDeviceInfo : get information about a device's identity
402   */
403 static HRESULT WINAPI SysKeyboardAImpl_GetDeviceInfo(
404         LPDIRECTINPUTDEVICE8A iface,
405         LPDIDEVICEINSTANCEA pdidi)
406 {
407     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
408     TRACE("(this=%p,%p)\n", This, pdidi);
409
410     if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA)) {
411         WARN(" dinput3 not supported yet...\n");
412         return DI_OK;
413     }
414
415     fill_keyboard_dideviceinstanceA(pdidi, This->base.dinput->dwVersion);
416     
417     return DI_OK;
418 }
419
420 static HRESULT WINAPI SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi) 
421 {
422     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
423     TRACE("(this=%p,%p)\n", This, pdidi);
424
425     if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)) {
426         WARN(" dinput3 not supported yet...\n");
427         return DI_OK;
428     }
429
430     fill_keyboard_dideviceinstanceW(pdidi, This->base.dinput->dwVersion);
431     
432     return DI_OK;
433 }
434
435 /******************************************************************************
436  *      GetProperty : Retrieves information about the input device.
437  */
438 static HRESULT WINAPI SysKeyboardAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
439         REFGUID rguid, LPDIPROPHEADER pdiph)
440 {
441     TRACE("(%p) %s,%p\n", iface, debugstr_guid(rguid), pdiph);
442     _dump_DIPROPHEADER(pdiph);
443
444     if (HIWORD(rguid)) return DI_OK;
445
446     switch (LOWORD(rguid))
447     {
448         case (DWORD_PTR)DIPROP_KEYNAME:
449         {
450             HRESULT hr;
451             LPDIPROPSTRING ps = (LPDIPROPSTRING)pdiph;
452             DIDEVICEOBJECTINSTANCEW didoi;
453
454             if (pdiph->dwSize != sizeof(DIPROPSTRING))
455                 return DIERR_INVALIDPARAM;
456
457             didoi.dwSize = sizeof(DIDEVICEOBJECTINSTANCEW);
458
459             hr = SysKeyboardWImpl_GetObjectInfo((LPDIRECTINPUTDEVICE8W)iface , &didoi,
460                                                  ps->diph.dwObj, ps->diph.dwHow);
461             if (hr == DI_OK)
462                 memcpy(ps->wsz, didoi.tszName, sizeof(ps->wsz));
463             return hr;
464         }
465         default:
466             return IDirectInputDevice2AImpl_GetProperty( iface, rguid, pdiph );
467     }
468     return DI_OK;
469 }
470
471 static const IDirectInputDevice8AVtbl SysKeyboardAvt =
472 {
473         IDirectInputDevice2AImpl_QueryInterface,
474         IDirectInputDevice2AImpl_AddRef,
475         IDirectInputDevice2AImpl_Release,
476         SysKeyboardAImpl_GetCapabilities,
477         IDirectInputDevice2AImpl_EnumObjects,
478         SysKeyboardAImpl_GetProperty,
479         IDirectInputDevice2AImpl_SetProperty,
480         IDirectInputDevice2AImpl_Acquire,
481         IDirectInputDevice2AImpl_Unacquire,
482         SysKeyboardAImpl_GetDeviceState,
483         IDirectInputDevice2AImpl_GetDeviceData,
484         IDirectInputDevice2AImpl_SetDataFormat,
485         IDirectInputDevice2AImpl_SetEventNotification,
486         IDirectInputDevice2AImpl_SetCooperativeLevel,
487         SysKeyboardAImpl_GetObjectInfo,
488         SysKeyboardAImpl_GetDeviceInfo,
489         IDirectInputDevice2AImpl_RunControlPanel,
490         IDirectInputDevice2AImpl_Initialize,
491         IDirectInputDevice2AImpl_CreateEffect,
492         IDirectInputDevice2AImpl_EnumEffects,
493         IDirectInputDevice2AImpl_GetEffectInfo,
494         IDirectInputDevice2AImpl_GetForceFeedbackState,
495         IDirectInputDevice2AImpl_SendForceFeedbackCommand,
496         IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
497         IDirectInputDevice2AImpl_Escape,
498         IDirectInputDevice2AImpl_Poll,
499         IDirectInputDevice2AImpl_SendDeviceData,
500         IDirectInputDevice7AImpl_EnumEffectsInFile,
501         IDirectInputDevice7AImpl_WriteEffectToFile,
502         IDirectInputDevice8AImpl_BuildActionMap,
503         IDirectInputDevice8AImpl_SetActionMap,
504         IDirectInputDevice8AImpl_GetImageInfo
505 };
506
507 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
508 # define XCAST(fun)     (typeof(SysKeyboardWvt.fun))
509 #else
510 # define XCAST(fun)     (void*)
511 #endif
512
513 static const IDirectInputDevice8WVtbl SysKeyboardWvt =
514 {
515         IDirectInputDevice2WImpl_QueryInterface,
516         XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
517         XCAST(Release)IDirectInputDevice2AImpl_Release,
518         XCAST(GetCapabilities)SysKeyboardAImpl_GetCapabilities,
519         IDirectInputDevice2WImpl_EnumObjects,
520         XCAST(GetProperty)SysKeyboardAImpl_GetProperty,
521         XCAST(SetProperty)IDirectInputDevice2AImpl_SetProperty,
522         XCAST(Acquire)IDirectInputDevice2AImpl_Acquire,
523         XCAST(Unacquire)IDirectInputDevice2AImpl_Unacquire,
524         XCAST(GetDeviceState)SysKeyboardAImpl_GetDeviceState,
525         XCAST(GetDeviceData)IDirectInputDevice2AImpl_GetDeviceData,
526         XCAST(SetDataFormat)IDirectInputDevice2AImpl_SetDataFormat,
527         XCAST(SetEventNotification)IDirectInputDevice2AImpl_SetEventNotification,
528         XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
529         SysKeyboardWImpl_GetObjectInfo,
530         SysKeyboardWImpl_GetDeviceInfo,
531         XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
532         XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
533         XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,
534         IDirectInputDevice2WImpl_EnumEffects,
535         IDirectInputDevice2WImpl_GetEffectInfo,
536         XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,
537         XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,
538         XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
539         XCAST(Escape)IDirectInputDevice2AImpl_Escape,
540         XCAST(Poll)IDirectInputDevice2AImpl_Poll,
541         XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
542         IDirectInputDevice7WImpl_EnumEffectsInFile,
543         IDirectInputDevice7WImpl_WriteEffectToFile,
544         IDirectInputDevice8WImpl_BuildActionMap,
545         IDirectInputDevice8WImpl_SetActionMap,
546         IDirectInputDevice8WImpl_GetImageInfo
547 };
548 #undef XCAST