Failed to open device /dev/input/js0

Hi all,

I’m truing to get jinput running on my notebook runnning fedora core 4.
Although jstest /dev/input/js0 works fine and I can use my joypad with zsnes, no joystick.pad is found using jinput, because opening the device fails:

java -Djinput.plugins=net.java.games.input.LinuxEnvironmentPlugin ControllerDetails 0
Initing event interface
Initing joystick interface
Trying to open /dev/input/js0
Failed to open device /dev/input/js0
Getting the number of event devices
Getting 0 event devices
Getting the number of joystick devices
Getting 0 joystick devices
The provided index is out of range.
Use a value between 0 and -1

Any suggestions would be great :slight_smile:

Yup. First suggestion. JInput is built on SDL. If you want to be able to read a device as anyoen other then root then you have top set its /dev/xxx file to readable by everyone (man ydestributiosn set it to root-only by default.)

If you want to be able to use the rumler then you also have to have write permissions.

If you want to check if this is the problem a quick fix is to su to root and run the test. If it works, then it is almost certainly a permissions mismatch.

Hope that helps.

Thanks for suggesions Jeff,

after chmod o+rwx /dev/input/js0 the joypad is initialized, but the number of available controllers is still 0:
(I didn’t use chmod for the other devices yet.)

java -Djinput.plugins=net.java.games.input.LinuxEnvironmentPlugin PollController 0 0
Initing event interface
Initing joystick interface
Trying to open /dev/input/js0
Opened /dev/input/js0, trying to get device name
Getting button and axes information for /dev/input/js0
Initialisation of /dev/input/js0 completed
Getting the number of event devices
Getting 0 event devices
Getting the number of joystick devices
Getting 1 joystick devices
The provided index is out of range.
Use a value between 0 and -1

Using the su command, everything works fine (see output below) , but I receive the following message every time I hit a key:
Received event of type 0x04 from AT Translated Set 2 keyboard, which I wasn’t expecting, please report it to jinput forum at www.java-gaming.org

So is there anything other I can do than chmod[/chmod] and why do other applications (e.g. zsnes) can uses the joypad without these permissions ?
(Is that SDL specific ?)

[font=Courrier]
java -Djinput.plugins=net.java.games.input.LinuxEnvironmentPlugin ListControllers
Initing event interface
Device name for device file /dev/input/event0 is AT Translated Set 2 keyboard
Device name for device file /dev/input/event1 is PS/2 Mouse
Device name for device file /dev/input/event2 is AlpsPS/2 ALPS GlidePoint
Device name for device file /dev/input/event3 is GreenAsia Electronics 4Axes 12Keys GamePad
Device name for device file /dev/input/event4 is Microsoft Microsoft Wireless Optical Mouse� 1.0A
Copied temp event device 0 to event device 0
Copied temp event device 1 to event device 1
Copied temp event device 2 to event device 2
Copied temp event device 3 to event device 3
Copied temp event device 4 to event device 4
Initing joystick interface
Trying to open /dev/input/js0
Opened /dev/input/js0, trying to get device name
Getting button and axes information for /dev/input/js0
Initialisation of /dev/input/js0 completed
Getting the number of event devices
Getting 5 event devices
Getting the number of joystick devices
Getting 1 joystick devices
Getting device information for event device 0 and joystick 0
Getting device information for event device 1 and joystick 0
Getting device information for event device 2 and joystick 0
Getting device information for event device 3 and joystick 0
Getting device information for event device 4 and joystick 0
Gettign device name for jinput device 0.
jinput device 0 is 165973552
EventDevice::getName()
Gettign device name for jinput device 0, (AT Translated Set 2 keyboard)
EventDevice::getName()
Gettign number of absolute axes for jinput device 0 (0)
Gettign number of relative axes for jinput device 0 (2)
Gettign number of buttons for jinput device 0 (146)
Getting bus type for device 0
Getting suported relative axes for jinput device 0
Getting suported absolute axes for jinput device 0
Getting bus type for keyboard device 0
Gettign number of buttons for jinput keyboard device 0
LinuxNativeTypesMap.getButtonID() returned class net.java.games.input.Mouse$ButtonID
Gettign device name for jinput device 1.
jinput device 1 is 165976784
EventDevice::getName()
Gettign device name for jinput device 1, (PS/2 Mouse)
EventDevice::getName()
Gettign number of absolute axes for jinput device 1 (0)
Gettign number of relative axes for jinput device 1 (2)
Gettign number of buttons for jinput device 1 (3)
Getting bus type for device 1
Getting supported buttons for jinput device 1
Getting suported relative axes for jinput device 1
Getting suported absolute axes for jinput device 1
Getting supported buttons for jinput device 1
Gettign device name for jinput device 2.
jinput device 2 is 165979160
EventDevice::getName()
Gettign device name for jinput device 2, (AlpsPS/2 ALPS GlidePoint)
EventDevice::getName()
Gettign number of absolute axes for jinput device 2 (3)
Gettign number of relative axes for jinput device 2 (2)
Gettign number of buttons for jinput device 2 (5)
Getting bus type for device 2
Getting supported buttons for jinput device 2
Getting suported relative axes for jinput device 2
Getting suported absolute axes for jinput device 2
Getting fuzz data for axis 0 on device 2
Getting absolute axes minimum value data for axis 0 on device 2
Getting absolute axes maximum value data for axis 0 on device 2
Getting fuzz data for axis 1 on device 2
Getting absolute axes minimum value data for axis 1 on device 2
Getting absolute axes maximum value data for axis 1 on device 2
Getting fuzz data for axis 2 on device 2
Getting absolute axes minimum value data for axis 2 on device 2
Getting absolute axes maximum value data for axis 2 on device 2
Getting supported buttons for jinput device 2
Gettign device name for jinput device 3.
jinput device 3 is 165981536
EventDevice::getName()
Gettign device name for jinput device 3, (GreenAsia Electronics 4Axes 12Keys GamePad )
EventDevice::getName()
Gettign number of absolute axes for jinput device 3 (12)
Gettign number of relative axes for jinput device 3 (0)
Gettign number of buttons for jinput device 3 (24)
Getting bus type for device 3
Getting supported buttons for jinput device 3
Getting suported relative axes for jinput device 3
Getting suported absolute axes for jinput device 3
Getting fuzz data for axis 0 on device 3
Getting absolute axes minimum value data for axis 0 on device 3
Getting absolute axes maximum value data for axis 0 on device 3
Getting fuzz data for axis 1 on device 3
Getting absolute axes minimum value data for axis 1 on device 3
Getting absolute axes maximum value data for axis 1 on device 3
Getting fuzz data for axis 2 on device 3
Getting absolute axes minimum value data for axis 2 on device 3
Getting absolute axes maximum value data for axis 2 on device 3
Getting fuzz data for axis 3 on device 3
Getting absolute axes minimum value data for axis 3 on device 3
Getting absolute axes maximum value data for axis 3 on device 3
Getting fuzz data for axis 4 on device 3
Getting absolute axes minimum value data for axis 4 on device 3
Getting absolute axes maximum value data for axis 4 on device 3
Getting fuzz data for axis 5 on device 3
Getting absolute axes minimum value data for axis 5 on device 3
Getting absolute axes maximum value data for axis 5 on device 3
Getting fuzz data for axis 6 on device 3
Getting absolute axes minimum value data for axis 6 on device 3
Getting absolute axes maximum value data for axis 6 on device 3
Getting fuzz data for axis 7 on device 3
Getting absolute axes minimum value data for axis 7 on device 3
Getting absolute axes maximum value data for axis 7 on device 3
Getting supported buttons for jinput device 3
Gettign device name for jinput device 4.
jinput device 4 is 165983912
EventDevice::getName()
Gettign device name for jinput device 4, (Microsoft Microsoft Wireless Optical Mouse� 1.0A)
EventDevice::getName()
Gettign number of absolute axes for jinput device 4 (0)
Gettign number of relative axes for jinput device 4 (5)
Gettign number of buttons for jinput device 4 (5)
Getting bus type for device 4
Getting supported buttons for jinput device 4
Getting suported relative axes for jinput device 4
Getting suported absolute axes for jinput device 4
Getting supported buttons for jinput device 4
0 - AT Translated Set 2 keyboard (buttons)
1 - PS/2 Mouse (mouse)
2 - AlpsPS/2 ALPS GlidePoint (mouse)
3 - GreenAsia Electronics 4Axes 12Keys GamePad (gamepad)
4 - Microsoft Microsoft Wireless Optical Mouse® 1.0A (mouse)

