public XInputPadInputSource() { SelectPad(); LeftThumbSpec = InputSystem.ThumbSpec.Default(); RightThumbSpec = InputSystem.ThumbSpec.Default(); }
/// <summary> /// compute ThumbInput data from game pad input /// </summary> /// <param name="thumbX">game pad input about x coord</param> /// <param name="thumbY">game pad input about y coord</param> /// <param name="spec">input spec data</param> /// <returns>computed data</returns> private InputSystem.ThumbInput _ComputeThumbInput(short thumbX, short thumbY, InputSystem.ThumbSpec spec) { var input = new InputSystem.ThumbInput(); input.Direction = new Vector2(thumbX, thumbY); input.RawMagnitude = input.Direction.Length(); input.Direction.Normalize(); if (input.RawMagnitude > spec.MinMagnitude) { input.Magnitude = Math.Min(input.RawMagnitude, spec.MaxMagnitude); input.Magnitude -= spec.MinMagnitude; input.NormalizedMagnitude = input.Magnitude / (spec.MaxMagnitude - spec.MinMagnitude); } else { input.Magnitude = 0; input.NormalizedMagnitude = 0; } return(input); }