JInput borked on linux!

Started by javalwjgl1, October 28, 2005, 01:45:40

Previous topic - Next topic

javalwjgl1

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

Endolf

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

kappa

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

Endolf

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

Endolf

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

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", 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!

elias

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

- elias

elias

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

Anonymous

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

Anonymous

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

elias

You probably know it, but the memory is not freed in any of the error paths... (oh the joy of C memory management).

- elias

princec

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

Anonymous

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

princec

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