ReactOS 0.4.15-dev-7659-ga55345b
joystick_private.h File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "dinput.h"
#include "wine/list.h"
#include "wine/unicode.h"
#include "dinput_private.h"
#include "device_private.h"
Include dependency graph for joystick_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  JoystickGenericImpl
 

Macros

#define MAX_PROPS   164
 
#define MAX_MAP_BUTTONS   32
 

Typedefs

typedef void joy_polldev_handler(LPDIRECTINPUTDEVICE8A iface)
 
typedef struct JoystickGenericImpl JoystickGenericImpl
 

Functions

LONG joystick_map_axis (ObjProps *props, int val) DECLSPEC_HIDDEN
 
HRESULT setup_dinput_options (JoystickGenericImpl *This, const int *default_axis_map) DECLSPEC_HIDDEN
 
DWORD joystick_map_pov (const POINTL *p) DECLSPEC_HIDDEN
 
BOOL device_disabled_registry (const char *name) DECLSPEC_HIDDEN
 
HRESULT WINAPI JoystickWGenericImpl_GetObjectInfo (LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) DECLSPEC_HIDDEN
 
HRESULT WINAPI JoystickAGenericImpl_GetObjectInfo (LPDIRECTINPUTDEVICE8A iface, LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) DECLSPEC_HIDDEN
 
HRESULT WINAPI JoystickAGenericImpl_GetProperty (LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph) DECLSPEC_HIDDEN
 
HRESULT WINAPI JoystickWGenericImpl_GetProperty (LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph) DECLSPEC_HIDDEN
 
HRESULT WINAPI JoystickAGenericImpl_GetCapabilities (LPDIRECTINPUTDEVICE8A iface, LPDIDEVCAPS lpDIDevCaps) DECLSPEC_HIDDEN
 
HRESULT WINAPI JoystickWGenericImpl_GetCapabilities (LPDIRECTINPUTDEVICE8W iface, LPDIDEVCAPS lpDIDevCaps) DECLSPEC_HIDDEN
 
void _dump_DIDEVCAPS (const DIDEVCAPS *lpDIDevCaps) DECLSPEC_HIDDEN
 
HRESULT WINAPI JoystickAGenericImpl_SetProperty (LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIPROPHEADER ph) DECLSPEC_HIDDEN
 
HRESULT WINAPI JoystickWGenericImpl_SetProperty (LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIPROPHEADER ph) DECLSPEC_HIDDEN
 
HRESULT WINAPI JoystickAGenericImpl_GetDeviceInfo (LPDIRECTINPUTDEVICE8A iface, LPDIDEVICEINSTANCEA pdidi) DECLSPEC_HIDDEN
 
HRESULT WINAPI JoystickWGenericImpl_GetDeviceInfo (LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi) DECLSPEC_HIDDEN
 
HRESULT WINAPI JoystickAGenericImpl_Poll (LPDIRECTINPUTDEVICE8A iface) DECLSPEC_HIDDEN
 
HRESULT WINAPI JoystickWGenericImpl_Poll (LPDIRECTINPUTDEVICE8W iface) DECLSPEC_HIDDEN
 
HRESULT WINAPI JoystickAGenericImpl_GetDeviceState (LPDIRECTINPUTDEVICE8A iface, DWORD len, LPVOID ptr) DECLSPEC_HIDDEN
 
HRESULT WINAPI JoystickWGenericImpl_GetDeviceState (LPDIRECTINPUTDEVICE8W iface, DWORD len, LPVOID ptr) DECLSPEC_HIDDEN
 
HRESULT WINAPI JoystickAGenericImpl_BuildActionMap (LPDIRECTINPUTDEVICE8A iface, LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags) DECLSPEC_HIDDEN
 
HRESULT WINAPI JoystickWGenericImpl_BuildActionMap (LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) DECLSPEC_HIDDEN
 
HRESULT WINAPI JoystickAGenericImpl_SetActionMap (LPDIRECTINPUTDEVICE8A iface, LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags) DECLSPEC_HIDDEN
 
HRESULT WINAPI JoystickWGenericImpl_SetActionMap (LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) DECLSPEC_HIDDEN
 
DWORD typeFromGUID (REFGUID guid) DECLSPEC_HIDDEN
 
void dump_DIEFFECT (LPCDIEFFECT eff, REFGUID guid, DWORD dwFlags) DECLSPEC_HIDDEN
 
BOOL is_xinput_device (const DIDEVCAPS *devcaps, WORD vid, WORD pid) DECLSPEC_HIDDEN
 

Macro Definition Documentation

◆ MAX_MAP_BUTTONS

#define MAX_MAP_BUTTONS   32

Definition at line 37 of file joystick_private.h.

◆ MAX_PROPS

#define MAX_PROPS   164

Definition at line 33 of file joystick_private.h.

Typedef Documentation

◆ joy_polldev_handler

typedef void joy_polldev_handler(LPDIRECTINPUTDEVICE8A iface)

Definition at line 39 of file joystick_private.h.

◆ JoystickGenericImpl

Function Documentation

◆ _dump_DIDEVCAPS()

void _dump_DIDEVCAPS ( const DIDEVCAPS lpDIDevCaps)

Definition at line 480 of file joystick.c.

