RetroArch
RetroArch copied to clipboard
[Feature Request] Add Windows.Gaming.Input API support
First and foremost consider this:
- Only RetroArch bugs should be filed here. Not core bugs or game bugs
- This is not a forum or a help section, this is strictly developer oriented
Description
Request to add support for the Windows.Gaming.Input API.
Benefits include Xbox One and Series controller trigger rumble motors to be utilized.
Also, support for the Share button on Xbox Series controller to be detectable and mappable, as well as possibly better battery level detection, though currently all xbox controllers under retroarch on windows doesn’t detect at all.
Possibly the newest input standard for Windows builds, with possible benefit of utilizing dynamic latency input.
Environment information
Windows 11
Partially related to #13636.
Duplicate: https://github.com/libretro/RetroArch/issues/9778
Looking at the Windows.Gaming.Input documentation, the share button is not defined, but the four paddle buttons of the Elite controller are.
https://docs.microsoft.com/en-us/uwp/api/windows.gaming.input.gamecontrollerbuttonlabel?view=winrt-22621
Halfway down Share
is referenced as 30
, though I don't know if that is technically defined or not.
Interesting, but it is not in [GamepadButtons] https://docs.microsoft.com/en-us/uwp/api/windows.gaming.input.gamepadbuttons?view=winrt-22621, so how should one read the state of the Share button? I don't have a series controller to test.
The Xbox button is also not listed, but is still defined.
Share could possibly be the button listed as None
with a value of 0
.
Also, given the labeling and grouping of the middle buttons, it could have an unlisted value of 3
.
The Share button is readable in Game Controller Settings
under Devices and Printers
under the Control Panel, detected as button 12
.
The buttons reading is a bitset, so 0 and 3 won't make sense. It might be 524288 (0x80000, or 1 << 19). Do you have a Series controller? I can give you a test program.
I do.
Can you try GamingInputTest.zip (code at https://github.com/driver1998/GamingInputTest), press down the share button, and see what does Button say?
Note: The Guide button value is undocumented too, and it uses 0x40000000 (1073741824, 1<<30) which is insanely big. I guess the share button would be similar.
It doesn't register the Share button.
The Guide button also doesn't register, though it still works fine in Retroarch.
Tried wireless and wired, and tried running as administrator, just in case.
All other inputs register fine.
You'll need to disable "press xbox button to open game bar" to make the Guide button register. But I guess you already did since it works in RetroArch.
Not sure about share though.
If it's not already, then maybe Raw input might help to detect the proper register values.
Trying to see if there is any other software that can pick up something, though most only assume a Guide button and 2 middle buttons.
https://github.com/djlastnight/HidRawDataWatcher
Detects button values listed below:
000 211 125 114 128 106 128 129 129 000 128 000 008 000 000 000
Share
000 211 125 114 128 106 128 129 129 000 128 000 000 000 000 000
000 211 125 114 128 106 128 129 129 000 128 000 004 000 000 000
Guide
000 211 125 114 128 106 128 129 129 000 128 000 000 000 000 000
LButton, XButton2 [released] | Make code: 0 | VKey: 7
Given these values and what you showed above for the Guide button, it's possible the Share button would register as 80000000
.
Pure speculation at this point.
Actually it will show the value even if it is not recognized, so I afraid it is not supported at all.
The Guide button wasn't showing a value in GamingInputTest either, but is still supported.
Also, the Share button does work under Steam, both with its default function of taking screenshots, and is configurable.
About the values in HidRawDataWatcher, Share in the 'ON' state was listed as 000 211 125 114 128 106 128 129 129 000 128 000 008 000 000 000
, in contrast the Y button was listed as 000 211 125 114 128 106 128 129 129 000 128 008 000 000 000 000
.
The values in both were identical, with the exception of the 008
part being shifted one section over.
The Guide button and the X button were the same way.
This may not mean much, but at least it's a visible difference, for what it's worth.
I just checked something after having a random thought. In RetroArch, if the controller driver is set to dinput, Share is detected as button 11.
The remaining buttons are detected as follows:
A=0, B=1, X=2, Y=3, LB=4, RB=5, View=6, Menu=7, LS=8, RS=9, Guide=10, Share=11
Xinput, sdl2, and HID do not detect the Share button, though HID didn't work at all for any function.
Sure I could do that (actually Windows.Gaming.GameInput has a raw HID interface).
But I afraid IGamepad (which is the interface specifically for Xbox controllers with rumble and battery report) does not expose the share button.
Rumble could be handled with a wrapper if need be, though not desired. Not sure about trigger motors.
As for battery reporting, currently battery levels are not shown in RetroArch for the Series controller, either wired or wireless, with neither Xbox Wireless Adapter or bluetooth.
Not sure if there is anything dinput is doing differently that can help expose the Share input for other drivers, but if you need me to test anything more, just let me know.
Thanks.
Interesting code experiment @driver1998 . Could this work from Win32 too?
@LibretroAdmin It is Win32 and pure C all along.
It would be nice to start having ways of reporting battery level per game pad. RetroArchs input system will obviously need some extensions for this but it'd be worth it.
Dolphin standalone has the Share button both detectable and configurable through SDL2, so that might be a better solution since SDL2 is already implemented here.
Not sure what is missing to allow for that to work, and also rumble doesn’t work with SDL2 under Windows in Retroarch, but does in Dolphin standalone, so additional work would be necessary.
It could detect share button by SDL2 controller driver. (not now) I found some clue on this code. https://github.com/Adam777Z/xbox-controller-button-remapper/blob/main/main.cpp (This app can detect share button via SDL library on windows.)