To put some context, I’m trying to detect in a circular menu witch item is selected, so I use either the mouse position or the stick direction using “SelectItemRoundMenu.ReadValue()”. If I use both schemes isolated it works perfect.
The problem is that when i use the mouse and after that i try to switch to the joystick this second input is shadowed by the last mouse position.
Is there a way to detect the last
“ControlScheme” used?
Is there a way
to read from specific action
“Binding”?
Is this not the correct way to
configure this feature?
I found a workaround combining multiple Unity forum questions…
I manage to know which device was the last used, and how to disable the ControlScheme related to the others devices.
Here is the code:
private void OnEnable()
{
// GameManager.Instance.getGameKeyController(): return my "Input Action Asset"
GameManager.Instance.getGameKeyController().DEBUG.Alive.performed += ctx => onInputAlive(ctx);
}
void onInputAlive(InputAction.CallbackContext c)
{
// Keyboard ==1, Mouse==2, >2: Other devices (There is a code for each one)
if (c.control.device.deviceId == 1 || c.control.device.deviceId==2)
{
GameManager.Instance.getGameKeyController().bindingMask = new InputBinding { groups = "Mouse&Keyboard" };
}
if (c.control.device.deviceId > 2)
{
GameManager.Instance.getGameKeyController().bindingMask = new InputBinding { groups = "Gamepad" };
}
}
In the action “Alive” all the Bindings must have no ControlScheme configured (Because we want to be triggered no matter which ControlScheme is enabled).
In all the other actions we must configure a ControlScheme for each Binding.