ReactOS  0.4.15-dev-1177-g6cb3b62
keyboard.c File Reference
#include "config.h"
#include "wine/port.h"
#include <stdarg.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winerror.h"
#include "dinput.h"
#include "dinput_private.h"
#include "device_private.h"
#include "wine/debug.h"
#include "wine/unicode.h"
Include dependency graph for keyboard.c:

Go to the source code of this file.

Classes

struct  SysKeyboardImpl
 

Macros

#define WINE_DINPUT_KEYBOARD_MAX_KEYS   256
 

Typedefs

typedef struct SysKeyboardImpl SysKeyboardImpl
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (dinput)
 
static SysKeyboardImplimpl_from_IDirectInputDevice8A (IDirectInputDevice8A *iface)
 
static SysKeyboardImplimpl_from_IDirectInputDevice8W (IDirectInputDevice8W *iface)
 
static IDirectInputDevice8A * IDirectInputDevice8A_from_impl (SysKeyboardImpl *This)
 
static IDirectInputDevice8W * IDirectInputDevice8W_from_impl (SysKeyboardImpl *This)
 
static BYTE map_dik_code (DWORD scanCode, DWORD vkCode, DWORD subType)
 
static int KeyboardCallback (LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam)
 
static DWORD get_keyboard_subtype (void)
 
static void fill_keyboard_dideviceinstanceA (LPDIDEVICEINSTANCEA lpddi, DWORD version, DWORD subtype)
 
static void fill_keyboard_dideviceinstanceW (LPDIDEVICEINSTANCEW lpddi, DWORD version, DWORD subtype)
 
static HRESULT keyboarddev_enum_deviceA (DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
 
static HRESULT keyboarddev_enum_deviceW (DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
 
static SysKeyboardImplalloc_device (REFGUID rguid, IDirectInputImpl *dinput)
 
static HRESULT keyboarddev_create_device (IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode)
 
static HRESULT WINAPI SysKeyboardWImpl_GetDeviceState (LPDIRECTINPUTDEVICE8W iface, DWORD len, LPVOID ptr)
 
static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState (LPDIRECTINPUTDEVICE8A iface, DWORD len, LPVOID ptr)
 
static HRESULT WINAPI SysKeyboardWImpl_GetCapabilities (LPDIRECTINPUTDEVICE8W iface, LPDIDEVCAPS lpDIDevCaps)
 
static HRESULT WINAPI SysKeyboardAImpl_GetCapabilities (LPDIRECTINPUTDEVICE8A iface, LPDIDEVCAPS lpDIDevCaps)
 
static DWORD map_dik_to_scan (DWORD dik_code, DWORD subtype)
 
static HRESULT WINAPI SysKeyboardAImpl_GetObjectInfo (LPDIRECTINPUTDEVICE8A iface, LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow)
 
static HRESULT WINAPI SysKeyboardWImpl_GetObjectInfo (LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow)
 
static HRESULT WINAPI SysKeyboardAImpl_GetDeviceInfo (LPDIRECTINPUTDEVICE8A iface, LPDIDEVICEINSTANCEA pdidi)
 
static HRESULT WINAPI SysKeyboardWImpl_GetDeviceInfo (LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi)
 
static HRESULT WINAPI SysKeyboardWImpl_GetProperty (LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph)
 
static HRESULT WINAPI SysKeyboardAImpl_GetProperty (LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph)
 
static HRESULT WINAPI SysKeyboardWImpl_Acquire (LPDIRECTINPUTDEVICE8W iface)
 
static HRESULT WINAPI SysKeyboardAImpl_Acquire (LPDIRECTINPUTDEVICE8A iface)
 
static HRESULT WINAPI SysKeyboardWImpl_BuildActionMap (LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags)
 
static HRESULT WINAPI SysKeyboardAImpl_BuildActionMap (LPDIRECTINPUTDEVICE8A iface, LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags)
 
static HRESULT WINAPI SysKeyboardWImpl_SetActionMap (LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags)
 
static HRESULT WINAPI SysKeyboardAImpl_SetActionMap (LPDIRECTINPUTDEVICE8A iface, LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags)
 

Variables

static const IDirectInputDevice8AVtbl SysKeyboardAvt
 
static const IDirectInputDevice8WVtbl SysKeyboardWvt
 
const struct dinput_device keyboard_device
 

Macro Definition Documentation

◆ WINE_DINPUT_KEYBOARD_MAX_KEYS

#define WINE_DINPUT_KEYBOARD_MAX_KEYS   256

Definition at line 41 of file keyboard.c.

Typedef Documentation

◆ SysKeyboardImpl

Definition at line 46 of file keyboard.c.

Function Documentation

◆ alloc_device()

static SysKeyboardImpl* alloc_device ( REFGUID  rguid,
IDirectInputImpl dinput 
)
static

Definition at line 255 of file keyboard.c.

256 {
257  SysKeyboardImpl* newDevice;
258  LPDIDATAFORMAT df = NULL;
259  int i, idx = 0;
260 
262  newDevice->base.IDirectInputDevice8A_iface.lpVtbl = &SysKeyboardAvt;
263  newDevice->base.IDirectInputDevice8W_iface.lpVtbl = &SysKeyboardWvt;
264  newDevice->base.ref = 1;
265  memcpy(&newDevice->base.guid, rguid, sizeof(*rguid));
266  newDevice->base.dinput = dinput;
267  newDevice->base.event_proc = KeyboardCallback;
268  InitializeCriticalSection(&newDevice->base.crit);
269  newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SysKeyboardImpl*->base.crit");
270  newDevice->subtype = get_keyboard_subtype();
271 
272  /* Create copy of default data format */
273  if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIKeyboard.dwSize))) goto failed;
275  if (!(df->rgodf = HeapAlloc(GetProcessHeap(), 0, df->dwNumObjs * df->dwObjSize))) goto failed;
276 
277  for (i = 0; i < df->dwNumObjs; i++)
278  {
279  char buf[MAX_PATH];
280  BYTE dik_code;
281 
282  if (!GetKeyNameTextA(((i & 0x7f) << 16) | ((i & 0x80) << 17), buf, sizeof(buf)))
283  continue;
284 
285  dik_code = map_dik_code(i, 0, newDevice->subtype);
286  memcpy(&df->rgodf[idx], &c_dfDIKeyboard.rgodf[dik_code], df->dwObjSize);
287  df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(dik_code) | DIDFT_PSHBUTTON;
288  }
289  df->dwNumObjs = idx;
290 
291  newDevice->base.data_format.wine_df = df;
292  IDirectInput_AddRef(&newDevice->base.dinput->IDirectInput7A_iface);
293 
294  EnterCriticalSection(&dinput->crit);
295  list_add_tail(&dinput->devices_list, &newDevice->base.entry);
296  LeaveCriticalSection(&dinput->crit);
297 
298  return newDevice;
299 
300 failed:
301  if (df) HeapFree(GetProcessHeap(), 0, df->rgodf);
302  HeapFree(GetProcessHeap(), 0, df);
303  HeapFree(GetProcessHeap(), 0, newDevice);
304  return NULL;
305 }
#define IDirectInput_AddRef(p)
Definition: dinput.h:2293
static DWORD get_keyboard_subtype(void)
Definition: keyboard.c:148
DWORD dwSize
Definition: dinput.h:808
#define DWORD_PTR
Definition: treelist.c:76
#define DIDFT_PSHBUTTON
Definition: dinput.h:754
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
DWORD dwNumObjs
Definition: dinput.h:812
#define DIDFT_MAKEINSTANCE(n)
Definition: dinput.h:762
DWORD dwObjSize
Definition: dinput.h:809
struct list devices_list
static int KeyboardCallback(LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam)
Definition: keyboard.c:106
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
Definition: list.h:102
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct IDirectInputDeviceImpl base
Definition: keyboard.c:49
unsigned int idx
Definition: utils.c:41
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
smooth NULL
Definition: ftsmooth.c:416
int WINAPI GetKeyNameTextA(_In_ LONG lParam, _Out_writes_(cchSize) LPSTR lpString, _In_ int cchSize)
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define MAX_PATH
Definition: compat.h:34
static BYTE map_dik_code(DWORD scanCode, DWORD vkCode, DWORD subType)
Definition: keyboard.c:71
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
LPDIOBJECTDATAFORMAT rgodf
Definition: dinput.h:813
DWORD subtype
Definition: keyboard.c:51
unsigned char BYTE
Definition: xxhash.c:193
CRITICAL_SECTION crit
static const IDirectInputDevice8WVtbl SysKeyboardWvt
Definition: keyboard.c:44
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
const DIDATAFORMAT c_dfDIKeyboard
Definition: data_formats.c:561
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define HeapFree(x, y, z)
Definition: compat.h:483
static const IDirectInputDevice8AVtbl SysKeyboardAvt
Definition: keyboard.c:43

