Recalbox Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • recalbox.com
    • Gitlab repository
    • Documentation
    • Discord
    1. Home
    2. redm
    3. Best
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 24
    • Best 2
    • Controversial 0
    • Groups 0

    Best posts made by redm

    • RE: Régler manuellement les deadzones

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

      posted in Manettes/GPIO/Encodeurs
      redm
      redm
    • RE: Configure joystick device in dosbox

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

      posted in Emulator Arcade/PC/Console
      redm
      redm