Recalbox Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • recalbox.com
    • Gitlab repository
    • Documentation
    • Discord

    Régler manuellement les deadzones

    Manettes/GPIO/Encodeurs
    régler manuellement deadzones
    7
    23
    7056
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • voljega
      voljega Banned last edited by

      @rockaddicted @Substring

      Est ce qu'il est possible de régler manuellement les deadzones des joysticks sur Recalbox avec une commande linux ou autre ?

      Sur dosbox, ça pose pas mal de problèmes avec un pad 360, en particulier avec les mappings de la souris, mais aussi pour se servir du joystick dans les jeux

      voljega 1 Reply Last reply Reply Quote 0
      • voljega
        voljega Banned @voljega last edited by

        @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 ?

        1 Reply Last reply Reply Quote 0
        • ironic
          ironic last edited by ironic

          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 commande jscal
          Je crois qu'elle est dispo sous Recalbox d'origine.

          Exemple, avant la calibration :
          text alternatif
          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) :
          text alternatif

          Maintenant, a voir si on peut faire la meme chose avec les 'events'...

          Rpi2/Rpi3 - LCD/CRT- NES30 Pro-iBUFFALO

          voljega 1 Reply Last reply Reply Quote 0
          • acris
            acris last edited by

            Salut @ironic et @voljega

            Dans differents sujets jai lu
            Qu en modifiant cette valeur du fichier dosbox.cfg

            cycles=max
            

            En ceci

            cycles=8000
            

            Ça pourrait regler des problemes de deadzone.

            voljega 1 Reply Last reply Reply Quote 0
            • voljega
              voljega Banned @ironic last edited by

              @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

              1 Reply Last reply Reply Quote 0
              • voljega
                voljega Banned @acris last edited by voljega

                @acris ah merci je vais tester dès que je peux

                1 Reply Last reply Reply Quote 0
                • acris
                  acris last edited by acris

                  Et aussi cette option

                  timed=true
                  

                  Cetait un sujet sur le jeu Privateer

                  voljega 1 Reply Last reply Reply Quote 0
                  • ironic
                    ironic last edited by

                    @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.

                    Rpi2/Rpi3 - LCD/CRT- NES30 Pro-iBUFFALO

                    1 Reply Last reply Reply Quote 0
                    • voljega
                      voljega Banned @acris last edited by

                      @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 ?

                      OyyoDams 1 Reply Last reply Reply Quote 0
                      • OyyoDams
                        OyyoDams Staff @voljega last edited by

                        @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

                        1 Reply Last reply Reply Quote 1
                        • ironic
                          ironic last edited by

                          Merci @OyyoDams
                          Tout est dit 🙂

                          Rpi2/Rpi3 - LCD/CRT- NES30 Pro-iBUFFALO

                          voljega 1 Reply Last reply Reply Quote 0
                          • voljega
                            voljega Banned @ironic last edited by voljega

                            @ironic @OyyoDams

                            Ok merci, bon malheureusement ça ne marche pas.
                            en éxécutant jscal -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 ?

                            1 Reply Last reply Reply Quote 0
                            • ironic
                              ironic last edited by ironic

                              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...

                              Rpi2/Rpi3 - LCD/CRT- NES30 Pro-iBUFFALO

                              voljega 1 Reply Last reply Reply Quote 0
                              • voljega
                                voljega Banned @ironic last edited by

                                @ironic

                                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

                                1 Reply Last reply Reply Quote 0
                                • acris
                                  acris last edited by acris

                                  @voljega
                                  Une faute de frappe sur le forum ou dans tin fichier ?

                                  timed= flase
                                  

                                  Au lieu de

                                  timed=false 
                                  
                                  voljega 1 Reply Last reply Reply Quote 0
                                  • voljega
                                    voljega Banned @acris last edited by

                                    @acris faute de frappe sur le forum 😉

                                    1 Reply Last reply Reply Quote 0
                                    • redm
                                      redm last edited by redm

                                      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:

                                      1. the joydev joystick driver and API, with devices /dev/input/js*, which is what you used here. This is configured using jscal and friends.
                                      2. 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 use sdl-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 ships jscal-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 then sdl-jstest should give you the results you expect, same as jstest. 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...

                                      voljega 1 Reply Last reply Reply Quote 2
                                      • voljega
                                        voljega Banned @redm last edited by

                                        @redm it's a program @ironic wrote but didn't share yet

                                        @rockaddicted @substring any thoughts on what redm discovered ?

                                        1 Reply Last reply Reply Quote 0
                                        • Substring
                                          Substring last edited by

                                          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 ?

                                          Former dev - Please reply with @substring so that i am notified when you answer me
                                          Ex dev - Merci de me répondre en utilisant @substring pour que je sois notifé

                                          redm rockaddicted voljega 3 Replies Last reply Reply Quote 0
                                          • redm
                                            redm @Substring last edited by

                                            @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.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Want to support us ?

                                            90
                                            Online

                                            99.6k
                                            Users

                                            28.1k
                                            Topics

                                            187.1k
                                            Posts

                                            Copyright © 2021 recalbox.com