Referenced by keyboarddev_create_device().

◆ fill_keyboard_dideviceinstanceA()

static void fill_keyboard_dideviceinstanceA ( LPDIDEVICEINSTANCEA  lpddi,
DWORD  version,
DWORD  subtype 
)
static

Definition at line 165 of file keyboard.c.

165  {
166  DWORD dwSize;
167  DIDEVICEINSTANCEA ddi;
168 
169  dwSize = lpddi->dwSize;
170 
171  TRACE("%d %p\n", dwSize, lpddi);
172 
173  memset(lpddi, 0, dwSize);
174  memset(&ddi, 0, sizeof(ddi));
175 
176  ddi.dwSize = dwSize;
177  ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
178  ddi.guidProduct = GUID_SysKeyboard;
179  if (version >= 0x0800)
180  ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (subtype << 8);
181  else
182  ddi.dwDevType = DIDEVTYPE_KEYBOARD | (subtype << 8);
183  strcpy(ddi.tszInstanceName, "Keyboard");
184  strcpy(ddi.tszProductName, "Wine Keyboard");
185 
186  memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
187 }
GUID guidInstance
Definition: dinput.h:413
#define DI8DEVTYPE_KEYBOARD
Definition: dinput.h:211
DWORD dwDevType
Definition: dinput.h:415
GUID guidProduct
Definition: dinput.h:414
static const WCHAR version[]
Definition: asmname.c:66
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DIDEVTYPE_KEYBOARD
Definition: dinput.h:199
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
CHAR tszInstanceName[MAX_PATH]
Definition: dinput.h:416
CHAR tszProductName[MAX_PATH]
Definition: dinput.h:417
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define memset(x, y, z)
Definition: compat.h:39
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by keyboarddev_enum_deviceA(), and SysKeyboardAImpl_GetDeviceInfo().

◆ fill_keyboard_dideviceinstanceW()

static void fill_keyboard_dideviceinstanceW ( LPDIDEVICEINSTANCEW  lpddi,
DWORD  version,
DWORD  subtype 
)
static

Definition at line 189 of file keyboard.c.

189  {
190  DWORD dwSize;
191  DIDEVICEINSTANCEW ddi;
192 
193  dwSize = lpddi->dwSize;
194 
195  TRACE("%d %p\n", dwSize, lpddi);
196 
197  memset(lpddi, 0, dwSize);
198  memset(&ddi, 0, sizeof(ddi));
199 
200  ddi.dwSize = dwSize;
201  ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
202  ddi.guidProduct = GUID_SysKeyboard;
203  if (version >= 0x0800)
204  ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (subtype << 8);
205  else
206  ddi.dwDevType = DIDEVTYPE_KEYBOARD | (subtype << 8);
207  MultiByteToWideChar(CP_ACP, 0, "Keyboard", -1, ddi.tszInstanceName, MAX_PATH);
208  MultiByteToWideChar(CP_ACP, 0, "Wine Keyboard", -1, ddi.tszProductName, MAX_PATH);
209 
210  memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
211 }
DWORD dwDevType
Definition: dinput.h:428
#define CP_ACP
Definition: compat.h:109
#define DI8DEVTYPE_KEYBOARD
Definition: dinput.h:211
static const WCHAR version[]
Definition: asmname.c:66
#define TRACE(s)
Definition: solgame.cpp:4
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR tszProductName[MAX_PATH]
Definition: dinput.h:430
#define DIDEVTYPE_KEYBOARD
Definition: dinput.h:199
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
WCHAR tszInstanceName[MAX_PATH]
Definition: dinput.h:429
GUID guidInstance
Definition: dinput.h:426
#define MultiByteToWideChar
Definition: compat.h:110
#define memset(x, y, z)
Definition: compat.h:39
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
GUID guidProduct
Definition: dinput.h:427

Referenced by keyboarddev_enum_deviceW(), and SysKeyboardWImpl_GetDeviceInfo().

◆ get_keyboard_subtype()

static DWORD get_keyboard_subtype ( void  )
static

Definition at line 148 of file keyboard.c.

