Fix joystick and gamepad library before jME 3.1 stable?

Hello,

I had a litte chat with the person who opened this thread: Thrustmaster Flight Hotas X - #3 by Empire_Phoenix
Yves said that he has a gamepad that runs perfectly fine under both jME TestJoystick and the jinput test here: Joystick in Java with JInput v2 | TheUzo007
In this jinput test his new joystick also works as expected, but in the jME TestJoystick it doesn’t work at all.

Seems like jME just needs a proper library version update and correct integration for jinput library (I think jME uses the same library - we would have to investigate this first).

Some two or more years ago I discovered that the force feedback integration doesn’t work correctly and that the jME joystick code doesn’t give the jME user correct access to all of the force feedback motors via the rumble() method. So it might be that the interface needs an update too (perhaps just a second method, and leave the old code to provide backwards compatibility - we would have to find out how much change to the core is needed).

Well, at this moment I don’t exactly know how to build the engine, make a proper update, change the interface, let other users test this, write a pull request and fix all this trouble - but I’m kind of willing to acquire the necessary skill set and investigate a little bit. I would be glad to get some help by others (e.g. someone who tells me how the jinput lib gets into the jME repository).

What do you think? Is it possible to fix the jinput integration before jME goes into its next stable release? :chimpanzee_laugh:

3 Likes

Regarding to force feedback, i remember reading some issues on linux since it requires additional privileges to run “write” to a device.

I am currently not at home, but if i remember correctly 3.1 does not use jinput at all.

Edit: After a quick check, jinput is indeed used for processing the joysticks.

1 Like

Well, that’s a nice info. So now we can give a little hint to Linux users in case of force feedback “not working”. :chimpanzee_smile:

Yes, there is a \lwjgl\jinput.jar in my old repo checkout. But that checkout is still subversion, so obsolete I guess…

It would require a not working joystick to track the issue down. Spot where this code fails:

and compare it with the jinput test…

Ah yes, I remember this piece of code. You can see there that the setRumble method simply goes into each motor and sets a value. A better interface would at least allow to specify which motor - and I should take a look at something (LWJGL docs, LWJGL example code) to find out how to do it correctly at all.

Yves has such a “not working joystick” and told me that he would be willing to test it with whatever we come up.

Somehow we also need to find out the actual version of the lib in jME. That’s what this statement was aiming for. Also, maybe there are some limitations (max version number etc.) or does jME just use the latest of LWJGL jinput?

Thrustmaster Flight Hotas X - not working

I can use it everywhere, but not in JME. I have a gamepad, which is working well, so i was confused.
I need good advice on what to do and then i check.
Here you can see my gamepad working, but i need this flightstick for better testing purpose, i am not the gamepad guy.

Btw. it’s an old video, it just showed, Yves can fly with gamepad his Viper MK II.

Ok, lets give it a try an see what can be done at least for the hotas issue.

If you have some time, could you check out and run

https://github.com/zzuegg/jinputtest

Then we see if the controller is recognized by jinput. Post the output here, or as issue. (I assumed you use a 64bit windows, and i have included only the natives for that)

@zuegg: Would it be intersetsting for you, if I would test it with a MS Sidewinder ForceFeedback Joystick? I could also test it with a MS Sidewinder ForceFeedback Wheel. But only if you are interested in the results.

Depends if the sidewinder is working with jme or not.
That would just be a first test, for devices working with the jinput test, but not with jme. AFAIK the hotas is one of those devices

I don’t know by now. I haven’t tested any of them with Java at all. Now I have no time for the test, but in 3 hours I’m back at home and will test it. Could be important in the future :smile: I will let you know what comes out.

2 Likes

Hmmm… something went wrong…

run:
WARNING: Found unknown Windows version: Windows 8
Attempting to use default windows plug-in.
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.Inputtest.main(Inputtest.java:13)
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.Inputtest.main(Inputtest.java:13)
BUILD SUCCESSFUL (total time: 0 seconds)

