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