mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-12 06:29:58 +00:00
Improved clamping of Mac joystick/gamepad axes
This commit is contained in:
parent
747a469241
commit
e5b3099b04
@ -132,8 +132,14 @@
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t x = (uint8_t)((value+DDHID_JOYSTICK_VALUE_MAX) * DDHID_JOYSTICK_NORMALIZER);
|
int x = (int)((value+DDHID_JOYSTICK_VALUE_MAX) * DDHID_JOYSTICK_NORMALIZER);
|
||||||
joydriver_setAxisValue(x, joydriver_getAxisY());
|
if (x < 0) {
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
if (x >= JOY_RANGE) {
|
||||||
|
x = JOY_RANGE-1;
|
||||||
|
}
|
||||||
|
joydriver_setAxisValue((uint8_t)x, joydriver_getAxisY());
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)ddhidJoystick:(DDHidJoystick *)joystick stick:(unsigned int)stick yChanged:(int)value
|
- (void)ddhidJoystick:(DDHidJoystick *)joystick stick:(unsigned int)stick yChanged:(int)value
|
||||||
@ -144,8 +150,14 @@
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t y = (uint8_t)((value+DDHID_JOYSTICK_VALUE_MAX) * DDHID_JOYSTICK_NORMALIZER);
|
int y = (int)((value+DDHID_JOYSTICK_VALUE_MAX) * DDHID_JOYSTICK_NORMALIZER);
|
||||||
joydriver_setAxisValue(joydriver_getAxisX(), y);
|
if (y < 0) {
|
||||||
|
y = 0;
|
||||||
|
}
|
||||||
|
if (y >= JOY_RANGE) {
|
||||||
|
y = JOY_RANGE-1;
|
||||||
|
}
|
||||||
|
joydriver_setAxisValue(joydriver_getAxisX(), (uint8_t)y);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)ddhidJoystick:(DDHidJoystick *)joystick stick:(unsigned int)stick otherAxis:(unsigned)otherAxis valueChanged:(int)value
|
- (void)ddhidJoystick:(DDHidJoystick *)joystick stick:(unsigned int)stick otherAxis:(unsigned)otherAxis valueChanged:(int)value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user