예제 #1
0
        /// <summary>
        /// Process the actual audio alert
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _timerSample_Tick(object sender, EventArgs e)
        {
            var axis = new Vector();

            try
            {
                if (_audioLimit == null && _audioThreshold == null)
                {
                    throw new NullReferenceException("Audio");
                }

                axis = _joystick.Axis; //nre ok

#if DEBUG_LOGGING
                Console.WriteLine($"x {axis.X}, y {axis.Y} | al: v < {_alertLowerMax}, au: v > {_alertUpperMin}");
#endif
            }
            catch (Exception ex) //joystick is not currently reachable... (ie was unplugged)
            {
#if DEBUG_LOGGING
                Console.WriteLine(ex.Message);
#endif

                _joystick?.Dispose();
                _joystick = null; //reset entirely

                DCSStatusChanged(this, new EventArgs());

                return;
            }

            HandleTimerSampleTick(sender, e, axis);
        }
예제 #2
0
        private void AssignDevice(string deviceName)
        {
            if (_joystick != null)
            {
                _joystick.Dispose();
                _joystick = null;
            }

            if (deviceName != null && Devices.Contains(deviceName))
            {
                _joystick = new JoystickHelper(deviceName);
            }
        }