Just to keep it complete: I run Windows 8 64bit, the Joystick is connected via USB and is using the standard Windows driver. I’m using the 3.0 SDK, also 64bit.

Now the question: Should I install version 3.1 of the SDK to test the functionality (Maybe this fixes the error) or should I search for the missing libraries? In the properties-section I haven’t got any library which is called jinput or similar. Perhaps the jinput-stuff is packed in a jme-library?!

arr. the required dlls should be in the working directory. Probably depends how you / your ide launches the application… At least they show up in the repository.

I wanted to keep it simple and just made a new jme-project. I thought this could be the problem and changed to a standard-java-project but the result was the same. So far as I got you, I have to search for the jInput-library of lwjgl, am I right? Shouldn’t be that hard :wink: Just a few minutes…

EDIT: Ok, now I have added the jinput library to the project and gave it the right path to the natives, but still the same error. After that I added the complete lwjgl-library but the error-message remains. Do you have an shortcut for me? Like… just copy the dlls to this or that path and it should work?

EDIT2: I launch the application with the green play-button in the SDK.

EDIT3: Everything is ok now. I took the dlls from your GitHub-project and copied it to “C:\Program Files\jmonkeyplatform\jdk\jre\bin”.

The result with the MS Sidewinder Force Feedback 2:

WARNING: Found unknown Windows version: Windows 8
Attempting to use default windows plug-in.
Loading: net.java.games.input.DirectAndRawInputEnvironmentPlugin
**************************
HID-Tastatur
114
Keyboard
Unknown
0
Back
Tab
Return
Left Shift
Left Control
Left Alt
Pause
Caps Lock
Kana
Kana
Kana
Kanji
Kanji
Escape
Convert
 
Pg Up
Pg Down
End
Home
Left
Up
Right
Down
SysRq
Insert
Delete
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
Left Windows
Right Windows
Apps
Sleep
Num 0
Num 1
Num 2
Num 3
Num 4
Num 5
Num 6
Num 7
Num 8
Num 9
Multiply
Num +
Num ,
Num -
Num .
Num /
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
F13
F14
F15
Num Lock
Scroll Lock
Num =
Num =
Left Shift
Right Shift
Left Control
Right Control
Left Alt
Right Alt
,
.
~
[
]
Ax
**************************
HID-Tastatur
114
Keyboard
Unknown
0
Back
Tab
Return
Left Shift
Left Control
Left Alt
Pause
Caps Lock
Kana
Kana
Kana
Kanji
Kanji
Escape
Convert
 
Pg Up
Pg Down
End
Home
Left
Up
Right
Down
SysRq
Insert
Delete
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
Left Windows
Right Windows
Apps
Sleep
Num 0
Num 1
Num 2
Num 3
Num 4
Num 5
Num 6
Num 7
Num 8
Num 9
Multiply
Num +
Num ,
Num -
Num .
Num /
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
F13
F14
F15
Num Lock
Scroll Lock
Num =
Num =
Left Shift
Right Shift
Left Control
Right Control
Left Alt
Right Alt
,
.
~
[
]
Ax
**************************
HID-Tastatur
114
Keyboard
Unknown
0
Back
Tab
Return
Left Shift
Left Control
Left Alt
Pause
Caps Lock
Kana
Kana
Kana
Kanji
Kanji
Escape
Convert
 
Pg Up
Pg Down
End
Home
Left
Up
Right
Down
SysRq
Insert
Delete
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
Left Windows
Right Windows
Apps
Sleep
Num 0
Num 1
Num 2
Num 3
Num 4
Num 5
Num 6
Num 7
Num 8
Num 9
Multiply
Num +
Num ,
Num -
Num .
Num /
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
F13
F14
F15
Num Lock
Scroll Lock
Num =
Num =
Left Shift
Right Shift
Left Control
Right Control
Left Alt
Right Alt
,
.
~
[
]
Ax
**************************
HID-Tastatur
114
Keyboard
Unknown
0
Back
Tab
Return
Left Shift
Left Control
Left Alt
Pause
Caps Lock
Kana
Kana
Kana
Kanji
Kanji
Escape
Convert
 