481{
482 int type = GET_DIDEVICE_TYPE(lpDIDevCaps->dwDevType);
483 const char *str, *hid = "";
484 TRACE("dwSize: %d\n", lpDIDevCaps->dwSize);
485 TRACE("dwFlags: %08x\n", lpDIDevCaps->dwFlags);
486 switch(type)
487 {
488 /* Direct X <= 7 definitions */
493 /* Direct X >= 8 definitions */
506 default: str = "UNKNOWN";
507 }
508
509 if (lpDIDevCaps->dwDevType & DIDEVTYPE_HID)
510 hid = " (HID)";
511
512 TRACE("dwDevType: %08x %s%s\n", lpDIDevCaps->dwDevType, str, hid);
513 TRACE("dwAxes: %d\n", lpDIDevCaps->dwAxes);
514 TRACE("dwButtons: %d\n", lpDIDevCaps->dwButtons);
515 TRACE("dwPOVs: %d\n", lpDIDevCaps->dwPOVs);
516 if (lpDIDevCaps->dwSize > sizeof(DIDEVCAPS_DX3)) {
517 TRACE("dwFFSamplePeriod: %d\n", lpDIDevCaps->dwFFSamplePeriod);
518 TRACE("dwFFMinTimeResolution: %d\n", lpDIDevCaps->dwFFMinTimeResolution);
519 TRACE("dwFirmwareRevision: %d\n", lpDIDevCaps->dwFirmwareRevision);
520 TRACE("dwHardwareRevision: %d\n", lpDIDevCaps->dwHardwareRevision);
521 TRACE("dwFFDriverVersion: %d\n", lpDIDevCaps->dwFFDriverVersion);
522 }
523}
#define DI8DEVTYPE_DEVICE
Definition: dinput.h:209
#define DI8DEVTYPE_1STPERSON
Definition: dinput.h:216
#define DIDEVTYPE_JOYSTICK
Definition: dinput.h:200
#define DI8DEVTYPE_SUPPLEMENTAL
Definition: dinput.h:220
#define DIDEVTYPE_KEYBOARD
Definition: dinput.h:199
#define DIDEVTYPE_HID
Definition: dinput.h:201
#define DI8DEVTYPE_GAMEPAD
Definition: dinput.h:213
#define DI8DEVTYPE_REMOTE
Definition: dinput.h:219
#define DIDEVTYPE_MOUSE
Definition: dinput.h:198
#define DI8DEVTYPE_DEVICECTRL
Definition: dinput.h:217
#define DIDEVTYPE_DEVICE
Definition: dinput.h:197
#define DI8DEVTYPE_DRIVING
Definition: dinput.h:214
#define DI8DEVTYPE_FLIGHT
Definition: dinput.h:215
#define DI8DEVTYPE_JOYSTICK
Definition: dinput.h:212
#define GET_DIDEVICE_TYPE(dwDevType)
Definition: dinput.h:320
#define DI8DEVTYPE_SCREENPOINTER
Definition: dinput.h:218
#define DI8DEVTYPE_MOUSE
Definition: dinput.h:210
#define DI8DEVTYPE_KEYBOARD
Definition: dinput.h:211
#define DEBUG_TYPE(x)
Definition: joystick.c:479
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
const WCHAR * str
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwHardwareRevision
Definition: dinput.h:941
DWORD dwAxes
Definition: dinput.h:935
DWORD dwFFSamplePeriod
Definition: dinput.h:938
DWORD dwButtons
Definition: dinput.h:936
DWORD dwPOVs
Definition: dinput.h:937
DWORD dwSize
Definition: dinput.h:932
DWORD dwFlags
Definition: dinput.h:933
DWORD dwFFDriverVersion
Definition: dinput.h:942
DWORD dwFirmwareRevision
Definition: dinput.h:940
DWORD dwDevType
Definition: dinput.h:934
DWORD dwFFMinTimeResolution
Definition: dinput.h:939

Referenced by JoystickWGenericImpl_GetCapabilities().

◆ device_disabled_registry()

BOOL device_disabled_registry ( const char name)

Definition at line 274 of file joystick.c.

275{
276 static const char disabled_str[] = "disabled";
277 static const char joystick_key[] = "Joysticks";
278 char buffer[MAX_PATH];
279 HKEY hkey, appkey, temp;
280 BOOL do_disable = FALSE;
281
282 get_app_key(&hkey, &appkey);
283
284 /* Joystick settings are in the 'joysticks' subkey */
285 if (appkey)
286 {
287 if (RegOpenKeyA(appkey, joystick_key, &temp)) temp = 0;
288 RegCloseKey(appkey);
289 appkey = temp;
290 }
291 if (hkey)
292 {
293 if (RegOpenKeyA(hkey, joystick_key, &temp)) temp = 0;
294 RegCloseKey(hkey);
295 hkey = temp;
296 }
297
298 /* Look for the "controllername"="disabled" key */
299 if (!get_config_key(hkey, appkey, name, buffer, sizeof(buffer)))
300 if (!strcmp(disabled_str, buffer))
301 {
302 TRACE("Disabling joystick '%s' based on registry key.\n", name);
303 do_disable = TRUE;
304 }
305
306 if (appkey) RegCloseKey(appkey);
307 if (hkey) RegCloseKey(hkey);
308
309 return do_disable;
310}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define RegCloseKey(hKey)
Definition: registry.h:49
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL get_app_key(HKEY *defkey, HKEY *appkey)
Definition: device.c:278
DWORD get_config_key(HKEY defkey, HKEY appkey, const char *name, char *buffer, DWORD size)
Definition: device.c:313
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3263
#define MAX_PATH
Definition: compat.h:34
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint buffer
Definition: glext.h:5915
static calc_node_t temp
Definition: rpn_ieee.c:38
Definition: name.c:39

◆ dump_DIEFFECT()

void dump_DIEFFECT ( LPCDIEFFECT  eff,
REFGUID  guid,
DWORD  dwFlags 
)

Definition at line 190 of file joystick.c.

