Open Youw opened 3 years ago
I have had a little "weekend codding" session, and tried to implement the WinRT backend implementation for HIDAPI, and here is the result: https://github.com/libusb/hidapi/compare/winrt
I'm not even sure if it worth making a PR into master as of yet, but here are some statements about the implementation:
hid_error
looks very familiar, but that's not the point);Windows.Devices.HumanInterfaceDevice
subsystem as of this moment, e.g.:
And I wasn't able to test it intensively, keeping it in the branch for now. Just in case someone would want to play with it.
- it is written in pure C++/WinRT, i.e. it can be use in Windows Store applications (I believe the WinAPI HIDAPI backend uses some APIs that are not available from UWP/Windows Store environment);
The Microsoft Store is no longer restricted to UWP: https://developer.microsoft.com/en-us/microsoft-store/desktop-apps
I believe there're still restrictions on WinAPI usage (and HIDAPI/WinAPI doesn't follow them). I'll search for link with description later.
This seems to work pretty well, tested under Windows 11 with VS2022.
Edit: this is not correct. So I deleted the output.
This seems to work pretty well, tested under Windows 11 with VS2022.
I do not believe you've actually used the winrt backend.
You need to pass -DHIDAPI_WITH_WINRT=ON
and run the hidtest-winrt
executable.
Here is the output for the draft WinRT backend. Other than the limitations mentioned in the first post, I can see that product string is also not correct when there is none. Now it uses the computer name.
Output from the normal Windows backend as a comparison.
Another computer using Windows 10.
Normal Windows backend output.
Looks about right - consistent with my testing. All of what is missing - are the limitation of the WinRT API for HID devices.
Current Windows backend is WinAPI based. There is also an alternative - WinRT API, and it actually uses a different implementation.
More discussion about it: #282. Having an alternative backend might be useful in the future. Leaving this ticket to follow up on it if someone ever gets to finish it. ~Some attempt to move in this direction:~ ~https://github.com/LeeChunHei/hidapi~ UPD: see next comment.
A general recommentation is to have this backend implemented in C++, due to way simpler implementation, when it comes to WinRT, compared to C.