0

I have these joypads:

enter image description here

And they work well (e.g. when interacting with RetroArch, in my Raspberry OS [Bullseye], and when interacting with a sample Godot 4.0 interface I created, this time in my Ubuntu 22.04).

BUT then I try the evdev library in Python 3.10, the mappings do not work properly.

However, instead of trying the Python code, I'll try evtest (which -I proved- has the same error happening; I'll not run it as sudo, but the same thing happens if I instead use sudo):

me@here:here$ evtest
No device specified, trying to scan all of /dev/input/event*
Not running as root, no devices may be available.
Available devices:
/dev/input/event18: Microntek              USB Joystick          
/dev/input/event19: usb gamepad           
Select the device event number [0-19]: 18
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x79 product 0x6 version 0x110
Input device name: "Microntek              USB Joystick          "
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 288 (BTN_TRIGGER)
    Event code 289 (BTN_THUMB)
    Event code 290 (BTN_THUMB2)
    Event code 291 (BTN_TOP)
    Event code 292 (BTN_TOP2)
    Event code 293 (BTN_PINKIE)
    Event code 294 (BTN_BASE)
    Event code 295 (BTN_BASE2)
    Event code 296 (BTN_BASE3)
    Event code 297 (BTN_BASE4)
    Event code 298 (BTN_BASE5)
    Event code 299 (BTN_BASE6)
  Event type 3 (EV_ABS)
    Event code 0 (ABS_X)
      Value    127
      Min        0
      Max      255
      Flat      15
    Event code 1 (ABS_Y)
      Value    127
      Min        0
      Max      255
      Flat      15
    Event code 2 (ABS_Z)
      Value    128
      Min        0
      Max      255
      Flat      15
    Event code 5 (ABS_RZ)
      Value    128
      Min        0
      Max      255
      Flat      15
    Event code 16 (ABS_HAT0X)
      Value      0
      Min       -1
      Max        1
    Event code 17 (ABS_HAT0Y)
      Value      0
      Min       -1
      Max        1
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
  Event type 21 (EV_FF)
    Event code 80 (FF_RUMBLE)
    Event code 81 (FF_PERIODIC)
    Event code 88 (FF_SQUARE)
    Event code 89 (FF_TRIANGLE)
    Event code 90 (FF_SINE)
    Event code 96 (FF_GAIN)
Properties:
Testing ... (interrupt to exit)
Event: time 1681999582.521318, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90009
Event: time 1681999582.521318, type 1 (EV_KEY), code 296 (BTN_BASE3), value 1
Event: time 1681999582.521318, -------------- SYN_REPORT ------------
Event: time 1681999582.729300, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90009
Event: time 1681999582.729300, type 1 (EV_KEY), code 296 (BTN_BASE3), value 0
Event: time 1681999582.729300, -------------- SYN_REPORT ------------
Event: time 1681999585.033447, type 4 (EV_MSC), code 4 (MSC_SCAN), value 9000a
Event: time 1681999585.033447, type 1 (EV_KEY), code 297 (BTN_BASE4), value 1
Event: time 1681999585.033447, -------------- SYN_REPORT ------------
Event: time 1681999585.241269, type 4 (EV_MSC), code 4 (MSC_SCAN), value 9000a
Event: time 1681999585.241269, type 1 (EV_KEY), code 297 (BTN_BASE4), value 0
Event: time 1681999585.241269, -------------- SYN_REPORT ------------

If you see the logs (which are pretty much the same for the joypad at event position 19) you'll notice two things:

  • First, I pressed and released the button typically present in the SELECT position. Two events. It shows as if BTN_BASE3 was present, whatever this one is.
  • Then, I pressed and released the button typically present in the START position. Again: two events, but this time BTN_BASE4.

I intended, or expected, the constants to be BTN_SELECT and BTN_START respectively but, while those exist, they're not matched (they have other values, instead of the BASE3 and BASE4 which seems to be 296 and 297 respectively).

This happens in the two devices (both are the generic joypads I shown in the picture) and in the two systems (Ubuntu and Raspberry OS). So I have a bunch of questions:

  • Is this how evdev is working now? Considering those constants instead of BTN_START/SELECT?
  • Or is somehow a driver error I happen to have in BOTH systems? (the weird part: In Ubuntu, I did not intentionally tune anything on joypads, but used whatever I have by default).
  • Is this subject to change in the future? Should I expect surprises if I rely on this? (however: consider the OS version will remain the same long time, since I pretend to rely on evdev to make a special game launcher with a kill sequence consisting of pressing START + SELECT simultaneously a fixed amount of time, pretty much respecting the convention of RetroArch and others alike).
  • Will this happen if other people connects, through proper adapters, other well-known (yet non-generic) joypads? (e.g. XBox, Nintendo GameCube, ...).

Edit: Yes, I notice the available events for keys are:

  Event type 1 (EV_KEY)
    Event code 288 (BTN_TRIGGER)
    Event code 289 (BTN_THUMB)
    Event code 290 (BTN_THUMB2)
    Event code 291 (BTN_TOP)
    Event code 292 (BTN_TOP2)
    Event code 293 (BTN_PINKIE)
    Event code 294 (BTN_BASE)
    Event code 295 (BTN_BASE2)
    Event code 296 (BTN_BASE3)
    Event code 297 (BTN_BASE4)
    Event code 298 (BTN_BASE5)
    Event code 299 (BTN_BASE6)

which is consistent with respect to the events I get. My question is: why is here different? RetroArch in Raspberry OS (and Godot internal joypad matching in Ubuntu) have no problem at all on matching these joypads (I understand they might not use evdev at all, but that does not affect my question in particular: what I can understand is that it is unlikely that both joypads come as blatantly non-standard even being different brands).

Luis Masuelli
  • 12,079
  • 10
  • 49
  • 87

0 Answers0