Joysticks detected with wrong logicalId on Linux

i have a question about the Joystick test/example.
Only pov buttons are highlighted when hit.

replacing the line jmonkeyengine/TestJoystick.java at master · jMonkeyEngine/jmonkeyengine · GitHub

- gamepad.setButtonValue( evt.getButton(), evt.isPressed() );
+ gamepad.setButtonValue( ""+evt.getButton().getButtonId(), evt.isPressed() ); 

resolved the highlight problem.

I just want to know if it’s really a issue or if there is a good reason for calling setButtonValue( evt.getButton(), evt.isPressed() ); ?

Well, one calls the method that takes a button and the other calls the method that takes a string that the other method calls. You also bypass the system.out.println call.

What is getLogicalId() in this case? This code used to work.

the logicalId is the same as the button name
joystick dump :

Joystick[0]:DragonRise Inc.   Generic   USB  Joystick  
  buttons:12
   JoystickButton[name=Trigger, parent=DragonRise Inc.   Generic   USB  Joystick  , id=0, logicalId=Trigger]
   JoystickButton[name=Thumb, parent=DragonRise Inc.   Generic   USB  Joystick  , id=1, logicalId=Thumb]
   JoystickButton[name=Thumb 2, parent=DragonRise Inc.   Generic   USB  Joystick  , id=2, logicalId=Thumb 2]
   JoystickButton[name=Top, parent=DragonRise Inc.   Generic   USB  Joystick  , id=3, logicalId=Top]
   JoystickButton[name=Top 2, parent=DragonRise Inc.   Generic   USB  Joystick  , id=4, logicalId=Top 2]
   JoystickButton[name=Pinkie, parent=DragonRise Inc.   Generic   USB  Joystick  , id=5, logicalId=Pinkie]
   JoystickButton[name=Base, parent=DragonRise Inc.   Generic   USB  Joystick  , id=6, logicalId=Base]
   JoystickButton[name=Base 2, parent=DragonRise Inc.   Generic   USB  Joystick  , id=7, logicalId=Base 2]
   JoystickButton[name=Base 3, parent=DragonRise Inc.   Generic   USB  Joystick  , id=8, logicalId=Base 3]
   JoystickButton[name=Base 4, parent=DragonRise Inc.   Generic   USB  Joystick  , id=9, logicalId=Base 4]
   JoystickButton[name=Base 5, parent=DragonRise Inc.   Generic   USB  Joystick  , id=10, logicalId=Base 5]
   JoystickButton[name=Base 6, parent=DragonRise Inc.   Generic   USB  Joystick  , id=11, logicalId=Base 6]
  axes:8
   JoystickAxis[name=x, parent=DragonRise Inc.   Generic   USB  Joystick  , id=0, logicalId=x, isAnalog=true, isRelative=false, deadZone=0.0]
   JoystickAxis[name=y, parent=DragonRise Inc.   Generic   USB  Joystick  , id=1, logicalId=y, isAnalog=true, isRelative=false, deadZone=0.0]
   JoystickAxis[name=z, parent=DragonRise Inc.   Generic   USB  Joystick  , id=2, logicalId=z, isAnalog=true, isRelative=false, deadZone=0.0]
   JoystickAxis[name=rx, parent=DragonRise Inc.   Generic   USB  Joystick  , id=3, logicalId=rx, isAnalog=true, isRelative=false, deadZone=0.0]
   JoystickAxis[name=rz, parent=DragonRise Inc.   Generic   USB  Joystick  , id=4, logicalId=rz, isAnalog=true, isRelative=false, deadZone=0.0]
   JoystickAxis[name=pov, parent=DragonRise Inc.   Generic   USB  Joystick  , id=5, logicalId=pov, isAnalog=false, isRelative=false, deadZone=0.0]
   JoystickAxis[name=pov_x, parent=DragonRise Inc.   Generic   USB  Joystick  , id=6, logicalId=pov_x, isAnalog=false, isRelative=false, deadZone=0.0]
   JoystickAxis[name=pov_y, parent=DragonRise Inc.   Generic   USB  Joystick  , id=7, logicalId=pov_y, isAnalog=false, isRelative=false, deadZone=0.0]

