XBOX 360 controller on Linux

Yesterday I played around with my Joysticks on Linux. Surprisingly they do not use the same identifiers as on Windows.

For my wired XBOX controller I had to use this joystick-mapping.properties file:
[java]

Wired XBOX 360 controller (Linux)

Microsoft\ X-Box\ 360\ pad.A=2
Microsoft\ X-Box\ 360\ pad.B=1
Microsoft\ X-Box\ 360\ pad.X=3
Microsoft\ X-Box\ 360\ pad.Y=0
Microsoft\ X-Box\ 360\ pad.Left\ Thumb=4
Microsoft\ X-Box\ 360\ pad.Right\ Thumb=5
Microsoft\ X-Box\ 360\ pad.Left\ Thumb\ 3=10
Microsoft\ X-Box\ 360\ pad.Right\ Thumb\ 3=11
Microsoft\ X-Box\ 360\ pad.Select=8

start button is not available, so use the mode button as start button

Microsoft\ X-Box\ 360\ pad.Mode=9
Microsoft\ X-Box\ 360\ pad.rx=z
Microsoft\ X-Box\ 360\ pad.ry=rz

requires custom code to support trigger buttons

Microsoft\ X-Box\ 360\ pad.z=LeftTrigger
Microsoft\ X-Box\ 360\ pad.rz=RightTrigger
[/java]

The start button is not available, so I use the mode button as start button
Left and right triggers need custom code (very similar to my Windows example)
On Windows left and right triggers are not independent. That means it’s hard to detect if both buttons are pushed.
On Windows the mode button is not supported, instead the start button works as expected.

I could not find out if the wireless version has another ID.

Here the TestJoystick output:

[java]
Joystick[0]:Microsoft X-Box 360 pad
buttons:10
JoystickButton[name=A, parent=Microsoft X-Box 360 pad, id=0, logicalId=A]
JoystickButton[name=B, parent=Microsoft X-Box 360 pad, id=1, logicalId=B]
JoystickButton[name=X, parent=Microsoft X-Box 360 pad, id=2, logicalId=X]
JoystickButton[name=Y, parent=Microsoft X-Box 360 pad, id=3, logicalId=Y]
JoystickButton[name=Left Thumb, parent=Microsoft X-Box 360 pad, id=4, logicalId=Left Thumb]
JoystickButton[name=Right Thumb, parent=Microsoft X-Box 360 pad, id=5, logicalId=Right Thumb]
JoystickButton[name=Select, parent=Microsoft X-Box 360 pad, id=6, logicalId=Select]
JoystickButton[name=Mode, parent=Microsoft X-Box 360 pad, id=7, logicalId=Mode]
JoystickButton[name=Left Thumb 3, parent=Microsoft X-Box 360 pad, id=8, logicalId=Left Thumb 3]
JoystickButton[name=Right Thumb 3, parent=Microsoft X-Box 360 pad, id=9, logicalId=Right Thumb 3]
axes:9
JoystickAxis[name=x, parent=Microsoft X-Box 360 pad, id=0, logicalId=x, isAnalog=true, isRelative=false, deadZone=0.0]
JoystickAxis[name=y, parent=Microsoft X-Box 360 pad, id=1, logicalId=y, isAnalog=true, isRelative=false, deadZone=0.0]
JoystickAxis[name=z, parent=Microsoft X-Box 360 pad, id=2, logicalId=z, isAnalog=true, isRelative=false, deadZone=0.0]
JoystickAxis[name=rx, parent=Microsoft X-Box 360 pad, id=3, logicalId=rx, isAnalog=true, isRelative=false, deadZone=0.0]
JoystickAxis[name=ry, parent=Microsoft X-Box 360 pad, id=4, logicalId=ry, isAnalog=true, isRelative=false, deadZone=0.0]
JoystickAxis[name=rz, parent=Microsoft X-Box 360 pad, id=5, logicalId=rz, isAnalog=true, isRelative=false, deadZone=0.0]
JoystickAxis[name=pov, parent=Microsoft X-Box 360 pad, id=6, logicalId=pov, isAnalog=false, isRelative=false, deadZone=0.0]
JoystickAxis[name=pov_x, parent=Microsoft X-Box 360 pad, id=7, logicalId=pov_x, isAnalog=false, isRelative=false, deadZone=0.0]
JoystickAxis[name=pov_y, parent=Microsoft X-Box 360 pad, id=8, logicalId=pov_y, isAnalog=false, isRelative=false, deadZone=0.0]
[/java]

Very strange. On the one hand, I wonder if there is a joystick remapping tool for Linux similar to what is available for Windows (there are several for Windows). On the other hand, it’s sad that it is so hard to support was is probably a common joystick.

Regarding the “custom code”… is that because you are trying to treat the left/right axis of those ‘buttons’ as buttons? Are they pressure sensitive?

If so then Lemur’s InputMapper may have a leg up here since it lets you treat an axis like buttons and buttons like an axis. Very nice for using joysticks and keyboards for driving the same ‘listeners’… but would also allow apps to more easily use the xbox controller trigger buttons (if they are pressure sensitive then some apps may want to use that).

@pspeed said: Regarding the "custom code"... is that because you are trying to treat the left/right axis of those 'buttons' as buttons? Are they pressure sensitive?

Yes and yes.

Currently I don’t need the trigger buttons. I just wanted to see TestJoystick.java working.

Lemur? Ah, I see. Thanks.

@revv said: Yes and yes.

Currently I don’t need the trigger buttons. I just wanted to see TestJoystick.java working.

Lemur? Ah, I see. Thanks.

It’s kind of neat. For example, I can map ‘W’ and ‘S’ to the same ‘function’ as the left joystick’s y axis. Code that registers to listen to that function can either listen to it as a -1 to 1 axis or a negative, off, positive state depending on how they want to see it. So my movement code registers with that ‘function’ as an axis and when WASD or the Joystick will work… but with the joystick you also get fine-grained movement speed.

Furthermore, it supports things like registering shift+w and shift+s to a ‘run’ function and then you’d see it as a different axis (in Mythruna I think I actually just use it as a speed toggle in the more conventional way but it’s a convenient example on how you can have ‘modes’ for different axes).

But, for example, maybe you have an inventory selector pop-up. On the joystick maybe you press a trigger and then can use the joystick or dpad to move left or right through inventory. You could register the trigger+dpad left/right to a function and maybe also map ‘q’ and ‘e’ to that same ‘function’. The inventory selector code just watches that function for the appropriate negative, off, positive state changes and treat it like two buttons.

I think I’m starting to get confusing now. Even if you don’t want to use all of Lemur, the InputMapper stuff can be used without touching the rest.

1 Like

I recently ran into this problem myself and solved it, so I’m posting this for anyone looking for a solution. The problem is in the jinput library, it is solved in newer version of jinput so by compiling the latest version and changing to that I managed to get all of the buttons on my controller to work.

1 Like