191{
193 unsigned int i;
194
195 TRACE("Dumping DIEFFECT structure:\n");
196 TRACE(" - dwSize: %d\n", eff->dwSize);
197 if ((eff->dwSize != sizeof(DIEFFECT)) && (eff->dwSize != sizeof(DIEFFECT_DX5))) {
198 WARN("Non-standard DIEFFECT structure size %d\n", eff->dwSize);
199 }
200 TRACE(" - dwFlags: %d\n", eff->dwFlags);
201 TRACE(" ");
203 TRACE(" - dwDuration: %d\n", eff->dwDuration);
204 TRACE(" - dwGain: %d\n", eff->dwGain);
205
206 if (eff->dwGain > 10000)
207 WARN("dwGain is out of range (>10,000)\n");
208
209 TRACE(" - dwTriggerButton: %d\n", eff->dwTriggerButton);
210 TRACE(" - dwTriggerRepeatInterval: %d\n", eff->dwTriggerRepeatInterval);
211 TRACE(" - rglDirection: %p\n", eff->rglDirection);
212 TRACE(" - cbTypeSpecificParams: %d\n", eff->cbTypeSpecificParams);
213 TRACE(" - lpvTypeSpecificParams: %p\n", eff->lpvTypeSpecificParams);
214
215 /* Only trace some members if dwFlags indicates they have data */
216 if (dwFlags & DIEP_AXES) {
217 TRACE(" - cAxes: %d\n", eff->cAxes);
218 TRACE(" - rgdwAxes: %p\n", eff->rgdwAxes);
219
220 if (TRACE_ON(dinput) && eff->rgdwAxes) {
221 TRACE(" ");
222 for (i = 0; i < eff->cAxes; ++i)
223 TRACE("%d ", eff->rgdwAxes[i]);
224 TRACE("\n");
225 }
226 }
227
228 if (dwFlags & DIEP_ENVELOPE) {
229 TRACE(" - lpEnvelope: %p\n", eff->lpEnvelope);
230 if (eff->lpEnvelope != NULL)
232 }
233
234 if (eff->dwSize > sizeof(DIEFFECT_DX5))
235 TRACE(" - dwStartDelay: %d\n", eff->dwStartDelay);
236
237 if (type == DIEFT_CONSTANTFORCE) {
238 if (eff->cbTypeSpecificParams != sizeof(DICONSTANTFORCE)) {
239 WARN("Effect claims to be a constant force but the type-specific params are the wrong size!\n");
240 } else {
242 }
243 } else if (type == DIEFT_PERIODIC) {
244 if (eff->cbTypeSpecificParams != sizeof(DIPERIODIC)) {
245 WARN("Effect claims to be a periodic force but the type-specific params are the wrong size!\n");
246 } else {
248 }
249 } else if (type == DIEFT_RAMPFORCE) {
250 if (eff->cbTypeSpecificParams != sizeof(DIRAMPFORCE)) {
251 WARN("Effect claims to be a ramp force but the type-specific params are the wrong size!\n");
252 } else {
254 }
255 } else if (type == DIEFT_CONDITION) {
256 if (eff->cbTypeSpecificParams == sizeof(DICONDITION)) {
258 } else if (eff->cbTypeSpecificParams == 2 * sizeof(DICONDITION)) {
262 } else {
263 WARN("Effect claims to be a condition but the type-specific params are the wrong size!\n");
264 }
265 } else if (type == DIEFT_CUSTOMFORCE) {
266 if (eff->cbTypeSpecificParams != sizeof(DICUSTOMFORCE)) {
267 WARN("Effect claims to be a custom force but the type-specific params are the wrong size!\n");
268 } else {
270 }
271 }
272}
#define WARN(fmt,...)
Definition: debug.h:112
#define DIEFT_CONDITION
Definition: dinput.h:996
#define DIEFT_CUSTOMFORCE
Definition: dinput.h:997
#define DIEFT_PERIODIC
Definition: dinput.h:995
#define DIEFT_CONSTANTFORCE
Definition: dinput.h:993
#define DIEP_ENVELOPE
Definition: dinput.h:1021
#define DIEFT_RAMPFORCE
Definition: dinput.h:994
#define DIEP_AXES
Definition: dinput.h:1019
#define NULL
Definition: types.h:112
DWORD typeFromGUID(REFGUID guid)
Definition: joystick.c:82
static void _dump_DIENVELOPE(LPCDIENVELOPE env)
Definition: joystick.c:140
static void _dump_DIPERIODIC(LPCDIPERIODIC frc)
Definition: joystick.c:154
static void _dump_DIEFFECT_flags(DWORD dwFlags)
Definition: joystick.c:117
static void _dump_DICONSTANTFORCE(LPCDICONSTANTFORCE frc)
Definition: joystick.c:149
static void _dump_DICUSTOMFORCE(LPCDICUSTOMFORCE frc)
Definition: joystick.c:173
static void _dump_DICONDITION(LPCDICONDITION frc)
Definition: joystick.c:166
static void _dump_DIRAMPFORCE(LPCDIRAMPFORCE frc)
Definition: joystick.c:160
#define TRACE_ON(x)
Definition: compat.h:75
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum condition
Definition: glext.h:9255
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
const GUID * guid
DWORD cAxes
Definition: dinput.h:1112
DWORD dwTriggerButton
Definition: dinput.h:1110
LPDIENVELOPE lpEnvelope
Definition: dinput.h:1115
DWORD dwDuration
Definition: dinput.h:1107
DWORD dwGain
Definition: dinput.h:1109
DWORD dwFlags
Definition: dinput.h:1106
DWORD dwTriggerRepeatInterval
Definition: dinput.h:1111
DWORD dwSize
Definition: dinput.h:1105
LPVOID lpvTypeSpecificParams
Definition: dinput.h:1117
LPLONG rglDirection
Definition: dinput.h:1114
DWORD dwStartDelay
Definition: dinput.h:1118
DWORD cbTypeSpecificParams
Definition: dinput.h:1116
LPDWORD rgdwAxes
Definition: dinput.h:1113
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

◆ is_xinput_device()

BOOL is_xinput_device ( const DIDEVCAPS devcaps,
WORD  vid,
WORD  pid 
)

Definition at line 312 of file joystick.c.

313{
314 int i;
315
316 if (vid == VID_MICROSOFT)
317 {
318 for (i = 0; i < ARRAY_SIZE(PID_XBOX_CONTROLLERS); i++)
319 if (pid == PID_XBOX_CONTROLLERS[i]) return TRUE;
320 }
321
322 return (devcaps->dwAxes == 6 && devcaps->dwButtons >= 14);
323}
#define ARRAY_SIZE(A)
Definition: main.h:33
#define VID_MICROSOFT
Definition: joystick.c:39
static const WORD PID_XBOX_CONTROLLERS[]
Definition: joystick.c:41
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3837

◆ joystick_map_axis()

LONG joystick_map_axis ( ObjProps props,
int  val 
)

Definition at line 985 of file joystick.c.

986{
987 LONG ret;
988 LONG dead_zone = MulDiv( props->lDeadZone, props->lDevMax - props->lDevMin, 10000 );
989 LONG dev_range = props->lDevMax - props->lDevMin - dead_zone;
990
991 /* Center input */
992 val -= (props->lDevMin + props->lDevMax) / 2;
993
994 /* Remove dead zone */
995 if (abs( val ) <= dead_zone / 2)
996 val = 0;
997 else
998 val = val < 0 ? val + dead_zone / 2 : val - dead_zone / 2;
999
1000 /* Scale and map the value from the device range into the required range */
1001 ret = MulDiv( val, props->lMax - props->lMin, dev_range ) +
1002 (props->lMin + props->lMax) / 2;
1003
1004 /* Clamp in case or rounding errors */
1005 if (ret > props->lMax) ret = props->lMax;
1006 else if (ret < props->lMin) ret = props->lMin;
1007
1008 TRACE( "(%d <%d> %d) -> (%d <%d> %d): val=%d ret=%d\n",
1009 props->lDevMin, dead_zone, props->lDevMax,
1010 props->lMin, props->lDeadZone, props->lMax,
1011 val, ret );
1012
1013 return ret;
1014}
#define abs(i)
Definition: fconv.c:206
GLuint GLfloat * val
Definition: glext.h:7180
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
long LONG
Definition: pedump.c:60
static const WCHAR props[]
Definition: wbemdisp.c:288
int ret

Referenced by remap_apply().

◆ joystick_map_pov()

DWORD joystick_map_pov ( const POINTL p)

Definition at line 1024 of file joystick.c.

1025{
1026 if (p->x > 0)
1027 return p->y < 0 ? 4500 : !p->y ? 9000 : 13500;
1028 else if (p->x < 0)
1029 return p->y < 0 ? 31500 : !p->y ? 27000 : 22500;
1030 else
1031 return p->y < 0 ? 0 : !p->y ? -1 : 18000;
1032}
GLfloat GLfloat p
Definition: glext.h:8902

◆ JoystickAGenericImpl_BuildActionMap()

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

Definition at line 906 of file joystick.c.