149 {
150  DWORD kbd_type, kbd_subtype, dev_subtype;
151  kbd_type = GetKeyboardType(0);
152  kbd_subtype = GetKeyboardType(1);
153 
154  if (kbd_type == 4 || (kbd_type == 7 && kbd_subtype == 0))
155  dev_subtype = DIDEVTYPEKEYBOARD_PCENH;
156  else if (kbd_type == 7 && kbd_subtype == 2)
157  dev_subtype = DIDEVTYPEKEYBOARD_JAPAN106;
158  else {
159  FIXME("Unknown keyboard type=%u, subtype=%u\n", kbd_type, kbd_subtype);
160  dev_subtype = DIDEVTYPEKEYBOARD_PCENH;
161  }
162  return dev_subtype;
163 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define DIDEVTYPEKEYBOARD_PCENH
Definition: dinput.h:232
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DIDEVTYPEKEYBOARD_JAPAN106
Definition: dinput.h:238
int WINAPI GetKeyboardType(_In_ int)

Referenced by alloc_device(), keyboarddev_enum_deviceA(), and keyboarddev_enum_deviceW().

◆ IDirectInputDevice8A_from_impl()

static IDirectInputDevice8A* IDirectInputDevice8A_from_impl ( SysKeyboardImpl This)
inlinestatic

Definition at line 62 of file keyboard.c.

63 {
64  return &This->base.IDirectInputDevice8A_iface;
65 }

Referenced by SysKeyboardWImpl_GetProperty().

◆ IDirectInputDevice8W_from_impl()

static IDirectInputDevice8W* IDirectInputDevice8W_from_impl ( SysKeyboardImpl This)
inlinestatic

Definition at line 66 of file keyboard.c.

67 {
68  return &This->base.IDirectInputDevice8W_iface;
69 }

Referenced by SysKeyboardAImpl_Acquire(), SysKeyboardAImpl_GetCapabilities(), SysKeyboardAImpl_GetDeviceState(), and SysKeyboardAImpl_GetProperty().

◆ impl_from_IDirectInputDevice8A()

static SysKeyboardImpl* impl_from_IDirectInputDevice8A ( IDirectInputDevice8A *  iface)
inlinestatic

Definition at line 54 of file keyboard.c.

55 {
56  return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface), SysKeyboardImpl, base);
57 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by KeyboardCallback(), SysKeyboardAImpl_Acquire(), SysKeyboardAImpl_BuildActionMap(), SysKeyboardAImpl_GetCapabilities(), SysKeyboardAImpl_GetDeviceInfo(), SysKeyboardAImpl_GetDeviceState(), SysKeyboardAImpl_GetObjectInfo(), SysKeyboardAImpl_GetProperty(), and SysKeyboardAImpl_SetActionMap().

◆ impl_from_IDirectInputDevice8W()

static SysKeyboardImpl* impl_from_IDirectInputDevice8W ( IDirectInputDevice8W *  iface)
inlinestatic

Definition at line 58 of file keyboard.c.

59 {
60  return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface), SysKeyboardImpl, base);
61 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by SysKeyboardWImpl_Acquire(), SysKeyboardWImpl_BuildActionMap(), SysKeyboardWImpl_GetCapabilities(), SysKeyboardWImpl_GetDeviceInfo(), SysKeyboardWImpl_GetDeviceState(), SysKeyboardWImpl_GetObjectInfo(), SysKeyboardWImpl_GetProperty(), and SysKeyboardWImpl_SetActionMap().

◆ KeyboardCallback()

static int KeyboardCallback ( LPDIRECTINPUTDEVICE8A  iface,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 106 of file keyboard.c.

107 {
109  int dik_code, ret = This->base.dwCoopLevel & DISCL_EXCLUSIVE;
111  BYTE new_diks;
112 
113  if (wparam != WM_KEYDOWN && wparam != WM_KEYUP &&
115  return 0;
116 
117  TRACE("(%p) wp %08lx, lp %08lx, vk %02x, scan %02x\n",
118  iface, wparam, lparam, hook->vkCode, hook->scanCode);
119 
120  switch (hook->vkCode)
121  {
122  /* R-Shift is special - it is an extended key with separate scan code */
123  case VK_RSHIFT : dik_code = DIK_RSHIFT; break;
124  case VK_PAUSE : dik_code = DIK_PAUSE; break;
125  case VK_NUMLOCK : dik_code = DIK_NUMLOCK; break;
126  case VK_SUBTRACT: dik_code = DIK_SUBTRACT; break;
127  default:
128  dik_code = map_dik_code(hook->scanCode & 0xff, hook->vkCode, This->subtype);
129  if (hook->flags & LLKHF_EXTENDED) dik_code |= 0x80;
130  }
131  new_diks = hook->flags & LLKHF_UP ? 0 : 0x80;
132 
133  /* returns now if key event already known */
134  if (new_diks == This->DInputKeyState[dik_code])
135  return ret;
136 
137  This->DInputKeyState[dik_code] = new_diks;
138  TRACE(" setting %02X to %02X\n", dik_code, This->DInputKeyState[dik_code]);
139 
140  EnterCriticalSection(&This->base.crit);
142  new_diks, GetCurrentTime(), This->base.dinput->evsequence++);
143  LeaveCriticalSection(&This->base.crit);
144 
145  return ret;
146 }
#define VK_SUBTRACT
Definition: winuser.h:2227
#define DIK_RSHIFT
Definition: dinput.h:523
#define DIDFT_PSHBUTTON
Definition: dinput.h:754
#define DIK_NUMLOCK
Definition: dinput.h:538
#define DIDFT_MAKEINSTANCE(n)
Definition: dinput.h:762
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define GetCurrentTime
Definition: winbase.h:2062
static SysKeyboardImpl * impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
Definition: keyboard.c:54
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
#define LLKHF_UP
Definition: winuser.h:2623
#define WM_KEYDOWN
Definition: winuser.h:1697
Definition: msg.h:42
#define TRACE(s)
Definition: solgame.cpp:4
#define DIK_PAUSE
Definition: dinput.h:577
#define WM_KEYUP
Definition: winuser.h:1698
int ret
#define VK_RSHIFT
Definition: winuser.h:2258
static BYTE map_dik_code(DWORD scanCode, DWORD vkCode, DWORD subType)
Definition: keyboard.c:71
#define LLKHF_EXTENDED
Definition: winuser.h:2620
unsigned char BYTE
Definition: xxhash.c:193
#define VK_NUMLOCK
Definition: winuser.h:2254
#define WM_SYSKEYUP
Definition: winuser.h:1702
void queue_event(LPDIRECTINPUTDEVICE8A iface, int inst_id, DWORD data, DWORD time, DWORD seq)
Definition: device.c:1025
#define VK_PAUSE
Definition: winuser.h:2180
#define WM_SYSKEYDOWN
Definition: winuser.h:1701
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define DIK_SUBTRACT
Definition: dinput.h:543
#define DISCL_EXCLUSIVE
Definition: dinput.h:963
static UINT WPARAM wparam
Definition: combo.c:716

Referenced by alloc_device().

◆ keyboarddev_create_device()

static HRESULT keyboarddev_create_device ( IDirectInputImpl dinput,
REFGUID  rguid,
REFIID  riid,
LPVOID pdev,
int  unicode 
)
static

Definition at line 308 of file keyboard.c.

309 {
310  TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode);
311  *pdev = NULL;
312 
313  if (IsEqualGUID(&GUID_SysKeyboard, rguid)) /* Wine Keyboard */
314  {
316 
317  if (riid == NULL)
318  ;/* nothing */
319  else if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) ||
320  IsEqualGUID(&IID_IDirectInputDevice2A, riid) ||
321  IsEqualGUID(&IID_IDirectInputDevice7A, riid) ||
322  IsEqualGUID(&IID_IDirectInputDevice8A, riid))
323  {
324  unicode = 0;
325  }
326  else if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) ||
327  IsEqualGUID(&IID_IDirectInputDevice2W, riid) ||
328  IsEqualGUID(&IID_IDirectInputDevice7W, riid) ||
329  IsEqualGUID(&IID_IDirectInputDevice8W, riid))
330  {
331  unicode = 1;
332  }
333  else
334  {
335  WARN("no interface\n");
336  return DIERR_NOINTERFACE;
337  }
338 
339  This = alloc_device(rguid, dinput);
340  TRACE("Created a Keyboard device (%p)\n", This);
341 
342  if (!This) return DIERR_OUTOFMEMORY;
343 
344  if (unicode)
345  *pdev = &This->base.IDirectInputDevice8W_iface;
346  else
347  *pdev = &This->base.IDirectInputDevice8A_iface;
348 
349  return DI_OK;
350  }
351 
352  return DIERR_DEVICENOTREG;
353 }
REFIID riid
Definition: precomp.h:44
#define WARN(fmt,...)
Definition: debug.h:112
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
static SysKeyboardImpl * alloc_device(REFGUID rguid, IDirectInputImpl *dinput)
Definition: keyboard.c:255
#define TRACE(s)
Definition: solgame.cpp:4
#define DIERR_OUTOFMEMORY
Definition: dinput.h:155
#define DIERR_DEVICENOTREG
Definition: dinput.h:147
#define DIERR_NOINTERFACE
Definition: dinput.h:153
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define DI_OK
Definition: dinput.h:128

