I am using the Auto-Switch option. When I use Controller but press “F12” on the keyboard, I don’t want to switch. Because that does a screenshot and I want to keep the controller-icons in this case.
can I simply ignore F12 and Printscreen but keep using the Auto-Switch? e.g. prevent the switch?
I have a Listener on the “controlsChangedEvent” but thats too late. I’d like to either ignore specific keys or say “only change control scheme, when a key in my scheme is pressed” and not when “any” key is pressed.
Maybe I can inherit from “???” and override the function that would do the auto-switch and do my filtering/ignoring there? I don’t know which class though.
It sounds like you want the control scheme behavior and auto-switching for a single player game? Remember you could just skip using control schemes all together and remove them or keep all actions in one which would solve your issue since no switching would happen and all would be active? They are however typically convenient if you are doing local multiplayer or want to keep playable controls to a sub-set of defined actions.
I am afraid what you ask for is currently not possible with the exposed API surface. It would have been easier if game was never played with the keyboard since then you could have excluded the keyboard from any control schemes to disable the switching. If you are fine modifying Input System source code which is possible since package is open source, you may find interest in modifying PlayerInput.cs:
private void PlayerInput.OnUnpairedDeviceUsed(InputControl control, InputEventPtr eventPtr) in such a way that it returns/aborts if input control is of type KeyControl and equals the key you want to ignore. For example:
private void OnUnpairedDeviceUsed(InputControl control, InputEventPtr eventPtr)
{
// Ignore F12 key on a keyboard device
if (control is KeyControl && ((KeyControl)control).keyCode == Key.F12)
return;
...
}
This method will be invoked when there is input associated with a device that is not currently assigned. This is the scenario when you press a key while gamepad is active. Modifying this allows you to intercept it, but its clear there is no convenient mechanism to do it available at the moment. I will make sure the team gets aware of this use-case for future considerations.