Pg Up
Pg Down
End
Home
Left
Up
Right
Down
SysRq
Insert
Delete
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
Left Windows
Right Windows
Apps
Sleep
Num 0
Num 1
Num 2
Num 3
Num 4
Num 5
Num 6
Num 7
Num 8
Num 9
Multiply
Num +
Num ,
Num -
Num .
Num /
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
F13
F14
F15
Num Lock
Scroll Lock
Num =
Num =
Left Shift
Right Shift
Left Control
Right Control
Left Alt
Right Alt
,
.
~
[
]
Ax
**************************
HID-konforme Maus
19
Mouse
Unknown
0
x
y
z
Left
Right
Middle
3
4
5
6
7
8
9
10
11
12
13
14
15
**************************
HID-konforme Maus
11
Mouse
Unknown
0
x
y
z
Left
Right
Middle
3
4
5
6
7
**************************
G15 Gaming Keyboard
0
Unknown
Unknown
0
**************************
G15 GamePanel LCD
0
Unknown
Unknown
0
**************************
Gaming Mouse G502
31
Unknown
Unknown
0
Steuerungsgerät
Numerischer Tastenblock
Taste 2
Taste 3
Taste 4
Taste 5
Taste 6
Taste 7
Taste 8
Taste 9
Taste 10
Taste 11
Taste 12
Taste 13
Taste 14
Taste 15
Taste 16
Taste 17
Taste 18
Taste 19
Taste 20
Taste 21
Taste 22
Taste 23
Taste 24
Taste 25
Taste 26
Taste 27
Taste 28
Taste 29
Taste 30
**************************
Gaming Mouse G502
3
Unknown
Unknown
0
Systemenergiesparmodus
Systemstromversorgung
Systemaktivierung
**************************
Gaming Mouse G502
0
Unknown
Unknown
0
**************************
Gaming Mouse G502
0
Unknown
Unknown
0
**************************
G15 Gaming Keyboard
7
Unknown
Unknown
0
Lautstärkeabnahme
Lautstärkezunahme
Ton aus
Wiedergabe/Pause
Stopp
Vorherige Spur scannen
Nächste Spur scannen
**************************
SideWinder Force Feedback 2 Joystick
13
Stick
Unknown
0
X-Achse
Y-Achse
Z-Rotation
Schieberegler
Mehrwegeschalter
Taste 0
Taste 1
Taste 2
Taste 3
Taste 4
Taste 5
Taste 6
Taste 7

Now the Wheel… just a few minutes…

run:
WARNING: Found unknown Windows version: Windows 8
Attempting to use default windows plug-in.
Loading: net.java.games.input.DirectAndRawInputEnvironmentPlugin
**************************
HID-Tastatur
114
Keyboard
Unknown
0
Back
Tab
Return
Left Shift
Left Control
Left Alt
Pause
Caps Lock
Kana
Kana
Kana
Kanji
Kanji
Escape
Convert
 
Pg Up
Pg Down
End
Home
Left
Up
Right
Down
SysRq
Insert
Delete
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
Left Windows
Right Windows
Apps
Sleep
Num 0
Num 1
Num 2
Num 3
Num 4
Num 5
Num 6
Num 7
Num 8
Num 9
Multiply
Num +
Num ,
Num -
Num .
Num /
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
F13
F14
F15
Num Lock
Scroll Lock
Num =
Num =
Left Shift
Right Shift
Left Control
Right Control
Left Alt
Right Alt
,
.
~
[
]
Ax
**************************
HID-Tastatur
114
Keyboard
Unknown
0
Back
Tab
Return
Left Shift
Left Control
Left Alt
Pause
Caps Lock
Kana
Kana
Kana
Kanji
Kanji
Escape
Convert
 
