modelica-3rdparty / Modelica_DeviceDrivers

Free library for interfacing hardware drivers to Modelica models. There is support for joysticks, keyboards, UDP, TCP/IP, LCM, MQTT, shared memory, AD/DA converters, serial port and other devices.
BSD 3-Clause "New" or "Revised" License
77 stars 31 forks source link

Spacemouse not working under Windows 10 #294

Closed bernhard-thiele closed 5 years ago

bernhard-thiele commented 5 years ago

When using the MDD Block for the 3DConnexion SpaceMouse on Windows 10, the block doesn't get the inputs from the SpaceMouse (it just returns zeros).

bernhard-thiele commented 5 years ago

The problem is that the length of the list of scanned potentially relevant USB devices is limited by a too low hard-coded value:

https://github.com/modelica-3rdparty/Modelica_DeviceDrivers/blob/3f6342e6b6d0bb84bccac41ca7682a9eaba6393d/Modelica_DeviceDrivers/Resources/src/SpaceMouse/MDDSpaceMouse.c#L23

At least for some of our Windows 10 systems the list needs to be longer, otherwise the SpaceMouse device will not appear in the list.

bernhard-thiele commented 5 years ago

Still need to provide the updated binaries

tbeu commented 5 years ago

This requires new binaries MDDSpaceMouse.[lib, dll, a], right?

bernhard-thiele commented 5 years ago

Yes, I just pushed a VS 2010 generated .lib and .dll using an old Windows Driver Kit (WDK) that I still have at home (Version 7.1.0) for backwards compatibility. Can't check if it works here (no SpaceMouse at home), but will check it tomorrow in my office. It is not needed to update the Linux binaries, since the changes are only for Windows.

tbeu commented 5 years ago

The updated MDDSpaceMouse.dll (both win32 and win64) does not export MDD_spacemouseGetData.

bernhard-thiele commented 5 years ago

Thanks for spotting this error. Should be fixed with f6f10fc.

tbeu commented 5 years ago

Is this issue really specific for Win10?

bernhard-thiele commented 5 years ago

No, not really specific to Win10. The issue with the previous code was that it limited the number of HID devices that were checked for being a SpaceMouse at a (too low) max value. For some reason that seems to be (usually?) no problem in Windows 7, but in Windows 10 the SpaceMouse appeared at an index that was not checked anymore. I've simply increased this max value from 10 to 50. This seems to be enough (though maybe there exists configurations there this is too low). It's a quick fix that got it working. It's probably not a super solid solution. I don't really want to invest too much time trying to understand the details of this Windows driver API, but I'm of course open if there are suggestions for a better solution.