From 36f2672e06b96b5a5e3050297c398f6686ef9447 Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Sun, 7 Mar 2021 16:20:43 -0500 Subject: [PATCH] (Hopefully) Fixed an obscure bug with SOCD and joystick hats --- main.lua | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/main.lua b/main.lua index 6699f2e..64dfbf7 100644 --- a/main.lua +++ b/main.lua @@ -258,13 +258,27 @@ function love.joystickhat(joystick, hat, direction) has_hat = true end if input_pressed then - scene:onInputPress({input=input_pressed, type="joyhat", name=joystick:getName(), hat=hat, direction=direction}) + dir = direction + for i, direction in ipairs{"d", "l", "u", "r"} do + if dir:sub(1, 1) == direction or dir:sub(2) == direction then + scene:onInputPress({input=input_pressed, type="joyhat", name=joystick:getName(), hat=hat, direction=direction}) + else + scene:onInputRelease({input=input_pressed, type="joyhat", name=joystick:getName(), hat=hat, direction=direction}) + end + end elseif has_hat then for i, direction in ipairs{"d", "l", "ld", "lu", "r", "rd", "ru", "u"} do scene:onInputRelease({input=config.input.joysticks[joystick:getName()].hats[hat][direction], type="joyhat", name=joystick:getName(), hat=hat, direction=direction}) end elseif direction ~= "c" then - scene:onInputPress({input=nil, type="joyhat", name=joystick:getName(), hat=hat, direction=direction}) + dir = direction + for i, direction in ipairs{"d", "l", "u", "r"} do + if dir:sub(1, 1) == direction or dir:sub(2) == direction then + scene:onInputPress({input=nil, type="joyhat", name=joystick:getName(), hat=hat, direction=direction}) + else + scene:onInputRelease({input=nil, type="joyhat", name=joystick:getName(), hat=hat, direction=direction}) + end + end else for i, direction in ipairs{"d", "l", "ld", "lu", "r", "rd", "ru", "u"} do scene:onInputRelease({input=nil, type="joyhat", name=joystick:getName(), hat=hat, direction=direction})