Recalbox Forum

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

    Configure joystick device in dosbox

    Emulator Arcade/PC/Console
    configure joystick device dosbox
    2
    7
    5141
    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.
    • redm
      redm last edited by

      Is there a way to configure the joystick device used by dosbox under Recalbox, ideally per game?

      I know you can configure this in dosbox by setting the SDL env variable SDL_JOYSTICK_DEVICE to set the primary joystick device, e.g. using the /dev/input/by-id/usb-My_Old_Favorite_Analog_Stick-joystick... But I can't get this to work on Recalbox.

      First problem is that I don't see an obvious place to put that setting for a certain game. Neither a config nor a shell script that is run per game where I could set it or whatever.

      Then I found /usr/lib/python2.7/site-packages/configgen/generators/dosbox/dosboxGenerator.py[c] which sets some other SDL variable. Here I might at least set it globally, like:

          return Command.Command(videomode='default', array=commandArray, env={"SDL_JOYSTICK_DEVICE":"/dev/input/js1","SDL_VIDEO_GL_DRIVER":"/usr/lib/libGLESv2.so"})
      

      But it seems to be ignored... it keeps always using /dev/input/js0.

      Anyone an idea?

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

        @redm see https://github.com/recalbox/recalbox-os/wiki/How-to-use-DOSBox-to-emulate-DOS-games Advanced Rundown section and mapperfile

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

          @voljega No, that's not quite what I mean. This is about mapping individual functions inside dosbox (I guess you could also map the entire 2nd device as the 1st device this way, but this would be a bit cumbersome and you still don't know which one this is, just that it is the second, which could change on next boot). What I mean is configuring the device that dosbox sees as first joystick. This could also be the 3rd OS device, where dosbox by default only sees the first two. And it allows to map a device explicitly by name, e.g. my analog joystick, no matter which OS device number it happens to be.

          Ideally there would be a device option inside the settings file (I think I even saw a patch for this in some forum somewhere in the internet), but as far as I found there is currently only this SDL variable to set the first device.

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

            @redm well ideally dosbox will see the device #1 as the one mapped as such in Emulation Station...
            Recalbox configgen should handle that, if you know python you can look into it.

            Besides that or tweaking the mapper there isn't much to be done I think

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

              @voljega well yea, right 😉 super-ideally I could then override this on a per-game basis. So I can have my gamepads as devices 1 and 2, my analog stick as 3, but I can override the general setting for flight games to have 3 as first device. That's actually what I'm trying to get solved: forcing the analog stick as primary device for flight games, while using gamepads otherwise. For this I would then still have to change the controller config every time I want to play such a game.

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

                Ok, I did some investigation... It seems the point of being able to configure joysitck devices at all boils down to an SDL compile configuration problem...

                My joystick devices (limited to the said analog stick for simplicity):

                # ls -l /dev/input/by-id/*joystick
                lrwxrwxrwx    1 root     root             9 Jan  1  1980 /dev/input/by-id/usb-Padix_Co._Ltd._2-axis_4button_joystick_w_view_finder_rudder-event-joystick -> ../event1
                lrwxrwxrwx    1 root     root             6 Jan  1  1980 /dev/input/by-id/usb-Padix_Co._Ltd._2-axis_4button_joystick_w_view_finder_rudder-joystick -> ../js0
                

                I.e. /dev/input/js0 and /dev/input/event1 repectively.

                Lets see which devices SDL programs use by default with sdl-jstest and sdl2-jstest:

                # sdl-jstest - open fds without SDL_JOYSTICK_DEVICE
                total 0
                lrwx------    1 root     root            64 Oct 31 16:16 0 -> /dev/pts/0
                lrwx------    1 root     root            64 Oct 31 16:16 1 -> /dev/pts/0
                lrwx------    1 root     root            64 Oct 31 16:16 2 -> /dev/pts/0
                lrwx------    1 root     root            64 Oct 31 16:16 3 -> /dev/fb0
                lrwx------    1 root     root            64 Oct 31 16:16 4 -> /dev/tty4
                lrwx------    1 root     root            64 Oct 31 16:16 5 -> /dev/input/mice
                lr-x------    1 root     root            64 Oct 31 16:16 6 -> /dev/input/event1
                
                
                # sdl2-jstest - open fds without SDL_JOYSTICK_DEVICE
                # ls -l /proc/1131/fd             
                total 0
                lrwx------    1 root     root            64 Oct 31 16:19 0 -> /dev/pts/0
                lrwx------    1 root     root            64 Oct 31 16:19 1 -> /dev/pts/0
                lrwx------    1 root     root            64 Oct 31 16:19 2 -> /dev/pts/0
                lrwx------    1 root     root            64 Oct 31 16:19 3 -> /dev/vchiq
                lrwx------    1 root     root            64 Oct 31 16:19 4 -> socket:[9440]
                lr-x------    1 root     root            64 Oct 31 16:19 5 -> /dev/input/event2
                lr-x------    1 root     root            64 Oct 31 16:19 6 -> /dev/input/event0
                lr-x------    1 root     root            64 Oct 31 16:19 7 -> /dev/input/mouse0
                lrwx------    1 root     root            64 Oct 31 16:19 8 -> /dev/tty1
                lr-x------    1 root     root            64 Oct 31 16:19 9 -> /dev/input/event1
                

                Both use the raw event device /dev/input/event1 as joystick device. Now you can override this by setting the environment variable export SDL_JOYSTICK_DEVICE=/dev/input/js0:

                # sdl-jstest - open fds with SDL_JOYSTICK_DEVICE
                # ls -l /proc/1140/fd
                total 0
                lrwx------    1 root     root            64 Oct 31 16:21 0 -> /dev/pts/0
                lrwx------    1 root     root            64 Oct 31 16:21 1 -> /dev/pts/0
                lrwx------    1 root     root            64 Oct 31 16:21 2 -> /dev/pts/0
                lrwx------    1 root     root            64 Oct 31 16:21 3 -> /dev/fb0
                lrwx------    1 root     root            64 Oct 31 16:21 4 -> /dev/tty4
                lrwx------    1 root     root            64 Oct 31 16:21 5 -> /dev/input/mice
                lr-x------    1 root     root            64 Oct 31 16:21 6 -> /dev/input/js0
                

                It uses the configured device, great, so for SDL1 this works.

                # sdl2-jstest - open fds without SDL_JOYSTICK_DEVICE
                # ls -l /proc/1131/fd             
                total 0
                lrwx------    1 root     root            64 Oct 31 16:19 0 -> /dev/pts/0
                lrwx------    1 root     root            64 Oct 31 16:19 1 -> /dev/pts/0
                lrwx------    1 root     root            64 Oct 31 16:19 2 -> /dev/pts/0
                lrwx------    1 root     root            64 Oct 31 16:19 3 -> /dev/vchiq
                lrwx------    1 root     root            64 Oct 31 16:19 4 -> socket:[9440]
                lr-x------    1 root     root            64 Oct 31 16:19 5 -> /dev/input/event2
                lr-x------    1 root     root            64 Oct 31 16:19 6 -> /dev/input/event0
                lr-x------    1 root     root            64 Oct 31 16:19 7 -> /dev/input/mouse0
                lrwx------    1 root     root            64 Oct 31 16:19 8 -> /dev/tty1
                lr-x------    1 root     root            64 Oct 31 16:19 9 -> /dev/input/event1
                

                However, unfortunately it doesn't work for SDL2, it keeps using /dev/input/event1.

                The problem: Dosbox as compiled for Recalbox uses SDL2, and thus ignores the env variable and keeps opening the first raw event devices 😞
                (Retropie for instance uses SDL1, that's why it works there).

                # ps xa|grep dos
                1163 root     /usr/bin/dosbox -userconf -exit /recalbox/share/roms/dos/wing2.pc/dosbox.bat -c set ROOT=/recalbox/share/roms/dos/wing2.pc -conf /recalbox/share/system/configs/dosbox/dosbox.conf
                
                # cat /proc/1163/environ 
                ... SDL_JOYSTICK_DEVICE=/dev/input/js0...
                
                # ls -l /proc/1163/fd
                lr-x------    1 root     root            64 Oct 31 16:27 11 -> /dev/input/event1
                
                # cat /proc/1163/maps |grep -i sdl
                76be4000-76cc5000 r-xp 00000000 b3:0b 39837      /usr/lib/libSDL2-2.0.so.0.4.0
                

                I didn't find any other possibility to convince SDL2 programs to use a different device. The only thing I found is that there seems to be a compile time option to use the real joystick devices by default instead of raw event devices. Even if, not sure if that would enable the env variable to actually allow selecting them. Or maybe there is another compile option for this?

                (Btw: this is most likely also the reason why your configured deadzones are not picked up by dosbox: you configure the joystick driver devices js* with jscal, but dosbox/SDL uses the raw event devices.)

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

                  @redm you must be right, good catch !

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

                  Want to support us ?

                  84
                  Online

                  98.9k
                  Users

                  28.1k
                  Topics

                  187.1k
                  Posts

                  Copyright © 2021 recalbox.com