all repos — mgba @ a0d0de137c16f025fdbb6c8952df9dd0cb3298c1

mGBA Game Boy Advance Emulator

Wii: Saturate joystick values
Vicki Pfau vi@endrift.com
Thu, 14 Feb 2019 20:14:57 -0800
commit

a0d0de137c16f025fdbb6c8952df9dd0cb3298c1

parent

0980b67736c6f3235710840c9a9e7030b4fcc75d

1 files changed, 18 insertions(+), 4 deletions(-)

jump to
M src/platform/wii/main.csrc/platform/wii/main.c

@@ -1072,8 +1072,15 @@ if (!js) {

return 0; } int centered = (int) js->pos.x - (int) js->center.x; - int range = js->max.x - js->min.x; - return (centered * 0xFF) / range; + int range = (int) js->max.x - (int) js->min.x; + int value = (centered * 0xFF) / range; + if (value > 0x7F) { + return 0x7F; + } + if (value < -0x80) { + return -0x80; + } + return value; } static s8 WPAD_StickY(u8 chan, u8 right) {

@@ -1103,8 +1110,15 @@ if (!js) {

return 0; } int centered = (int) js->pos.y - (int) js->center.y; - int range = js->max.y - js->min.y; - return (centered * 0xFF) / range; + int range = (int) js->max.y - (int) js->min.y; + int value = (centered * 0xFF) / range; + if (value > 0x7F) { + return 0x7F; + } + if (value < -0x80) { + return -0x80; + } + return value; } void _retraceCallback(u32 count) {