godotengine / godotengine/godot
Button Shortcut does not trigger if set to InputEventAction and the action is a Joypad Axis or anything Mouse related.
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
Godot Engine v4.2.1.stable.official.b09f793f5
### System information
Godot v4.2.1.stable - Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3080 (NVIDIA; 31.0.15.5123) - Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (16 Threads)
### Issue description
When a button shortcut is set to `InputEventAction` and that action is bound to a joypad axis, it does not trigger. However, if bound to a key or button, it does.
I believe it happens because the code below filters out `InputEventJoypadMotion` among others.
```c++
void Viewport::_push_unhandled_input_internal(const Ref &p_event) {
// Shortcut Input.
if (Object::cast_to(*p_event) != nullptr || Object::cast_to(*p_event) != nullptr || Object::cast_to(*p_event) != nullptr) {
ERR_FAIL_COND(!is_inside_tree());
get_tree()->_call_input_pause(shortcut_input_group, SceneTree::CALL_INPUT_TYPE_SHORTCUT_INPUT, p_event, this);
}
```
### Steps to reproduce
The MRP has one button that, when pressed, turns the background blue.
The action is bound to four inputs:
- The Space key on the keyboard -- OK
- Joypad Button 0 (Button A on an Xbox Controller) -- OK
- Joypad Axis 1 (Left Stick Up, Joystick 0 Up) -- Reproduces bug
- Right Mouse Button -- Reproduces bug
To reproduce the bug:
1. Download and run the minimal reproduction project
2. Press the Left Stick Up, notice nothing happens
3. Press the Right mouse button, notice nothing happens
4. Press the Space bar or Joypad Button 0 to see the background turn blue.
### Minimal reproduction project (MRP)
[ShortcutBug.zip](https://github.com/godotengine/godot/files/14941813/ShortcutBug.zip)
Contributor guide
Research direction
Start with Viewport::_push_unhandled_input_internal and reproduce the issue using the supplied ShortcutBug.zip project. Compare the input event types that reach shortcut handling for keyboard, joypad button, joypad axis, and mouse input. Done means the button shortcut triggers for the joypad axis and right mouse button as well as the currently working inputs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100