From 73a093348e49290cb7ef3a691685709deb72a2cd Mon Sep 17 00:00:00 2001 From: Nadia Holmquist Pedersen Date: Fri, 19 Feb 2021 23:33:54 +0100 Subject: [PATCH] Match controller left stick ranges to N64 (#32) --- src/pc/controller/controller_sdl.c | 7 ++++--- src/pc/controller/controller_xinput.c | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/pc/controller/controller_sdl.c b/src/pc/controller/controller_sdl.c index c3ab242..f6880e7 100644 --- a/src/pc/controller/controller_sdl.c +++ b/src/pc/controller/controller_sdl.c @@ -88,9 +88,10 @@ static void controller_sdl_read(OSContPad *pad) { uint32_t magnitude_sq = (uint32_t)(leftx * leftx) + (uint32_t)(lefty * lefty); if (magnitude_sq > (uint32_t)(DEADZONE * DEADZONE)) { - pad->stick_x = leftx / 0x100; - int stick_y = -lefty / 0x100; - pad->stick_y = stick_y == 128 ? 127 : stick_y; + // Game expects stick coordinates within -80..80 + // 32768 / 409 = ~80 + pad->stick_x = leftx / 409; + pad->stick_y = -lefty / 409; } } diff --git a/src/pc/controller/controller_xinput.c b/src/pc/controller/controller_xinput.c index bb44bc1..e8634d7 100644 --- a/src/pc/controller/controller_xinput.c +++ b/src/pc/controller/controller_xinput.c @@ -33,8 +33,10 @@ static void xinput_read(OSContPad *pad) { uint32_t magnitude_sq = (uint32_t)(gp->sThumbLX * gp->sThumbLX) + (uint32_t)(gp->sThumbLY * gp->sThumbLY); if (magnitude_sq > (uint32_t)(DEADZONE * DEADZONE)) { - pad->stick_x = gp->sThumbLX / 0x100; - pad->stick_y = gp->sThumbLY / 0x100; + // Game expects stick coordinates within -80..80 + // 32768 / 409 = ~80 + pad->stick_x = gp->sThumbLX / 409; + pad->stick_y = gp->sThumbLY / 409; } break; }