◆ keyboarddev_enum_deviceA()

static HRESULT keyboarddev_enum_deviceA ( DWORD  dwDevType,
DWORD  dwFlags,
LPDIDEVICEINSTANCEA  lpddi,
DWORD  version,
int  id 
)
static

Definition at line 213 of file keyboard.c.

214 {
215  if (id != 0)
216  return E_FAIL;
217 
219  return S_FALSE;
220 
221  if ((dwDevType == 0) ||
222  ((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 0x0800)) ||
223  (((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 0x0800))) {
224  TRACE("Enumerating the Keyboard device\n");
225 
227 
228  return S_OK;
229  }
230 
231  return S_FALSE;
232 }
static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version, DWORD subtype)
Definition: keyboard.c:165
static DWORD get_keyboard_subtype(void)
Definition: keyboard.c:148
#define DIEDFL_FORCEFEEDBACK
Definition: dinput.h:192
#define DI8DEVTYPE_KEYBOARD
Definition: dinput.h:211
#define E_FAIL
Definition: ddrawi.h:102
#define S_FALSE
Definition: winerror.h:2357
static const WCHAR version[]
Definition: asmname.c:66
#define TRACE(s)
Definition: solgame.cpp:4
#define DI8DEVCLASS_KEYBOARD
Definition: dinput.h:206
#define DIDEVTYPE_KEYBOARD
Definition: dinput.h:199
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define S_OK
Definition: intsafe.h:51

◆ keyboarddev_enum_deviceW()

static HRESULT keyboarddev_enum_deviceW ( DWORD  dwDevType,
DWORD  dwFlags,
LPDIDEVICEINSTANCEW  lpddi,
DWORD  version,
int  id 
)
static

Definition at line 234 of file keyboard.c.

235 {
236  if (id != 0)
237  return E_FAIL;
238 
240  return S_FALSE;
241 
242  if ((dwDevType == 0) ||
243  ((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 0x0800)) ||
244  (((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 0x0800))) {
245  TRACE("Enumerating the Keyboard device\n");
246 
248 
249  return S_OK;
250  }
251 
252  return S_FALSE;
253 }
static DWORD get_keyboard_subtype(void)
Definition: keyboard.c:148
#define DIEDFL_FORCEFEEDBACK
Definition: dinput.h:192
#define DI8DEVTYPE_KEYBOARD
Definition: dinput.h:211
#define E_FAIL
Definition: ddrawi.h:102
#define S_FALSE
Definition: winerror.h:2357
static const WCHAR version[]
Definition: asmname.c:66
#define TRACE(s)
Definition: solgame.cpp:4
#define DI8DEVCLASS_KEYBOARD
Definition: dinput.h:206
#define DIDEVTYPE_KEYBOARD
Definition: dinput.h:199
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define S_OK
Definition: intsafe.h:51
static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version, DWORD subtype)
Definition: keyboard.c:189

◆ map_dik_code()

static BYTE map_dik_code ( DWORD  scanCode,
DWORD  vkCode,
DWORD  subType 
)
static

Definition at line 71 of file keyboard.c.

72 {
73  if (!scanCode)
74  scanCode = MapVirtualKeyW(vkCode, MAPVK_VK_TO_VSC);
75 
76  if (subType == DIDEVTYPEKEYBOARD_JAPAN106)
77  {
78  switch (scanCode)
79  {
80  case 0x0d: /* ^ */
81  scanCode = DIK_CIRCUMFLEX;
82  break;
83  case 0x1a: /* @ */
84  scanCode = DIK_AT;
85  break;
86  case 0x1b: /* [ */
87  scanCode = DIK_LBRACKET;
88  break;
89  case 0x28: /* : */
90  scanCode = DIK_COLON;
91  break;
92  case 0x29: /* Hankaku/Zenkaku */
93  scanCode = DIK_KANJI;
94  break;
95  case 0x2b: /* ] */
96  scanCode = DIK_RBRACKET;
97  break;
98  case 0x73: /* \ */
99  scanCode = DIK_BACKSLASH;
100  break;
101  }
102  }
103  return scanCode;
104 }
#define DIK_AT
Definition: dinput.h:564
#define DIK_BACKSLASH
Definition: dinput.h:512
#define DIK_CIRCUMFLEX
Definition: dinput.h:563
#define DIK_COLON
Definition: dinput.h:565
UINT WINAPI MapVirtualKeyW(_In_ UINT, _In_ UINT)
#define DIK_KANJI
Definition: dinput.h:567
#define DIK_LBRACKET
Definition: dinput.h:495
#define MAPVK_VK_TO_VSC
Definition: winuser.h:2330
#define DIK_RBRACKET
Definition: dinput.h:496
#define DIDEVTYPEKEYBOARD_JAPAN106
Definition: dinput.h:238

