RetroArch icon indicating copy to clipboard operation
RetroArch copied to clipboard

[Feature Request] Add Windows.Gaming.Input API support

Open ichee opened this issue 2 years ago • 27 comments

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

ichee avatar Jun 17 '22 23:06 ichee

Partially related to #13636.

ichee avatar Jun 19 '22 00:06 ichee

Duplicate: https://github.com/libretro/RetroArch/issues/9778

driver1998 avatar Jul 01 '22 03:07 driver1998

Looking at the Windows.Gaming.Input documentation, the share button is not defined, but the four paddle buttons of the Elite controller are.

driver1998 avatar Jul 15 '22 03:07 driver1998

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.

ichee avatar Jul 15 '22 04:07 ichee

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.

driver1998 avatar Jul 15 '22 05:07 driver1998

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.

ichee avatar Jul 15 '22 14:07 ichee

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.

driver1998 avatar Jul 19 '22 10:07 driver1998

I do.

ichee avatar Jul 19 '22 12:07 ichee

Can you try GamingInputTest.zip (code at https://github.com/driver1998/GamingInputTest), press down the share button, and see what does Button say?

image

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.

driver1998 avatar Jul 19 '22 16:07 driver1998

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.

ichee avatar Jul 20 '22 01:07 ichee

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.

driver1998 avatar Jul 20 '22 01:07 driver1998

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.

ichee avatar Jul 20 '22 01:07 ichee

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

ichee avatar Jul 20 '22 02:07 ichee

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.

ichee avatar Jul 20 '22 03:07 ichee

Actually it will show the value even if it is not recognized, so I afraid it is not supported at all.

driver1998 avatar Jul 20 '22 03:07 driver1998

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.

ichee avatar Jul 20 '22 03:07 ichee

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.

ichee avatar Jul 20 '22 04:07 ichee

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.

driver1998 avatar Jul 20 '22 04:07 driver1998

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.

ichee avatar Jul 20 '22 05:07 ichee

Interesting code experiment @driver1998 . Could this work from Win32 too?

LibretroAdmin avatar Sep 02 '22 00:09 LibretroAdmin

@LibretroAdmin It is Win32 and pure C all along.

driver1998 avatar Sep 02 '22 01:09 driver1998

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.

LibretroAdmin avatar Sep 02 '22 13:09 LibretroAdmin

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.

ichee avatar Jun 08 '23 20:06 ichee

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

nayasis avatar May 08 '24 16:05 nayasis

As workaround and testing purpose for SDL2 driver, may you try to update SDL2.dll and check if button detection/rumble is working ?

Source

gouchi avatar May 10 '24 14:05 gouchi