910{
912 DIACTIONFORMATW diafW;
913 HRESULT hr;
914 WCHAR *lpszUserNameW = NULL;
915 int username_size;
916
917 diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiaf->dwNumActions);
918 _copy_diactionformatAtoW(&diafW, lpdiaf);
919
920 if (lpszUserName != NULL)
921 {
922 username_size = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
923 lpszUserNameW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*username_size);
924 MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, lpszUserNameW, username_size);
925 }
926
927 hr = JoystickWGenericImpl_BuildActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags);
928
929 _copy_diactionformatWtoA(lpdiaf, &diafW);
930 HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
931 HeapFree(GetProcessHeap(), 0, lpszUserNameW);
932
933 return hr;
934}
void _copy_diactionformatWtoA(LPDIACTIONFORMATA to, LPDIACTIONFORMATW from)
Definition: dinput_main.c:366
void _copy_diactionformatAtoW(LPDIACTIONFORMATW to, LPDIACTIONFORMATA from)
Definition: dinput_main.c:339
static JoystickGenericImpl * impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
Definition: joystick.c:65
HRESULT WINAPI JoystickWGenericImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags)
Definition: joystick.c:831
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define MultiByteToWideChar
Definition: compat.h:110
HRESULT hr
Definition: shlfolder.c:183
DWORD dwNumActions
Definition: dinput.h:1311
LPDIACTIONW rgoAction
Definition: dinput.h:1330
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ JoystickAGenericImpl_GetCapabilities()

HRESULT WINAPI JoystickAGenericImpl_GetCapabilities ( LPDIRECTINPUTDEVICE8A  iface,
LPDIDEVCAPS  lpDIDevCaps 
)

Definition at line 554 of file joystick.c.

555{
558}
HRESULT WINAPI JoystickWGenericImpl_GetCapabilities(LPDIRECTINPUTDEVICE8W iface, LPDIDEVCAPS lpDIDevCaps)
Definition: joystick.c:526
static IDirectInputDevice8W * IDirectInputDevice8W_from_impl(JoystickGenericImpl *This)
Definition: joystick.c:77

◆ JoystickAGenericImpl_GetDeviceInfo()

HRESULT WINAPI JoystickAGenericImpl_GetDeviceInfo ( LPDIRECTINPUTDEVICE8A  iface,
LPDIDEVICEINSTANCEA  pdidi 
)

Definition at line 689 of file joystick.c.

692{
694 DIPROPDWORD pd;
695 DWORD index = 0;
696
697 TRACE("(%p,%p)\n", This, pdidi);
698
699 if (pdidi == NULL) {
700 WARN("invalid pointer\n");
701 return E_POINTER;
702 }
703
704 if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3A)) &&
705 (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA))) {
706 WARN("invalid parameter: pdidi->dwSize = %d\n", pdidi->dwSize);
707 return DIERR_INVALIDPARAM;
708 }
709
710 /* Try to get joystick index */
711 pd.diph.dwSize = sizeof(pd);
712 pd.diph.dwHeaderSize = sizeof(pd.diph);
713 pd.diph.dwObj = 0;
716 index = pd.dwData;
717
718 /* Return joystick */
719 pdidi->guidInstance = This->guidInstance;
720 pdidi->guidProduct = This->guidProduct;
721 /* we only support traditional joysticks for now */
722 pdidi->dwDevType = This->devcaps.dwDevType;
723 snprintf(pdidi->tszInstanceName, MAX_PATH, "Joystick %d", index);
724 lstrcpynA(pdidi->tszProductName, This->name, MAX_PATH);
725 if (pdidi->dwSize > sizeof(DIDEVICEINSTANCE_DX3A)) {
726 pdidi->guidFFDriver = GUID_NULL;
727 pdidi->wUsagePage = 0;
728 pdidi->wUsage = 0;
729 }
730
731 return DI_OK;
732}
#define DIERR_INVALIDPARAM
Definition: dinput.h:152
#define DIPROP_JOYSTICKID
Definition: dinput.h:912
#define DI_OK
Definition: dinput.h:128
#define IDirectInputDevice2_GetProperty(p, a, b)
Definition: dinput.h:1729
#define DIPH_DEVICE
Definition: dinput.h:835
#define lstrcpynA
Definition: compat.h:751
GLuint index
Definition: glext.h:6031
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define GUID_NULL
Definition: ks.h:106
GUID guidProduct
Definition: dinput.h:414
GUID guidFFDriver
Definition: dinput.h:418
GUID guidInstance
Definition: dinput.h:413
CHAR tszInstanceName[MAX_PATH]
Definition: dinput.h:416
CHAR tszProductName[MAX_PATH]
Definition: dinput.h:417
DWORD dwDevType
Definition: dinput.h:415
DIPROPHEADER diph
Definition: dinput.h:843
DWORD dwData
Definition: dinput.h:844
DWORD dwObj
Definition: dinput.h:830
DWORD dwSize
Definition: dinput.h:828
DWORD dwHeaderSize
Definition: dinput.h:829
DWORD dwHow
Definition: dinput.h:831
#define E_POINTER
Definition: winerror.h:2365
#define snprintf
Definition: wintirpc.h:48

◆ JoystickAGenericImpl_GetDeviceState()

HRESULT WINAPI JoystickAGenericImpl_GetDeviceState ( LPDIRECTINPUTDEVICE8A  iface,
DWORD  len,
LPVOID  ptr 
)

Definition at line 824 of file joystick.c.

825{
828}
HRESULT WINAPI JoystickWGenericImpl_GetDeviceState(LPDIRECTINPUTDEVICE8W iface, DWORD len, LPVOID ptr)
Definition: joystick.c:804
GLenum GLsizei len
Definition: glext.h:6722
static PVOID ptr
Definition: dispmode.c:27

◆ JoystickAGenericImpl_GetObjectInfo()

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

Definition at line 586 of file joystick.c.

588{
590 HRESULT res;
592 DWORD dwSize = pdidoi->dwSize;
593
594 didoiW.dwSize = sizeof(didoiW);
596 if (res != DI_OK) return res;
597
598 memset(pdidoi, 0, pdidoi->dwSize);
599 memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName));
600 pdidoi->dwSize = dwSize;
601 WideCharToMultiByte(CP_ACP, 0, didoiW.tszName, -1, pdidoi->tszName,
602 sizeof(pdidoi->tszName), NULL, NULL);
603
604 return res;
605}
HRESULT WINAPI JoystickWGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow)
Definition: joystick.c:563
#define WideCharToMultiByte
Definition: compat.h:111
GLuint res
Definition: glext.h:9613
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define memset(x, y, z)
Definition: compat.h:39
CHAR tszName[MAX_PATH]
Definition: dinput.h:352
WCHAR tszName[MAX_PATH]
Definition: dinput.h:371
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

◆ JoystickAGenericImpl_GetProperty()

HRESULT WINAPI JoystickAGenericImpl_GetProperty ( LPDIRECTINPUTDEVICE8A  iface,
REFGUID  rguid,
LPDIPROPHEADER  pdiph 
)

Definition at line 680 of file joystick.c.

681{
684}
HRESULT WINAPI JoystickWGenericImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph)
Definition: joystick.c:610

◆ JoystickAGenericImpl_Poll()

HRESULT WINAPI JoystickAGenericImpl_Poll ( LPDIRECTINPUTDEVICE8A  iface)

Definition at line 794 of file joystick.c.

