Linux Joystick Mapper Wiki
Status: Beta
Brought to you by:
alexandrehardy
A linux userspace device driver that allows joystick events to be remapped. Several joysticks can be combined into a single controller, and button/axes events can be remapped to new joystick, keyboard or mouse events. Advanced scripting also supported.
For a graphical UI to program the joystick (using this software) please see https://rb3d.nl/rb3d/joymixerUI.html
Hi Alexandre,
Here are the contents of the .map file I am using. The mappings that I am having trouble with are below. Everything else works perfectly.
As for jsinfo, I compiled it and ran it.
The first few columns reported zeros for all the buttons. I pressed them and they all returned a 1 like normal.
The next 4 columns displayed zeros as well, but if I moved the joysticks, they went from -32767 to 32767. They returned to zero once the axes were in the neutral position.
1st - left stick x axis
2nd - left stick y axis
3rd - right sitck x axis
4th - right stick y axis
The next three columns contained -32767, 32767 and 32767 respectively. They did not change at all. The remaining columns were all zero and nothing changed them.
Hopefully the issue stick out like a sore thumb for you because I couldn't actually see what the columns represented...
Thanks
Hi Colin,
I am surprised. It sounds like your joysticks are giving absolute 0 when returned to neutral position. I did not expect that. I would have expected it to oscillate a little bit (that is more typical of rheostat based joysticks).
I'm going to recomment a starting point to work from, and then we can tweak further from there.
This will mean that your key presses will not repeat. The key press will happen once and only once when you push the joystick in a particular direction. Let's see if that works.
Heh. Also found a bug. Not sure why I didn't see it before...
You can also try this patch, if you are willing:
I'll only be able to test that tonight.
Hi Alexandre,
I tried the modified mapping you suggested, but with that .map file none of the mappings worked (as if the file wasn't loading at all). I assume this is due to some syntax error, so I tried
Note the only difference is the quotes around trinary. This does load the mapping, and the axes do behave differently - they don't get "stuck" as before. That said, they behave contrary to what you described should happen with the trinary flag. If I push the joystick in one direction, it does not press the key once. (e.g. holding down on joystick scrolls down through a menu in dosbox. Release joystick stops the scrolling)
Normally I'd be happy because this is actually the behaviour I want, but unfortunately there is another problem - only down and right worked. Pressing the axes left and up responds only once, each time the map is loaded. After I press it once, it no longer works.
FYI, a dead zone of 1000 must be too large for me because the joystick was unresponsive. I lowered it to 100 to eliminate that as a source of error and the joystick responded again. I'm not too concerned with this because a deadzone doesn't seem to be my issue...
I tried to learn how to apply a diff file, but I gave up when the site I was reading says patch files start with the line "$ diff original.c new.c". Your diff file seems to have that in reverse, and is actually a patch for the new file (to revert it back to the old file). I might be misunderstanding this... I am fairly ignorant when it comes to programming :)
Hi Colin,
I tested on a VM, and you should not need quotes around trinary. Maybe you can post the error message so I can see why that reported an error.
I worked through the problem a bit, and discovered that the osxjoymap implementation is behaving differently to the linuxjoymap implementation. Which is why I had different expectations.
So here is the reason why (as far as I can make out) your keys get "stuck". The keys are not being released by the axis mapping (as per my patch, which I have redone properly). When the key events accumulate enough, it appears that new key events are excluded. (Test that on a terminal, hold "a", then add "b", then add "c"). This may come down to the exact software reading the key events, but I think in most cases there are some limits as to how this is processed.
Anyway. Fixed that so that keys are released (too many times actually, but that doesn't seem to harm anything). The new upload is joymap-0.4.1. I have tested with joymaps own virtual joystick, but testing with real hardware would be appreciated.
Hi again,
I tested out v4.1 and with the trinary flag it works exactly as I want it to. That is, if I hold the axes down, it acts like down is being held on the keyboard, and it releases when the axes is returned to the neutral position. Great work!
Without the trinary flag, it does still do some peculiar things though... that is, it won't release. I still need to test more to be able to describe the behaviour better, but for the moment the trinary flag solves everything.
Last edit: Colin Dryden 2016-08-26
Hi again Alexandre,
I dug more into the files and in man/loadmap.1 it states:
Please help me understand. When I load a map, are the joystick values reported to the program in the range of 0-255? Even if the range is actually -32767 to 32767 natively?
More to the point, if I'm on the right track, how do I use the flags above to convert the range back to -32767 to 32767 as the program expects...?
I am trying to use this mapper for the PPSSPP emulator on RetroPie. I am using a PS3 controller. The joysticks work fine when I do not load a map. However, the built in mapper for PPSSPP has too many issues, so I use your program. It works perfectly for all buttons, but I cannot get the joystick to respond correctly.
Since the axes work with no mapper, I simply tried to map the axes to joyaxis, thinking the program would read them as normal:
The joysticks were unresponsive.
Next I tried to map them to the built-in keyboard mapping that PPSSPP uses:
This causes the program to constantly recieve a "k" input, which of course acts as if the axis is stuck in one direction. That's when I tried the binary flags and was also unsuccessful.
I'm taking one more crack at understanding how your program works with respect to axes. Ideally I just want to "pass" the joyaxis through to the program without any mapping at all. The only mapping needed is the buttons because the axes work when no map is loaded.
It is whatever the linux joystick driver reports. And the linux joystick driver supports calibration, so the values are not necessarily device native values.
As with most of the projects I have made available, this was developed for my own use, and then made available for others to take and extend as they wished. I was sloppy with some of the values, since it worked perfectly for me (still does, even though I'm using it on OSX now).
That should work just fine, it should pass the values through. I read the code quickly for PPSSPP. Are you using SDL? If so, then it seems that SDL will be picking up your joysticks in the order that they are found.
loadmap
cannot replace/dev/js0
with its own device (not without implementing a custom kernel module). That means that the joymap (loadmap
) device drivers will be something like/dev/js1
. The statementdevice=0 axis=0
tells joymap to map this axis to the first joystick that joymap manages, which may in fact be/dev/js1
. In that case it won't map to PAD 0 in PPSSPP as far as I can tell.loadmap
will also (while it is running) prevent other programs from seeing any events from the joystick. That would explain why it is unresponsive (because PPSSPP isn't using the joymap joystick, and joymap is preventing PPSSPP from seeing any joystick events on the PS3 controller).The solution to that problem is to run
reserve_js
at bootup, which will ensure thatloadmap
always gets/dev/js0
(well, it worked for me in the distant past anyway). This should mean that your controller is unresponsive wheneverloadmap
is not running, but should work otherwise.Let me know if that helps. I'll probably work up the motivation to implement thresholds for the axes at some time. But no promises as to when.
Kind regards
Alexandre
Hi Alexandre,
Thanks for writing this software and open sourcing it! I ran into 2 issues and wanted to provide feedback. I have 2 controllers, one wired the other wireless.
Issue #1: Button mappings are not working for my bluetooth wireless controller (8bitdo SNES30 Gamepad). I've triple-checked that the vendor ID, product ID, and button codes are correct (the button codes were found using jstest). This controller works fine in other games. The d-pad axis mappings work OK so it's just an issue with the buttons.
Is there any reason why bluetooth controller button mappings wouldn't work with joymap?
Loadmap output:
Mapping config:
Issue #2: The axis mappings for the d-pads on both my wired and wireless controllers work fine with joymap-0.2 and joymap-0.3.1 but do not work in joymap-0.4.1. Here's the mapping config I'm using for the wired controller:
When I try to use joymap-0.4.1, the mouse cursor immediately moves all the way into the bottom right corner of the screen and I'm unable to move it from there. This does not happen with versions 0.2 or 0.3.1. I have not tested 0.4.0.
Thanks again for the wonderful software, I appreciate it!
Last edit: James 2016-10-10
Hi James,
I changed the mouse code in joymap-0.4.1 to cater for other users, and to make the mapping more powerful. The mouse movement is directly influenced by the range of joystick values for the axes you have specified. By default the mouse code now assumes a range of -32767 to 32767 (it used to assume 0 to 255, and could not be configured in any way).
There are now new settings for the mouse axis target. You can specify
min
,max
,deadzone
andspeed
to control the mapping from the joystick to the mouse axis. I suggest you usejstest
again to determine the range of values returned when moving the joystick around and then plug that into the min and max setting for the axis. You can then start playing with the deadzone and speed, and see if you can make the mouse more controllable.As for the buttons on the bluetooth joystick: I'm afraid I don't have any answer there. It is possible that other software grabbed the device for exclusive use, but then the axes wouldn't work either. There is also the remote chance that what you think is a button is actually reported as an axis, but I can't be sure about that either.
Maybe you could grab the output of
jstest
and paste that for further scrutiny?It might also help to
cat /proc/bus/input/devices
and see what that says. That may also provide some hints as to what is going on.Kind regards
Alexandre
Thanks for the help Alexandre, I appreciate it. I ran jstest on my wireless controller (the one with the broken button mappings) and got the following output.
Here's the contents of /proc/bus/input/devices:
I'll keep trying things and post updates if I make progress. Thanks again.
Thanks James.
I notice that with jstest none of the buttons were ever reported as on.
Now jstest only seems to report 15 buttons, but /proc/bus/input/devices shows that the SNES30 GamePad has 16 buttons, but if I read that correctly, the buttons start at button 16 and end at button 31.
So you probably need to add 16 to your src field for each button on the SNES30.
Kind regards
Alexandre
That worked! Thank you so much Alexandre! Do you have a Paypal or Amazon wishlist? I'd be happy to make a donation. I'm building a system as a gift for my father and it means a lot to me that he'll be able to play his favorite old DOS games again.
To clarify, the jstest output above is what gets printed when I start the program. I had not yet pressed any buttons, hence everything reported as "off".
Thanks again!
Thank you for the kind offer. No donation of any sort is necessary, as I developed this mostly for my own use in my spare time and decided that sharing it would be a good idea since I benefit from so many open source projects.
Kind regards
Alexandre
Hello Alexandre,
I would suggest you to look at the following patch.
It fixes an issue that I found when trying to map the mouse wheel to joystick buttons.
Regards,
Thanks Dan,
Good catch!
Kind regards
Alexandre
Hi Alexandre! I ran into another issue I thought you might have insight on. I'm unable to get the "shift" feature to work. I tried to debug the issue using evtest to dump the target event output but nothing appears for the shifted button mapping. joymap seems to work just fine for non-shifted mappings. Is the "shift" flag still supported? I'm using joymap-0.4.1.
joymap mapping file:
joymap output:
evtest output:
Thanks again for your time and this wonderful program.
-James
Last edit: James 2016-11-02
Hi James,
You are correct. The shift functionality is not working. Not sure at which point it broke, probably during some code reworking.
You can solve this temporarily by adding 288 to your shift button.
In your case that would be:
shift vendor=0x0079 product=0x0011 src=296
I'll be working on a fix (but probably not very quickly even though the fix is trivial), but such a fix will break any mapping where you apply this workaround.
Kind regards
Alexandre
Last edit: Alexandre Hardy 2016-11-06
Hi James,
This bug should be fixed in joymap-0.5.0.
joymap-0.5.0 also adds a few other options;
* Ability to specify a joystick by event device number instead of vendor and product.
* Daemonize option, to run the program in the background.
* Handles removal and insertion of devices at runtime (no need to have the devices plugged in before you start).
* You can now provide a search path for configuration files in the JOYMAP_PATH environment variable so config files don't have to use absolute paths or be in the same directory where loadmap is executed from.
* An additional command line option is provided to automatically map axes into the -32767 to 32767 range based on what the linux event subsystem reports the axis range to be.
Kind regards
Alexandre
Running joymap 0.4.2; thank you so much for this.
Having a difficult time getting it working with an Xbox One controller and xpad on my Raspberry Pi.
When I run jsinfo, it shows the d-pad as being a04 (X) and a05 (Y) with a range of -32767 to 32767.; button "A" on the controller is b00 and "B" is b01.
My map file looks like this:
It doesn't appear that these settings work when I run joymap though. In fact, the right analog stick (should be a02) appears to be getting used for the X control.
Any thoughts?
Not sure if it's relevant but when I run joymap, I get the following:
Last edit: Joe 2016-11-24
Hi Joe,
I'm afraid I cannot say why the axes are being mapped differently to what you observe in jsinfo. It may be useful to provide the output of
cat /proc/bus/input/devices
.The D-Pad may not be reported as an axis, but possibly as something else.
Kind regards
Alexandre
Hello , sorry for my english
I tried to use loadmap with pico-8 on raspberry (recalbox) but axis doesn't work I don't know why
I killed emulationstation and use putty to launch command.
pico-8 use sdl2 to use joystick (analogy stick) but to shutdown I need keyboard (CLTR+Q)
I would like use loadmap to exit and play games.
Can you tell me why It does'nt work ?
sdl2-jstest
gamepad.map
Last edit: Acris 2017-03-08
Hi Acris,
Can you explain what you mean by "but axis doesn't work". Do you mean:
a) That absolutely nothing happens when you move the axis?
b) It looks like the keypress gets stuck?
c) It works once and then never again?
Have you tried with a different key such as 'a' instead of 'left' or 'right' so that you can see on the terminal what actions are being taken?
I notice that you have not specified the trinary flag with
flags=trinary
. You also haven't set thedeadzone
ormin
andmax
values. You probably want to add one or more of these (one at a time is probably best) and test the results to see what happens.Kind regards
Alexandre
Ho Alexandre,
sorry for my english.
a) That absolutely nothing happens when you move the axis : yes
No, i have not because pico-8 use arrow on keyboard but i tried with kbd or mouse , no move.
I tried with flage=trinary with deadzone and min or max and didn't work.
buttons work very fine but D-Pad or joystick no move.
I dont know how to choose axis : target=mouse ? target=joyaxis = target=kbd ? or other ?
help me :(
Last edit: Acris 2017-03-10
Ok ... I decided to give this a try today. I am attempting to use this to allow my PS4 controller to act as a mouse in dosbox games on retropie. I will outline the steps I have taken methodically to see if I am doing anything wrong.
As you can see the controller is Vendor : 054c Product:09cc
The next thing to do was to create a mouse.map file for the controller.
I ran jstest
/dev/input/js0
to get the correct src for the mapping and stored it in \roms\pc\dosbox-map\mouse.map. Here is my mapping ...at this point i createst a .sh file to launch my game in dosbox.
CC.sh :
CC_conf.conf :
So when command and conquer loads up ... i dont think it sees my controller as a mouse. I am at a loss. The mouse just jets to the bottom right corner of the screen.
I scoured the config for dosbox. I did find the joystick section and I am wondering if its it somehow overriding the joymap ?
from CC_conf.conf :
# Is there a way to test joymap in dosbox without launching the game ?
Thanks ! I am near my wits end with this.
The mouse just jets to the bottom right corner of the screen when I move the thumbstick.
Last edit: mpd 2017-03-14