Pg Up
Pg Down
End
Home
Left
Up
Right
Down
SysRq
Insert
Delete
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
Left Windows
Right Windows
Apps
Sleep
Num 0
Num 1
Num 2
Num 3
Num 4
Num 5
Num 6
Num 7
Num 8
Num 9
Multiply
Num +
Num ,
Num -
Num .
Num /
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
F13
F14
F15
Num Lock
Scroll Lock
Num =
Num =
Left Shift
Right Shift
Left Control
Right Control
Left Alt
Right Alt
,
.
~
[
]
Ax
**************************
HID-Tastatur
114
Keyboard
Unknown
0
Back
Tab
Return
Left Shift
Left Control
Left Alt
Pause
Caps Lock
Kana
Kana
Kana
Kanji
Kanji
Escape
Convert
 
Pg Up
Pg Down
End
Home
Left
Up
Right
Down
SysRq
Insert
Delete
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
Left Windows
Right Windows
Apps
Sleep
Num 0
Num 1
Num 2
Num 3
Num 4
Num 5
Num 6
Num 7
Num 8
Num 9
Multiply
Num +
Num ,
Num -
Num .
Num /
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
F13
F14
F15
Num Lock
Scroll Lock
Num =
Num =
Left Shift
Right Shift
Left Control
Right Control
Left Alt
Right Alt
,
.
~
[
]
Ax
**************************
HID-Tastatur
114
Keyboard
Unknown
0
Back
Tab
Return
Left Shift
Left Control
Left Alt
Pause
Caps Lock
Kana
Kana
Kana
Kanji
Kanji
Escape
Convert
 
Pg Up
Pg Down
End
Home
Left
Up
Right
Down
SysRq
Insert
Delete
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
Left Windows
Right Windows
Apps
Sleep
Num 0
Num 1
Num 2
Num 3
Num 4
Num 5
Num 6
Num 7
Num 8
Num 9
Multiply
Num +
Num ,
Num -
Num .
Num /
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
F13
F14
F15
Num Lock
Scroll Lock
Num =
Num =
Left Shift
Right Shift
Left Control
Right Control
Left Alt
Right Alt
,
.
~
[
]
Ax
**************************
HID-konforme Maus
19
Mouse
Unknown
0
x
y
z
Left
Right
Middle
3
4
5
6
7
8
9
10
11
12
13
14
15
**************************
HID-konforme Maus
11
Mouse
Unknown
0
x
y
z
Left
Right
Middle
3
4
5
6
7
**************************
G15 Gaming Keyboard
0
Unknown
Unknown
0
**************************
G15 GamePanel LCD
0
Unknown
Unknown
0
**************************
Gaming Mouse G502
31
Unknown
Unknown
0
Steuerungsgerät
Numerischer Tastenblock
Taste 2
Taste 3
Taste 4
Taste 5
Taste 6
Taste 7
Taste 8
Taste 9
Taste 10
Taste 11
Taste 12
Taste 13
Taste 14
Taste 15
Taste 16
Taste 17
Taste 18
Taste 19
Taste 20
Taste 21
Taste 22
Taste 23
Taste 24
Taste 25
Taste 26
Taste 27
Taste 28
Taste 29
Taste 30
**************************
Gaming Mouse G502
3
Unknown
Unknown
0
Systemenergiesparmodus
Systemstromversorgung
Systemaktivierung
**************************
Gaming Mouse G502
0
Unknown
Unknown
0
**************************
Gaming Mouse G502
0
Unknown
Unknown
0
**************************
G15 Gaming Keyboard
7
Unknown
Unknown
0
Lautstärkeabnahme
Lautstärkezunahme
Ton aus
Wiedergabe/Pause
Stopp
Vorherige Spur scannen
Nächste Spur scannen
**************************
SideWinder Force Feedback Wheel (USB)
11
Stick
Unknown
0
X-Achse
Y-Achse
Z-Rotation
Taste 0
Taste 1
Taste 2
Taste 3
Taste 4
Taste 5
Taste 6
Taste 7

