JInput and Linux

At the moment, I’m trying JInput in my engine and game under Linux (Mandriva Spring 2007).
Everything works fine as long as I manually change the permission for /dev/input/* (Mandriva does not allow neither read nor write).
I do not consider asking the user to change it’s computer configuration as a suitable solution for deployment.
Are there any other alternative ?

I was thinking of things like ;

  • a plugin that would rely on SDL (as I heard, SDL seems to handle the permission problem),
  • a plugin that would rely on one of X11 / AWT / SWT
  • a way to dynamically select the choosen plugin ; i.e. a way for the game to select the plugin based on the the capability of the running platform (for example ; Linux Kernel plugin reports no controller, AWT reports mouse/keyboard only, SWT reports plugin not available due to missing SWT library, SDL reports joystick/mouse/keyboard then select SDL plugin).
  • another existing library that could serve as a backup when the running system is not properly configured for JInput.

In short, I would like running my game under Linux to be as easy as running it under Windows.

Any suggestion would be welcomed !

Thanks

               Vincent

Hi

If you want easy, use windows

No, really, I hate myself for saying it, but if you want something that ‘just work’s’, then it’s not linux. Nore Vista for that matter :).

You could do a plugin that wraps other plugins, assign priorities, and then pick it, but it’s not currently there. There is an SDL plugin around, but I’ve no idea how up to date it is. There is an AWT plugin, but obviously thats only mouse and keyboard. You can add the AWT plugin so it’s always there, but you will then get mouse and keyboard devices twice if other plugins are working. You could parse the controller names so you know if it’s an AWT device though.

Even Ubuntu, does not provide even read access to /dev/input/event* devices by default, so system config needs to be changed to read them directly.

If you wish to do an X or SWT plugin, feel free :slight_smile:

Right now though, most users running linux, are capable of changing a few permissions. It’s a pain, but unfortunatly, thems the breaks.

I’m not sure what oddlabs do about this? Elias?

Certainly needs some further thought.

Endolf

I have so little time and my TODO list is so huge that I don’t think I can seriously offer to work on a new plugin.
I moved to Linux recently (Vista is really too expensive) and, if the general feeling is great, I’m sad to say that developping under Linux is fairly harder…
Perhaps I will have to go back to Windows when I will have stopped my mourning against Microsoft…

Anyway, thanks for the fast answer. I will only detect the permission problem and give an information message explaining how to set up the permission right.
When I will have finished the more urgent tasks I have, perhaps I will get back on the subject (who knows…).

Thanks

Yeah, I think thas the best option for now.

Endolf

Hi, ;D

I have the same problem, i tried use the KeyListener, but this don’t work well at Linux :(. So, i tried use the JInput and I has the problem with permissions. :’(

So… this is very old topic. Has anything new?

Is the best way tell to user “Change your permissions” ?

Sorry to bad english. :slight_smile:

Tankyou :stuck_out_tongue:

No worries, it’s good enough to understand the question :slight_smile:

Unfortunatly nothing has changed, I don’t think it’s something that is likely to either I’m afraid. There is the option of adding the AWT plugin in, this only handles system mouse and keyboard, so no multple device support, and no joysticks etc, but it doesn’t require any permission changes.

HTH

Endolf

A very good howto to setup these permissions can be found here : http://gizmod.wiki.sourceforge.net/HOWTO+-+Setting+Input+Device+Permissions+-+Creating+a+udev+Rule

[quote]No worries, it’s good enough to understand the question
[/quote]
Thanks =)

[quote]There is the option of adding the AWT plugin in, this only handles system mouse and keyboard, so no multple device support, and no joysticks etc.
[/quote]
With this can I use the mouse and keybord at same time ? My linux keylistener return aways this:

KEYPRESSED
KEYRELEASED
KEYPRESSED
KEYRELEASED
KEYPRESSED
KEYRELEASED

on windows( >:() it returns (WHY GOD?)

KEYPRESSED

KEYRELEASED

with this can I fix the repeat problem ? I wrote a Timed Key Listener, on my Desk Pc Work fine but on my Laptop(core DUO) did’nt.

If it works. you know a example ?

Tankyou endolf

Hi

If you specify -Djinput.plugins=net.java.games.input.AWTEnvironmentPlugin JInput will load the AWT plugin, you don’t call it directly, it shows up like any other controller. It supports mouse and keyboard. It uses AWT events underneath, so it doesn’t support multiple keyboards and mice (multiple mice will both move the pointer, but AWT doesn’t know which one is doing it).

HTH

Endolf

Endolf, tankyou for help.

Sorry to the noob question, but where I set this plugin?. Tankyou.

If your running from the command line, it’s just another command line arg, just like the library path. If your running in an IDE, it’s a VM argument.

HTH

Endolf

I put " -Djinput.plugins=net.java.games.input.AWTEnvironmentPlugin " in my run configurations/ Arguments (eclipse) and I run this code:


public class ControllerManager {

	public static void main(String[] args) {
		ControllerEnvironment controllerEnvironment = ControllerEnvironment
				.getDefaultEnvironment();
		Controller[] aController = controllerEnvironment.getControllers();
		for (int iController = 0; iController < aController.length; iController++) {
			Controller controller = aController[iController];
			System.out.println(controller.getType());
		}
	}

}

and i’ve this output


Loading: net.java.games.input.AWTEnvironmentPlugin
Loading: net.java.games.input.LinuxEnvironmentPlugin
Failed to open device (/dev/input/event5): Failed to open device /dev/input/event5 (13)

Failed to open device (/dev/input/event3): Failed to open device /dev/input/event3 (13)

Failed to open device (/dev/input/event1): Failed to open device /dev/input/event1 (13)

Failed to open device (/dev/input/event0): Failed to open device /dev/input/event0 (13)

Linux plugin claims to have found 2 controllers
Keyboard
Mouse
Mouse
Mouse

So… I’ve a keyboard and mouse =~~~ and I don’t change any permission =)

Now I Want test if it really work. But i don’t found a good tutorial about Keyboard + JInput :-\

Someone can help ? ;D