LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: javalwjgl1 on October 28, 2005, 01:45:40

Title: JInput borked on linux!
Post by: javalwjgl1 on October 28, 2005, 01:45:40
joypad is not detected on linux!

i have tried a usb joypad, which works and is detected on mame, GXMame(a gtk front end), gunroar(uses sdl, i think), the joypad is detected fine and runs perfectly on these. mame looks at "/dev/js".

however with lwjgl the controller is just not detected, i have tried with the controller demo on the lwjgl demo page and with kevglass's tempest game both detect 0 controllers!

thanks
Title: LWJGL Joystick issues
Post by: Endolf on October 28, 2005, 17:21:29
2 things

JInput looks in /dev/input for all it's device nodes, try creating a sym link to check.

I'm currently looking at solutions so it checks both places.

Also, try enabling the event interface nodes in your kernel config, this will allow jinput to get some extra information, and also, if your joypad is rumble enabled, then you'll only get it if the event interface is enabled.

HTH

Endolf
Title: LWJGL Joystick issues
Post by: kappa on October 28, 2005, 21:26:23
thx for your reply, funny enough when i look in /dev/input with the joypad connected, i can see js0, js1, js2, js3 in there

also maybe this might help, have a look how its done in the game gunroar http://www.emhsoft.net/gunroar/ as that works very nice with the joypad
Title: LWJGL Joystick issues
Post by: Endolf on October 28, 2005, 21:48:02
Hi

Sounds like it's a different issue. Javaws should have some debug from the jinput side of things that LWJGL wraps. If you can dig them out I can take a look.

Endolf
Title: LWJGL Joystick issues
Post by: Endolf on October 29, 2005, 10:04:02
Hi

Can you also confirm where (if you have them) you event* devices are, should be /dev/input/event* or maybe (and thats what I want to check) in /dev/event*

Cheers

Endolf
Title: LWJGL Joystick issues
Post by: Anonymous on October 29, 2005, 14:41:53
ok i've done a few test and i've come across using "cat /dev/input/js0"

that the location of the controller is indeed at "/dev/input/js0", i've tried it with gxmame and runs fine without any root permission and stuff.

i've tried symlinking it to "/dev/input/js" but it still doesn't find it, i've had a look at the jinput source to see where it looks (i don't know c) but from what i could gather thats the place it looks
https://jinput.dev.java.net/source/browse/jinput/plugins/linux/src/native/joystickInterface.cpp?rev=1.3&view=markup

also i tried a few sdl games and they work perfectly and detect the joypad every time, from what i could gather from the sdl linux native source it actually looks in 3 places


/* The base path of the joystick devices */
const char *joydev_pattern[] = {
#ifdef USE_INPUT_EVENTS
"/dev/input/event%d",
#endif
"/dev/input/js%d",
"/dev/js%d"
};

http://www.libsdl.org/cgi/cvsweb.cgi/SDL12/src/joystick/linux/SDL_sysjoystick.c?rev=1.12.2.2&content-type=text/x-cvsweb-markup

also there is no file called "/dev/input/js" or at "dev/js" only files like js0, js1, js2 etc


also i've seen if any logs are dropped by jinput but i can only see that it says 0 controllers found!
Title: LWJGL Joystick issues
Post by: elias on October 29, 2005, 14:52:08
A completely off topic note: it seems that jsInit() is leaking memory, since the memory allocated by jsGetDeviceFiles is never free()ed.

- elias
Title: LWJGL Joystick issues
Post by: elias on October 29, 2005, 14:56:20
This also seems wrong:


 numDeviceFiles = jsGetDeviceFiles(&deviceFileNames);
 if(numDeviceFiles<0) {
   return -1;
 }

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


when numDeviceFiles == 0, jinput still accesses deviceFileNames[0], which is bad. Maybe the check should be if (numDeviceFiles <= 0) {...

- elias
Title: LWJGL Joystick issues
Post by: Anonymous on October 30, 2005, 20:42:45
Quote from: "Anonymous"ok i've done a few test and i've come across using "cat /dev/input/js0"

that the location of the controller is indeed at "/dev/input/js0"


Right, thats the place it already looks


/* The base path of the joystick devices */
const char *joydev_pattern[] = {
#ifdef USE_INPUT_EVENTS
"/dev/input/event%d",
#endif
"/dev/input/js%d",
"/dev/js%d"
};


Right, /dev/input/event* is the event interface device nodes, they are looked at by the event interface parts of jinput, the /dev/input/js* and /dev/js* are joystick interface device nodes.

QuoteA completely off topic note: it seems that jsInit() is leaking memory, since the memory allocated by jsGetDeviceFiles is never free()ed.

yeah, well spotted, a few bytes each time the system starts up and that the OS should clear when it's gone. It does need fixing though :).

Quotewhen numDeviceFiles == 0, jinput still accesses deviceFileNames[0]

Aye :)

Endolf
Title: LWJGL Joystick issues
Post by: Anonymous on October 30, 2005, 21:57:50
Updates done but not yet tested for checking /dev after /dev/input

First attempt at freeing some of the memory from the init processes

No longer read the 0th element if no device files are found.

Endolf
Title: LWJGL Joystick issues
Post by: elias on October 31, 2005, 05:39:54
You probably know it, but the memory is not freed in any of the error paths... (oh the joy of C memory management).

- elias
Title: LWJGL Joystick issues
Post by: princec on October 31, 2005, 18:02:50
Fortunately it's very very little memory so that's a lower priority than getting Controller to create properly after Display is created without clobbering keyboard and mouse ;)

Cas :)
Title: LWJGL Joystick issues
Post by: Anonymous on October 31, 2005, 20:29:25
Erg, not knowing lwjgl all that well, is that a lwjgl issue, or a jinput lwjgl interaction issue? i.e. is it my fault? :)

Endolf
Title: LWJGL Joystick issues
Post by: princec on October 31, 2005, 21:11:40
This should help you diagnose it: if you create the Display first, which in LWJGL automatically creates the mouse and keyboard, and then create the Controllers, mouse and keyboard input stops working on Win32 until you alt-tab off the game and back again, and then all is well.

The workaround for now is just to do Controllers.create() before Display.create(), and all is well.

Cas :)