Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Failed to open device /dev/input/js0  (Read 2044 times)
0 Members and 1 Guest are viewing this topic.
Offline zero

Junior Member





« Posted 2005-06-22 02:15:38 »

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 Smiley
Offline Jeff

JGO Coder




Got any cats?


« Reply #1 - Posted 2005-06-22 06:29:55 »

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.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline zero

Junior Member





« Reply #2 - Posted 2005-06-22 15:47:40 »

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 ?)


 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)



Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline endolf

JGO Knight


Medals: 7
Projects: 1


Current project release date: sometime in 3003


« Reply #3 - Posted 2005-06-22 17:59:02 »

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

Offline zero

Junior Member





« Reply #4 - Posted 2005-06-22 22:00:40 »

wow, newer version demos all work great without any tuning Smiley
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
Offline endolf

JGO Knight


Medals: 7
Projects: 1


Current project release date: sometime in 3003


« Reply #5 - Posted 2005-06-24 09:23:18 »

Just updated the javadoc link.

Glad it all works out ok Smiley

do all the devices work properly?

Endolf

Offline zero

Junior Member





« Reply #6 - Posted 2005-06-24 12:19:57 »

unfortunately not,

I guess I was su(ed)  while running java net.java.games.input.test.ControllerReadTest Sad
With the appropriate permissions, all controllers work well, even verticel scrooling with my mouse Smiley
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
Offline zero

Junior Member





« Reply #7 - Posted 2005-06-24 15:59:11 »

got it Cheesy

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.)

As I told you it lists 1 joystick device but this isn't accessible:

Quote
Getting the number of joystick devices
Getting 1 joystick devices
The provided index is out of range.
Use a value between 0 and -1


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

1  
2  
3  
4  
5  
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 Smiley

Thanks again
 -michael
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (64 views)
2014-04-15 18:08:23

BurntPizza (62 views)
2014-04-15 03:46:01

UprightPath (75 views)
2014-04-14 17:39:50

UprightPath (58 views)
2014-04-14 17:35:47

Porlus (76 views)
2014-04-14 15:48:38

tom_mai78101 (101 views)
2014-04-10 04:04:31

BurntPizza (161 views)
2014-04-08 23:06:04

tom_mai78101 (256 views)
2014-04-05 13:34:39

trollwarrior1 (209 views)
2014-04-04 12:06:45

CJLetsGame (216 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!