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)
* 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];
HKEY hkey, appkey;
......
......@@ -82,8 +82,7 @@ struct JoyDev
BYTE axis_count;
BYTE button_count;
BYTE dev_axes_map[ABS_MAX + 1];
int have_axes_map;
int *dev_axes_map;
};
typedef struct JoystickImpl JoystickImpl;
......@@ -124,6 +123,7 @@ static INT find_joystick_devices(void)
{
int fd;
struct JoyDev joydev, *new_joydevs;
BYTE axes_map[ABS_MAX + 1];
snprintf(joydev.device, sizeof(joydev.device), "%s%d", JOYDEV_NEW, i);
if ((fd = open(joydev.device, O_RDONLY)) < 0)
......@@ -152,28 +152,28 @@ static INT find_joystick_devices(void)
}
#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));
joydev.have_axes_map = 0;
joydev.dev_axes_map = NULL;
}
else
{
INT j;
joydev.have_axes_map = 1;
/* Remap to DI numbers */
for (j = 0; j < ABS_MAX; j++)
if (joydev.dev_axes_map[j] < 8)
/* Axis match 1-to-1 */
joydev.dev_axes_map[j] = j;
else if (joydev.dev_axes_map[j] == 16 ||
joydev.dev_axes_map[j] == 17)
/* POV axis */
joydev.dev_axes_map[j] = 8;
else
joydev.dev_axes_map[j] = -1;
}
if ((joydev.dev_axes_map = HeapAlloc(GetProcessHeap(), 0, joydev.axis_count * sizeof(int))))
{
INT j;
/* Remap to DI numbers */
for (j = 0; j < joydev.axis_count; j++)
if (axes_map[j] < 8)
/* Axis match 1-to-1 */
joydev.dev_axes_map[j] = j;
else if (axes_map[j] == 16 ||
axes_map[j] == 17)
/* POV axis */
joydev.dev_axes_map[j] = 8;
else
joydev.dev_axes_map[j] = -1;
}
close(fd);
......@@ -324,8 +324,7 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
newDevice->generic.deadzone = 0;
/* do any user specified configuration */
hr = setup_dinput_options(&newDevice->generic, newDevice->joydev->have_axes_map ?
newDevice->joydev->dev_axes_map : NULL);
hr = setup_dinput_options(&newDevice->generic, newDevice->joydev->dev_axes_map);
if (hr != DI_OK)
goto FAILED1;
......
......@@ -378,7 +378,7 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm
JoystickImpl* newDevice;
LPDIDATAFORMAT df = NULL;
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));
if (!newDevice) return NULL;
......
......@@ -53,7 +53,7 @@ typedef struct JoystickGenericImpl
} JoystickGenericImpl;
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);
......
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