Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report Share button as a BTN_, instead of KEY_RECORD #20 #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Beanow
Copy link

@Beanow Beanow commented Oct 7, 2023

Porting over from medusalix#20

On kernel 6.5.5, can confirm that evtest is updated accordingly and under Firefox https://luser.github.io/gamepadtest/ will report the share button as a working 11th button. Though it doesn't seem to work under Edge (flatpak) or Rocket League (proton 8.0).

evtest                                                                                                                                                                                      1 ✘  13s  
No device specified, trying to scan all of /dev/input/event*
Not running as root, no devices may be available.
Available devices:
...
/dev/input/event258:    Microsoft Xbox Controller
...
Select the device event number [0-258]: 258

Input driver version is 1.0.1
Input device ID: bus 0x6 vendor 0x45e product 0xb12 version 0x511
Input device name: "Microsoft Xbox Controller"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 304 (BTN_SOUTH)
    Event code 305 (BTN_EAST)
    Event code 307 (BTN_NORTH)
    Event code 308 (BTN_WEST)
    Event code 310 (BTN_TL)
    Event code 311 (BTN_TR)
    Event code 314 (BTN_SELECT)
    Event code 315 (BTN_START)
    Event code 316 (BTN_MODE)
    Event code 317 (BTN_THUMBL)
    Event code 318 (BTN_THUMBR)
    Event code 714 (BTN_TRIGGER_HAPPY11)
  Event type 3 (EV_ABS)
    Event code 0 (ABS_X)
      Value    412
      Min   -32768
      Max    32767
      Fuzz      16
      Flat     128
    Event code 1 (ABS_Y)
      Value    245
      Min   -32768
      Max    32767
      Fuzz      16
      Flat     128
    Event code 2 (ABS_Z)
      Value      0
      Min        0
      Max     1023
    Event code 3 (ABS_RX)
      Value    177
      Min   -32768
      Max    32767
      Fuzz      16
      Flat     128
    Event code 4 (ABS_RY)
      Value   -397
      Min   -32768
      Max    32767
      Fuzz      16
      Flat     128
    Event code 5 (ABS_RZ)
      Value      0
      Min        0
      Max     1023
    Event code 16 (ABS_HAT0X)
      Value      0
      Min       -1
      Max        1
    Event code 17 (ABS_HAT0Y)
      Value      0
      Min       -1
      Max        1
  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)
...
Event: time 1696689585.729637, type 1 (EV_KEY), code 714 (BTN_TRIGGER_HAPPY11), value 1
Event: time 1696689585.729637, -------------- SYN_REPORT ------------
Event: time 1696689585.817695, type 1 (EV_KEY), code 714 (BTN_TRIGGER_HAPPY11), value 0
Event: time 1696689585.817695, -------------- SYN_REPORT ------------

mbenkmann and others added 2 commits March 15, 2023 21:48
KEY_RECORD is a multi-media keyboard key that starts audio recording.
This is not the meaning of the Share button.
Having the Share button report KEY_RECORD has side-effects:
- software gets confused (see e.g. libsdl-org/SDL#6296)
- The Xorg server opens the controller device, keeps it permanently open and
  reads its buttons and reports share button presses as XF86AudioRecord to
  applications. Users do not expect this.
I grepped the Linux kernel's drivers/input/joystick and there exists
NO OTHER joystick type controller that reports a KEY_ type event.
They all use BTN_* events.
I'm sure the person who added the Share button originally just grabbed
some event without giving it much thought.
@dlundqvist
Copy link
Owner

Sorry for the late response. I think this is the correct thing to do, my only questions what button to use. I tried looking around in different input and joystick drivers but could not see any other uses of HAPPY11. Is it up to our discretion to choose one?

@Beanow
Copy link
Author

Beanow commented Oct 18, 2023

I'm not completely sure either. Maybe @mbenkmann had a rationale for this number specifically.

But my understanding is that... 14 years ago torvalds/linux@cf2f765 the BTN_TRIGGER_HAPPY* range was added since the existing BTN_* range was too short to cover controllers with more buttons.

Looking at a recent addition of trigger happy to xpad.c which adds back paddles like these:
image

They seem to be using BTN_* and BTN_TRIGGER_HAPPY* freely mixed though. So rather than starting at HAPPY11 because it happens to be the 11th button. You also see HAPPY1 - 4 in case the D-pad is mapped to buttons rather than an axis. And the new HAPPY5 - 8 for the paddles.

I think if we're looking to avoid conflicts with what xpad is defining anywhere above HAPPY9 appears unclaimed.

(Nb: Android seems to have the RECORD binding, and xpadneo maps to F12 to try and trigger steam's screenshots )

There's discussion in xpadneo btw including feedback from the SDL side: atar-axis/xpadneo#428 (comment) There wasn't a conclusion on the SHARE button specifically, but looking through it there certainly seems more to it than just pick one 😆

@Beanow
Copy link
Author

Beanow commented Oct 18, 2023

Actually, while the thread said KEY_RECORD probably wasn't the best idea to go into the kernel. It is in the kernel for xpad.c and so SDL added support too. libsdl-org/SDL@db1d4d3#diff-7d94ff2175e20395f77eafb0287c2f5efa984bc6adfba9a1becd6cd2a8314187R2110

The maintainer there at least seems to have gone from RECORD to HAPPY1 to F12, with more plans to look for better solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants