LocalScript is not handling gamepad inputs

I have been trying to add gamepad support to my train’s movement system but it wont listen to any input that I put in, keyboard inputs work just fine

The relevant lines are as follows:
The Listener

ContextActionService:BindAction("IncreaseLever1", ActionHandler, false, _Tune.Keybinds.Keyboard.IncreaseLever1, _Tune.Keybinds.Gamepad.IncreaseLever1)

(ActionHandler is merely just a function to bridge input names to other functions)

The code that actually processes IncreaseLever1

ContextActions.IncreaseLever1 = function(inputState, inputObject)
	if inputState == Enum.UserInputState.Begin then
		CALocks.IncreaseLever1 = true
		while UserInputService:IsKeyDown(inputObject.KeyCode) == true and ThrottleNotch < _Tune.Lever1Notches do
			local Clamp = (IsCombinedLever == true and -_Tune.Lever2Notches) or 0
			
			ThrottleNotch = math.clamp(ThrottleNotch + 1, Clamp, _Tune.Lever1Notches)	
			SetTargets(IsCombinedLever)
			
			wait(0.2)
		end
		CALocks.IncreaseLever1 = nil
	end
end
2 Likes

Ok, from some debugging, gamepad buttons ironically always return false (because gamepad buttons are analog, not digital) in IsKeyDown()

now i have to write my own IsKeyDown to handle gamepad inputs properly :upside_down_face:

1 Like