grayver / mi-vigem

ViGEm adapter for Xiaomi Gamepad
MIT License
69 stars 24 forks source link

Shared vs exclusive HID access #3

Open dancol90 opened 4 years ago

dancol90 commented 4 years ago

Hi! mi-360 developer here. Nice project!

I saw that you don't enforce exclusive access to the HID devices when you open them, hence reverting to the standard shared mode. This leaves the Xiaomi Gamepad visible and accessible to the applications and games along with the virtual XBox controller.

Have you ever noticed some incompatibilities with some game leaving two game devices simultaneously available? Have you ever had problems with exclusive access too?

grayver commented 4 years ago

Hi Daniele! Nice to meet you! Thanks for your project!

Actually, I didn't test my project in many games, just in couple platformers I played recently. I'm aware of the issue you describing and I see 2 devices in Steam client or in Gamepad Tester (https://html5gamepad.com/). But it doesn't bring any problems in games I've played.

I've read about different solutions described on the README page of HidGuardian (https://github.com/ViGEm/HidGuardian) and I suspect that this problem has no easy solution. I also suspect that exclusive capture of HID device is possible only in kernel mode (but I'm not sure, though). However, this is subject for research.

grayver commented 4 years ago

Here is interesting reading on the subject: https://github.com/signal11/hidapi/issues/302

dancol90 commented 4 years ago

No, there's no easy solution. I found this MSDN page that also confirms that exclusive access is not viable for HID devices.

Since last version of mi-360, it will fallback to shared access if exclusive is not available, but it doesn't feel like the right thing to do