Gamepad firing Keyboard Events

I’ve encountered a bug where gamepads will fire keyboard and mouse events. I found this in my studio, and tested it in several live games.

When you move a Gamepad thumbstick forward, LastInputType will change to gamepad, then the InputBegan event will be fired for Enum.KeyCode.Up. This is true of all directions. R2 will fire MouseButton, and the A Button will fire Enum.KeyCode.Return. In the screenshot below I printed LastInputType on changed, and inputBegan.

RobloxStudioBeta_awNf7lLllL

All the gamepad buttons and thumbsticks seem to fire unwanted Keyboard events.

You can reproduce this simply by printing UserInputService.LastInputTypeChanged, plugging in a gamepad, and pressing the thumbstick or any button. You can test this live on Polyhex’s Super Bomb Survival, where the on-screen keybinds (such as R for Ragdoll in the lower left corner) change based on Last User Input Type - they flicker back and forth on gamepad input, and return to Keyboard after you finish pressing a Gamepad input.

This is a problem because it makes it impossible to know what the user’s LastUserInputType actually was. Like Super Bomb Survival, in my game I change all the on-screen keybinds to be Gamepad icons, or Keyboard keys depending on the last input type. This is currently unusable.

Thanks for reading.

1 Like

Hi,

I think you may be experiencing a feature as opposed to a bug. I don’t know which versions of
which Roblox apps you’re talking about, but I can tell you that if you use ContextActionService and
bind your inputs (BIndAction/BindActionAtPriority) doing so will mask the input from UserInputService
(InputBegan/InputEnded)–So try binding–I think that will solve your problem.

:slight_smile:

1 Like

I don’t understand how a Gamepad input also firing inputBegan for keyboard events is a feature? Sure that’s incredibly confusing, and makes using LastInputType pointless (as I described in the post)? Like there’s no way for me to detect when the user has actually switched from Gamepad to keyboard in this case.

I will test binding when I have some time. But I’m pretty sure gamepad inputs shouldn’t also be firing keypad inputs.