/// <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; }
/// <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; }