Referenced by alloc_device(), and KeyboardCallback().

◆ map_dik_to_scan()

static DWORD map_dik_to_scan ( DWORD  dik_code,
DWORD  subtype 
)
static

Definition at line 437 of file keyboard.c.

438 {
439  if (dik_code == DIK_PAUSE || dik_code == DIK_NUMLOCK) dik_code ^= 0x80;
440  if (subtype == DIDEVTYPEKEYBOARD_JAPAN106)
441  {
442  switch (dik_code)
443  {
444  case DIK_CIRCUMFLEX:
445  dik_code = 0x0d;
446  break;
447  case DIK_AT:
448  dik_code = 0x1a;
449  break;
450  case DIK_LBRACKET:
451  dik_code = 0x1b;
452  break;
453  case DIK_COLON:
454  dik_code = 0x28;
455  break;
456  case DIK_KANJI:
457  dik_code = 0x29;
458  break;
459  case DIK_RBRACKET:
460  dik_code = 0x2b;
461  break;
462  case DIK_BACKSLASH:
463  dik_code = 0x73;
464  break;
465  }
466  }
467 
468  return dik_code;
469 }
#define DIK_AT
Definition: dinput.h:564
#define DIK_NUMLOCK
Definition: dinput.h:538
#define DIK_BACKSLASH
Definition: dinput.h:512
#define DIK_CIRCUMFLEX
Definition: dinput.h:563
#define DIK_COLON
Definition: dinput.h:565
#define DIK_KANJI
Definition: dinput.h:567
#define DIK_LBRACKET
Definition: dinput.h:495
#define DIK_PAUSE
Definition: dinput.h:577
#define DIK_RBRACKET
Definition: dinput.h:496
#define DIDEVTYPEKEYBOARD_JAPAN106
Definition: dinput.h:238

Referenced by SysKeyboardAImpl_GetObjectInfo(), and SysKeyboardWImpl_GetObjectInfo().

◆ SysKeyboardAImpl_Acquire()

static HRESULT WINAPI SysKeyboardAImpl_Acquire ( LPDIRECTINPUTDEVICE8A  iface)
static

Definition at line 612 of file keyboard.c.

613 {
616 }
static IDirectInputDevice8W * IDirectInputDevice8W_from_impl(SysKeyboardImpl *This)
Definition: keyboard.c:66
static SysKeyboardImpl * impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
Definition: keyboard.c:54
static HRESULT WINAPI SysKeyboardWImpl_Acquire(LPDIRECTINPUTDEVICE8W iface)
Definition: keyboard.c:595

◆ SysKeyboardAImpl_BuildActionMap()

static HRESULT WINAPI SysKeyboardAImpl_BuildActionMap ( LPDIRECTINPUTDEVICE8A  iface,
LPDIACTIONFORMATA  lpdiaf,
LPCSTR  lpszUserName,
DWORD  dwFlags 
)
static

Definition at line 629 of file keyboard.c.

633 {
635  DIACTIONFORMATW diafW;
636  HRESULT hr;
637  WCHAR *lpszUserNameW = NULL;
638  int username_size;
639 
640  diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiaf->dwNumActions);
641  _copy_diactionformatAtoW(&diafW, lpdiaf);
642 
643  if (lpszUserName != NULL)
644  {
645  username_size = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
646  lpszUserNameW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*username_size);
647  MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, lpszUserNameW, username_size);
648  }
649 
650  hr = SysKeyboardWImpl_BuildActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags);
651 
652  _copy_diactionformatWtoA(lpdiaf, &diafW);
653  HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
654  HeapFree(GetProcessHeap(), 0, lpszUserNameW);
655 
656  return hr;
657 }
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:109
DWORD dwNumActions
Definition: dinput.h:1311
static SysKeyboardImpl * impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
Definition: keyboard.c:54
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static HRESULT WINAPI SysKeyboardWImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags)
Definition: keyboard.c:618
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
LPDIACTIONW rgoAction
Definition: dinput.h:1330
void _copy_diactionformatAtoW(LPDIACTIONFORMATW to, LPDIACTIONFORMATA from)
Definition: dinput_main.c:339
void _copy_diactionformatWtoA(LPDIACTIONFORMATA to, LPDIACTIONFORMATW from)
Definition: dinput_main.c:366
#define MultiByteToWideChar
Definition: compat.h:110
#define HeapFree(x, y, z)
Definition: compat.h:483

◆ SysKeyboardAImpl_GetCapabilities()

static HRESULT WINAPI SysKeyboardAImpl_GetCapabilities ( LPDIRECTINPUTDEVICE8A  iface,
LPDIDEVCAPS  lpDIDevCaps 
)
static

Definition at line 431 of file keyboard.c.

432 {
435 }
static IDirectInputDevice8W * IDirectInputDevice8W_from_impl(SysKeyboardImpl *This)
Definition: keyboard.c:66
static SysKeyboardImpl * impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
Definition: keyboard.c:54
static HRESULT WINAPI SysKeyboardWImpl_GetCapabilities(LPDIRECTINPUTDEVICE8W iface, LPDIDEVCAPS lpDIDevCaps)
Definition: keyboard.c:399

◆ SysKeyboardAImpl_GetDeviceInfo()

static HRESULT WINAPI SysKeyboardAImpl_GetDeviceInfo ( LPDIRECTINPUTDEVICE8A  iface,
LPDIDEVICEINSTANCEA  pdidi 
)
static

Definition at line 522 of file keyboard.c.

525 {
527  TRACE("(this=%p,%p)\n", This, pdidi);
528 
529  fill_keyboard_dideviceinstanceA(pdidi, This->base.dinput->dwVersion, This->subtype);
530 
531  return DI_OK;
532 }
static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version, DWORD subtype)
Definition: keyboard.c:165
static SysKeyboardImpl * impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
Definition: keyboard.c:54
#define TRACE(s)
Definition: solgame.cpp:4
#define DI_OK
Definition: dinput.h:128

◆ SysKeyboardAImpl_GetDeviceState()

