I'm seeking a way to reorder my gamepads. What I mean is, I have multiple gamepads plugged or wireless and they are affected to /dev/input/js0 (Player 1), /dev/input/js1 (Player 2), ect. and I want to be able to say that one gamepad become /dev/input/js0 (Player 1) and it would switch position with the other gamepad (like on the PS3).
Is there a way with an utility or a command line to do that?
There is no way to change device names in /dev directory. Maybe this is not statued for input devices like gamepads. I cant test this because I have no gamepads around.
But this will be necessary for your approach. So, the first answer is: It is impossible.
The second answer is more a hint to a way which may help you to deal with your idea:
As you may assign symbol links to devices using udev rules, maybe you can deal with it that way. I will explain it by means of a usb-stick.
What we do is:
- Disconnect the usb stick using a command - create a temporary rule for assigning a symlink - Reconnect the usb stick using a command - delete the temporary rule
For the background read these articles: udev, about udev rules, Authorizing USB devices and sudo echo access denied
As a prerequisite we need some information about the targeting usb stick. Remove the stick and run the command
Plug the stick in an you get a lot of information on the screen. I extract the device path on the usb bus from the first line of output:
With this information run the command
Again there is a lot of output. We are interested in
This is an unique serialnumber to the usb-device.
Now lets give this stick an symlink.
First we have to disconnect our usb stick:
Now we create a temporary rule for udev:
Next step is to reconnect the usb stick:
Now you find a symlink /dev/myusb300 to /deb/sdb1
The idea behind all this is, even if you can't rename
/dev/js0
, you can create symlinks, i.e./dev/js10
, to the gamepad controller. This symlinks can be swapped, just on thy fly or by programmatic disconnect and reconnect the controller. The application (the game) itself should be configured to use the gamepads /dev/js10, /dev/js11, and so on.By the unique serialnumbers of the gamepads you may always assign a specific symlink to a choosen gamepad.
Maybe it is possible to find more possibilities dealing with udev. That depends not only on the concrete solution you are looking for but also on the application, the controllers and other things.
ok, its not a complete solution, but I'm kinda annoyed about the "Theres no way to do it" non-sense.
Right here:
which says create a block device, with major number 8, minor number 0, named /dev/lol. ls, shows us it is a block device. Then, I deleted it.
what we need to know about your device, is the type: (character or block), permissions, type of input it expects, and such. With the device plugged in,
$ls -l /dev/input/js0
will tell us most of that. It wont tell us if it expects cooked or raw data. Update your question with these details, and I'll try to write a script or something to solve the problem. Rootly power required.Also, with the controllers connected, show the output of
$lsusb
(I'm assuming which ever device is plugged in first, gets enumerated /dev/input/js0 , and that the software isnt doing silly things like explicitly enumerating specific controllers as specific device files)