microsoft / xlang

MIT License
875 stars 103 forks source link

Cannot work with Xbox 360 gamepads via cppwinrt #564

Closed DJm00n closed 5 years ago

DJm00n commented 5 years ago

I'm not sure if it's cppwinrt or the internal WinRT API issue. I described it here: https://stackoverflow.com/questions/57042069/xbox-360-wireless-controller-is-not-working-via-c-winrt-and-windows-gaming-inp And here in FeedbackHub: https://aka.ms/AA5n0lv My simple repro project source code is here: https://github.com/DJm00n/cppwinrtgamepad But there's been no word from MS employees for over a month. Is there any chance that any of you can check this out and get the information to the right people?

kennykerr commented 5 years ago

This sounds like a gaming API question rather than a problem with C++/WinRT. Perhaps @walbourn can help.

Scottj1s commented 5 years ago

Yes, particularly with these test results: Windows 1809: from user X1 and X360 pads are NOT WORKING. from administrator: X1 pad is OK, X360 pad is NOT WORKING. Windows 1903: from user and from administrator X1 and X360 pads are NOT WORKING.

C++/WinRT projections do not change behavior based on OS or account

walbourn commented 5 years ago

A few details:

You can also try the "GamePadTest" in my DirectX Tool Kit for DX12 which uses the WIndows.Gaming.Input API to see if it repros there.

walbourn commented 5 years ago

Apparently this is a focus handling design issue. Windows.Gaming.Input basically doesn't work for console apps as a result, but does work for Win32 or UWP apps that have a window in focus.

Note that the one case where the Xbox One controller worked for you is only because both the user was an admin -and- because you had developer mode enabled. It wouldn't work from a console app at all otherwise.

DJm00n commented 5 years ago

@walbourn Thank you for a blazing answer!

Apparently this is a focus handling design issue. Windows.Gaming.Input basically doesn't work for console apps as a result, but does work for Win32 or UWP apps that have a window in focus.

How Windows.Gaming.Input knows that app have a window? Does it get the window via something like EnumWindows? This Win32 unique behavior should be mentioned in the documentation then.

Also in window-less app there should be meaningful exceptions instead of strange debugging messages like:

onecoreuap\xbox\devices\api\winrt\pnpdevice.cpp(506)\Windows.Gaming.Input.dll!00007FFBE4417B64: (caller: 00007FFBE441AF5A) ReturnHr(1) tid(d250) 80070005 Access is denied.

onecoreuap\xbox\devices\api\winrt\pnpdevicewatcher.cpp(500)\Windows.Gaming.Input.dll!00007FFBE441ABC7: (caller: 00007FFBE441A367) ReturnHr(2) tid(d250) 80070006 The handle is invalid.

Whether there are plans to change or correct this behavior?

ChrisGuzak commented 5 years ago

in window-less app there should be meaningful exceptions instead of strange debugging messages

+1

kennykerr commented 5 years ago

Closing this issue as it has nothing to do with xlang, but feel free to keep chatting here.