795{
798}
HRESULT WINAPI JoystickWGenericImpl_Poll(LPDIRECTINPUTDEVICE8W iface)
Definition: joystick.c:779

◆ JoystickAGenericImpl_SetActionMap()

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

Definition at line 948 of file joystick.c.

952{
954 DIACTIONFORMATW diafW;
955 HRESULT hr;
956 WCHAR *lpszUserNameW = NULL;
957 int username_size;
958
959 diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiaf->dwNumActions);
960 _copy_diactionformatAtoW(&diafW, lpdiaf);
961
962 if (lpszUserName != NULL)
963 {
964 username_size = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
965 lpszUserNameW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*username_size);
966 MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, lpszUserNameW, username_size);
967 }
968
969 hr = JoystickWGenericImpl_SetActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags);
970
971 lpdiaf->dwCRC = diafW.dwCRC;
972
973 HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
974 HeapFree(GetProcessHeap(), 0, lpszUserNameW);
975
976 return hr;
977}
HRESULT WINAPI JoystickWGenericImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags)
Definition: joystick.c:936

◆ JoystickAGenericImpl_SetProperty()

HRESULT WINAPI JoystickAGenericImpl_SetProperty ( LPDIRECTINPUTDEVICE8A  iface,
REFGUID  rguid,
LPCDIPROPHEADER  ph 
)

Definition at line 473 of file joystick.c.

474{
477}
HRESULT WINAPI JoystickWGenericImpl_SetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIPROPHEADER ph)
Definition: joystick.c:398

◆ JoystickWGenericImpl_BuildActionMap()

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

Definition at line 831 of file joystick.c.

835{
836 static const DWORD object_types[] = { DIDFT_AXIS, DIDFT_BUTTON };
837 static const DWORD type_map[] = { DIDFT_RELAXIS, DIDFT_PSHBUTTON };
839 unsigned int i, j;
840 BOOL has_actions = FALSE;
842 DWORD size;
843 BOOL load_success = FALSE;
844
845 FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", This, lpdiaf, debugstr_w(lpszUserName), dwFlags);
846
847 /* Unless asked the contrary by these flags, try to load a previous mapping */
848 if (!(dwFlags & DIDBAM_HWDEFAULTS))
849 {
850 if (!lpszUserName)
852 else
853 size = lstrlenW(lpszUserName) + 1;
854
855 username = heap_alloc(size * sizeof(WCHAR));
856 if (!lpszUserName)
858 else
859 lstrcpynW(username, lpszUserName, size);
860
861 load_success = load_mapping_settings(&This->base, lpdiaf, username);
863 }
864
865 if (load_success) return DI_OK;
866
867 for (i=0; i < lpdiaf->dwNumActions; i++)
868 {
869 DWORD inst = (0x000000ff & (lpdiaf->rgoAction[i].dwSemantic)) - 1;
870 DWORD type = 0x000000ff & (lpdiaf->rgoAction[i].dwSemantic >> 8);
871 DWORD genre = 0xff000000 & lpdiaf->rgoAction[i].dwSemantic;
872
873 /* Don't touch a user configured action */
874 if (lpdiaf->rgoAction[i].dwHow == DIAH_USERCONFIG) continue;
875
876 /* Only consider actions of the right genre */
877 if (lpdiaf->dwGenre != genre && genre != DIGENRE_ANY) continue;
878
879 for (j = 0; j < ARRAY_SIZE(object_types); j++)
880 {
881 if (type & object_types[j])
882 {
883 /* Ensure that the object exists */
884 LPDIOBJECTDATAFORMAT odf = dataformat_to_odf_by_type(This->base.data_format.wine_df, inst, object_types[j]);
885
886 if (odf != NULL)
887 {
888 lpdiaf->rgoAction[i].dwObjID = type_map[j] | (0x0000ff00 & (inst << 8));
889 lpdiaf->rgoAction[i].guidInstance = This->base.guid;
890 lpdiaf->rgoAction[i].dwHow = DIAH_DEFAULT;
891
892 has_actions = TRUE;
893
894 /* No need to try other types if the action was already mapped */
895 break;
896 }
897 }
898 }
899 }
900
901 if (!has_actions) return DI_NOEFFECT;
902
903 return IDirectInputDevice8WImpl_BuildActionMap(iface, lpdiaf, lpszUserName, dwFlags);
904}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define FIXME(fmt,...)
Definition: debug.h:111
#define DIDBAM_HWDEFAULTS
Definition: dinput.h:1355
#define DIDFT_RELAXIS
Definition: dinput.h:751
#define DIAH_DEFAULT
Definition: dinput.h:1304
#define DIDFT_PSHBUTTON
Definition: dinput.h:754
#define DIDFT_AXIS
Definition: dinput.h:753
#define DI_NOEFFECT
Definition: dinput.h:132
#define DIAH_USERCONFIG
Definition: dinput.h:1300
#define DIDFT_BUTTON
Definition: dinput.h:756
#define DIGENRE_ANY
LPDIOBJECTDATAFORMAT dataformat_to_odf_by_type(LPCDIDATAFORMAT df, int n, DWORD type)
Definition: device.c:412
HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags)
Definition: device.c:1924
BOOL load_mapping_settings(IDirectInputDeviceImpl *This, LPDIACTIONFORMATW lpdiaf, const WCHAR *username)
Definition: device.c:740
static JoystickGenericImpl * impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
Definition: joystick.c:69
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
#define lstrcpynW
Definition: compat.h:738
#define lstrlenW
Definition: compat.h:750
GLsizeiptr size
Definition: glext.h:5919
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 GLint GLint j
Definition: glfuncs.h:250
#define debugstr_w
Definition: kernel32.h:32
static WCHAR username[]
Definition: url.c:32
DWORD dwNumActions
Definition: dinput.h:1329
GUID guidInstance
Definition: dinput.h:1283
DWORD dwHow
Definition: dinput.h:1285
DWORD dwSemantic
Definition: dinput.h:1277
DWORD dwObjID
Definition: dinput.h:1284

Referenced by JoystickAGenericImpl_BuildActionMap().

◆ JoystickWGenericImpl_GetCapabilities()

HRESULT WINAPI JoystickWGenericImpl_GetCapabilities ( LPDIRECTINPUTDEVICE8W  iface,
LPDIDEVCAPS  lpDIDevCaps 
)

Definition at line 526 of file joystick.c.

527{
529 int size;
530
531 TRACE("%p->(%p)\n",This,lpDIDevCaps);
532
533 if (lpDIDevCaps == NULL) {
534 WARN("invalid pointer\n");
535 return E_POINTER;
536 }
537
538 size = lpDIDevCaps->dwSize;
539
540 if (!(size == sizeof(DIDEVCAPS) || size == sizeof(DIDEVCAPS_DX3))) {
541 WARN("invalid parameter\n");
542 return DIERR_INVALIDPARAM;
543 }
544
545 CopyMemory(lpDIDevCaps, &This->devcaps, size);
546 lpDIDevCaps->dwSize = size;
547
548 if (TRACE_ON(dinput))
549 _dump_DIDEVCAPS(lpDIDevCaps);
550
551 return DI_OK;
552}
void _dump_DIDEVCAPS(const DIDEVCAPS *lpDIDevCaps)
Definition: joystick.c:480
#define CopyMemory
Definition: winbase.h:1710

