/// <summary> /// Shutdown device access /// </summary> public override void FinishDX() { if (null != m_device) { log.DebugFormat("Release DirectInput device: {0}", m_device.Information.ProductName); m_device.Unacquire( ); m_device = null; } }
public void Dispose() { if (stick != null) { stick.Unacquire(); stick.Dispose(); stick = null; } }
public override bool Exit() { if (joystick != null) { joystick.Unacquire(); } return(true); }
public void StopEventHandling() { m_abort = true; if ((m_thread != null) && m_thread.IsAlive) { m_thread.Abort( ); } if (m_device != null) { if (m_device.IsDisposed) { return; } m_device.Unacquire( ); m_device.SetNotification(null); } }
public bool AcquireJoystick(Guid guid) { try { if (_joystick != null) { _joystick.Unacquire(); _joystick = null; } var dinput = new DirectInput(); foreach (DeviceInstance device in dinput.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly)) { if (device.InstanceGuid == guid) { _joystick = new SharpDX.DirectInput.Joystick(dinput, device.InstanceGuid); } } if (_joystick != null) { foreach (DeviceObjectInstance deviceObject in _joystick.GetObjects()) { //if ((deviceObject.ObjectType & ObjectDeviceType.Axis) != 0) switch (deviceObject.ObjectId.Flags) { case DeviceObjectTypeFlags.Axis: case DeviceObjectTypeFlags.AbsoluteAxis: case DeviceObjectTypeFlags.RelativeAxis: var ir = _joystick.GetObjectPropertiesById(deviceObject.ObjectId); if (ir != null) { try { ir.Range = new InputRange(-100, 100); } catch (Exception ex) { MainForm.LogExceptionToFile(ex); } } break; } } _joystick.Acquire(); var cps = _joystick.Capabilities; AxisCount = cps.AxeCount; UpdateStatus(); } } catch (Exception ex) { MainForm.LogExceptionToFile(ex); return(false); } return(true); }
public void ReleaseJoystick() => _joystick?.Unacquire();