[Bug] Controls can still have an axis state even after joypad is disconnected
I've been fixing a bug where ifa controller is disconnected while an axis is held down, its ghost can still affect the game. I tracked my problem to controls:get_axis_state() still returning a value even when no joypad is connected anymore, and no buttons on the keyboard are pressed.
function controls_meta:get_angle()
local controls = self
local x, y = controls:get_axis_state("X"), controls:get_axis_state("Y")
print("Is there an axis state?", x, y)
print("Is there a joypad?", controls:get_joypad())
endPrints:
Is there an axis state? 0 1
Is there a joypad? nilI expect if there is no joypad, and no keys are pressed, axis state should be 0.
Simple workaround in my case, to just check if a joypad is connected and return no angle if none is connected. However, I believe the directions from the keyboard are supposed to simulate an axis input as well, which I confirmed is current behavior (for example, with a controller having never been connected during a game, I can press the arrow keys and get an axis state).
Edited by Max Mraz