Hi

There is an SDL driven plugin, but the distributed one goes right the the kernel.

What build of jinput are you using?, there are new ones (19th june) on jinput.dev.java.net in the files section. I’m sure the event 0x04 got fixed a while back. The newer builds also only need read access to the device files (unless you want ff effects). You will also not need to specify the plugin to use as it will use the native platform one by default.

The output you list at the bottom seems to indicate everything has gone fine.

Endolf

wow, newer version demos all work great without any tuning :slight_smile:
thanks, for telling me where to download it.

btw. is it possible that the api is incompatible with earlier version?
and it seems that the javadoc link is broken:
http://www.newdawnsoftware.com/resources/jinput_coreapi_javadoc.zip

Just updated the javadoc link.

Glad it all works out ok :slight_smile:

do all the devices work properly?

Endolf

unfortunately not,

I guess I was su(ed) while running java net.java.games.input.test.ControllerReadTest :frowning:
With the appropriate permissions, all controllers work well, even verticel scrooling with my mouse :slight_smile:
But the also list contains two devices, that I dont’ have (PS/2 mouse and AlpsPS/2 ALPS GlidePoint)

Device name for device file /dev/input/event0 is AT Translated Set 2 keyboard
Device name for device file /dev/input/event1 is PS/2 Mouse
Device name for device file /dev/input/event2 is AlpsPS/2 ALPS GlidePoint
Device name for device file /dev/input/event3 is GreenAsia Electronics 4Axes 12Keys GamePad
Device name for device file /dev/input/event4 is Microsoft Microsoft Wireless Optical Mouse� 1.0A

I noticed the follwing output:

Copied temp event device 0 to event device 0
Copied temp event device 1 to event device 1
Copied temp event device 2 to event device 2
Copied temp event device 3 to event device 3
Copied temp event device 4 to event device 4

What is done here ? This may be the reason why the devices can’t be listed without being in su mode.

Finally, I got antoher question:
Since the API has changed, I gues the ‘new’ linux and windows versions are incompatible with macosx version, right ?

best regards
-michael

got it :smiley:

The problem was that I only changed the permisions on /dev/input/js0 as mentioned before:

[quote]after chmod o+rwx /dev/input/js0 the joypad is initialized, but the number of available controllers is still 0:
(I didn’t use chmod for the other devices yet.)
[/quote]
As I told you it lists 1 joystick device but this isn’t accessible:

After taking a look at the source code (eventInterface.cpp), I found the reason:

if ((fd = open(deviceFileNames[0], O_RDONLY)) <0) {
    evNumDevices=0;
    evInited=1;
    return 0;
  }

No device is used if the first cannot be wirtten by ‘others’. Now I cahnged the permission of all files in /dev/input/ and everything works fine :slight_smile:

Thanks again
-michael