USB XBox 360 controller

Forums:

I have a USB XBox 360 controller Im following your guide on Joyborg. When I run jstest /dev/input/js0 I get :

Driver version is 2.1.0.
Joystick (Microsoft X-Box 360 pad) has 8 axes (X, Y, Z, Rx, Ry, Rz, Hat0X, Hat0Y)
and 11 buttons (BtnX, BtnY, BtnTL, BtnTR, BtnTR2, BtnSelect, BtnThumbL, BtnThumbR, ?, ?, ?).
Testing ... (interrupt to exit)

Then the list of buttons / axes

When I press buttons / move sticks the numbers on the screen change and scroll. So I know its recongised and working.

Do I need to modify the JoyBorg.py script axis numbers, or are all XBox 360 controllers recognised the same by the driver and my controller should just work with the script by default ?

I ask because when I move a stick and try to see which numbers change on the screen, it seems extremely sensitive so Im having trouble working out which stick is which axis. The buttons are easy.

Is there an ccepted axis numbersing scheme for XBox360 controllers ? Do I need to change the JoyBorg.py file at all ?

Thank u.

piborg's picture

You will probably need to change the axisLeftRight value to 4 as the axis numbers are slightly different for the X-Box controller from memory.

This is the line that need to be changed:

# Settings for JoyBorg
leftDrive = DRIVE_1                     # Drive number for left motor
rightDrive = DRIVE_4                    # Drive number for right motor
axisUpDown = 1                          # Joystick axis to read for up / down position
axisUpDownInverted = False              # Set this to True if up and down appear to be swapped
axisLeftRight = 4                       # Joystick axis to read for left / right position
axisLeftRightInverted = False           # Set this to True if left and right appear to be swapped
interval = 0.1                          # Time between keyboard updates in seconds, smaller responds faster but uses more processor time

For reference I think these are the index numbers for the X-Box 360 controller:

Control / Action
Axis index
Button index
Left stick left / right
0
---
Left stick up / down
1
---
Left stick push in
---
8
Right stick left / right
4
---
Right stick up / down
3
---
Right stick push in
---
9
A
---
0
B
---
1
X
---
2
Y
---
3
LT
2
---
LB
---
4
RT
5
---
RB
---
5
Back
---
6
Start
---
7

The D-Pad uses the hat functionality instead of behaving like buttons, so it requires slightly different code.

Subscribe to Comments for "USB XBox 360 controller"