static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState ( LPDIRECTINPUTDEVICE8A  iface,
DWORD  len,
LPVOID  ptr 
)
static

Definition at line 390 of file keyboard.c.

391 {
394 }
static IDirectInputDevice8W * IDirectInputDevice8W_from_impl(SysKeyboardImpl *This)
Definition: keyboard.c:66
static SysKeyboardImpl * impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
Definition: keyboard.c:54
static PVOID ptr
Definition: dispmode.c:27
static HRESULT WINAPI SysKeyboardWImpl_GetDeviceState(LPDIRECTINPUTDEVICE8W iface, DWORD len, LPVOID ptr)
Definition: keyboard.c:362
GLenum GLsizei len
Definition: glext.h:6722

◆ SysKeyboardAImpl_GetObjectInfo()

static HRESULT WINAPI SysKeyboardAImpl_GetObjectInfo ( LPDIRECTINPUTDEVICE8A  iface,
LPDIDEVICEOBJECTINSTANCEA  pdidoi,
DWORD  dwObj,
DWORD  dwHow 
)
static

Definition at line 476 of file keyboard.c.

481 {
483  HRESULT res;
484  LONG scan;
485 
486  res = IDirectInputDevice2AImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
487  if (res != DI_OK) return res;
488 
489  scan = map_dik_to_scan(DIDFT_GETINSTANCE(pdidoi->dwType), This->subtype);
490  if (!GetKeyNameTextA((scan & 0x80) << 17 | (scan & 0x7f) << 16,
491  pdidoi->tszName, sizeof(pdidoi->tszName)))
492  return DIERR_OBJECTNOTFOUND;
493 
494  _dump_OBJECTINSTANCEA(pdidoi);
495  return res;
496 }
void _dump_OBJECTINSTANCEA(const DIDEVICEOBJECTINSTANCEA *ddoi)
Definition: device.c:186
#define DIDFT_GETINSTANCE(n)
Definition: dinput.h:764
static SysKeyboardImpl * impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
Definition: keyboard.c:54
long LONG
Definition: pedump.c:60
int WINAPI GetKeyNameTextA(_In_ LONG lParam, _Out_writes_(cchSize) LPSTR lpString, _In_ int cchSize)
LONG HRESULT
Definition: typedefs.h:79
CHAR tszName[MAX_PATH]
Definition: dinput.h:352
static DWORD map_dik_to_scan(DWORD dik_code, DWORD subtype)
Definition: keyboard.c:437
GLuint res
Definition: glext.h:9613
#define DI_OK
Definition: dinput.h:128
HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface, LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow)
Definition: device.c:1544
#define DIERR_OBJECTNOTFOUND
Definition: dinput.h:150

◆ SysKeyboardAImpl_GetProperty()

static HRESULT WINAPI SysKeyboardAImpl_GetProperty ( LPDIRECTINPUTDEVICE8A  iface,
REFGUID  rguid,
LPDIPROPHEADER  pdiph 
)
static

Definition at line 588 of file keyboard.c.

590 {
593 }
static IDirectInputDevice8W * IDirectInputDevice8W_from_impl(SysKeyboardImpl *This)
Definition: keyboard.c:66
static HRESULT WINAPI SysKeyboardWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph)
Definition: keyboard.c:552
static SysKeyboardImpl * impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
Definition: keyboard.c:54

◆ SysKeyboardAImpl_SetActionMap()

static HRESULT WINAPI SysKeyboardAImpl_SetActionMap ( LPDIRECTINPUTDEVICE8A  iface,
LPDIACTIONFORMATA  lpdiaf,
LPCSTR  lpszUserName,
DWORD  dwFlags 
)
static

Definition at line 670 of file keyboard.c.

674 {
676  DIACTIONFORMATW diafW;
677  HRESULT hr;
678  WCHAR *lpszUserNameW = NULL;
679  int username_size;
680 
681  diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiaf->dwNumActions);
682  _copy_diactionformatAtoW(&diafW, lpdiaf);
683 
684  if (lpszUserName != NULL)
685  {
686  username_size = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
687  lpszUserNameW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*username_size);
688  MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, lpszUserNameW, username_size);
689  }
690 
691  hr = SysKeyboardWImpl_SetActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags);
692 
693  lpdiaf->dwCRC = diafW.dwCRC;
694 
695  HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
696  HeapFree(GetProcessHeap(), 0, lpszUserNameW);
697 
698  return hr;
699 }
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:109
DWORD dwNumActions
Definition: dinput.h:1311
static HRESULT WINAPI SysKeyboardWImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags)
Definition: keyboard.c:659
static SysKeyboardImpl * impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
Definition: keyboard.c:54
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
LPDIACTIONW rgoAction
Definition: dinput.h:1330
void _copy_diactionformatAtoW(LPDIACTIONFORMATW to, LPDIACTIONFORMATA from)
Definition: dinput_main.c:339
#define MultiByteToWideChar
Definition: compat.h:110
#define HeapFree(x, y, z)
Definition: compat.h:483

◆ SysKeyboardWImpl_Acquire()

static HRESULT WINAPI SysKeyboardWImpl_Acquire ( LPDIRECTINPUTDEVICE8W  iface)
static

Definition at line 595 of file keyboard.c.

596 {
598  HRESULT res;
599 
600  TRACE("(%p)\n", This);
601 
603  if (res == DI_OK)
604  {
605  TRACE("clearing keystate\n");
606  memset(This->DInputKeyState, 0, sizeof(This->DInputKeyState));
607  }
608 
609  return res;
610 }
HRESULT WINAPI IDirectInputDevice2WImpl_Acquire(LPDIRECTINPUTDEVICE8W iface)
Definition: device.c:1076
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
static SysKeyboardImpl * impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
Definition: keyboard.c:58
GLuint res
Definition: glext.h:9613
#define DI_OK
Definition: dinput.h:128
#define memset(x, y, z)
Definition: compat.h:39

Referenced by SysKeyboardAImpl_Acquire().

◆ SysKeyboardWImpl_BuildActionMap()

static HRESULT WINAPI SysKeyboardWImpl_BuildActionMap ( LPDIRECTINPUTDEVICE8W  iface,
LPDIACTIONFORMATW  lpdiaf,
LPCWSTR  lpszUserName,
DWORD  dwFlags 
)
static

Definition at line 618 of file keyboard.c.

622 {
624  FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", This, lpdiaf, debugstr_w(lpszUserName), dwFlags);
625 
626  return _build_action_map(iface, lpdiaf, lpszUserName, dwFlags, DIKEYBOARD_MASK, &c_dfDIKeyboard);
627 }
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define DIKEYBOARD_MASK
const DIDATAFORMAT c_dfDIKeyboard
Definition: data_formats.c:561
HRESULT _build_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags, DWORD devMask, LPCDIDATAFORMAT df)
Definition: device.c:791
static SysKeyboardImpl * impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
Definition: keyboard.c:58

