Gamepad connected to /dev/input/js1

Hello everyone,

I really like the Piborg Gamepad library. No installation, obviously not much overhead, no unnecessary functionality.

I seem to have the same situation as described in http://forum.piborg.org/node/2102 "ps3 ghost controller".
(I purposely do not write "problem" but "situation".)
I create a new thread here, because think that the discussion on "ps3 ghost controller" goes in the wrong direction.
In my opinion, the system may place my controller anywhere it wants, I need to find it.
What if I have multiple controllers? Then it will not only be joystick 0.

I run PollingExample.py on the Raspberry Pi.
It reacts to mouse movemets and mouse clicks instead of gamepad actions.
(mouse movements from my PC mouse, when I use VNC.
It does not react to movements of the mouse directly connected to the Raspi)
I think this is OK, maybe someone wants to control a robot via mouse.

My gamepad ist found on /dev/input/js1.
When I disconnect the gamepad-dongle (a Strike NX which identifies as Xbox 360, connected via a usb dongle), /dev/input/js1 does not exist.
/dev/input/js0 always exists.
Good, so far.

I have seen that Gamepad.available() defaults to 0 and checks /dev/input/js0, so I added the parameter 1 in the exmple.
Now, Gamepad.available(1) should check for /dev/input/js1.
I still get the message "Gamepad connected" when I disconnect the dongle.
I still get messages when I move the mouse, no messages from the gamepad even when the gamepad is connected.

So, there seem to be more places to add a parameter.
Unfortunately, I am not used to Object Oriented Programming.
Please help.

piborg's picture

No problem, this should be simple to fix :)

When you create the actual gamepad object you need to pass the controller number.

For example this would check if ID #1 is available, then create an Xbox 360 controller instance for ID #1

import Gamepad
if Gamepad.available(1):
    gamepad = Gamepad.Xbox360(1)
else:
    print('Controller not connected :(')
Subscribe to Comments for "Gamepad connected to /dev/input/js1"