REPENTOGON
REPENTOGON copied to clipboard
Suggestions for more input/controller stuff
I'm in the process of creating a new menu on the main menu and ran into a small couple issues in relation to input, as I want to be able to differentiate keyboard and controller inputs for different actions and different graphics. Here's some suggestions I thought of that could be handy
- Input.GetDeviceNameByIdx() currently doesn't appear to return anything useful. Keyboard will always be "Keyboard" but I connected both an Xbox and Switch Pro controller and the only result I got was "XInput Controller 1", 2, 3, etc. In gfx/ui, there's buttons.anm2, which has different animations depending on the type of identified controller. I'd like to be able to get the proper name of the controller if possible to point to the right set of buttons...though its possible that this is just how the game sees the controllers and these are meant for the other consoles? Regardless, the main menu seemed to use the XboxOne buttons despite PS4 being the literal "default" animation, so there surely must be some kind of default identification
- The main menu clearly tracks whichever device had an input of any kind last and updates its graphics accordingly. Maybe an "Input.GetLastActiveDeviceIdx()"? I currently have to loop through index 0 - 4 just to guess the number of indexes present and check every single ButtonAction to update a local variable that stores the last used idx
- Controller enum/enum per controller type for IsButtonTriggered/Pressed. I'm assuming this would line up with the controls_buttons.anm2, as gfx/backdrops/controls_buttons.anm2 has a Keyboard animation and it certainly matches up with the Keyboard enum
tl;dr:
- Input.GetDeviceNameByIdx() except the actual names like XboxOne, PS4, Switch_Pro, etc. On PC its currently returning XInput Controller 1, 2, 3, etc
- Input.GetLastActiveDeviceIdx() for the menu
- Generic Controller or per-controller-type enum for Input.IsButtonTriggered/Pressed
Adding on to this...
- Can we get a function that returns all the valid controller indexes the game recognizes? Presumably the game knows this since it lists them on the settings page. It's possible to do this right now with Input.GetDeviceNameByIdx and iterating over a large set of numbers, but something more concise would be nice.
- Is it possible to add a callback that would let us know when a controller has been connected/disconnected?