Referenced by JoystickAGenericImpl_GetCapabilities().

◆ JoystickWGenericImpl_GetDeviceInfo()

HRESULT WINAPI JoystickWGenericImpl_GetDeviceInfo ( LPDIRECTINPUTDEVICE8W  iface,
LPDIDEVICEINSTANCEW  pdidi 
)

Definition at line 737 of file joystick.c.

740{
743 DIPROPDWORD pd;
744 DWORD index = 0;
745
746 TRACE("(%p,%p)\n", iface, pdidi);
747
748 if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3W)) &&
749 (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW))) {
750 WARN("invalid parameter: pdidi->dwSize = %d\n", pdidi->dwSize);
751 return DIERR_INVALIDPARAM;
752 }
753
754 /* Try to get joystick index */
755 pd.diph.dwSize = sizeof(pd);
756 pd.diph.dwHeaderSize = sizeof(pd.diph);
757 pd.diph.dwObj = 0;
760 index = pd.dwData;
761
762 /* Return joystick */
763 pdidi->guidInstance = This->guidInstance;
764 pdidi->guidProduct = This->guidProduct;
765 /* we only support traditional joysticks for now */
766 pdidi->dwDevType = This->devcaps.dwDevType;
767 snprintf(buffer, sizeof(buffer), "Joystick %d", index);
769 MultiByteToWideChar(CP_ACP, 0, This->name, -1, pdidi->tszProductName, MAX_PATH);
770 if (pdidi->dwSize > sizeof(DIDEVICEINSTANCE_DX3W)) {
771 pdidi->guidFFDriver = GUID_NULL;
772 pdidi->wUsagePage = 0;
773 pdidi->wUsage = 0;
774 }
775
776 return DI_OK;
777}
DWORD dwDevType
Definition: dinput.h:428
WCHAR tszProductName[MAX_PATH]
Definition: dinput.h:430
GUID guidFFDriver
Definition: dinput.h:431
GUID guidProduct
Definition: dinput.h:427
WCHAR tszInstanceName[MAX_PATH]
Definition: dinput.h:429
GUID guidInstance
Definition: dinput.h:426
char CHAR
Definition: xmlstorage.h:175

◆ JoystickWGenericImpl_GetDeviceState()

HRESULT WINAPI JoystickWGenericImpl_GetDeviceState ( LPDIRECTINPUTDEVICE8W  iface,
DWORD  len,
LPVOID  ptr 
)

Definition at line 804 of file joystick.c.

805{
807
808 TRACE("(%p,0x%08x,%p)\n", This, len, ptr);
809
810 if (!This->base.acquired) {
811 WARN("not acquired\n");
812 return DIERR_NOTACQUIRED;
813 }
814
815 /* update joystick state */
817
818 /* convert and copy data to user supplied buffer */
819 fill_DataFormat(ptr, len, &This->js, &This->base.data_format);
820
821 return DI_OK;
822}
#define DIERR_NOTACQUIRED
Definition: dinput.h:167
void fill_DataFormat(void *out, DWORD size, const void *in, const DataFormat *df)
Definition: device.c:326
static IDirectInputDevice8A * IDirectInputDevice8A_from_impl(JoystickGenericImpl *This)
Definition: joystick.c:73

Referenced by JoystickAGenericImpl_GetDeviceState().

◆ JoystickWGenericImpl_GetObjectInfo()

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

Definition at line 563 of file joystick.c.

565{
566 static const WCHAR axisW[] = {'A','x','i','s',' ','%','d',0};
567 static const WCHAR povW[] = {'P','O','V',' ','%','d',0};
568 static const WCHAR buttonW[] = {'B','u','t','t','o','n',' ','%','d',0};
569 HRESULT res;
570
571 res = IDirectInputDevice2WImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
572 if (res != DI_OK) return res;
573
574 if (pdidoi->dwType & DIDFT_AXIS) {
575 sprintfW(pdidoi->tszName, axisW, DIDFT_GETINSTANCE(pdidoi->dwType));
576 pdidoi->dwFlags |= DIDOI_ASPECTPOSITION;
577 } else if (pdidoi->dwType & DIDFT_POV)
578 sprintfW(pdidoi->tszName, povW, DIDFT_GETINSTANCE(pdidoi->dwType));
579 else if (pdidoi->dwType & DIDFT_BUTTON)
580 sprintfW(pdidoi->tszName, buttonW, DIDFT_GETINSTANCE(pdidoi->dwType));
581
582 _dump_OBJECTINSTANCEW(pdidoi);
583 return res;
584}
#define DIDFT_POV
Definition: dinput.h:757
#define DIDOI_ASPECTPOSITION
Definition: dinput.h:820
#define DIDFT_GETINSTANCE(n)
Definition: dinput.h:764
void _dump_OBJECTINSTANCEW(const DIDEVICEOBJECTINSTANCEW *ddoi)
Definition: device.c:191
HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow)
Definition: device.c:1576
static const WCHAR buttonW[]
Definition: htmlelem.c:24
#define sprintfW
Definition: unicode.h:58

Referenced by JoystickAGenericImpl_GetObjectInfo().

◆ JoystickWGenericImpl_GetProperty()

HRESULT WINAPI JoystickWGenericImpl_GetProperty ( LPDIRECTINPUTDEVICE8W  iface,
REFGUID  rguid,
LPDIPROPHEADER  pdiph 
)

Definition at line 610 of file joystick.c.

