/// <summary> /// Called in WndPrc to process the Window Messages /// </summary> /// <param name="msg">Message Number</param> /// <param name="wParam"></param> /// <param name="lParam"></param> public void ProcessWindowMessage(int msg, IntPtr wParam, IntPtr lParam) { if (this.IsDisposed) //We don't throw an Exception in the Message Loop, just return { return; } SiApp.SiGetEventData evd = default(SiApp.SiGetEventData); SiApp.SiGetEventWinInit(ref evd, msg, wParam, lParam); SiApp.SiSpwEvent_SpwData edata = default(SiApp.SiSpwEvent_SpwData); var t = SiApp.SiGetEvent(_deviceHandle, SiApp.SI_AVERAGE_EVENTS, ref evd, ref edata); if (t == SiApp.SpwRetVal.SI_IS_EVENT) { switch (edata.type) { case SiApp.SiEventType.SI_ZERO_EVENT: lock (eventBuffer) { eventBuffer[SiApp.SiEventType.SI_ZERO_EVENT] = EventArgs.Empty; Monitor.Pulse(eventBuffer); } break; case SiApp.SiEventType.SI_MOTION_EVENT: lock (eventBuffer) { eventBuffer[SiApp.SiEventType.SI_MOTION_EVENT] = MotionEventArgs.FromEventArray(edata.spwData.mData); Monitor.Pulse(eventBuffer); } break; } } }
/// <summary> /// Close the Device /// </summary> public void CloseDevice() { if (_deviceHandle != IntPtr.Zero) { SiApp.SiClose(_deviceHandle); _deviceHandle = IntPtr.Zero; } }
/// <summary> /// Initialize the Device /// </summary> /// <param name="windowHandle">Handle to window using the device</param> public void InitDevice(IntPtr windowHandle) { if (IsDisposed) { throw new ObjectDisposedException(""); } if (IsAvailable) { return; //Init already done. } SiApp.SpwRetVal v = SiApp.SpwRetVal.SPW_DLL_LOAD_ERROR; v = SiApp.SiInitialize(); //try //{ // v = SiApp.SiInitialize(); //} //catch //{ // // throw new _3DxException("Driver not installed."); // Diagnostics.Log("3DX Driver is not installed"); // eventThread.Abort(); // Dispose(); // return; //} if (v == SiApp.SpwRetVal.SPW_DLL_LOAD_ERROR) { throw new _3DxException("Unable to load SiApp DLL"); } var o = default(SiApp.SiOpenData); SiApp.SiOpenWinInit(ref o, windowHandle); _deviceHandle = SiApp.SiOpen(this.AppName, SiApp.SI_ANY_DEVICE, IntPtr.Zero, SiApp.SI_EVENT, ref o); if (_deviceHandle == IntPtr.Zero) { SiApp.SiTerminate(); throw new _3DxException("Unable to open device"); } string devName; SiApp.SiGetDeviceName(_deviceHandle, out devName); this.DeviceName = devName; this.DeviceID = SiApp.SiGetDeviceID(_deviceHandle); SiApp.SiDevInfo info = default(SiApp.SiDevInfo); SiApp.SiGetDeviceInfo(_deviceHandle, ref info); this.FirmwareVersion = info.firmware; }
public void ResetAllButtonBindings() { if (this.IsDisposed) { throw new ObjectDisposedException(""); } SiApp.SiSyncSendQuery(_deviceHandle); for (uint it = 1; it <= NumButtons; it++) { SiApp.SiSyncSetButtonAssignment(_deviceHandle, it, 0); } }
/// <summary> /// Initialize the Device /// </summary> /// <param name="windowHandle">Handle to window using the device</param> public void InitDevice(IntPtr windowHandle) { if (this.IsDisposed) { throw new ObjectDisposedException(""); } if (IsAvailable) { return; //Init already done. } var v = SiApp.SiInitialize(); if (v == SiApp.SpwRetVal.SPW_DLL_LOAD_ERROR) { throw new _3DxException("Unable to load SiApp DLL"); } SiApp.SiOpenData o = default(SiApp.SiOpenData); SiApp.SiOpenWinInit(ref o, windowHandle); _deviceHandle = SiApp.SiOpen(this.AppName, SiApp.SI_ANY_DEVICE, IntPtr.Zero, SiApp.SI_EVENT, ref o); if (_deviceHandle == IntPtr.Zero) { SiApp.SiTerminate(); throw new _3DxException("Unable to open device"); } string devName; SiApp.SiGetDeviceName(_deviceHandle, out devName); this.DeviceName = devName; this.DeviceID = SiApp.SiGetDeviceID(_deviceHandle); SiApp.SiDevInfo info = default(SiApp.SiDevInfo); SiApp.SiGetDeviceInfo(_deviceHandle, ref info); this.FirmwareVersion = info.firmware; this.NumButtons = info.numButtons; }
public void Beep(string tone) { var retVal = SiApp.SiBeep(_deviceHandle, tone); }