The wheel was also tested with the Windows8-driver.

I further tested both with the TestJoystick.class from the jmeTest and I sadly have to tell you, that lwjgl seems to have a problem with them. I got this error-message:

Error in application

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

I think that means that these two devices are not working with jme.

What the console says about it…

Okt 22, 2015 7:55:47 PM com.jme3.app.Application handleError
Schwerwiegend: 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)

EDIT: I just found out, that it is NOT a jme-problem. Has to be something in lwjgl that doesn’t work as suspected.

That is good because that’s a thing we can start working on. I guess zzuegg’s Test uses a newer Version of jinput and they solved some things internally.

Now the only question is if this Upgrade is a drop in replacement or not.

If it would help you with debugging, I could test a wii-controller tomorrow. I don’t know if they work out-of-the-box, but if not, there is a nice tool called GlovePie Maybe this could emulate the controller to something like an joystick. I don’t know if the results are interesting for you, so please tell me. I don’t want to test it without any sense :smile:

OT: GlovePie isn’t the most elegant way to reach inputs, but in some cases the easiest :wink: Years ago I made a “laser-pointer” with the wii-controller. Not really a laser… something to shove the cursor around on an presentation. Sure, not the best solution, but it worked and was cheap :wink:

Actually that is a best case result, since i use the library from jme, as well as jme’s lwjgl-natives. Its already late, and i am quite busy over the weekend, but i am going to investiage the issue

If there is any way I might help you, feel free to ask. I’m not very experienced in lwjgl, but I have enough spare-time to check such things like e.g.: “Could you please install a vm with linux xy to test the joystick in another environment.”

A quick test shows there is some error in the jme’s testchooser. As it does not use the Test’s main to launch the test, the Test’s settings are not used. As a result, use joysticks is set to false

3 Likes

Now, that should be the solution! I’ve always tried the JostickTest via the TestChooser and it wasn’t working. Now that I’ve started the JoystickTest directly, it works at least for the joystick. I haven’t tested the wheel by now, but I’m confindent that it works too.

Btw. I deleted the two dll-files which I included from your repo and the JoystickTest works, too.

Just a part of the console:

Button:0 state:0
Button:1 state:0
Button:2 state:0
Button:3 state:0
Button:4 state:0
Button:5 state:0
Button:6 state:0
Button:7 state:0
Button:8 state:0
Button:9 state:0
Button:10 state:0
Button:11 state:0
Button:POV +Y state:0
Button:POV +X state:0
Button:POV -Y state:0
Button:POV -X state:0
Axis:X-Achse=-0.2636912
Axis:Y-Achse=0.15294123
Axis:Schieberegler=-0.10939193
Axis:X-Achse=-0.2656443
Axis:X-Achse=-0.2636912
Axis:X-Achse=-0.2656443
Axis:X-Achse=-0.2636912
Axis:X-Achse=-0.2656443
Axis:Y-Achse=0.14509809
Axis:Y-Achse=0.13334858
Axis:Y-Achse=0.119615436
Axis:Y-Achse=0.09803927
Axis:Y-Achse=0.06666672
Axis:Y-Achse=0.029434681
Axis:Y-Achse=0.0019683838
Axis:Y-Achse=-1.5258789E-5
Axis:Y-Achse=-0.0019684434
Axis:Y-Achse=-0.021499991
Axis:Y-Achse=-0.042984664
Axis:Y-Achse=-0.058609903
Axis:Y-Achse=-0.07423514
Axis:Y-Achse=-0.08595407
Axis:Y-Achse=-0.09376669