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

[Linux] The share button on Xbox Series X|S controller produces "double events" #6296

Closed
Igetin opened this issue Sep 28, 2022 · 6 comments
Closed
Assignees
Milestone

Comments

@Igetin
Copy link

Igetin commented Sep 28, 2022

Description

When pressing the share button on the Xbox Series X|S controller, it seems to be produce "double events". When running the testjoypad program provided with the SDL source, a button press outputs the following:

INFO: Joystick 0 button 15 down
The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL forums/mailing list <https://discourse.libsdl.org/> X11 KeyCode 175 (167), X11 KeySym 0x1008FF1C (XF86AudioRecord).
INFO: Joystick 0 button 15 up

I originally posted about this erroneously on a different SDL issue. My use case is that I want to map the share button in AntiMicroX, which uses SDL behind the scenes. However, the button press is not recognized by the program, and its developer deemed that the issue might be caused by SDL.

Note that I do not know if this is actually a bug in SDL, or even if it is a bug at all! I was just redirected here by another developer.

I can try to provide more information if needed.

Environment

  • Operating system: Fedora 35
  • Display server: Xorg 1.20.14
  • Kernel: Linux 5.18.18
@slouken
Copy link
Collaborator

slouken commented Sep 28, 2022

There are several issues here. The first is AntiMicroX not recognizing the share button. I haven't looked at the source code, but AntiMicroX may not be looking for the button SDL_CONTROLLER_BUTTON_MISC1. The bug report there didn't have enough information because of the second issue - the Xbox kernel driver being used to generate the log output doesn't support the share button at all, so it never showed up.

The final issue, is the kernel driver on your system is translating the share button into a keypress that is being interpreted by X11 as an audio record action.

I can fix the error message, but you might want to debug AntiMicroX and see if it's handling the misc1 button. If you find that it isn't, the author is more likely to see what's happening if you file a working patch or a pull request that fixes the issue for you.

@slouken slouken self-assigned this Sep 28, 2022
@slouken slouken added this to the 2.26.0 milestone Sep 28, 2022
@Igetin
Copy link
Author

Igetin commented Sep 28, 2022

AntiMicroX may not be looking for the button SDL_CONTROLLER_BUTTON_MISC1

I just checked, seems like you are right about this. I'll message the author about it. Thanks!

The final issue, is the kernel driver on your system is translating the share button into a keypress that is being interpreted by X11 as an audio record action.

Ah, that might be a nuisance at some point… in that case I will have to research if I can somehow easily disable that behavior.

@pktiuk
Copy link

pktiuk commented Oct 16, 2022

Hello @slouken

The main source of the problem is not the lack of direct handling of SDL_CONTROLLER_BUTTON_MISC1 but the different behaviour of Share button in comparison to other buttons of gamepad.

While other buttons when pressed launch two events (for example SDL_CONTROLLERBUTTONDOWN and SDL_JOYBUTTONDOWN) the Share button launches only one event (SDL_JOYBUTTONDOWN).

Is it intended behaviour? (for devices that are marked as SDL_IsGameController() only events SDL_GAMECONTROLLER... are handled)

Example logs
[15:12:59.492] 🐞DEBUG	Processing event: SDL_CONTROLLERBUTTONDOWN From joystick with instance id: 0 Got button with id: 0 is one of the GameControllers: true is one of the joysticks:false (file unner/work/antimicrox/antimicrox/src/inputdaemon.cpp:751)
[15:12:59.492] 🐞DEBUG	Processing event: SDL_JOYBUTTONDOWN From joystick with instance id: 0 Got button with id: 0 is one of the GameControllers: true is one of the joysticks:false (file unner/work/antimicrox/antimicrox/src/inputdaemon.cpp:751)
[15:12:59.492] 🐞DEBUG	Processing JoyButton::joyEvent for: A: [NO KEY] SDL index: 0 className: JoyButton (file unner/work/antimicrox/antimicrox/src/joybutton.cpp:179)
[15:12:59.623] 🐞DEBUG	Processing event: SDL_CONTROLLERBUTTONUP From joystick with instance id: 0 Got button with id: 0 is one of the GameControllers: true is one of the joysticks:false (file unner/work/antimicrox/antimicrox/src/inputdaemon.cpp:751)
[15:12:59.623] 🐞DEBUG	Processing event: SDL_JOYBUTTONUP From joystick with instance id: 0 Got button with id: 0 is one of the GameControllers: true is one of the joysticks:false (file unner/work/antimicrox/antimicrox/src/inputdaemon.cpp:751)
[15:12:59.623] 🐞DEBUG	Processing JoyButton::joyEvent for: A: [NO KEY] SDL index: 0 className: JoyButton (file unner/work/antimicrox/antimicrox/src/joybutton.cpp:179)
[15:13:02.394] 🐞DEBUG	Processing event: SDL_JOYBUTTONDOWN From joystick with instance id: 0 Got button with id: 15 is one of the GameControllers: true is one of the joysticks:false (file unner/work/antimicrox/antimicrox/src/inputdaemon.cpp:751)
[15:13:02.544] 🐞DEBUG	Processing event: SDL_JOYBUTTONUP From joystick with instance id: 0 Got button with id: 15 is one of the GameControllers: true is one of the joysticks:false (file unner/work/antimicrox/antimicrox/src/inputdaemon.cpp:751)

@slouken
Copy link
Collaborator

slouken commented Oct 16, 2022

Ah, this means it's just not in the mapping. You can use controllermap (that comes in the SDL test directory) to generate a binding and include it here for the next SDL release.

@Igetin
Copy link
Author

Igetin commented Oct 16, 2022

I actually added the mapping for that controller in the SDL_GameControllerDB repository a few days ago, but I wasn't really familiar with the exact relationship of that project and the main SDL repo. It seems like SDL also has its own set of mappings included with the library? In any case, you can find the mapping from the link.

@slouken
Copy link
Collaborator

slouken commented Oct 16, 2022

The projects are independent. The ones that are included in SDL directly are validated a little more rigorously and so aren't automatically added from SDL_GameControllerDB.

I added your mapping, thanks!

mbenkmann added a commit to mbenkmann/xone that referenced this issue Mar 15, 2023
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.
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

No branches or pull requests

3 participants