From bb85d2c77ee0a5a69f94cb2c8f0434955ad58ad0 Mon Sep 17 00:00:00 2001 From: zoltanvb Date: Sun, 11 Feb 2024 14:54:24 +0100 Subject: [PATCH] Fix R3 button combo handling in general. --- input/input_driver.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index d89077187f6..50ac1581f33 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -785,11 +785,13 @@ static int32_t input_state_wrap( /* Drivers can overflow when sending too many keys at once.. */ if (id == RETRO_DEVICE_ID_JOYPAD_MASK && ret) { - /* Deal with menu toggle combo buttons that won't stay inside +32767. */ - if (ret == -0x8000) /* R3 */ - ret = 0x8000; - else if (ret == -0x4000) /* LR+R3 */ - ret = 0x8000 + 0x4000; + /* Deal with R3 + possible combo buttons that won't stay inside +32767. */ + if (ret < 0 && ret >= -0x8000) /* R3 */ + { + /* Undo the int16_t conversion effects to int32_t * + * Example: -32752 / 0xffff8010 to 32784 / 0x8010 */ + ret += 0x10000; + } else if (ret < 0) ret = 0; return ret;