diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c index e0be1795d3b..489342e1b6a 100644 --- a/dlls/dinput/joystick.c +++ b/dlls/dinput/joystick.c @@ -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; diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 39731f3c788..bf31eafa01a 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -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; + if ((joydev.dev_axes_map = HeapAlloc(GetProcessHeap(), 0, joydev.axis_count * sizeof(int)))) + { + INT j; - /* 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; - } + /* 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; diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 4409b739133..42daaebbeef 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -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; diff --git a/dlls/dinput/joystick_private.h b/dlls/dinput/joystick_private.h index 027e81ab853..aaa82948965 100644 --- a/dlls/dinput/joystick_private.h +++ b/dlls/dinput/joystick_private.h @@ -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);