/// <summary> /// Function to reset the directions. /// </summary> internal void Reset() { X = JoystickDirections.Center; Y = JoystickDirections.Center; SecondaryX = JoystickDirections.Center; SecondaryY = JoystickDirections.Center; Throttle = JoystickDirections.Center; Rudder = JoystickDirections.Center; POV = JoystickDirections.Center; }
/// <summary> /// Function to get an orientation for a value. /// </summary> /// <param name="value">Value to evaluate.</param> /// <param name="deadZone">The dead zone.</param> /// <param name="orientation">Orientation of the axis.</param> /// <param name="midRange">Mid point for the range.</param> /// <returns>The direction that the axis is pointed at.</returns> private static JoystickDirections GetDirection(int value, GorgonRange deadZone, JoystickDirections orientation, int midRange) { var result = JoystickDirections.Center; if ((deadZone != GorgonRange.Empty) && (deadZone.Contains(value))) { return(result); } switch (orientation) { case JoystickDirections.Horizontal: if (value > midRange) { result = JoystickDirections.Right; } if (value < midRange) { result = JoystickDirections.Left; } break; case JoystickDirections.Vertical: if (value < midRange) { result = JoystickDirections.Down; } if (value > midRange) { result = JoystickDirections.Up; } break; default: if (value > midRange) { result = JoystickDirections.MoreThanCenter; } if (value < midRange) { result = JoystickDirections.LessThanCenter; } break; } return(result); }