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;
{
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)
}
#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);
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;