Régler manuellement les deadzones
-
@voljega trouvé quelques trucs pour un linux standard mais je suppose que rien de tout ça n'est dans le buildroot de recalbox
https://askubuntu.com/questions/32031/how-do-i-configure-a-joystick-or-gamepad
https://wiki.archlinux.org/index.php/Gamepad#Setting_up_deadzones_and_calibration
https://www.x.org/releases/X11R7.5/doc/man/man4/joystick.4.html@ironic est ce que le tool que tu étais en train de développer permet de configurer les deadzones ?
-
Figure toi que j'ai aussi un pad X360 qui a une fâcheuse tendance a avoir un '0' qu traine plutôt près de '8000' maxi.
Donc, sans deadzone configurée, ça pose probleme. Des mouvements se produisent spontanément.'Mon' soft ne gère pas les deadzones, par contre, je le fais sous Python quand j'ai besoin des joysticks dans mon script.
Mais, il y a une solution, pas contre, j'ai testé que sur
/dev/input/js0
, la commandejscal
Je crois qu'elle est dispo sous Recalbox d'origine.Exemple, avant la calibration :
On peut voir que les 2 sticks (axes 0/1 et 2/3) ont des valeurs non nuls malgré le fait qu'on ne touche pas a la manette.Pour avoir des infos sur le joystick 1 :
jscal /dev/input/js0
On voit que le gamepad Xbox360 a 6 axes et 13 butons.
Joystick has 6 axes and 13 buttons. Correction for axis 0 is broken line, precision is 16. Coeficients are: 0, 0, 16513, 16513 Correction for axis 1 is broken line, precision is 16. Coeficients are: 0, 0, 16513, 16513 Correction for axis 2 is broken line, precision is 16. Coeficients are: 0, 0, 16513, 16513 Correction for axis 3 is broken line, precision is 16. Coeficients are: -128, 128, 16513, 16513 Correction for axis 4 is broken line, precision is 0. Coeficients are: 0, 0, 536870912, 536870912 Correction for axis 5 is broken line, precision is 0. Coeficients are: 0, 0, 536870912, 536870912
On va créé un fichier de config :
# jscal -p /dev/input/js0 > /tmp/joystick.cal
Ce qui donne :
jscal -s 6,1,16,-128,128,16513,16513,1,16,-128,128,16513,16513,1,16,-128,128,16513,16513,1,16,-128,128,16513,16513,1,0,0,0,536870912,536870912,1,0,0,0,536870912,536870912 /dev/input/js0
Je modifie le seuil mini pour les axes 0,1,2,3 à 8000 et maxi a 32768:
jscal -s 6,1,16,-8000,8000,32768,32768,1,16,-8000,8000,32768,32768,1,16,-8000,8000,32768,32768,1,16,-8000,8000,32768,32768,1,0,0,0,536870912,536870912,1,0,0,0,536870912,536870912 /dev/input/js0
Bon, je dois avoué que j'ai pas tout compris ces chiffres, j'ai pas cherché dans la mesure ou cela fonctionne.
Le résultat (apres avoir manipulé les axes) :
Maintenant, a voir si on peut faire la meme chose avec les 'events'...
-
-
@ironic excellent, c'est à peu près que j'avais ku mais c'est mieux avec un exemple !
J'ai lu aussi que par contre à moins de rajouter ça ds les règles udev (ce qui passe largement au dessus de mes connaissances) il faut aussi le refaire à chaque démarrage
-
@acris ah merci je vais tester dès que je peux
-
Et aussi cette option
timed=true
Cetait un sujet sur le jeu Privateer
-
@acris
Merci pour les infos.@voljega
J'ai ajouté un fichier :
/etc/init.d/S97jscal
dans lequel il y a :
#!/bin/bash /usr/bin/jscal -s 6,1,16,-8000,8000,32768,32768,1,16,-8000,8000,32768,32768,1,16,-8000,8000,32768,32768,1,16,-8000,8000,32768,32768,1,0,0,0,536870912,536870912,1,0,0,0,536870912,536870912 /dev/input/js0
Et ça fonctionne, j'ai testé que sous AdvMame.
- Sans ce fichier, je souffle sur le stick et c'est suffisant pour déclancher un mouvement . Le mouvement continue car le stick n'est pas a 0.
- Avec ce fichier, plus aucun souci, on sent même qu'il faut 'bien' appuyer sur le stick pour déclencher un mouvement.
-
@acris yes ça je savais déjà, mais bon ça ne semble pas suffire...
sinon pour le cycles :
# cycles: Amount of instructions DOSBox tries to emulate each millisecond. # Setting this value too high results in sound dropouts and lags. # Cycles can be set in 3 ways: # 'auto' tries to guess what a game needs. # It usually works, but can fail for certain games. # 'fixed #number' will set a fixed amount of cycles. This is what you usually # need if 'auto' fails (Example: fixed 4000). # 'max' will allocate as much cycles as your computer is able to # handle. # Possible values: auto, fixed, max.
Je vois comment ça peut marcher en limitant le nombre de fois où la position du joystick va être récupéré, mais ça va surement réduire le mouvement de 'glissement' dû à la deazone mais pas le supprimer complètement.
Et je pense que la plupart des jeux que j'ai testé sont en auto et pas en max de toute façon@ironic
ah ok bon plus simple que ce que je croyais ! je vais esssayer de faire ça et je ferais ptet une page wiki avec.
le simple fait que le fichier S97jscal soit dans /etc/init.d va l'exécuter automatiquement au démarrage (en dernier je suppose) ou alors il faut ajouer une référence quelque part ? -
@voljega said in Régler manuellement les deadzones:
le simple fait que le fichier S97jscal soit dans /etc/init.d va l'exécuter automatiquement au démarrage (en dernier je suppose) ou alors il faut ajouer une référence quelque part ?
S'il est en S97 il s'exécutera bien en dernier (juste avant le S98cleanup), il faut juste qu'il soit en chmod +x
-
Merci @OyyoDams
Tout est dit -
Ok merci, bon malheureusement ça ne marche pas.
en éxécutantjscal -s 6,1,16,-16000,16000,16513,16513,1,16,-16000,16000,16513,16513,1,16,-16000,16000,16513,16513,1,16,-16000,16000,16513,16513,1,0,0,0,536870912,536870912,1,0,0,0,536870912,536870912 /dev/input/js0
avec les couples -6000/6000, -8000/8000 et même -16000/16000 et en mettant bien
timed=flase
aucun effet (c'est principalement le stick droit mappé sur la souris dans dosbox qui fait chier)j'ai aussi un clavier de brancher est ce que mon joy ne serait pas en js1 ? je pense pas mais bon
sinon comment voir l'état de mon joy au repos pour les valeurs du stick en passant par une commande, comme le fait ton soft ?
-
sdl2-jstest -t 0
Mais sdl2-jstest n'utilise pas les deadzones.
Je pousserais un peu plus loin les recherches des que j'aurais le temps.
Ou si quelqu'un en sait plus... -
Joystick Name: 'Microsoft X-Box 360 pad' Joystick Number: 0 Axes 4: 0: 795 [ # ] 1: -1445 [ # ] 2: 2137 [ # ] 3: -2799 [ # ] Buttons 13: 0: 0 [ ] 1: 0 [ ] 2: 0 [ ] 3: 0 [ ] 4: 0 [ ] 5: 0 [ ] 6: 0 [ ] 7: 0 [ ] 8: 0 [ ] 9: 0 [ ] 10: 0 [ ] 11: 0 [ ] 12: 0 [ ] Hats 1: 0: value: 0 +-----+ up: 0B***s 0: Press Ctrl-c to exit
bizarre... après c'est ptet le fait de mapper dans dosbox la souris sur le stick droit qui merde je sais pas, le gauche a l'air de faire moins de bétises tout seul
-
-
@acris faute de frappe sur le forum
-
Hi guys. Maybe I can shed some light on this. @voljega notified me of this thread... I speak no word of french (exept maybe merci ;), but Google helped so much to understand, but I choose to answer in english if you don't mind...
First thing to note is there there are (at least) two different ways to access joysticks in Linux:
- the joydev joystick driver and API, with devices
/dev/input/js*
, which is what you used here. This is configured using jscal and friends. - and the raw event devices,
/dev/input/event*
. It's not clear to me if this is configurable. Some sources say it's just raw events, not configurable, the Archwiki @voljega linked seems to suggest you can configure/calibrate them...). Otherwise the apps or SDL would have to take care of that. No idea if SDL has any support for this.
So what do we have?
-
the coefficients you modified for jscal at pretty much wrong. When I take the initial line from @ironic:
jscal -s 6,1,16,-128,128,16513,16513,1,16,-128,128,16513,16513,1,16,-128,128,16513,16513,1,16,-128,128,16513,16513,1,0,0,0,536870912,536870912,1,0,0,0,536870912,536870912 /dev/input/js0
then the coefficents of the first axis are:
-128,128,16513,16513
. As you figured out the first two are the borders of the deadzone. But they have to stay in the input range, i.e. between 0..255. So changing them to 8000 or whatever is likely just plain wrong. The other two are actually scaling factors, mapping the remaining input range to the entire output range (-32767..0, 0..32767). You can not simply change them, but you have to actually calculate them, taking into account the actual input range minus deadzone. -
if you want to test these changes you should use
jstest
. If you want to verify how things behave in SDL apps you can usesdl-jstest/sdl2-jstest
, for SDL 1 and 2 respectively. -
as for making the values persistent, you should use some udev magic. Relying on the generic device is likely to fail sooner or later, as they are just numbered by the OS as they are detected or plugged in. If at all, you should use the named devices
/dev/input/by-id/usb-Foo_Bar-joystick
. And the init script won't work if you plug in the device later on. The debian joystick package (used in Raspbian or Retropie) also shipsjscal-store/-restore
, which take of the udev magic. But they are not available on Recalbox. -
somehow something else seems wrong on Recalbox as jscal button mapping is broken:
# jscal -q /dev/input/js0 "jscal: error getting axis map: Success"
The other thing is, as I just found out, that the joydev driver devices (js0) are ignored by SDL1 and SDL2 (and thus programs like dosbox) on Recalbox. See https://forum.recalbox.com/post/75291
For SDL1 you can override the default device and work around this with
export SDL_JOYSTICK_DEVICE=/dev/input/js0
. If you do that thensdl-jstest
should give you the results you expect, same asjstest
. Otherwise you only get the erratic, uncalibrated default behaviour.For SDL2 however this does not work. It just ignores this variable. As dosbox on Recalbox uses SDL2 your jscal based calibration will never end up there. It will always use the erratic, uncalibrated default.
The open questions are:
- can SDL2 be compile configured to obey SDL_JOYSTICK_DEVICE?
- can SDL2 be compile configured to default to joydev driver devices (js*)?
- can the raw event devices be calibrated (as the archwiki page suggests)? At least the tools are not available in Recalbox.
So yea, I guess we are stuck the way things currently are. No calibration for Dosbox (or any other SDL2 based apps, ScummVM? uae4arm/amiberry?).
Btw: what is this blue program? I couldn't find a "Recalbox Joystick/Gamepad Utility" anywhere...
- the joydev joystick driver and API, with devices
-
@redm it's a program @ironic wrote but didn't share yet
@rockaddicted @substring any thoughts on what redm discovered ?
-
Just read a part of https://www.reddit.com/r/linux_gaming/comments/5xics8/a_big_problem_with_joysticks_in_linux_right_now/ today, it's the same as what @redm said.
Regarding Recalbox :
- the joystick API is outdated, clearly. I think only AplleII and scummvm use SDL 1 for now. Scummvm will switch to SDL2 on the next b*mp, leaving only AppleII on SDL1 (if my memory is not failing)
- considering the joystick API shouldn't be used anymore, we removed
jstest
The questions so far are :
- can we patch dosbox to add a custom deadzone
- is there a way to calibrate a joystick for evdev
Just a reminder : we're talking about a system that needed joystick calibration. Today, is the emulation right regarding this technologic gap ?
-
@substring said in Régler manuellement les deadzones:
Just read a part of https://www.reddit.com/r/linux_gaming/comments/5xics8/a_big_problem_with_joysticks_in_linux_right_now/ today, it's the same as what @redm said.
doh .. I should have found this page earlier, it would have saved me a lot of time
The questions so far are :
- can we patch dosbox to add a custom deadzone
I think this is only the 2nd best option. I would do as much as possible outside of dosbox. Not only because configuring dosbox is a pain anyway, but also because you could then reuse the calibration for all other SDL based emulators and possibly add a UI somewhere.
- is there a way to calibrate a joystick for evdev
Apparently there is a calibration tool now, but evdev is still lacking making the changes persistent though udev.
I would add another point related to this:
-is there a way to select joystick devices for dosbox?With joydev and SDL1 you could set the env variable SDL_JOYSTICK_DEVICE, which is not possible anymore with SDL2. Patch dosbox? Apparently somebody created a patch for dosbox to add a config option: https://sourceforge.net/p/dosbox/patches/253/. But also here, doing this from outside would be nicer. You could add per rom controller configuration to the ES context menu...
Just a reminder : we're talking about a system that needed joystick calibration. Today, is the emulation right regarding this technologic gap ?
What do you mean with this question? I think we need calibration outside of dosbox, if that is the question. At least in my (limited) experience I found it to be more reliable to calibrate with system tools and leave alone all possible in game joystick calibration. That only made things worse. Or are you questioning whether we need calibration at all? In this case I would also say: yes.
-
@substring said in Régler manuellement les deadzones:
the joystick API is outdated, clearly. I think only AplleII and scummvm use SDL 1 for now. Scummvm will switch to SDL2 on the next b*mp, leaving only AppleII on SDL1 (if my memory is not failing)
scummvm is already using sdl2 since last b*mp.
ScummVM-RASPBERRYPI README ============================================================================== Notes ============ This version of ScummVM uses SDL2 hardware accelerated graphics, be it plain SDL2 which in turn uses dispmanx/gles2 or by using gles1 via an SDL2-configured GLES1 context.