611{
613
614 TRACE("(%p,%s,%p)\n", This, debugstr_guid(rguid), pdiph);
615
616 if (TRACE_ON(dinput))
617 _dump_DIPROPHEADER(pdiph);
618
619 if (IS_DIPROP(rguid)) {
620 switch (LOWORD(rguid)) {
621 case (DWORD_PTR) DIPROP_RANGE: {
622 LPDIPROPRANGE pr = (LPDIPROPRANGE)pdiph;
623 int obj = find_property(&This->base.data_format, pdiph);
624
625 /* The app is querying the current range of the axis
626 * return the lMin and lMax values */
627 if (obj >= 0) {
628 pr->lMin = This->props[obj].lMin;
629 pr->lMax = This->props[obj].lMax;
630 TRACE("range(%d, %d) obj=%d\n", pr->lMin, pr->lMax, obj);
631 return DI_OK;
632 }
633 break;
634 }
635 case (DWORD_PTR) DIPROP_DEADZONE: {
636 LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
637 int obj = find_property(&This->base.data_format, pdiph);
638
639 if (obj >= 0) {
640 pd->dwData = This->props[obj].lDeadZone;
641 TRACE("deadzone(%d) obj=%d\n", pd->dwData, obj);
642 return DI_OK;
643 }
644 break;
645 }
647 LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
648 int obj = find_property(&This->base.data_format, pdiph);
649
650 if (obj >= 0) {
651 pd->dwData = This->props[obj].lSaturation;
652 TRACE("saturation(%d) obj=%d\n", pd->dwData, obj);
653 return DI_OK;
654 }
655 break;
656 }
659 DIPROPSTRING *ps = (DIPROPSTRING*) pdiph;
660 DIDEVICEINSTANCEW didev;
661
662 didev.dwSize = sizeof(didev);
663
665 if (LOWORD(rguid) == (DWORD_PTR) DIPROP_PRODUCTNAME)
667 else
669
670 return DI_OK;
671 }
672 default:
673 return IDirectInputDevice2WImpl_GetProperty(iface, rguid, pdiph);
674 }
675 }
676
677 return DI_OK;
678}
#define DIPROP_RANGE
Definition: dinput.h:892
struct DIPROPDWORD * LPDIPROPDWORD
#define DIPROP_INSTANCENAME
Definition: dinput.h:910
#define DIPROP_SATURATION
Definition: dinput.h:894
#define DIPROP_PRODUCTNAME
Definition: dinput.h:911
#define IDirectInputDevice_GetDeviceInfo(p, a)
Definition: dinput.h:1616
#define DIPROP_DEADZONE
Definition: dinput.h:893
struct DIPROPRANGE * LPDIPROPRANGE
#define IS_DIPROP(x)
void _dump_DIPROPHEADER(LPCDIPROPHEADER diph)
Definition: device.c:176
int find_property(const DataFormat *df, LPCDIPROPHEADER ph)
Definition: device.c:607
HRESULT WINAPI IDirectInputDevice2WImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph)
Definition: device.c:1386
#define debugstr_guid
Definition: kernel32.h:35
#define LOWORD(l)
Definition: pedump.c:82
LONG lMin
Definition: dinput.h:850
LONG lMax
Definition: dinput.h:851
WCHAR wsz[MAX_PATH]
Definition: dinput.h:875
uint32_t DWORD_PTR
Definition: typedefs.h:65

Referenced by JoystickAGenericImpl_GetProperty().

◆ JoystickWGenericImpl_Poll()

HRESULT WINAPI JoystickWGenericImpl_Poll ( LPDIRECTINPUTDEVICE8W  iface)

Definition at line 779 of file joystick.c.

780{
782
783 TRACE("(%p)\n",This);
784
785 if (!This->base.acquired) {
786 WARN("not acquired\n");
787 return DIERR_NOTACQUIRED;
788 }
789
791 return DI_OK;
792}

Referenced by JoystickAGenericImpl_Poll().

◆ JoystickWGenericImpl_SetActionMap()

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

Definition at line 936 of file joystick.c.

940{
942
943 FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", This, lpdiaf, debugstr_w(lpszUserName), dwFlags);
944
945 return _set_action_map(iface, lpdiaf, lpszUserName, dwFlags, This->base.data_format.wine_df);
946}
HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags, LPCDIDATAFORMAT df)
Definition: device.c:866

Referenced by JoystickAGenericImpl_SetActionMap().

◆ JoystickWGenericImpl_SetProperty()

HRESULT WINAPI JoystickWGenericImpl_SetProperty ( LPDIRECTINPUTDEVICE8W  iface,
REFGUID  rguid,
LPCDIPROPHEADER  ph 
)

Definition at line 398 of file joystick.c.

399{
401 DWORD i;
402
403 TRACE("(%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
404
405 if (ph == NULL) {
406 WARN("invalid parameter: ph == NULL\n");
407 return DIERR_INVALIDPARAM;
408 }
409
410 if (TRACE_ON(dinput))
412
413 if (IS_DIPROP(rguid)) {
414 switch (LOWORD(rguid)) {
415 case (DWORD_PTR)DIPROP_RANGE: {
417 if (ph->dwHow == DIPH_DEVICE) {
418 TRACE("proprange(%d,%d) all\n", pr->lMin, pr->lMax);
419 for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++)
420 remap_range(This, i, pr);
421 } else {
422 int obj = find_property(&This->base.data_format, ph);
423
424 TRACE("proprange(%d,%d) obj=%d\n", pr->lMin, pr->lMax, obj);
425 if (obj >= 0)
426 remap_range(This, obj, pr);
427 }
428 break;
429 }
432 if (ph->dwHow == DIPH_DEVICE) {
433 TRACE("deadzone(%d) all\n", pd->dwData);
434 for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++)
435 remap_deadzone(This, i, pd);
436 } else {
437 int obj = find_property(&This->base.data_format, ph);
438
439 TRACE("deadzone(%d) obj=%d\n", pd->dwData, obj);
440 if (obj >= 0)
441 remap_deadzone(This, obj, pd);
442 }
443 break;
444 }
447 if (ph->dwHow == DIPH_DEVICE) {
448 TRACE("saturation(%d) all\n", pd->dwData);
449 for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++)
450 remap_saturation(This, i, pd);
451 } else {
452 int obj = find_property(&This->base.data_format, ph);
453
454 TRACE("saturation(%d) obj=%d\n", pd->dwData, obj);
455 if (obj >= 0)
457 }
458 break;
459 }
462 FIXME("DIPROP_CALIBRATIONMODE(%d)\n", pd->dwData);
463 break;
464 }
465 default:
466 return IDirectInputDevice2WImpl_SetProperty(iface, rguid, ph);
467 }
468 }
469
470 return DI_OK;
471}
#define DIPROP_CALIBRATIONMODE
Definition: dinput.h:902
const DIPROPRANGE * LPCDIPROPRANGE
Definition: dinput.h:853
const DIPROPDWORD * LPCDIPROPDWORD
Definition: dinput.h:846
HRESULT WINAPI IDirectInputDevice2WImpl_SetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIPROPHEADER pdiph)
Definition: device.c:1450
static void remap_saturation(JoystickGenericImpl *This, int obj, LPCDIPROPDWORD pd)
Definition: joystick.c:382
static void remap_range(JoystickGenericImpl *This, int obj, LPCDIPROPRANGE pr)
Definition: joystick.c:354
static void remap_deadzone(JoystickGenericImpl *This, int obj, LPCDIPROPDWORD pd)
Definition: joystick.c:369

Referenced by JoystickAGenericImpl_SetProperty().

◆ setup_dinput_options()

HRESULT setup_dinput_options ( JoystickGenericImpl This,
const int default_axis_map 
)

Definition at line 1038 of file joystick.c.

