[UWP] [CX]注册HidDevice-> InputReportReceived在断开Xbox One S控制器时总是会导致事件异常 [英] [UWP][CX] Registering for HidDevice->InputReportReceived always causes event exception when disconnecting Xbox One S controller

查看:86
本文介绍了[UWP] [CX]注册HidDevice-> InputReportReceived在断开Xbox One S控制器时总是会导致事件异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用HID API获取游戏控制器输入的UWP应用程序。我知道Windows.Gaming.Input,但我想要选项支持非Xbox控制器。 (它也可以选择使用Windows.Gaming.Input API。)


我遇到了一个严重的错误,每次有线Xbox One都会崩溃应用程序注册HID输入报告事件后,S控制器被拔出。我花了几天时间尝试调试这个,但我把它归结为在HidDevice-> InputReportReceived事件上注册
事件监听器的行为。如果我立即取消注册侦听器或设备删除通知并不重要,它会在拔出控制器后立即崩溃应用程序。使用旧的非XInput游戏手柄或有线Xbox 360控制器不会发生


这是来自VS的错误和堆栈跟踪:

检测到严重错误c0000374 
MyApplication.exe已触发断点。
> ntdll.dll!_RtlReportCriticalFailure@12()未知
ntdll.dll!_RtlpReportHeapFailure@4()未知
ntdll.dll!_RtlpHeapHandleError@4()未知
ntdll.dll!_RtlpLogHeapFailure@24( )未知
ntdll.dll!_RtlpHpLfhSubsegmentFreeBlock@16()未知
ntdll.dll!_RtlpHpSegFree@12()未知
ntdll.dll!_RtlpHpFreeHeap@20()未知
ntdll。 dll!RtlpFreeHeapInternal()未知
ntdll.dll!_RtlpHpFreeWithExceptionProtection@12()未知
ntdll.dll!RtlFreeHeap()未知
msvcrt.dll!_free()未知
Windows。 Devices.HumanInterfaceDevice.dll!Windows :: Devices :: HumanInterfaceDevice :: ReadInputOperation ::`vector deletion destructor'(unsigned int)Unknown
Windows.Devices.HumanInterfaceDevice.dll!Microsoft :: WRL :: Details :: RuntimeClass< ; struct Microsoft :: WRL :: Details :: InterfaceList< struct Windows :: Foundation :: IAsyncOperation< unsigned int> ;, struct Microsoft :: WRL :: Details :: InterfaceList< class Microsoft :: WRL :: AsyncBase< struct Windows :: Foundation :: IAsyncOperationCompletedHandler< unsigned int>,类Microsoft :: WRL :: Details :: Nil,1,struct Microsoft :: WRL :: AsyncOptions< -1,0,& struct _GUID const GUID_CAUSALITY_WINDOWS_PLATFORM_ID,2> > ;,类Microsoft :: WRL :: Details :: Nil> > ;, struct Microsoft :: WRL :: RuntimeClassFlags< 1>,1,1,0> :: Release(void)Unknown
Windows.Devices.HumanInterfaceDevice.dll!Microsoft :: WRL :: Details :: MakeAndInitialize< ;类Windows :: Devices :: HumanInterfaceDevice :: ReadInputOperation,struct Windows :: Foundation :: IAsyncOperation< class Windows :: Devices :: HumanInterfaceDevice :: HidInputReport *> ;, void *&,struct _TP_IO *& ;, unsigned short &,struct _HIDP_PREPARSED_DATA *&,void(&)(long,void *,void *),类Windows :: Devices :: HumanInterfaceDevice :: HidDeviceServer * const>(struct Windows :: Foundation :: IAsyncOperation< class Windows :: Devices :: HumanInterfaceDevice :: HidInputReport *> * *,void *&,struct _TP_IO *& ;, unsigned short&,struct _HIDP_PREPARSED_DATA *&,void(&)(long,void *,void * ),类Windows :: Devices :: HumanInterfaceDevice :: HidDeviceServer * const&&)未知
Windows.Devices.HumanInterfaceDevice.dll!Windows :: Devices :: HumanInterfaceDevice :: HidDeviceServer :: Qu eueAsyncReadOperation(void)未知
Windows.Devices.HumanInterfaceDevice.dll!Windows :: Devices :: HumanInterfaceDevice :: HidDeviceServer :: InvokeListeners(long,struct Windows :: Devices :: HumanInterfaceDevice :: IHidInputReport *)Unknown
Windows.Devices.HumanInterfaceDevice.dll!Windows :: Devices :: HumanInterfaceDevice :: HidDeviceServer :: OnEvent(long,void *,void *)未知
Windows.Devices.HumanInterfaceDevice.dll!Windows :: Devices :: HumanInterfaceDevice :: ReadInputOperation :: ThreadpoolCompletionCallback(struct _TP_CALLBACK_INSTANCE *,void *,void *,unsigned long,unsigned long,struct _TP_IO *)Unknown
Windows.Devices.HumanInterfaceDevice.dll!Windows :: Devices :: HumanInterfaceDevice :: HidDeviceServer :: OnThreadpoolIoComplete(struct _TP_CALLBACK_INSTANCE *,void *,void *,unsigned long,unsigned long,struct _TP_IO *)Unknown
KernelBase.dll !_BasepTpIoCallback@20()未知
ntdll.dll!TppIopExecuteCallback( )未知
ntdll.dll!TppWorkerThread()未知
kernel32 .dll!@BaseThreadInitThunk @ 12()未知
ntdll.dll!__ RtlUserThreadStart()未知
ntdll.dll!__RtlUserThreadStart@8()未知

这是我用来注册事件监听器的代码:

 EventRegistrationToken token = hidDevice-> InputReportReceived + = ref new TypedEventHandler< HidDevice ^, HidInputReportReceivedEventArgs ^>(HidDevice_OnInputReportReceived); 
return& token;

并取消注册:

 hidDevice-> InputReportReceived  - = * token; 

输入报告事件是否实际消耗并不重要。如果事件回调只是一个空的静态函数,它甚至会崩溃。


正如我所提到的,它对我测试的其他HID设备完美无缺,只能在Xbox One S上死机控制器。

解决方案

您好GuavamanX,


您能告诉我您的设备操作系统版本和操作系统构建,具体设备或控制器是否有此问题?此外,您可以使用反馈中心应用程序反馈此问题,以便相关团队可以查看并缩小范围。


祝你好运,


微风


I'm developing a UWP application that uses the HID API for getting game controller input. I'm aware of Windows.Gaming.Input, but I want the option to support non-Xbox controllers. (It will have an option to use the Windows.Gaming.Input API as well.)

I've run into a serious bug that crashes the application every single time when a wired Xbox One S controller is unplugged after registering for HID input report events. I've spent days trying to debug this, but I've boiled it down to the very act of registering an event listener on the HidDevice->InputReportReceived event. It doesn't matter if I unregister the listener immediately or on device removal notification, it always crashes the application immediately after unplugging the controller. This does not happen with an old non-XInput gamepad or with a wired Xbox 360 controller.

Here is the error and the stack trace from VS:

Critical error detected c0000374
MyApplication.exe has triggered a breakpoint.
>	ntdll.dll!_RtlReportCriticalFailure@12()	Unknown
 	ntdll.dll!_RtlpReportHeapFailure@4()	Unknown
 	ntdll.dll!_RtlpHeapHandleError@4()	Unknown
 	ntdll.dll!_RtlpLogHeapFailure@24()	Unknown
 	ntdll.dll!_RtlpHpLfhSubsegmentFreeBlock@16()	Unknown
 	ntdll.dll!_RtlpHpSegFree@12()	Unknown
 	ntdll.dll!_RtlpHpFreeHeap@20()	Unknown
 	ntdll.dll!RtlpFreeHeapInternal()	Unknown
 	ntdll.dll!_RtlpHpFreeWithExceptionProtection@12()	Unknown
 	ntdll.dll!RtlFreeHeap()	Unknown
 	msvcrt.dll!_free()	Unknown
 	Windows.Devices.HumanInterfaceDevice.dll!Windows::Devices::HumanInterfaceDevice::ReadInputOperation::`vector deleting destructor'(unsigned int)	Unknown
 	Windows.Devices.HumanInterfaceDevice.dll!Microsoft::WRL::Details::RuntimeClass<struct Microsoft::WRL::Details::InterfaceList<struct Windows::Foundation::IAsyncOperation<unsigned int>,struct Microsoft::WRL::Details::InterfaceList<class Microsoft::WRL::AsyncBase<struct Windows::Foundation::IAsyncOperationCompletedHandler<unsigned int>,class Microsoft::WRL::Details::Nil,1,struct Microsoft::WRL::AsyncOptions<-1,0,&struct _GUID const GUID_CAUSALITY_WINDOWS_PLATFORM_ID,2> >,class Microsoft::WRL::Details::Nil> >,struct Microsoft::WRL::RuntimeClassFlags<1>,1,1,0>::Release(void)	Unknown
 	Windows.Devices.HumanInterfaceDevice.dll!Microsoft::WRL::Details::MakeAndInitialize<class Windows::Devices::HumanInterfaceDevice::ReadInputOperation,struct Windows::Foundation::IAsyncOperation<class Windows::Devices::HumanInterfaceDevice::HidInputReport *>,void * &,struct _TP_IO * &,unsigned short &,struct _HIDP_PREPARSED_DATA * &,void (&)(long,void *,void *),class Windows::Devices::HumanInterfaceDevice::HidDeviceServer * const>(struct Windows::Foundation::IAsyncOperation<class Windows::Devices::HumanInterfaceDevice::HidInputReport *> * *,void * &,struct _TP_IO * &,unsigned short &,struct _HIDP_PREPARSED_DATA * &,void (&)(long,void *,void *),class Windows::Devices::HumanInterfaceDevice::HidDeviceServer * const &&)	Unknown
 	Windows.Devices.HumanInterfaceDevice.dll!Windows::Devices::HumanInterfaceDevice::HidDeviceServer::QueueAsyncReadOperation(void)	Unknown
 	Windows.Devices.HumanInterfaceDevice.dll!Windows::Devices::HumanInterfaceDevice::HidDeviceServer::InvokeListeners(long,struct Windows::Devices::HumanInterfaceDevice::IHidInputReport *)	Unknown
 	Windows.Devices.HumanInterfaceDevice.dll!Windows::Devices::HumanInterfaceDevice::HidDeviceServer::OnEvent(long,void *,void *)	Unknown
 	Windows.Devices.HumanInterfaceDevice.dll!Windows::Devices::HumanInterfaceDevice::ReadInputOperation::ThreadpoolCompletionCallback(struct _TP_CALLBACK_INSTANCE *,void *,void *,unsigned long,unsigned long,struct _TP_IO *)	Unknown
 	Windows.Devices.HumanInterfaceDevice.dll!Windows::Devices::HumanInterfaceDevice::HidDeviceServer::OnThreadpoolIoComplete(struct _TP_CALLBACK_INSTANCE *,void *,void *,unsigned long,unsigned long,struct _TP_IO *)	Unknown
 	KernelBase.dll!_BasepTpIoCallback@20()	Unknown
 	ntdll.dll!TppIopExecuteCallback()	Unknown
 	ntdll.dll!TppWorkerThread()	Unknown
 	kernel32.dll!@BaseThreadInitThunk@12()	Unknown
 	ntdll.dll!__RtlUserThreadStart()	Unknown
 	ntdll.dll!__RtlUserThreadStart@8()	Unknown

Here's the code I'm using to register the event listener:

EventRegistrationToken token = hidDevice->InputReportReceived += ref new TypedEventHandler<HidDevice^, HidInputReportReceivedEventArgs^>(HidDevice_OnInputReportReceived);
return &token;

And to unregister it:

hidDevice->InputReportReceived -= *token;

It doesn't matter whether or not the input report events are actually consumed. It will even crash if the event callback is just an empty static function.

As I mentioned, it works flawlessly for the other HID devices I've tested and only dies on the Xbox One S controller.

解决方案

Hi GuavamanX,

Could you tell me your device OS version and OS build, does the specific device or controller have this issue? Besides, you can feedback this issue using the Feedback Hub app so that the related team can look into and narrow down it.

Best regards,

Breeze


这篇关于[UWP] [CX]注册HidDevice-&gt; InputReportReceived在断开Xbox One S控制器时总是会导致事件异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