Referenced by SysKeyboardAImpl_BuildActionMap().

◆ SysKeyboardWImpl_GetCapabilities()

static HRESULT WINAPI SysKeyboardWImpl_GetCapabilities ( LPDIRECTINPUTDEVICE8W  iface,
LPDIDEVCAPS  lpDIDevCaps 
)
static

Definition at line 399 of file keyboard.c.

400 {
402  DIDEVCAPS devcaps;
403 
404  TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
405 
406  if ((lpDIDevCaps->dwSize != sizeof(DIDEVCAPS)) && (lpDIDevCaps->dwSize != sizeof(DIDEVCAPS_DX3))) {
407  WARN("invalid parameter\n");
408  return DIERR_INVALIDPARAM;
409  }
410 
411  devcaps.dwSize = lpDIDevCaps->dwSize;
412  devcaps.dwFlags = DIDC_ATTACHED | DIDC_EMULATED;
413  if (This->base.dinput->dwVersion >= 0x0800)
414  devcaps.dwDevType = DI8DEVTYPE_KEYBOARD | (This->subtype << 8);
415  else
416  devcaps.dwDevType = DIDEVTYPE_KEYBOARD | (This->subtype << 8);
417  devcaps.dwAxes = 0;
418  devcaps.dwButtons = This->base.data_format.wine_df->dwNumObjs;
419  devcaps.dwPOVs = 0;
420  devcaps.dwFFSamplePeriod = 0;
421  devcaps.dwFFMinTimeResolution = 0;
422  devcaps.dwFirmwareRevision = 100;
423  devcaps.dwHardwareRevision = 100;
424  devcaps.dwFFDriverVersion = 0;
425 
426  memcpy(lpDIDevCaps, &devcaps, lpDIDevCaps->dwSize);
427 
428  return DI_OK;
429 }
DWORD dwFFMinTimeResolution
Definition: dinput.h:939
#define DIDC_EMULATED
Definition: dinput.h:947
#define WARN(fmt,...)
Definition: debug.h:112
#define DIDC_ATTACHED
Definition: dinput.h:945
#define DI8DEVTYPE_KEYBOARD
Definition: dinput.h:211
DWORD dwDevType
Definition: dinput.h:934
DWORD dwFFSamplePeriod
Definition: dinput.h:938
DWORD dwFlags
Definition: dinput.h:933
DWORD dwAxes
Definition: dinput.h:935
DWORD dwPOVs
Definition: dinput.h:937
DWORD dwHardwareRevision
Definition: dinput.h:941
#define DIERR_INVALIDPARAM
Definition: dinput.h:152
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwSize
Definition: dinput.h:932
DWORD dwFFDriverVersion
Definition: dinput.h:942
DWORD dwButtons
Definition: dinput.h:936
#define DIDEVTYPE_KEYBOARD
Definition: dinput.h:199
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static SysKeyboardImpl * impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
Definition: keyboard.c:58
#define DI_OK
Definition: dinput.h:128
DWORD dwFirmwareRevision
Definition: dinput.h:940

Referenced by SysKeyboardAImpl_GetCapabilities().

◆ SysKeyboardWImpl_GetDeviceInfo()

static HRESULT WINAPI SysKeyboardWImpl_GetDeviceInfo ( LPDIRECTINPUTDEVICE8W  iface,
LPDIDEVICEINSTANCEW  pdidi 
)
static

Definition at line 534 of file keyboard.c.

535 {
537  TRACE("(this=%p,%p)\n", This, pdidi);
538 
539  if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)) {
540  WARN(" dinput3 not supported yet...\n");
541  return DI_OK;
542  }
543 
544  fill_keyboard_dideviceinstanceW(pdidi, This->base.dinput->dwVersion, This->subtype);
545 
546  return DI_OK;
547 }
#define WARN(fmt,...)
Definition: debug.h:112
#define TRACE(s)
Definition: solgame.cpp:4
static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version, DWORD subtype)
Definition: keyboard.c:189
static SysKeyboardImpl * impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
Definition: keyboard.c:58
#define DI_OK
Definition: dinput.h:128

◆ SysKeyboardWImpl_GetDeviceState()

static HRESULT WINAPI SysKeyboardWImpl_GetDeviceState ( LPDIRECTINPUTDEVICE8W  iface,
DWORD  len,
LPVOID  ptr 
)
static

Definition at line 362 of file keyboard.c.

363 {
365  TRACE("(%p)->(%d,%p)\n", This, len, ptr);
366 
367  if (!This->base.acquired) return DIERR_NOTACQUIRED;
368 
369  if (len != This->base.data_format.user_df->dwDataSize )
370  return DIERR_INVALIDPARAM;
371 
373 
374  EnterCriticalSection(&This->base.crit);
375 
376  if (TRACE_ON(dinput)) {
377  int i;
378  for (i = 0; i < WINE_DINPUT_KEYBOARD_MAX_KEYS; i++) {
379  if (This->DInputKeyState[i] != 0x00)
380  TRACE(" - %02X: %02x\n", i, This->DInputKeyState[i]);
381  }
382  }
383 
384  fill_DataFormat(ptr, len, This->DInputKeyState, &This->base.data_format);
385  LeaveCriticalSection(&This->base.crit);
386 
387  return DI_OK;
388 }
void check_dinput_events(void)
Definition: dinput_main.c:1900
#define WINE_DINPUT_KEYBOARD_MAX_KEYS
Definition: keyboard.c:41
#define DIERR_NOTACQUIRED
Definition: dinput.h:167
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static PVOID ptr
Definition: dispmode.c:27
#define DIERR_INVALIDPARAM
Definition: dinput.h:152
#define TRACE(s)
Definition: solgame.cpp:4
void fill_DataFormat(void *out, DWORD size, const void *in, const DataFormat *df)
Definition: device.c:326
GLenum GLsizei len
Definition: glext.h:6722
static SysKeyboardImpl * impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
Definition: keyboard.c:58
#define DI_OK
Definition: dinput.h:128
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define TRACE_ON(x)
Definition: compat.h:75

Referenced by SysKeyboardAImpl_GetDeviceState().

◆ SysKeyboardWImpl_GetObjectInfo()

static HRESULT WINAPI SysKeyboardWImpl_GetObjectInfo ( LPDIRECTINPUTDEVICE8W  iface,
LPDIDEVICEOBJECTINSTANCEW  pdidoi,
DWORD  dwObj,
DWORD  dwHow 
)
static

