Optimal Way to Detect Input Source (Keyboard vs. Gamepad) in Control Change System

Hi!

I’m currently working on implementing a control change system in my game. The user interface is represented in the following screenshot:

My goal is to allow players to change the key associated with each action by clicking on the respective control. However, I want to ensure that I can distinguish between keyboard and gamepad inputs for each action.

My question is: What is the most optimized method for detecting whether a key input is coming from a keyboard or a gamepad?

I’d appreciate any insights and suggestions on how to achieve this effectively. Thank you in advance for your assistance!

Not sure if this answers your question but I personally use this amazing open sourced module! qDevice - A utility for getting user devices

1 Like

I mean, most inputs aren’t even related? Keyboards move with WASD while controllers use the analogue or L3 or whatever u call it key. Jump is space while controllers use X/A and A isn’t the same as the A of keyboard it has it’s own Keycode named as “ButtonA”, and you get the point, what exactly is the problem then?

1 Like

My initial concern was to prevent a keyboard user from binding a keyboard key in the same space designated for their gamepad key. However, I’ve come to the conclusion that a simpler approach is to disallow changing the gamepad key without having a controller connected.

Your suggestion also makes sense, and I appreciate your assistance. Thank you!

1 Like

This is a really interesting module! I’ll certainly use it in future projects!

Thank you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.