I guess maybe for all 8 of my joysticks the logical ID was always “0”, “1”, etc…

Anyway, the right place to make that fix would be line 290:
setButtonValue( button.getLogicalId(), isPressed );

Change to:
setButtonValue(String.valueOf(button.getButtonIndex(), isPressed);

…but I wonder what else that screws up as the buttons were supposed to map to logical IDs. I suspect your joystick just needs to be remapped to the standard IDs in the joystick.properties file.

i also encounter the same issue with another joystick :

Joystick[1]:Microsoft SideWinder Force Feedback 2 Joystick
  buttons:9
   JoystickButton[name=Trigger, parent=Microsoft SideWinder Force Feedback 2 Joystick, id=0, logicalId=Trigger]
   JoystickButton[name=Thumb, parent=Microsoft SideWinder Force Feedback 2 Joystick, id=1, logicalId=Thumb]
   JoystickButton[name=Thumb 2, parent=Microsoft SideWinder Force Feedback 2 Joystick, id=2, logicalId=Thumb 2]
   JoystickButton[name=Top, parent=Microsoft SideWinder Force Feedback 2 Joystick, id=3, logicalId=Top]
   JoystickButton[name=Top 2, parent=Microsoft SideWinder Force Feedback 2 Joystick, id=4, logicalId=Top 2]
   JoystickButton[name=Pinkie, parent=Microsoft SideWinder Force Feedback 2 Joystick, id=5, logicalId=Pinkie]
   JoystickButton[name=Base, parent=Microsoft SideWinder Force Feedback 2 Joystick, id=6, logicalId=Base]
   JoystickButton[name=Base 2, parent=Microsoft SideWinder Force Feedback 2 Joystick, id=7, logicalId=Base 2]
   JoystickButton[name=Dead, parent=Microsoft SideWinder Force Feedback 2 Joystick, id=8, logicalId=Dead]
  axes:7
   JoystickAxis[name=x, parent=Microsoft SideWinder Force Feedback 2 Joystick, id=0, logicalId=x, isAnalog=true, isRelative=false, deadZone=0.0]
   JoystickAxis[name=y, parent=Microsoft SideWinder Force Feedback 2 Joystick, id=1, logicalId=y, isAnalog=true, isRelative=false, deadZone=0.0]
   JoystickAxis[name=rz, parent=Microsoft SideWinder Force Feedback 2 Joystick, id=2, logicalId=rz, isAnalog=true, isRelative=false, deadZone=0.0]
   JoystickAxis[name=slider, parent=Microsoft SideWinder Force Feedback 2 Joystick, id=3, logicalId=slider, isAnalog=true, isRelative=false, deadZone=0.0]
   JoystickAxis[name=pov, parent=Microsoft SideWinder Force Feedback 2 Joystick, id=4, logicalId=pov, isAnalog=false, isRelative=false, deadZone=0.0]
   JoystickAxis[name=pov_x, parent=Microsoft SideWinder Force Feedback 2 Joystick, id=5, logicalId=pov_x, isAnalog=false, isRelative=false, deadZone=0.0]
   JoystickAxis[name=pov_y, parent=Microsoft SideWinder Force Feedback 2 Joystick, id=6, logicalId=pov_y, isAnalog=false, isRelative=false, deadZone=0.0]

so should i edit the joystick properties file ?

Yes, I’ve seen this thing before and did not report it here. Sorry for that.
Using “1”, “0” etc. is wrong. Let me look what I did to do it correct…

Here, that’s my code:

    public void setButtonValue( JoystickButton button, boolean isPressed ) {
        System.out.println( "Button:" + button.getName() + "=" + (isPressed ? "Down" : "Up") );
        setButtonValue( button.getLogicalId(), isPressed );
    }
1 Like

You don’t have to be sorry :smile:

And also this:

addButton( app, JoystickButton.BUTTON_0, 371, 512 - 176, 42, 42 );

EDIT:
The code seems to be right in the latest github version. I’m working with jME 3.0 and there it was slightly broken.
So if you work with latest 3.1, then something else must be wrong.

i still didn’t understand how joystick.properties file works … halp please

Hm, don’t know if that .properties file will help, since you don’t see any buttons except the pov cross.
When I write entries for that file - I press some buttons - see them blinking in the wrong space - write some numbers into the text file - repeat until all buttons blink correct (upper button when I press upper button, left button when I press left button, …) - with a little thinking you can reduce this from “random guessing” to "I only need to start TestJoystick twice for one gamepad.

But you could do this: Watch the sys.out.println - what does it write to the log when you press a button?

Questions:
Do the two sticks work (are they moving)?
Did you install the drivers for the gamepad?
Is it a gamepad or a flight stick?
Which one is it? (EDIT: we can see that in your log - SideWinder stick)
Which OS are you using?

Often it’s just a missing driver. Sometimes there is a switch (e.g. you might have a hardware switch to select XInput or DirectInput - it should be set to “DirectInput”). Might be that Linux is the problem (Windows works best with gamepads and DirectInput).

Hi buttons actually have real names for the IDs instead of just “0”, “1”, etc… At least that’s what it looks like to me without being able to plugin a joystick and recheck mine.

So in the joystick.properties file he needs to map “0” to one of his names like “Thumb” or whatever. I can show some real examples when I have more time.

Ah I see the error:

The logical id is wrong.
Please run it with jME 3.0 to see if it’s still the case.

The logical id should not be the same as the name of the button.

Here is how it should be:

Joystick[2]:TG-30 USB GAME PAD
  buttons:10
   JoystickButton[name=Taste 0, parent=TG-30 USB GAME PAD, id=0, logicalId=0]
   JoystickButton[name=Taste 1, parent=TG-30 USB GAME PAD, id=1, logicalId=1]
   JoystickButton[name=Taste 2, parent=TG-30 USB GAME PAD, id=2, logicalId=2]
   JoystickButton[name=Taste 3, parent=TG-30 USB GAME PAD, id=3, logicalId=3]
   JoystickButton[name=Taste 4, parent=TG-30 USB GAME PAD, id=4, logicalId=4]
   JoystickButton[name=Taste 5, parent=TG-30 USB GAME PAD, id=5, logicalId=5]
   JoystickButton[name=Taste 6, parent=TG-30 USB GAME PAD, id=6, logicalId=6]
   JoystickButton[name=Taste 7, parent=TG-30 USB GAME PAD, id=7, logicalId=7]
   JoystickButton[name=Taste 8, parent=TG-30 USB GAME PAD, id=8, logicalId=8]
   JoystickButton[name=Taste 9, parent=TG-30 USB GAME PAD, id=9, logicalId=9]
  axes:8

Or

Joystick[0]:Thrustmaster T-Mini Wireless 3-in-1
  buttons:13
   JoystickButton[name=Button 1, parent=Thrustmaster T-Mini Wireless 3-in-1, id=0, logicalId=0]
   JoystickButton[name=Button 2, parent=Thrustmaster T-Mini Wireless 3-in-1, id=1, logicalId=1]
   JoystickButton[name=Button 3, parent=Thrustmaster T-Mini Wireless 3-in-1, id=2, logicalId=2]
   JoystickButton[name=Button 4, parent=Thrustmaster T-Mini Wireless 3-in-1, id=3, logicalId=3]
   JoystickButton[name=Button 5, parent=Thrustmaster T-Mini Wireless 3-in-1, id=4, logicalId=4]
   JoystickButton[name=Button 6, parent=Thrustmaster T-Mini Wireless 3-in-1, id=5, logicalId=5]
   JoystickButton[name=Button 7, parent=Thrustmaster T-Mini Wireless 3-in-1, id=6, logicalId=6]
   JoystickButton[name=Button 8, parent=Thrustmaster T-Mini Wireless 3-in-1, id=7, logicalId=7]
   JoystickButton[name=Button 9, parent=Thrustmaster T-Mini Wireless 3-in-1, id=8, logicalId=8]
   JoystickButton[name=Button 10, parent=Thrustmaster T-Mini Wireless 3-in-1, id=9, logicalId=9]
   JoystickButton[name=Ministick Left, parent=Thrustmaster T-Mini Wireless 3-in-1, id=10, logicalId=10]
   JoystickButton[name=Ministick Right, parent=Thrustmaster T-Mini Wireless 3-in-1, id=11, logicalId=11]
   JoystickButton[name=Taste 12, parent=Thrustmaster T-Mini Wireless 3-in-1, id=12, logicalId=12]
  axes:7

Obviously the logical id is broken in your version of the jME software.
Please validate by using an earlier version.
If jME 3.0 has wrong logical id too, then you would try to hack (or try to use that logical id you see in your file and map that to “0” and “1” and etc. in your joystick-mapping.properties - but I don’t know if that will work).

Answer :

there is a “analog” hardware switch and it’s also work.


I successfully remapped all the logical id to match the button id. And all the button are highlighted when pressed (without applying changes to setButtonValue at l.290)

1 Like

Okay, so that apparently works. Good to know…

All my sticks and gamepads reported “0” and “1” and similar as logical ids. I would have to check to see if things changed with jME 3.1 then. Would not be so cool, but hey… a little text file hacking and it works again…

Hey that’s a clever marketing gag! :chimpanzee_closedlaugh:

I’ll try with jme 3.0 to see if i get the same issue, (since i have exaclty the same issue for “Microsoft SideWinder Force Feedback 2 Joystick”)
And i also did some modification to “JoystickCompatibilityMappings.java” to support remapping for my gamepad.

Okay, if you hack the engine then I can not give guarantees that you didn’t break it! :chimpanzee_closedlaugh:

i didn’t, I just take care of multiple spaces and allow ‘.’ in the gamepad name

Hm, even the Wacom drawing tablet reports “0”, “1”, “2”, … as logical ids for buttons:

Joystick[4]:Wacom Virtual Hid Driver
  buttons:5
   JoystickButton[name=Radierer, parent=Wacom Virtual Hid Driver, id=0, logicalId=0]
   JoystickButton[name=Umkehrung, parent=Wacom Virtual Hid Driver, id=1, logicalId=1]
   JoystickButton[name=Geschützrohrschalter, parent=Wacom Virtual Hid Driver, id=2, logicalId=2]
   JoystickButton[name=Tippschalter, parent=Wacom Virtual Hid Driver, id=3, logicalId=3]
   JoystickButton[name=Im Bereich, parent=Wacom Virtual Hid Driver, id=4, logicalId=4]
  axes:8
   JoystickAxis[name=X-Achse, parent=Wacom Virtual Hid Driver, id=0, logicalId=x, isAnalog=true, isRelative=false, deadZone=0.0]
   JoystickAxis[name=Y-Achse, parent=Wacom Virtual Hid Driver, id=1, logicalId=y, isAnalog=true, isRelative=false, deadZone=0.0]
   JoystickAxis[name=Druckempfindliche Spitze, parent=Wacom Virtual Hid Driver, id=2, logicalId=unknown, isAnalog=true, isRelative=false, deadZone=0.0]
   JoystickAxis[name=X-Neigung, parent=Wacom Virtual Hid Driver, id=3, logicalId=unknown, isAnalog=true, isRelative=false, deadZone=0.0]
   JoystickAxis[name=Y-Neigung, parent=Wacom Virtual Hid Driver, id=4, logicalId=unknown, isAnalog=true, isRelative=false, deadZone=0.0]
   JoystickAxis[name=Azimut, parent=Wacom Virtual Hid Driver, id=5, logicalId=unknown, isAnalog=true, isRelative=false, deadZone=0.0]
   JoystickAxis[name=Flughöhe, parent=Wacom Virtual Hid Driver, id=6, logicalId=unknown, isAnalog=true, isRelative=false, deadZone=0.0]
   JoystickAxis[name=Drehen, parent=Wacom Virtual Hid Driver, id=7, logicalId=unknown, isAnalog=true, isRelative=false, deadZone=0.0]

:chimpanzee_smile:

Well, it might be Linux with that Windows API. It’s btw great that it works “somehow”.
I’ve got an ubuntu on this machine too - maybe I try to see if it makes a difference.
But too lazy to check it now :chimpanzee_closedlaugh: