public static float GetGamepad(GamepadList gamepad, int device = 0) { float val; switch (gamepad) { case GamepadList.leftstick_left: val = Input.GetJoyAxis(device, (int)JoystickList.AnalogLx); return(val >= 0 ? 0 : -val); case GamepadList.leftstick_right: val = Input.GetJoyAxis(device, (int)JoystickList.AnalogLx); return(val <= 0 ? 0 : val); case GamepadList.leftstick_down: val = Input.GetJoyAxis(device, (int)JoystickList.AnalogLy); return(val <= 0 ? 0 : val); case GamepadList.leftstick_up: val = Input.GetJoyAxis(device, (int)JoystickList.AnalogLy); return(val >= 0 ? 0 : -val); case GamepadList.rightstick_left: val = Input.GetJoyAxis(device, (int)JoystickList.AnalogRx); return(val >= 0 ? 0 : -val); case GamepadList.rightstick_right: val = Input.GetJoyAxis(device, (int)JoystickList.AnalogRx); return(val <= 0 ? 0 : val); case GamepadList.rightstick_down: val = Input.GetJoyAxis(device, (int)JoystickList.AnalogRy); return(val <= 0 ? 0 : val); case GamepadList.rightstick_up: val = Input.GetJoyAxis(device, (int)JoystickList.AnalogRy); return(val >= 0 ? 0 : -val); case GamepadList.left_trigger: return(Input.GetJoyAxis(device, (int)JoystickList.AnalogL2)); case GamepadList.right_trigger: return(Input.GetJoyAxis(device, (int)JoystickList.AnalogR2)); default: return(Input.IsJoyButtonPressed(device, (int)gamepad) ? 1: 0); } }
public GamepadBinding(GamepadList key, int device = 0) { this.device = device; this.key = key; }
public InputAction AddBinding(GamepadList game, int device = 0) { bindings.Add(new GamepadBinding(game, device)); return(this); }