Joystick Raw Input: Do not add the axis if the center is 0 - prevents malformed vJoy 2.0.5 axes from causing 86Box to crash with a division by zero.

This commit is contained in:
OBattler
2023-06-11 22:58:16 +02:00
parent 68e6d7eb40
commit 68e970b9cd
2 changed files with 12 additions and 2 deletions

View File

@@ -98,6 +98,8 @@ joystick_add_button(raw_joystick_t *rawjoy, plat_joystick_t *joy, USAGE usage)
void
joystick_add_axis(raw_joystick_t *rawjoy, plat_joystick_t *joy, PHIDP_VALUE_CAPS prop)
{
LONG center;
if (joy->nr_axes >= 8)
return;
@@ -141,7 +143,10 @@ joystick_add_axis(raw_joystick_t *rawjoy, plat_joystick_t *joy, PHIDP_VALUE_CAPS
}
rawjoy->axis[joy->nr_axes].min = prop->LogicalMin;
joy->nr_axes++;
center = (rawjoy->axis[joy->nr_axes].max - rawjoy->axis[joy->nr_axes].min + 1) / 2;
if (center != 0x00)
joy->nr_axes++;
}
void

View File

@@ -99,6 +99,8 @@ joystick_add_button(raw_joystick_t *rawjoy, plat_joystick_t *joy, USAGE usage)
void
joystick_add_axis(raw_joystick_t *rawjoy, plat_joystick_t *joy, PHIDP_VALUE_CAPS prop)
{
LONG center;
if (joy->nr_axes >= 8)
return;
@@ -142,7 +144,10 @@ joystick_add_axis(raw_joystick_t *rawjoy, plat_joystick_t *joy, PHIDP_VALUE_CAPS
}
rawjoy->axis[joy->nr_axes].min = prop->LogicalMin;
joy->nr_axes++;
center = (rawjoy->axis[joy->nr_axes].max - rawjoy->axis[joy->nr_axes].min + 1) / 2;
if (center != 0x00)
joy->nr_axes++;
}
void