Joystick mapping tool for Linux

For discussion of ports to POSIX based systems, especially using GNUStep.

Moderators: winston, another_commander, Getafix

User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Joystick mapping tool for Linux

Post by phkb »

Can anyone recommend a UI-based tool for mapping keys to joystick buttons? I've got one for Windows, but would like to get one for Linux and have no idea where to look.
User avatar
hiran
Theorethicist
Posts: 2410
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: Joystick mapping tool for Linux

Post by hiran »

phkb wrote: Sun Sep 03, 2023 1:24 am
Can anyone recommend a UI-based tool for mapping keys to joystick buttons? I've got one for Windows, but would like to get one for Linux and have no idea where to look.
I have no good idea about joystick programming on Linux. Not to talk about how key/button mapping should work.
My expectation would be that the application opens the joystick interface - possibly not for polling but for event notification. As soon as a button gets pressed the application needs to decide what to do.

That is fairly similar to keyboard handling - with the exception that you would not map buttons to keyboard or vice versa. Instead you would map keyboard keys to actions, and joystick buttons likewise.
Sunshine - Moonlight - Good Times - Oolite
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Joystick mapping tool for Linux

Post by phkb »

Sometimes, even when an application supports joysticks, there are limits to what it can do. There are two things I'd like to do with my joystick in Oolite on Linux, which I can do without issue on Windows.

1. Use the right stick Y axis for speed.
On Windows, I use a Logitec app called "Logitec Profiler", which looks like this:
Image
On this screen I can remap any of the buttons to keyboard functions. In this example, though, I have left almost all the buttons as default. On the right stick Y axis, though, you can see "Speed". This is defined as
Image

That allows me to quickly turn the right stick into a throttle. I can do something almost the same inside Oolite, but when I do that, I have to hold the stick at a particular position in order to maintain a throttle setting. This config allows me to push stick forward to increase throttle, and when I stop pushing, the speed stays set.

Now, I could probably play around with splines and deadzones to try and achieve the same thing. But this utility makes it dead easy.

2. Use the X button to switch between the "Ident" system and the "Target missile" system. This option can't be done in Oolite at all. I want to use one button for two functions, switching between the two in turn. By using this utility, I can enter the two keyboard commands I want to toggle between:
Image

That's what I'm trying to achieve, which I can do quite easily on Windows. Are there no tools on Linux to do a similar job?
Commander_X
---- E L I T E ----
---- E L I T E ----
Posts: 678
Joined: Sat Aug 09, 2014 4:16 pm

Re: Joystick mapping tool for Linux

Post by Commander_X »

Disclaimer: don't use a joystick/gamepad too often, and didn't test this.

