mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-12-24 02:33:19 +00:00
Improved clamping of Mac joystick/gamepad axes
This commit is contained in:
parent
747a469241
commit
e5b3099b04
@ -132,8 +132,14 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t x = (uint8_t)((value+DDHID_JOYSTICK_VALUE_MAX) * DDHID_JOYSTICK_NORMALIZER);
|
||||
joydriver_setAxisValue(x, joydriver_getAxisY());
|
||||
int x = (int)((value+DDHID_JOYSTICK_VALUE_MAX) * DDHID_JOYSTICK_NORMALIZER);
|
||||
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
|
||||
@ -144,8 +150,14 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t y = (uint8_t)((value+DDHID_JOYSTICK_VALUE_MAX) * DDHID_JOYSTICK_NORMALIZER);
|
||||
joydriver_setAxisValue(joydriver_getAxisX(), y);
|
||||
int y = (int)((value+DDHID_JOYSTICK_VALUE_MAX) * DDHID_JOYSTICK_NORMALIZER);
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user