/// <summary>Retrieves the current value of the axis</summary> /// <param name="gamePadState">Game pad state that will receive the value</param> /// <param name="joystickState">State from which the axis is retrieved</param> public void Convert( FlatGamePadState gamePadState, ref JoystickState joystickState ) { int slider = joystickState.GetSliders()[this.sliderIndex]; gamePadState.RightTrigger = (float)(slider - this.min) / this.max; }
/// <summary>Retrieves the current value of the axis</summary> /// <param name="gamePadState">Game pad state that will receive the value</param> /// <param name="joystickState">State from which the axis is retrieved</param> public void Convert( FlatGamePadState gamePadState, ref JoystickState joystickState ) { if (joystickState.X < base.Center) { gamePadState.LeftThumbStick.X = (float)(base.Center - joystickState.X) / base.Min; } else { gamePadState.LeftThumbStick.X = (float)(joystickState.X - base.Center) / base.Max; } }
/// <summary>Converts all digital buttons and the controller's PoV hat</summary> /// <param name="gamePadState">Game pad state that will receive the results</param> /// <param name="joystickState">Joystick state the values are taken from</param> private void convertButtonsAndPov( FlatGamePadState gamePadState, ref JoystickState joystickState ) { Buttons pressedButtons = 0; // Try to match up the joystick's buttons with those that would be on // an XBox 360 controller. bool[] buttons = joystickState.GetButtons(); for (int index = 0; index < this.buttonCount; ++index) { if (buttons[index]) { pressedButtons |= buttonOrder[index]; } } // If this controller has a Point-of-View hat, we interpret the hat as // 4 additional buttons. If not, the buttonCount property is limited to // 14, allowing an additional 4 normal buttons on the controller to act // as if they were a PoV hat. if (this.hasPovHat) { int pov = joystickState.GetPointOfViewControllers()[0]; // PoV hats report either -1 or 65535 when they're centered and their // position in degrees times 100 if they're not centered. if ((ushort)(pov) != 0xFFFF) { bool right = ((pov > 0) && (pov < 18000)); bool down = ((pov > 9000) && (pov < 27000)); bool left = ((pov > 18000) && (pov < 36000)); bool up = ((pov > 27000) || (pov < 9000)); if (right) { pressedButtons |= Buttons.DPadRight; } if (down) { pressedButtons |= Buttons.DPadDown; } if (left) { pressedButtons |= Buttons.DPadLeft; } if (up) { pressedButtons |= Buttons.DPadUp; } } } this.gamePadState.Buttons = pressedButtons; }
/// <summary>Retrieves the current value of the axis</summary> /// <param name="gamePadState">Game pad state that will receive the value</param> /// <param name="joystickState">State from which the axis is retrieved</param> public void Convert( FlatGamePadState gamePadState, ref JoystickState joystickState ) { if (joystickState.RotationZ < 0) { gamePadState.LeftTrigger = (float)(base.Center - joystickState.RotationZ) / base.Min; } else { gamePadState.LeftTrigger = (float)(joystickState.RotationZ - base.Center) / base.Max; } }
/// <summary>Retrieves the current value of the axis</summary> /// <param name="gamePadState">Game pad state that will receive the value</param> /// <param name="joystickState">State from which the axis is retrieved</param> public void Convert( FlatGamePadState gamePadState, ref JoystickState joystickState ) { if (joystickState.RotationY < 0) { gamePadState.RightThumbStick.Y = (float)(base.Center - joystickState.RotationY) / base.Min; } else { gamePadState.RightThumbStick.Y = (float)(joystickState.RotationY - base.Center) / base.Max; } }