jme3test.input.TestJoystick IllegalStateException

When I run the TestJoystick test I got the error:

Uncaught exception thrown in Thread[LWJGL Render Thread,6,main]
IllegalStateException: Cannot find any joysticks!

I am sure I have Joystick attached, no problem with games.

Windows Vista Ultimate 64-bit
Logitech Gamepad F710 and XBOX 360 wireless gamepad

Can you post the whole exception?

Here is the output

Uncaught exception thrown in Thread[LWJGL Renderer Thread,6,main]
java.lang.IllegalStateException: Cannot find any joysticks!
at jme3test.input.TestJoystick.simpleInitApp(TestJoystick.java:49)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:226)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:744)

Thanks… I just wanted to be sure.

For whatever reason, Joysticks are not being detected on your system. This is down at the JInput level and not really something we have direct control over. We asked JInput for a list of joysticks and it returned: none

@pspeed said: We asked JInput for a list of joysticks and it returned: none

JInput does not support joystick??! :-o

The is the end of my evaluation of jMonkeyEngine. :facepalm:

I found a similar issue here

http://hub.jmonkeyengine.org/forum/topic/cannot-find-any-joysticks/

But I can’t figure out how to fix it. Is it a bug?

@limwerks said: JInput does not support joystick??! :-o

The is the end of my evaluation of jMonkeyEngine. :facepalm:

I didn’t say that. I said it’s not detecting joysticks on YOUR system. I’ve used 10 different joysticks on my system… sometimes at the same time. It even detects the arrow pads on my drawing tablet.

I have no idea why it won’t detect joysticks on YOUR system, though.

@limwerks said: I found a similar issue here

http://hub.jmonkeyengine.org/forum/topic/cannot-find-any-joysticks/

But I can’t figure out how to fix it. Is it a bug?

That thread is really old but looks like ultimately joystick support wasn’t being turned on in his app. The joystick test specifically does turn it on, though.

As a test to see if your gamepads are there and just being detected strangely by JInput, you could run some JInput using code directly:
[java]
ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
Controller cs = ce.getControllers();
[/java]

And then see what’s in that array. JME skips anything reported as a keyboard or a mouse. It also skips anything with no axes… but will log that at FINE level.

I have this problem too with Windows 8 Pro 64 bit and a Logitech F510 gamepad.

I will try the JInput code too.

I add the following lines to the BasicGame project:

[java]
import net.java.games.input.*;

public static void main(String args) {
Main app = new Main();
app.start();
ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
Controller cs = ce.getControllers();
}
[/java]

Then I got the following error in output window:

Loading: net.java.games.input.DirectAndRawInputEnvironmentPlugin java.lang.UnsatisfiedLinkError: no jinput-dx8_64 in java.library.path net.java.games.input.DirectAndRawInputEnvironmentPlugin is not supported at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886) at java.lang.Runtime.loadLibrary0(Runtime.java:849) at java.lang.System.loadLibrary(System.java:1088) at net.java.games.input.DirectInputEnvironmentPlugin$1.run(DirectInputEnvironmentPlugin.java:75) at java.security.AccessController.doPrivileged(Native Method) at net.java.games.input.DirectInputEnvironmentPlugin.loadLibrary(DirectInputEnvironmentPlugin.java:67) at net.java.games.input.DirectInputEnvironmentPlugin.<clinit>(DirectInputEnvironmentPlugin.java:109) at net.java.games.input.DirectAndRawInputEnvironmentPlugin.<init>(DirectAndRawInputEnvironmentPlugin.java:45) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at java.lang.Class.newInstance(Class.java:374) at net.java.games.input.DefaultControllerEnvironment.getControllers(DefaultControllerEnvironment.java:157) at mygame.Main.main(Main.java:22) java.lang.UnsatisfiedLinkError: no jinput-raw_64 in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886) at java.lang.Runtime.loadLibrary0(Runtime.java:849) at java.lang.System.loadLibrary(System.java:1088) at net.java.games.input.RawInputEnvironmentPlugin$1.run(RawInputEnvironmentPlugin.java:75) at java.security.AccessController.doPrivileged(Native Method) at net.java.games.input.RawInputEnvironmentPlugin.loadLibrary(RawInputEnvironmentPlugin.java:67) at net.java.games.input.RawInputEnvironmentPlugin.<clinit>(RawInputEnvironmentPlugin.java:109) at net.java.games.input.DirectAndRawInputEnvironmentPlugin.<init>(DirectAndRawInputEnvironmentPlugin.java:46) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at java.lang.Class.newInstance(Class.java:374) at net.java.games.input.DefaultControllerEnvironment.getControllers(DefaultControllerEnvironment.java:157) at mygame.Main.main(Main.java:22)