1039{
1040 char buffer[MAX_PATH+16];
1041 HKEY hkey, appkey;
1042 int tokens = 0;
1043 int axis = 0;
1044 int pov = 0;
1045 int button;
1046
1047 get_app_key(&hkey, &appkey);
1048
1049 /* get options */
1050
1051 if (!get_config_key(hkey, appkey, "DefaultDeadZone", buffer, sizeof(buffer)))
1052 {
1053 This->deadzone = atoi(buffer);
1054 TRACE("setting default deadzone to: \"%s\" %d\n", buffer, This->deadzone);
1055 }
1056
1057 for (button = 0; button < MAX_MAP_BUTTONS; button++)
1058 This->button_map[button] = button;
1059
1060 if (!get_config_key(hkey, appkey, "ButtonMap", buffer, sizeof(buffer)))
1061 {
1062 static const char *delim = ",";
1063 int button = 0;
1064 char *token;
1065
1066 TRACE("ButtonMap = \"%s\"\n", buffer);
1067 for (token = strtok(buffer, delim);
1069 token = strtok(NULL, delim), button++)
1070 {
1071 char *s;
1072 int value = strtol(token, &s, 10);
1073 if (value < 0 || *s != '\0')
1074 {
1075 ERR("invalid button number: \"%s\"", token);
1076 }
1077 else
1078 {
1079 TRACE("mapping physical button %d to DInput button %d", value, button);
1080 This->button_map[value] = button;
1081 }
1082 }
1083 }
1084
1085 This->axis_map = HeapAlloc(GetProcessHeap(), 0, This->device_axis_count * sizeof(int));
1086 if (!This->axis_map) return DIERR_OUTOFMEMORY;
1087
1088 if (!get_config_key(hkey, appkey, This->name, buffer, sizeof(buffer)))
1089 {
1090 static const char *axis_names[] = {"X", "Y", "Z", "Rx", "Ry", "Rz",
1091 "Slider1", "Slider2",
1092 "POV1", "POV2", "POV3", "POV4"};
1093 const char *delim = ",";
1094 char * ptr;
1095 TRACE("\"%s\" = \"%s\"\n", This->name, buffer);
1096
1097 if ((ptr = strtok(buffer, delim)) != NULL)
1098 {
1099 do
1100 {
1101 int i;
1102
1103 for (i = 0; i < ARRAY_SIZE(axis_names); i++)
1104 {
1105 if (!strcmp(ptr, axis_names[i]))
1106 {
1107 if (!strncmp(ptr, "POV", 3))
1108 {
1109 if (pov >= 4)
1110 {
1111 WARN("Only 4 POVs supported - ignoring extra\n");
1112 i = -1;
1113 }
1114 else
1115 {
1116 /* Pov takes two axes */
1117 This->axis_map[tokens++] = i;
1118 pov++;
1119 }
1120 }
1121 else
1122 {
1123 if (axis >= 8)
1124 {
1125 FIXME("Only 8 Axes supported - ignoring extra\n");
1126 i = -1;
1127 }
1128 else
1129 axis++;
1130 }
1131 break;
1132 }
1133 }
1134
1135 if (i == ARRAY_SIZE(axis_names))
1136 {
1137 ERR("invalid joystick axis type: \"%s\"\n", ptr);
1138 i = -1;
1139 }
1140
1141 This->axis_map[tokens] = i;
1142 tokens++;
1143 } while ((ptr = strtok(NULL, delim)) != NULL);
1144
1145 if (tokens != This->device_axis_count)
1146 {
1147 ERR("not all joystick axes mapped: %d axes(%d,%d), %d arguments\n",
1148 This->device_axis_count, axis, pov, tokens);
1149 while (tokens < This->device_axis_count)
1150 {
1151 This->axis_map[tokens] = -1;
1152 tokens++;
1153 }
1154 }
1155 }
1156 }
1157 else
1158 {
1159 int i;
1160
1161 if (default_axis_map)
1162 {
1163 /* Use default mapping from the driver */
1164 for (i = 0; i < This->device_axis_count; i++)
1165 {
1166 This->axis_map[i] = default_axis_map[i];
1167 tokens = default_axis_map[i];
1168 if (tokens < 0)
1169 continue;
1170 if (tokens < 8)
1171 axis++;
1172 else if (tokens < 15)
1173 {
1174 i++;
1175 pov++;
1176 This->axis_map[i] = default_axis_map[i];
1177 }
1178 }
1179 }
1180 else
1181 {
1182 /* No config - set default mapping. */
1183 for (i = 0; i < This->device_axis_count; i++)
1184 {
1185 if (i < 8)
1186 This->axis_map[i] = axis++;
1187 else if (i < 15)
1188 {
1189 This->axis_map[i++] = 8 + pov;
1190 This->axis_map[i ] = 8 + pov++;
1191 }
1192 else
1193 This->axis_map[i] = -1;
1194 }
1195 }
1196 }
1197 This->devcaps.dwAxes = axis;
1198 This->devcaps.dwPOVs = pov;
1199
1200 if (appkey) RegCloseKey(appkey);
1201 if (hkey) RegCloseKey(hkey);
1202
1203 return DI_OK;
1204}
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
char * strtok(char *String, const char *Delimiters)
Definition: utclib.c:338
#define ERR(fmt,...)
Definition: debug.h:110
#define DIERR_OUTOFMEMORY
Definition: dinput.h:155
GLdouble s
Definition: gl.h:2039
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 token
Definition: glfuncs.h:210
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
_Check_return_ long __cdecl strtol(_In_z_ const char *_Str, _Out_opt_ _Deref_post_z_ char **_EndPtr, _In_ int _Radix)
#define MAX_MAP_BUTTONS
if(dx< 0)
Definition: linetemp.h:194
DWORD button
Definition: button.c:166
Definition: pdh_main.c:94

◆ typeFromGUID()

DWORD typeFromGUID ( REFGUID  guid)

Definition at line 82 of file joystick.c.

83{
84 if (IsEqualGUID(guid, &GUID_ConstantForce)) {
86 } else if (IsEqualGUID(guid, &GUID_Square)
87 || IsEqualGUID(guid, &GUID_Sine)
88 || IsEqualGUID(guid, &GUID_Triangle)
89 || IsEqualGUID(guid, &GUID_SawtoothUp)
90 || IsEqualGUID(guid, &GUID_SawtoothDown)) {
91 return DIEFT_PERIODIC;
92 } else if (IsEqualGUID(guid, &GUID_RampForce)) {
93 return DIEFT_RAMPFORCE;
94 } else if (IsEqualGUID(guid, &GUID_Spring)
95 || IsEqualGUID(guid, &GUID_Damper)
96 || IsEqualGUID(guid, &GUID_Inertia)
97 || IsEqualGUID(guid, &GUID_Friction)) {
98 return DIEFT_CONDITION;
99 } else if (IsEqualGUID(guid, &GUID_CustomForce)) {
100 return DIEFT_CUSTOMFORCE;
101 } else {
102 WARN("GUID (%s) is not a known force type\n", _dump_dinput_GUID(guid));
103 return 0;
104 }
105}
const char * _dump_dinput_GUID(const GUID *guid)
Definition: device.c:197
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147

Referenced by dump_DIEFFECT().