Definition at line 498 of file keyboard.c.

502 {
504  HRESULT res;
505  LONG scan;
506 
507  res = IDirectInputDevice2WImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
508  if (res != DI_OK) return res;
509 
510  scan = map_dik_to_scan(DIDFT_GETINSTANCE(pdidoi->dwType), This->subtype);
511  if (!GetKeyNameTextW((scan & 0x80) << 17 | (scan & 0x7f) << 16,
512  pdidoi->tszName, ARRAY_SIZE(pdidoi->tszName)))
513  return DIERR_OBJECTNOTFOUND;
514 
515  _dump_OBJECTINSTANCEW(pdidoi);
516  return res;
517 }
void _dump_OBJECTINSTANCEW(const DIDEVICEOBJECTINSTANCEW *ddoi)
Definition: device.c:191
WCHAR tszName[MAX_PATH]
Definition: dinput.h:371
#define DIDFT_GETINSTANCE(n)
Definition: dinput.h:764
long LONG
Definition: pedump.c:60
LONG HRESULT
Definition: typedefs.h:79
static DWORD map_dik_to_scan(DWORD dik_code, DWORD subtype)
Definition: keyboard.c:437
int WINAPI GetKeyNameTextW(_In_ LONG lParam, _Out_writes_(cchSize) LPWSTR lpString, _In_ int cchSize)
#define ARRAY_SIZE(a)
Definition: main.h:24
HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow)
Definition: device.c:1576
static SysKeyboardImpl * impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
Definition: keyboard.c:58
GLuint res
Definition: glext.h:9613
#define DI_OK
Definition: dinput.h:128
#define DIERR_OBJECTNOTFOUND
Definition: dinput.h:150

Referenced by SysKeyboardWImpl_GetProperty().

◆ SysKeyboardWImpl_GetProperty()

static HRESULT WINAPI SysKeyboardWImpl_GetProperty ( LPDIRECTINPUTDEVICE8W  iface,
REFGUID  rguid,
LPDIPROPHEADER  pdiph 
)
static

Definition at line 552 of file keyboard.c.

554 {
556 
557  TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(rguid), pdiph);
558  _dump_DIPROPHEADER(pdiph);
559 
560  if (!IS_DIPROP(rguid)) return DI_OK;
561 
562  switch (LOWORD(rguid))
563  {
565  {
566  HRESULT hr;
567  LPDIPROPSTRING ps = (LPDIPROPSTRING)pdiph;
569 
570  if (pdiph->dwSize != sizeof(DIPROPSTRING))
571  return DIERR_INVALIDPARAM;
572 
573  didoi.dwSize = sizeof(DIDEVICEOBJECTINSTANCEW);
574 
575  hr = SysKeyboardWImpl_GetObjectInfo(iface, &didoi, ps->diph.dwObj, ps->diph.dwHow);
576  if (hr == DI_OK)
577  memcpy(ps->wsz, didoi.tszName, sizeof(ps->wsz));
578  return hr;
579  }
580  case (DWORD_PTR) DIPROP_RANGE:
581  return DIERR_UNSUPPORTED;
582  default:
584  }
585  return DI_OK;
586 }
struct DIPROPSTRING * LPDIPROPSTRING
DWORD dwSize
Definition: dinput.h:828
HRESULT hr
Definition: shlfolder.c:183
WCHAR tszName[MAX_PATH]
Definition: dinput.h:371
#define DIPROP_RANGE
Definition: dinput.h:892
DWORD dwHow
Definition: dinput.h:831
#define DIERR_UNSUPPORTED
Definition: dinput.h:156
HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph)
Definition: device.c:1440
static HRESULT WINAPI SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow)
Definition: keyboard.c:498
struct DIDEVICEOBJECTINSTANCEW DIDEVICEOBJECTINSTANCEW
#define debugstr_guid
Definition: kernel32.h:35
#define DIERR_INVALIDPARAM
Definition: dinput.h:152
#define TRACE(s)
Definition: solgame.cpp:4
void _dump_DIPROPHEADER(LPCDIPROPHEADER diph)
Definition: device.c:176
LONG HRESULT
Definition: typedefs.h:79
WCHAR wsz[MAX_PATH]
Definition: dinput.h:875
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
uint32_t DWORD_PTR
Definition: typedefs.h:65
DWORD dwObj
Definition: dinput.h:830
static SysKeyboardImpl * impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
Definition: keyboard.c:58
#define DI_OK
Definition: dinput.h:128
#define IS_DIPROP(x)
static IDirectInputDevice8A * IDirectInputDevice8A_from_impl(SysKeyboardImpl *This)
Definition: keyboard.c:62
DIPROPHEADER diph
Definition: dinput.h:874
#define LOWORD(l)
Definition: pedump.c:82
#define DIPROP_KEYNAME
Definition: dinput.h:914

Referenced by SysKeyboardAImpl_GetProperty().

◆ SysKeyboardWImpl_SetActionMap()

static HRESULT WINAPI SysKeyboardWImpl_SetActionMap ( LPDIRECTINPUTDEVICE8W  iface,
LPDIACTIONFORMATW  lpdiaf,
LPCWSTR  lpszUserName,
DWORD  dwFlags 
)
static

Definition at line 659 of file keyboard.c.

663 {
665  FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", This, lpdiaf, debugstr_w(lpszUserName), dwFlags);
666 
667  return _set_action_map(iface, lpdiaf, lpszUserName, dwFlags, &c_dfDIKeyboard);
668 }
HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags, LPCDIDATAFORMAT df)
Definition: device.c:866
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
const DIDATAFORMAT c_dfDIKeyboard
Definition: data_formats.c:561
static SysKeyboardImpl * impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
Definition: keyboard.c:58

Referenced by SysKeyboardAImpl_SetActionMap().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( dinput  )

Variable Documentation

◆ keyboard_device

const struct dinput_device keyboard_device
Initial value:
= {
"Wine keyboard driver",
}
static HRESULT keyboarddev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
Definition: keyboard.c:234
static HRESULT keyboarddev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode)
Definition: keyboard.c:308
static HRESULT keyboarddev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
Definition: keyboard.c:213

Definition at line 355 of file keyboard.c.

◆ SysKeyboardAvt

static const IDirectInputDevice8AVtbl SysKeyboardAvt
static

Definition at line 43 of file keyboard.c.

Referenced by alloc_device().

◆ SysKeyboardWvt

static const IDirectInputDevice8WVtbl SysKeyboardWvt
static

Definition at line 44 of file keyboard.c.

Referenced by alloc_device().