Commit 9d861103 authored by Vitaliy Margolen's avatar Vitaliy Margolen Committed by Alexandre Julliard

dinput: Convert axis mapping array to int instead of BYTE. BYTE is unsigned and…

dinput: Convert axis mapping array to int instead of BYTE. BYTE is unsigned and char isn't enough to store all possible axis values.
parent f6351117
...@@ -448,7 +448,7 @@ DWORD joystick_map_pov(POINTL *p) ...@@ -448,7 +448,7 @@ DWORD joystick_map_pov(POINTL *p)
* Setup the dinput options. * Setup the dinput options.
*/ */
HRESULT setup_dinput_options(JoystickGenericImpl *This, const BYTE *default_axis_map) HRESULT setup_dinput_options(JoystickGenericImpl *This, const int *default_axis_map)
{ {
char buffer[MAX_PATH+16]; char buffer[MAX_PATH+16];
HKEY hkey, appkey; HKEY hkey, appkey;
......
...@@ -82,8 +82,7 @@ struct JoyDev ...@@ -82,8 +82,7 @@ struct JoyDev
BYTE axis_count; BYTE axis_count;
BYTE button_count; BYTE button_count;
BYTE dev_axes_map[ABS_MAX + 1]; int *dev_axes_map;
int have_axes_map;
}; };
typedef struct JoystickImpl JoystickImpl; typedef struct JoystickImpl JoystickImpl;
...@@ -124,6 +123,7 @@ static INT find_joystick_devices(void) ...@@ -124,6 +123,7 @@ static INT find_joystick_devices(void)
{ {
int fd; int fd;
struct JoyDev joydev, *new_joydevs; struct JoyDev joydev, *new_joydevs;
BYTE axes_map[ABS_MAX + 1];
snprintf(joydev.device, sizeof(joydev.device), "%s%d", JOYDEV_NEW, i); snprintf(joydev.device, sizeof(joydev.device), "%s%d", JOYDEV_NEW, i);
if ((fd = open(joydev.device, O_RDONLY)) < 0) if ((fd = open(joydev.device, O_RDONLY)) < 0)
...@@ -152,28 +152,28 @@ static INT find_joystick_devices(void) ...@@ -152,28 +152,28 @@ static INT find_joystick_devices(void)
} }
#endif #endif
if (ioctl(fd, JSIOCGAXMAP, joydev.dev_axes_map) < 0) if (ioctl(fd, JSIOCGAXMAP, axes_map) < 0)
{ {
WARN("ioctl(%s,JSIOCGNAME) failed: %s\n", joydev.device, strerror(errno)); WARN("ioctl(%s,JSIOCGNAME) failed: %s\n", joydev.device, strerror(errno));
joydev.have_axes_map = 0; joydev.dev_axes_map = NULL;
} }
else else
{ if ((joydev.dev_axes_map = HeapAlloc(GetProcessHeap(), 0, joydev.axis_count * sizeof(int))))
INT j; {
joydev.have_axes_map = 1; INT j;
/* Remap to DI numbers */ /* Remap to DI numbers */
for (j = 0; j < ABS_MAX; j++) for (j = 0; j < joydev.axis_count; j++)
if (joydev.dev_axes_map[j] < 8) if (axes_map[j] < 8)
/* Axis match 1-to-1 */ /* Axis match 1-to-1 */
joydev.dev_axes_map[j] = j; joydev.dev_axes_map[j] = j;
else if (joydev.dev_axes_map[j] == 16 || else if (axes_map[j] == 16 ||
joydev.dev_axes_map[j] == 17) axes_map[j] == 17)
/* POV axis */ /* POV axis */
joydev.dev_axes_map[j] = 8; joydev.dev_axes_map[j] = 8;
else else
joydev.dev_axes_map[j] = -1; joydev.dev_axes_map[j] = -1;
} }
close(fd); close(fd);
...@@ -324,8 +324,7 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di ...@@ -324,8 +324,7 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
newDevice->generic.deadzone = 0; newDevice->generic.deadzone = 0;
/* do any user specified configuration */ /* do any user specified configuration */
hr = setup_dinput_options(&newDevice->generic, newDevice->joydev->have_axes_map ? hr = setup_dinput_options(&newDevice->generic, newDevice->joydev->dev_axes_map);
newDevice->joydev->dev_axes_map : NULL);
if (hr != DI_OK) if (hr != DI_OK)
goto FAILED1; goto FAILED1;
......
...@@ -378,7 +378,7 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm ...@@ -378,7 +378,7 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm
JoystickImpl* newDevice; JoystickImpl* newDevice;
LPDIDATAFORMAT df = NULL; LPDIDATAFORMAT df = NULL;
int i, idx = 0; int i, idx = 0;
BYTE default_axis_map[WINE_JOYSTICK_MAX_AXES + WINE_JOYSTICK_MAX_POVS*2]; int default_axis_map[WINE_JOYSTICK_MAX_AXES + WINE_JOYSTICK_MAX_POVS*2];
newDevice = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(JoystickImpl)); newDevice = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(JoystickImpl));
if (!newDevice) return NULL; if (!newDevice) return NULL;
......
...@@ -53,7 +53,7 @@ typedef struct JoystickGenericImpl ...@@ -53,7 +53,7 @@ typedef struct JoystickGenericImpl
} JoystickGenericImpl; } JoystickGenericImpl;
LONG joystick_map_axis(ObjProps *props, int val); LONG joystick_map_axis(ObjProps *props, int val);
HRESULT setup_dinput_options(JoystickGenericImpl *This, const BYTE *default_axis_map); HRESULT setup_dinput_options(JoystickGenericImpl *This, const int *default_axis_map);
DWORD joystick_map_pov(POINTL *p); DWORD joystick_map_pov(POINTL *p);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment