Open solarstrings opened 2 years ago
On an Xbox controller, L2 and R2 are analog triggers and are therefore considered joypad axes, not joypad buttons. if event is InputEventJoypadMotion
is what you're looking for here.
The majority of controllers nowadays have analog triggers, the most notable exception being the Switch controllers.
@Calinou Thanks for pointing that out :) However, in windows they report as buttons: 6 & 7, so we have some inconsistency between different operating systems here.
Some devices may send both key events and abs events, usually occurs on triggers..
You can use the evtest
/evemu-record
command line tool to confirm that the button/stick/trigger sends events when pressed.
Maybe or found some output logs like these:
E: 116.550009 0004 0004 589834 # EV_MSC / MSC_SCAN 589834
E: 116.550009 0001 0139 0001 # EV_KEY / BTN_TR2 1
E: 116.550009 0003 0009 0016 # EV_ABS / ABS_GAS 16
E: 116.550009 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +4140ms
E: 116.558064 0003 0009 0025 # EV_ABS / ABS_GAS 25
E: 116.558064 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +8ms
E: 116.565000 0003 0009 0001 # EV_ABS / ABS_GAS 1
E: 116.565000 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +7ms
E: 116.573044 0004 0004 589834 # EV_MSC / MSC_SCAN 589834
E: 116.573044 0001 0139 0000 # EV_KEY / BTN_TR2 0
E: 116.573044 0003 0009 0000 # EV_ABS / ABS_GAS 0
E: 116.573044 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +8ms
If not, the keycode scheme used by the device on Linux is not such a device scheme. It may also be common for the same device to use different mapping schemes on different platforms.
The joypad mapping for my specific Gamepad was missing in linux.
They available mappings are listed here: https://github.com/godotengine/godot/blob/master/core/input/gamecontrollerdb.txt
I wrote my own mapping program to create the gamepad mappings I needed for my gamepad, then used: Input.AddJoyMapping() to add the gamepad mapping.
I recently made a PR (#95486) to improve the usability of gamepads that adhere to the Linux Gamepad Specification on Linux. Of course, the PR is also trying to take into account mainstream devices such as Xbox.
Some xbox devices do not follow this specification, and I don't have that many devices. If it is convenient, you can use your gamepad to test this PR. You can download the binary from the Artifacts in Checks.
Godot version
3.4.4
System information
Ubuntu 22.04, XBOX Controller
Issue description
The L2 And the R2 buttons are not registering when pressed. The InputEventJoypadButton shows activity for all other buttons.
I've tested the Gamepad in other software, and there the L2 and R2 buttons are working perfectly fine.
Steps to reproduce
Plugin the Xbox 360 controller.
Add the following C# code to any script:
or the following GDScript code to any script:
Build, Run and press each button om the XBOX Gamepad to test
Minimal reproduction project
XboxButtonsL2AndR2NotWorking.zip