I wonder what cause the error “no jinput-dx8_64 in java.library.path” and “no jinput-raw_64 in java.library.path”, may the environment or sdk setting problem?

You can’t do that in main. You would have to do that in simpleInit() or something. A lot of the stuff hasn’t been setup properly until simpleInit() is called… including extracting the native libraries.

1 Like

I tried put in SimpleInitApp and main but the result is same. I guess something missing in the SDK on 64-bit system.

Just weird that the joystick test didn’t give you a similar error somewhere.

I google and try to extract the dll from jME3-lwjgl-natives.jar to a folder, then add the folder in Project Properties->Run->VM Options:

"-Djava.library.path=“C:\Program Files\jmonkeyplatform\jmonkeyplatform\libs\jME3-lwjgl-natives\windows”

No exception in BasicGame.

Then I add the same setting to JmeTests, but I still got the dll not found in TestChooser.

Then I run the TestJoystick.java file directly, this time the program detect my joystick. I run the TestChooser again and works, it works even I remove the VM Options:

I delete the JmeTests project and folders, recreate a new JmeTests project, this time the SDK automatically extract the jinput-dx8_64.dll and jinput-raw_64.dll in the project root folder. It can detect my joystick.

I think there is a bug in jMonkeyEngine SDK.

@Vortex said: I have this problem too with Windows 8 Pro 64 bit and a Logitech F510 gamepad.

I will try the JInput code too.

The workaround is extract the required dll manually.

C:\Program Files\jmonkeyplatform\jmonkeyplatform\libs\jME3-lwjgl-natives.jar

Open the jar archive, I use 7zip, in the native\windows folder, you can find the jinput dlls, extract the dll to your project root folder, your program can detect joystick now.

It is strange that other native dll like lwjgl and OpenAL are extracted by the SDK but not jinput, which contain in the same archive. This is very confusing for new user.

1 Like

Especially since for everyone else it seems to work ok. This is what I get just by running my apps:
jinput-dx8.dll
jinput-raw.dll
lwjgl.dll
OpenAL32.dll

…perhaps it is a 64 bit specific issue?

I am not sure, I don’t have 32-bit OS for test.

I tested on Windows Vista 64-bit and Windows 8.1 Pro 64-bit.

For fresh SDK installation, a project require joystick will not run because missing jinput dlls.

But after doing the workaround (extract the dll manually once), every new project require joystick will have the proper dll in project root folder. Very strange.

1 Like

@pspeed : I also have 64 bit Windows and it also doesn’t work on my system.
@limwerks : Thanks for the solution. I’m going to try it out when I have time.

It works now with a standalone sample and in my game.

I think it only doesn’t work from the JmeTests for some reason, but I’m not sure.

I have also fiddled around with library paths and copying DLL’s.

Thanks for the help.

@limwerks @pspeed
After some time, I think I know what fixed the problem.
I added a . by the working directory in the project properties.
After that the program found the DLL’s.
Then I removed the . and than it still worked.
I looks like the program has to find the DLL’s once and than it works everytime.
Hopefully this is useful for anyone.