Code: Select all
if (Input.IsActionJustPressed(InputAction.Attack) {
...
}
Code: Select all
if (Input.IsActionJustPressed(InputAction.Attack, out var actionBinding) {
if (actionBinding.IsMouse()) {
// mouse aim logic
}
else {
// aim where the character is facing based on movement
}
}
Code: Select all
if (Input.IsActionJustPressed(InputAction.Attack) {
...
}
Code: Select all
if (Input.IsActionJustPressed(InputAction.Attack, out var actionBinding) {
if (actionBinding.IsMouse()) {
// mouse aim logic
}
else {
// aim where the character is facing based on movement
}
}
Very interesting, I've never considered this aspect. So it's not possible to differentiate between someone moving their cursor with a mouse vs steam controller?As an owner of a steam controller, I know how annoying it is when games use mouse movement as an indicator that the player is using keyboard and mouse, so I'm not gonna do that.
A bit confused by this. Even if the player uses the mouse to attack, they are still using the keyboard for movement. Could attack action be bound to both mouse and keyboard at the same time? That way, both styles are combined in one.Using keyboard input as a predictor that the player is playing with their mouse is thus not possible.
Ha! Before you showed your API, I've pictured something like:Problem is, if my code has any sort of special logic that depends on the input device, as I described above, I need to undo that, and... check each input device manually?
Code: Select all
if Input.Pressed(InputAction.Attack) is action {
match action {
ActionType::Mouse => {},
ActionType::Controller => {}
}
}
Most likely another classic instance of "we do whatever is most simple for a beginner, any slightly more complicated use case is the user's problem".I'm very mad no other engine has it.
Very interesting, I've never considered this aspect. So it's not possible to differentiate between someone moving their cursor with a mouse vs steam controller?As an owner of a steam controller, I know how annoying it is when games use mouse movement as an indicator that the player is using keyboard and mouse, so I'm not gonna do that.
A bit confused by this. Even if the player uses the mouse to attack, they are still using the keyboard for movement. Could attack action be bound to both mouse and keyboard at the same time? That way, both styles are combined in one.Using keyboard input as a predictor that the player is playing with their mouse is thus not possible.
Ha! Before you showed your API, I've pictured something like:Problem is, if my code has any sort of special logic that depends on the input device, as I described above, I need to undo that, and... check each input device manually?
Code: Select all
if Input.Pressed(InputAction.Attack) is action {
match action {
ActionType::Mouse => {},
ActionType::Controller => {}
}
}
Most likely another classic instance of "we do whatever is most simple for a beginner, any slightly more complicated use case is the user's problem".I'm very mad no other engine has it.
Well the thing is, I have keyboard and keyboard&mouse as two separate input schemes, and I want to implement a feature (attack in the direction the mouse is pointing at) that should only work in one of the two cases. If you are using keyboard-only and the mouse happens to be left of your character, your attacks will always go to the left which would be badpalas wrote: Mon Mar 16, 2026 3:04 am A bit confused by this. Even if the player uses the mouse to attack, they are still using the keyboard for movement. Could attack action be bound to both mouse and keyboard at the same time? That way, both styles are combined in one.
Hehe, good one! Pretty much the same thing I came up with. Actually, I'm using that DUnion source generator you shared a while back for this, and the `.IsMouse()` in my code was auto-generated from the union, but I could've used at `.Match(...)` as well!
When I had this issue in Godot, I had to fall back to the non "input action" API, so checking the keyboard, mouse and gamepad devices directly without going through the abstraction layer. I'm not sure if it's any better now but all their "is_action_*" methods return a boolean, and judging by GDScript's limitations, it's unlikely they return anything else anytime soon ^^'']]>palas wrote: Mon Mar 16, 2026 3:04 am Most likely another classic instance of "we do whatever is most simple for a beginner, any slightly more complicated use case is the user's problem".
But, surely every half competent engine has a way to tell whether a mouse or a controller is used, and process each one separately? This is such a fundamental feature after all.
Well the thing is, I have keyboard and keyboard&mouse as two separate input schemes, and I want to implement a feature (attack in the direction the mouse is pointing at) that should only work in one of the two cases. If you are using keyboard-only and the mouse happens to be left of your character, your attacks will always go to the left which would be badpalas wrote: Mon Mar 16, 2026 3:04 am A bit confused by this. Even if the player uses the mouse to attack, they are still using the keyboard for movement. Could attack action be bound to both mouse and keyboard at the same time? That way, both styles are combined in one.
Hehe, good one! Pretty much the same thing I came up with. Actually, I'm using that DUnion source generator you shared a while back for this, and the `.IsMouse()` in my code was auto-generated from the union, but I could've used at `.Match(...)` as well!
When I had this issue in Godot, I had to fall back to the non "input action" API, so checking the keyboard, mouse and gamepad devices directly without going through the abstraction layer. I'm not sure if it's any better now but all their "is_action_*" methods return a boolean, and judging by GDScript's limitations, it's unlikely they return anything else anytime soon ^^'']]>palas wrote: Mon Mar 16, 2026 3:04 am Most likely another classic instance of "we do whatever is most simple for a beginner, any slightly more complicated use case is the user's problem".
But, surely every half competent engine has a way to tell whether a mouse or a controller is used, and process each one separately? This is such a fundamental feature after all.