// Token: 0x0600002A RID: 42 RVA: 0x00002E78 File Offset: 0x00001078 public static float GetAxis(string axisName) { InputRecord inputRecord = Manager.controller.Current; if (axisName == "Horizontal") { return(-inputRecord.GetX()); } if (axisName == "Vertical") { return(-inputRecord.GetY()); } if (axisName == "DPadX") { return(inputRecord.GetXMax()); } if (axisName == "DPadY") { return(inputRecord.GetYMax()); } if (axisName == "LeftStickX") { return(inputRecord.GetX()); } if (!(axisName == "LeftStickY")) { return(0f); } return(inputRecord.GetY()); }
private static Vector2 ValidateFeatherInput(InputRecord input) { const float maxShort = short.MaxValue; short X; short Y; switch (analogueMode) { case AnalogueMode.Ignore: return(new Vector2(input.GetX(), input.GetY())); case AnalogueMode.Circle: X = (short)(input.GetX() * maxShort); Y = (short)(input.GetY() * maxShort); break; case AnalogueMode.Square: float x = input.GetX(); float y = input.GetY(); float mult = 1 / Math.Max(Math.Abs(x), Math.Abs(y)); x *= mult; y *= mult; X = (short)(x * maxShort); Y = (short)(y * maxShort); break; case AnalogueMode.Precise: if (input.Angle == 0) { X = 0; Y = short.MaxValue; break; } GetPreciseFeatherPos(input.GetX(), input.GetY(), out X, out Y); break; default: throw new Exception("what the f**k"); } // SDL2_FNAPlatform.GetGamePadState() // (float)SDL.SDL_GameControllerGetAxis(intPtr, SDL.SDL_GameControllerAxis.SDL_CONTROLLER_AXIS_LEFTX) / 32767f return(new Vector2((float)X / maxShort, (float)Y / maxShort)); }
public static void SetInputs(InputRecord input) { GamePadDPad pad; GamePadThumbSticks sticks; if (input.HasActions(Actions.Feather)) { pad = new GamePadDPad(ButtonState.Released, ButtonState.Released, ButtonState.Released, ButtonState.Released); sticks = new GamePadThumbSticks(new Vector2(input.GetX(), input.GetY()), new Vector2(0, 0)); } else { pad = new GamePadDPad( input.HasActions(Actions.Up) ? ButtonState.Pressed : ButtonState.Released, input.HasActions(Actions.Down) ? ButtonState.Pressed : ButtonState.Released, input.HasActions(Actions.Left) ? ButtonState.Pressed : ButtonState.Released, input.HasActions(Actions.Right) ? ButtonState.Pressed : ButtonState.Released ); sticks = new GamePadThumbSticks(new Vector2(0, 0), new Vector2(0, 0)); } GamePadState state = new GamePadState( sticks, new GamePadTriggers(input.HasActions(Actions.Journal) ? 1f : 0f, 0), new GamePadButtons( (input.HasActions(Actions.Jump) ? Buttons.A : (Buttons)0) | (input.HasActions(Actions.Jump2) ? Buttons.Y : (Buttons)0) | (input.HasActions(Actions.Dash) ? Buttons.B : (Buttons)0) | (input.HasActions(Actions.Dash2) ? Buttons.X : (Buttons)0) | (input.HasActions(Actions.Grab) ? Buttons.RightShoulder : (Buttons)0) | (input.HasActions(Actions.Start) ? Buttons.Start : (Buttons)0) | (input.HasActions(Actions.Restart) ? Buttons.LeftShoulder : (Buttons)0) ), pad ); bool found = false; for (int i = 0; i < 4; i++) { MInput.GamePads[i].Update(); if (MInput.GamePads[i].Attached) { found = true; MInput.GamePads[i].CurrentState = state; } } if (!found) { MInput.GamePads[0].CurrentState = state; MInput.GamePads[0].Attached = true; } MInput.UpdateVirtualInputs(); }
public static float GetAxis(string axisName) { InputRecord input = controller.Current; switch (axisName) { case "Horizontal": return(-input.GetX()); case "Vertical": return(-input.GetY()); case "DPadX": return(input.GetXMax()); case "DPadY": return(input.GetYMax()); case "LeftStickX": return(input.GetX()); case "LeftStickY": return(input.GetY()); } return(0); }