comctl32: datetime: Reject invalid flags in DTM_SETSYSTEMTIME.
[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 static 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     dik_code = id_to_offset(&This->base.data_format, DIDFT_MAKEINSTANCE(dik_code) | DIDFT_PSHBUTTON);
89     EnterCriticalSection(&This->base.crit);
90     queue_event((LPDIRECTINPUTDEVICE8A)This, dik_code, new_diks, hook->time, This->dinput->evsequence++);
91     LeaveCriticalSection(&This->base.crit);
92     
93     return CallNextHookEx(0, code, wparam, lparam);
94 }
95
96 static const GUID DInput_Wine_Keyboard_GUID = { /* 0ab8648a-7735-11d2-8c73-71df54a96441 */
97   0x0ab8648a,
98   0x7735,
99   0x11d2,
100   {0x8c, 0x73, 0x71, 0xdf, 0x54, 0xa9, 0x64, 0x41}
101 };
102
103 static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version) {
104     DWORD dwSize;
105     DIDEVICEINSTANCEA ddi;
106     
107     dwSize = lpddi->dwSize;
108
109     TRACE("%d %p\n", dwSize, lpddi);
110     
111     memset(lpddi, 0, dwSize);
112     memset(&ddi, 0, sizeof(ddi));
113
114     ddi.dwSize = dwSize;
115     ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
116     ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
117     if (version >= 0x0800)
118         ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
119     else
120         ddi.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
121     strcpy(ddi.tszInstanceName, "Keyboard");
122     strcpy(ddi.tszProductName, "Wine Keyboard");
123
124     memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
125 }
126
127 static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version) {
128     DWORD dwSize;
129     DIDEVICEINSTANCEW ddi;
130     
131     dwSize = lpddi->dwSize;
132
133     TRACE("%d %p\n", dwSize, lpddi);
134     
135     memset(lpddi, 0, dwSize);
136     memset(&ddi, 0, sizeof(ddi));
137  
138     ddi.dwSize = dwSize;
139     ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
140     ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
141     if (version >= 0x0800)
142         ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
143     else
144         ddi.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
145     MultiByteToWideChar(CP_ACP, 0, "Keyboard", -1, ddi.tszInstanceName, MAX_PATH);
146     MultiByteToWideChar(CP_ACP, 0, "Wine Keyboard", -1, ddi.tszProductName, MAX_PATH);
147
148     memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
149 }
150  
151 static BOOL keyboarddev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
152 {
153   if (id != 0)
154     return FALSE;
155
156   if ((dwDevType == 0) ||
157       ((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 0x0800)) ||
158       (((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 0x0800))) {
159     TRACE("Enumerating the Keyboard device\n");
160  
161     fill_keyboard_dideviceinstanceA(lpddi, version);
162     
163     return TRUE;
164   }
165
166   return FALSE;
167 }
168
169 static BOOL keyboarddev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
170 {
171   if (id != 0)
172     return FALSE;
173
174   if ((dwDevType == 0) ||
175       ((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 0x0800)) ||
176       (((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 0x0800))) {
177     TRACE("Enumerating the Keyboard device\n");
178
179     fill_keyboard_dideviceinstanceW(lpddi, version);
180     
181     return TRUE;
182   }
183
184   return FALSE;
185 }
186
187 static SysKeyboardImpl *alloc_device(REFGUID rguid, const void *kvt, IDirectInputImpl *dinput)
188 {
189     SysKeyboardImpl* newDevice;
190     LPDIDATAFORMAT df = NULL;
191     int i, idx = 0;
192
193     newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardImpl));
194     newDevice->base.lpVtbl = kvt;
195     newDevice->base.ref = 1;
196     memcpy(&newDevice->base.guid, rguid, sizeof(*rguid));
197     newDevice->dinput = dinput;
198     InitializeCriticalSection(&newDevice->base.crit);
199     newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SysKeyboardImpl*->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, This->base.data_format.wine_df->rgodf);
290     HeapFree(GetProcessHeap(), 0, This->base.data_format.wine_df);
291     release_DataFormat(&This->base.data_format);
292
293     IDirectInput_Release((LPDIRECTINPUTDEVICE8A)This->dinput);
294     This->base.crit.DebugInfo->Spare[0] = 0;
295     DeleteCriticalSection(&This->base.crit);
296     HeapFree(GetProcessHeap(), 0, This);
297
298     return DI_OK;
299 }
300
301 static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState(
302         LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
303 )
304 {
305     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
306     TRACE("(%p)->(%d,%p)\n", This, len, ptr);
307
308     if (!This->base.acquired) return DIERR_NOTACQUIRED;
309
310     if (len != WINE_DINPUT_KEYBOARD_MAX_KEYS)
311         return DIERR_INVALIDPARAM;
312
313     EnterCriticalSection(&This->base.crit);
314
315     if (TRACE_ON(dinput)) {
316         int i;
317         for (i = 0; i < WINE_DINPUT_KEYBOARD_MAX_KEYS; i++) {
318             if (DInputKeyState[i] != 0x00) {
319                 TRACE(" - %02X: %02x\n", i, DInputKeyState[i]);
320             }
321         }
322     }
323     
324     memcpy(ptr, DInputKeyState, WINE_DINPUT_KEYBOARD_MAX_KEYS);
325     LeaveCriticalSection(&This->base.crit);
326
327     return DI_OK;
328 }
329
330 static HRESULT WINAPI SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface);
331
332 static HRESULT WINAPI SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
333 {
334     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
335     HRESULT res;
336
337     TRACE("(%p)\n",This);
338
339     if ((res = IDirectInputDevice2AImpl_Acquire(iface)) != DI_OK) return res;
340
341     if (current_lock != NULL) {
342         FIXME("Not more than one keyboard can be acquired at the same time.\n");
343         SysKeyboardAImpl_Unacquire((LPDIRECTINPUTDEVICE8A)current_lock);
344     }
345     current_lock = This;
346
347     set_dinput_hook(WH_KEYBOARD_LL, KeyboardCallback);
348
349     return DI_OK;
350 }
351
352 static HRESULT WINAPI SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
353 {
354     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
355     HRESULT res;
356
357     TRACE("(this=%p)\n",This);
358
359     if ((res = IDirectInputDevice2AImpl_Unacquire(iface)) != DI_OK) return res;
360
361     set_dinput_hook(WH_KEYBOARD_LL, NULL);
362
363     /* No more locks */
364     if (current_lock == This)
365         current_lock = NULL;
366     else
367         ERR("this != current_lock\n");
368
369     return DI_OK;
370 }
371
372 /******************************************************************************
373   *     GetCapabilities : get the device capablitites
374   */
375 static HRESULT WINAPI SysKeyboardAImpl_GetCapabilities(
376         LPDIRECTINPUTDEVICE8A iface,
377         LPDIDEVCAPS lpDIDevCaps)
378 {
379     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
380     DIDEVCAPS devcaps;
381
382     TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
383
384     if ((lpDIDevCaps->dwSize != sizeof(DIDEVCAPS)) && (lpDIDevCaps->dwSize != sizeof(DIDEVCAPS_DX3))) {
385         WARN("invalid parameter\n");
386         return DIERR_INVALIDPARAM;
387     }
388     
389     devcaps.dwSize = lpDIDevCaps->dwSize;
390     devcaps.dwFlags = DIDC_ATTACHED;
391     if (This->dinput->dwVersion >= 0x0800)
392         devcaps.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
393     else
394         devcaps.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
395     devcaps.dwAxes = 0;
396     devcaps.dwButtons = This->base.data_format.wine_df->dwNumObjs;
397     devcaps.dwPOVs = 0;
398     devcaps.dwFFSamplePeriod = 0;
399     devcaps.dwFFMinTimeResolution = 0;
400     devcaps.dwFirmwareRevision = 100;
401     devcaps.dwHardwareRevision = 100;
402     devcaps.dwFFDriverVersion = 0;
403
404     memcpy(lpDIDevCaps, &devcaps, lpDIDevCaps->dwSize);
405     
406     return DI_OK;
407 }
408
409 /******************************************************************************
410   *     GetObjectInfo : get information about a device object such as a button
411   *                     or axis
412   */
413 static HRESULT WINAPI
414 SysKeyboardAImpl_GetObjectInfo(
415         LPDIRECTINPUTDEVICE8A iface,
416         LPDIDEVICEOBJECTINSTANCEA pdidoi,
417         DWORD dwObj,
418         DWORD dwHow)
419 {
420     HRESULT res;
421
422     res = IDirectInputDevice2AImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
423     if (res != DI_OK) return res;
424
425     if (!GetKeyNameTextA((DIDFT_GETINSTANCE(pdidoi->dwType) & 0x80) << 17 |
426                          (DIDFT_GETINSTANCE(pdidoi->dwType) & 0x7f) << 16,
427                          pdidoi->tszName, sizeof(pdidoi->tszName)))
428         return DIERR_OBJECTNOTFOUND;
429
430     _dump_OBJECTINSTANCEA(pdidoi);
431     return res;
432 }
433
434 static HRESULT WINAPI SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
435                                                      LPDIDEVICEOBJECTINSTANCEW pdidoi,
436                                                      DWORD dwObj,
437                                                      DWORD dwHow)
438 {
439     HRESULT res;
440
441     res = IDirectInputDevice2WImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
442     if (res != DI_OK) return res;
443
444     if (!GetKeyNameTextW((DIDFT_GETINSTANCE(pdidoi->dwType) & 0x80) << 17 |
445                          (DIDFT_GETINSTANCE(pdidoi->dwType) & 0x7f) << 16,
446                          pdidoi->tszName, sizeof(pdidoi->tszName)))
447         return DIERR_OBJECTNOTFOUND;
448
449     _dump_OBJECTINSTANCEW(pdidoi);
450     return res;
451 }
452
453 /******************************************************************************
454   *     GetDeviceInfo : get information about a device's identity
455   */
456 static HRESULT WINAPI SysKeyboardAImpl_GetDeviceInfo(
457         LPDIRECTINPUTDEVICE8A iface,
458         LPDIDEVICEINSTANCEA pdidi)
459 {
460     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
461     TRACE("(this=%p,%p)\n", This, pdidi);
462
463     if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA)) {
464         WARN(" dinput3 not supported yet...\n");
465         return DI_OK;
466     }
467
468     fill_keyboard_dideviceinstanceA(pdidi, This->dinput->dwVersion);
469     
470     return DI_OK;
471 }
472
473 static HRESULT WINAPI SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi) 
474 {
475     SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
476     TRACE("(this=%p,%p)\n", This, pdidi);
477
478     if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)) {
479         WARN(" dinput3 not supported yet...\n");
480         return DI_OK;
481     }
482
483     fill_keyboard_dideviceinstanceW(pdidi, This->dinput->dwVersion);
484     
485     return DI_OK;
486 }
487
488 static const IDirectInputDevice8AVtbl SysKeyboardAvt =
489 {
490         IDirectInputDevice2AImpl_QueryInterface,
491         IDirectInputDevice2AImpl_AddRef,
492         SysKeyboardAImpl_Release,
493         SysKeyboardAImpl_GetCapabilities,
494         IDirectInputDevice2AImpl_EnumObjects,
495         IDirectInputDevice2AImpl_GetProperty,
496         IDirectInputDevice2AImpl_SetProperty,
497         SysKeyboardAImpl_Acquire,
498         SysKeyboardAImpl_Unacquire,
499         SysKeyboardAImpl_GetDeviceState,
500         IDirectInputDevice2AImpl_GetDeviceData,
501         IDirectInputDevice2AImpl_SetDataFormat,
502         IDirectInputDevice2AImpl_SetEventNotification,
503         IDirectInputDevice2AImpl_SetCooperativeLevel,
504         SysKeyboardAImpl_GetObjectInfo,
505         SysKeyboardAImpl_GetDeviceInfo,
506         IDirectInputDevice2AImpl_RunControlPanel,
507         IDirectInputDevice2AImpl_Initialize,
508         IDirectInputDevice2AImpl_CreateEffect,
509         IDirectInputDevice2AImpl_EnumEffects,
510         IDirectInputDevice2AImpl_GetEffectInfo,
511         IDirectInputDevice2AImpl_GetForceFeedbackState,
512         IDirectInputDevice2AImpl_SendForceFeedbackCommand,
513         IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
514         IDirectInputDevice2AImpl_Escape,
515         IDirectInputDevice2AImpl_Poll,
516         IDirectInputDevice2AImpl_SendDeviceData,
517         IDirectInputDevice7AImpl_EnumEffectsInFile,
518         IDirectInputDevice7AImpl_WriteEffectToFile,
519         IDirectInputDevice8AImpl_BuildActionMap,
520         IDirectInputDevice8AImpl_SetActionMap,
521         IDirectInputDevice8AImpl_GetImageInfo
522 };
523
524 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
525 # define XCAST(fun)     (typeof(SysKeyboardWvt.fun))
526 #else
527 # define XCAST(fun)     (void*)
528 #endif
529
530 static const IDirectInputDevice8WVtbl SysKeyboardWvt =
531 {
532         IDirectInputDevice2WImpl_QueryInterface,
533         XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
534         XCAST(Release)SysKeyboardAImpl_Release,
535         XCAST(GetCapabilities)SysKeyboardAImpl_GetCapabilities,
536         IDirectInputDevice2WImpl_EnumObjects,
537         XCAST(GetProperty)IDirectInputDevice2AImpl_GetProperty,
538         XCAST(SetProperty)IDirectInputDevice2AImpl_SetProperty,
539         XCAST(Acquire)SysKeyboardAImpl_Acquire,
540         XCAST(Unacquire)SysKeyboardAImpl_Unacquire,
541         XCAST(GetDeviceState)SysKeyboardAImpl_GetDeviceState,
542         XCAST(GetDeviceData)IDirectInputDevice2AImpl_GetDeviceData,
543         XCAST(SetDataFormat)IDirectInputDevice2AImpl_SetDataFormat,
544         XCAST(SetEventNotification)IDirectInputDevice2AImpl_SetEventNotification,
545         XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
546         SysKeyboardWImpl_GetObjectInfo,
547         SysKeyboardWImpl_GetDeviceInfo,
548         XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
549         XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
550         XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,
551         IDirectInputDevice2WImpl_EnumEffects,
552         IDirectInputDevice2WImpl_GetEffectInfo,
553         XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,
554         XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,
555         XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
556         XCAST(Escape)IDirectInputDevice2AImpl_Escape,
557         XCAST(Poll)IDirectInputDevice2AImpl_Poll,
558         XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
559         IDirectInputDevice7WImpl_EnumEffectsInFile,
560         IDirectInputDevice7WImpl_WriteEffectToFile,
561         IDirectInputDevice8WImpl_BuildActionMap,
562         IDirectInputDevice8WImpl_SetActionMap,
563         IDirectInputDevice8WImpl_GetImageInfo
564 };
565 #undef XCAST