I have implemented SpaceMouse support in my application running (C# 4.6 + WinForms) a while back. Its based on the SDK and uses a wrapper for the "siappdll". Was working fine. I switched to Windows 10 now and can observe the following:
When running my app and listening to the Messages and then lock my machine with [Windows] + [L] it results in BSOD. Same is true for plugging in / out the space mouse while running the software.
I am confused! Can anyone help here?
Another question: I have seen people getting information from the SpaceMouse without using the driver. Its registered as HID by Windows and they can still get all axis and buttons. How does that work?
Code for listening to the device:
Code: Select all
protected override void OnNotifyMessage(Message msg)
{
SiApp.SiGetEventWinInit(ref this.dev_evt_data, msg.Msg, msg.WParam, msg.LParam);
SiApp.SiSpwEvent_SpwData data_spw = new SiApp.SiSpwEvent_SpwData();
IntPtr type = Marshal.AllocHGlobal(Marshal.SizeOf(data_spw));
this.dev_value = SiApp.SiGetEvent(this.dev_hdl, SiApp.SI_AVERAGE_EVENTS, ref this.dev_evt_data, type);
data_spw = (SiApp.SiSpwEvent_SpwData)Marshal.PtrToStructure(type, typeof(SiApp.SiSpwEvent_SpwData));
data_spw = (SiApp.SiSpwEvent_SpwData)Marshal.PtrToStructure(type, typeof(SiApp.SiSpwEvent_SpwData));
if (dev_value == SiApp.SpwRetVal.SI_IS_EVENT)
{
if (data_spw.type == SiApp.SiEventType.SI_ZERO_EVENT)
this.Handle_Events_Zero();
if (data_spw.type == SiApp.SiEventType.SI_MOTION_EVENT)
this.Handle_Events_Motion(ref data_spw);
if (data_spw.type == SiApp.SiEventType.SI_BUTTON_EVENT)
this.Handle_Events_Button(ref data_spw);
}
//Util.ConsoleWriteLineColor("-> Space Control:\tEvent: " + evt.type.ToString(), Util_OutputType.Text);
Marshal.FreeHGlobal(type);
}