Google-fu for "linux joystick button mapping app", returns AntiMicroX (https://github.com/AntiMicroX/antimicrox), which seems to cover to some extent what the Logitech app is capable of.

One caveat (might or might not affect its usage with Oolite): seems to have a relationship with SDL2 (not sure if only config time or runtime, after configuration).
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Joystick mapping tool for Linux

Post by phkb »

Thanks, Commander_X! That's perfect. And works beautifully for my use-case. Brilliant!
User avatar
hiran
Theorethicist
Posts: 2410
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: Joystick mapping tool for Linux

Post by hiran »

While talking about the joystick interface/mapping-
Most joysticks are input devices so the computer knows what the user wants to know.

But force feedback joysticks support two way communication. Oolite could give the player haptic feedback if
- the ship is taking damage
- the ship is in the starting-landing rail of a station
- the ship is too close to a star/planet and is speeding through it's atmosphere
- precision mode could increase centering force

I believe most of that could be controlled via the javascript engine. The necessary events are available. But can the scripting engine access the joystick? Is there another way to achieve that?
Sunshine - Moonlight - Good Times - Oolite
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Joystick mapping tool for Linux

Post by phkb »

At the moment, the Javascript engine has no access to raw joystick info. The only things it responds to are events raised by core code. So, we’d need core code changes and a bunch of events created to allow a JS interface.

I’m not sure if our version of SDL has access to rumble/vibration options on joysticks. I assume it must but I haven’t had a good look for it. If you have any primers or urls that expound the details, lob them my way and I’ll have a look. No promises on implementation though. I know from experience that working with SDL is hard.
User avatar
Cholmondely
Archivist
Archivist
Posts: 5381
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: Joystick mapping tool for Linux

Post by Cholmondely »

I'd read that Force Feedback was no longer available in the new joysticks.

But I just came across this: 10 Best joysticks force feedbacks in 2022
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: Joystick mapping tool for Linux

Post by Cody »

They look like rather old sticks - very old, in fact!
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
User avatar
hiran
Theorethicist
Posts: 2410
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: Joystick mapping tool for Linux

Post by hiran »

Cholmondely wrote: Wed Sep 06, 2023 11:32 am
I'd read that Force Feedback was no longer available in the new joysticks.

But I just came across this: 10 Best joysticks force feedbacks in 2022
Both of my two FFB sticks are mentioned.
I do not have Arcade or DIY so now you know what I have.

Recently I tested and found out despite the documentation they are supported by the linux kernel. But I did not test libraries like SDL.

See also https://askubuntu.com/questions/1450181 ... winder-ff2

And... if Vega Strike can do it, why can't we?
https://discourse.libsdl.org/t/force-feedback/7302/10
Sunshine - Moonlight - Good Times - Oolite
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6696
Joined: Wed Feb 28, 2007 7:54 am

Re: Joystick mapping tool for Linux

Post by another_commander »

The sdl libraries we use both for Linux and Windows support haptic devices. We do not have code that makes use of the force feedback feature in the present engine though. It could be added, if someone takes on the task and has the proper equipment for testing changes available.
User avatar
hiran
Theorethicist
Posts: 2410
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: Joystick mapping tool for Linux

Post by hiran »

another_commander wrote: Wed Sep 06, 2023 2:28 pm
The sdl libraries we use both for Linux and Windows support haptic devices. We do not have code that makes use of the force feedback feature in the present engine though. It could be added, if someone takes on the task and has the proper equipment for testing changes available.
Maybe it could be done in a modular way.
We define the function that would get called by the engine. In parallel I could try to create content for such function that use sdl to drive the ffb stick. After successful testing we move the example function into the Oolite code and just need final testing.

But I am no Objective C guy. What alternatives are feasible?
Sunshine - Moonlight - Good Times - Oolite
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6696
Joined: Wed Feb 28, 2007 7:54 am

Re: Joystick mapping tool for Linux

Post by another_commander »

Actually I think I made a mistake in my previous post. I searched for haptic function strings inside the SDL binary distributed with the Linux build and came up with nothing. Which most likely means that currently haptic support capability is Windows-only. It seems that Getafix had updated only the Windows part in his 5 years old haptic branch on github and I misremembered, I thought he had it done for Linux as well.

Which means that the first step towards Linux force feedback effects would be to update the distributed Linux SDL binary to a version that contains the ff support. Until then, there is not much that can be done.
User avatar
hiran
Theorethicist
Posts: 2410
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: Joystick mapping tool for Linux

Post by hiran »

another_commander wrote: Thu Sep 07, 2023 6:28 am
Actually I think I made a mistake in my previous post. I searched for haptic function strings inside the SDL binary distributed with the Linux build and came up with nothing. Which most likely means that currently haptic support capability is Windows-only. It seems that Getafix had updated only the Windows part in his 5 years old haptic branch on github and I misremembered, I thought he had it done for Linux as well.

Which means that the first step towards Linux force feedback effects would be to update the distributed Linux SDL binary to a version that contains the ff support. Until then, there is not much that can be done.
When updating anyway it might make sense to go for the latest SDL2 version - but that is way beyond my capabilities.
Sunshine - Moonlight - Good Times - Oolite
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6696
Joined: Wed Feb 28, 2007 7:54 am

Re: Joystick mapping tool for Linux

Post by another_commander »

SDL2 is out of the question for me - it was tried before and it failed hard. And it pissed me off too because I had to debug libraries again. Check https://github.com/OoliteProject/oolite/issues/222 and https://github.com/OoliteProject/oolite/pull/234 for the gory details.

Of course, anyone wishing to repeat the attempt is more than welcome, if they feel brave enough.
Post Reply