public static bool GetFretInput(this GamepadInput gamepad, Note.GuitarFret fret) { switch (fret) { case (Note.GuitarFret.Green): return(gamepad.GetButton(GamepadInput.Button.A)); case (Note.GuitarFret.Red): return(gamepad.GetButton(GamepadInput.Button.B)); case (Note.GuitarFret.Yellow): return(gamepad.GetButton(GamepadInput.Button.Y)); case (Note.GuitarFret.Blue): return(gamepad.GetButton(GamepadInput.Button.X)); case (Note.GuitarFret.Orange): return(gamepad.GetButton(GamepadInput.Button.LB)); case (Note.GuitarFret.Open): return(false); default: Debug.LogError("Unhandled note type for guitar input: " + fret); break; } return(false); }
void Update() { if (_currentGamepads != null) { for (int i = 0; i < _currentGamepads.Length; i++) { float h = GamepadInput.GetAxis("Horizontal", _currentGamepads[i].Type, _currentGamepads[i].Id); float v = GamepadInput.GetAxis("Vertical", _currentGamepads[i].Type, _currentGamepads[i].Id); playerPanels[i].h.text = "H = " + h.ToString("0.00"); playerPanels[i].h.color = (h == 0f ? Color.black : Color.red); playerPanels[i].v.text = "V = " + v.ToString("0.00"); playerPanels[i].v.color = (v == 0f ? Color.black : Color.red); bool f1 = GamepadInput.GetButton("Fire1", _currentGamepads[i].Type, _currentGamepads[i].Id); bool f2 = GamepadInput.GetButton("Fire2", _currentGamepads[i].Type, _currentGamepads[i].Id); bool f3 = GamepadInput.GetButton("Fire3", _currentGamepads[i].Type, _currentGamepads[i].Id); bool f4 = GamepadInput.GetButton("Fire4", _currentGamepads[i].Type, _currentGamepads[i].Id); bool f5 = GamepadInput.GetButton("Fire5", _currentGamepads[i].Type, _currentGamepads[i].Id); bool f6 = GamepadInput.GetButton("Fire6", _currentGamepads[i].Type, _currentGamepads[i].Id); playerPanels[i].f1.color = (f1 ? Color.red : Color.black); playerPanels[i].f2.color = (f2 ? Color.red : Color.black); playerPanels[i].f3.color = (f3 ? Color.red : Color.black); playerPanels[i].f4.color = (f4 ? Color.red : Color.black); playerPanels[i].f5.color = (f5 ? Color.red : Color.black); playerPanels[i].f6.color = (f6 ? Color.red : Color.black); if (_currentGamepads[i].Player == Player.One) { string submit = GamepadInput.GetButtonForUI("Submit", _currentGamepads[i].Type, _currentGamepads[i].Id); string cancel = GamepadInput.GetButtonForUI("Cancel", _currentGamepads[i].Type, _currentGamepads[i].Id); bool sValue = Input.GetButtonDown(submit); bool cValue = Input.GetButtonDown(cancel); playerPanels[i].submit.color = (sValue ? Color.red : Color.black); playerPanels[i].cancel.color = (cValue ? Color.red : Color.black); bool start = GamepadInput.GetButton("Start", _currentGamepads[i].Type, _currentGamepads[i].Id); if (f5 && f6 && start) { gameObject.SetActive(false); prevScreen.SetActive(true); if (_prevButton != null) { EventSystem.current.SetSelectedGameObject(_prevButton); } } } } } }
private void UpdateForGamepadManager() { _state = GamepadManager.Instance.GetAssignedGamepad(0); if (!_state.IsConnected()) { return; } float h = GamepadInput.GetAxis("Horizontal", _state.Type, _state.Id); float v = GamepadInput.GetAxis("Vertical", _state.Type, _state.Id); _player.SetMoveValue(h, v); if (GamepadInput.GetButtonDown("Fire1", _state.Type, _state.Id)) { _player.SetRunValue(true); } if (GamepadInput.GetButtonUp("Fire1", _state.Type, _state.Id)) { _player.SetRunValue(true); } switch (currentShootType) { case ShootType.WithButtons: if (GamepadInput.GetButtonDown("Fire4", _state.Type, _state.Id)) { _player.InitShootAttack(); } if (GamepadInput.GetButton("Fire4", _state.Type, _state.Id)) { _player.UpdateShootAttack(); } if (GamepadInput.GetButtonUp("Fire4", _state.Type, _state.Id)) { _player.FinalizeShootAttack(); } break; } }
private void UpdateForGamepadManager() { _state = GamepadManager.Instance.GetAssignedGamepad(0); if (!_state.IsConnected()) { return; } float ah = GamepadInput.GetAxis("AltHorizontal", _state.Type, _state.Id); float av = GamepadInput.GetAxis("AltVertical", _state.Type, _state.Id); _assist.SetMoveValue(ah, av); if (GamepadInput.GetButton("Fire5", _state.Type, _state.Id)) { _assist.SetState(-1f); } if (GamepadInput.GetButton("Fire6", _state.Type, _state.Id)) { _assist.SetState(1f); } float rt = GamepadInput.GetAxis("RightTrigger", _state.Type, _state.Id); if (rt > 0f && _prevRT == 0f) // RT Down { _assist.SetHead(true); } _prevRT = rt; float lt = GamepadInput.GetAxis("LeftTrigger", _state.Type, _state.Id); if (lt > 0f && _prevLT == 0f) // LT Down { _assist.SetHead(false); } _prevLT = lt; }
private void UpdateForGamepadManager() { _state = GamepadManager.Instance.GetAssignedGamepad(0); if (!_state.IsConnected()) { return; } float ah = GamepadInput.GetAxis("AltHorizontal", _state.Type, _state.Id); float av = GamepadInput.GetAxis("AltVertical", _state.Type, _state.Id); _assist.SetMoveValue(ah, av); if (GamepadInput.GetButton("Fire1", _state.Type, _state.Id)) { _assist.SetState(AssistBehavior.AssistState.Shield); } if (GamepadInput.GetButton("Fire2", _state.Type, _state.Id)) { _assist.SetState(AssistBehavior.AssistState.AutoFire); } if (GamepadInput.GetButton("Fire3", _state.Type, _state.Id)) { _assist.SetState(AssistBehavior.AssistState.MultiplyFire); } if (GamepadInput.GetButton("Fire4", _state.Type, _state.Id)) { _assist.SetState(AssistBehavior.AssistState.MultiplyVelocity); } _assist.AlignWithPlayer(GamepadInput.GetButton("Fire5", _state.Type, _state.Id)); }
private void UpdateManagerState() { switch (_currentManagerState) { case GamepadManagerState.WaitForFirstJoystick: UpdateJoystickState(); for (int i = 0; i < _detectedGamepads.Length; i++) { if (_detectedGamepads[i].Type != Gamepad.None && _detectedGamepads[i].Type != Gamepad.Unknown) { bool pressL = GamepadInput.GetButton("Fire5", _detectedGamepads[i].Type, i + 1); bool pressR = GamepadInput.GetButton("Fire6", _detectedGamepads[i].Type, i + 1); string submit = GamepadInput.GetButtonForUI("Submit", _detectedGamepads[i].Type, i + 1); if ((pressL && pressR) || Input.GetButtonDown(submit)) { int emptySlot = GetNextJoystickEmptySlot(); if (emptySlot != -1) { _mainGamepad.Player = _assignedGamepads[emptySlot].Player = Player.One; _mainGamepad.Id = _assignedGamepads[emptySlot].Id = i + 1; _mainGamepad.Type = _assignedGamepads[emptySlot].Type = _detectedGamepads[i].Type; _detectedGamepads[i].Selected = true; SetStandaloneInputModule(_mainGamepad); //Debug.Log("Joystick #" + _assignedGamepeds[0].Id); whenWaitForFirstJoystickSuccess.Invoke(); _currentManagerState = GamepadManagerState.WaitForDisconnection; } } } } break; case GamepadManagerState.CheckForOneJoystick: case GamepadManagerState.CheckForTwoJoystick: case GamepadManagerState.CheckForThreeJoystick: case GamepadManagerState.CheckForFourJoystick: UpdateJoystickState(); if (!GamepadAreConfigured((int)_currentManagerState - 1)) { _currentPanel.SetOnSubmitActive(false); for (int i = 0; i < _detectedGamepads.Length; i++) { if (_detectedGamepads[i].Type != Gamepad.None && _detectedGamepads[i].Type != Gamepad.Unknown && !_detectedGamepads[i].Selected) { bool pressL = GamepadInput.GetButton("Fire5", _detectedGamepads[i].Type, i + 1); bool pressR = GamepadInput.GetButton("Fire6", _detectedGamepads[i].Type, i + 1); if (pressL && pressR) { int emptySlotIndex = GetNextJoystickEmptySlot(); if (emptySlotIndex != -1) { _assignedGamepads[emptySlotIndex].Player = (Player)(emptySlotIndex + 1); _assignedGamepads[emptySlotIndex].Id = i + 1; _assignedGamepads[emptySlotIndex].Type = _detectedGamepads[i].Type; _detectedGamepads[i].Selected = true; if (emptySlotIndex == 0) { _mainGamepad = _assignedGamepads[emptySlotIndex]; SetStandaloneInputModule(_mainGamepad); } //Debug.Log("Joystick #" + _assignedGamepeds[emptySlotIndex].Id); _currentPanel.AddJoystickSlot(emptySlotIndex, _assignedGamepads[emptySlotIndex]); } } } } } else { _currentPanel.SetOnSubmitActive(true); } break; case GamepadManagerState.WaitForDisconnection: UpdateJoystickState(); //TODO break; } }
private void UpdateForGamepadManager() { _state = GamepadManager.Instance.GetAssignedGamepad(0); if (!_state.IsConnected()) { return; } float h = GamepadInput.GetAxis("Horizontal", _state.Type, _state.Id); float v = GamepadInput.GetAxis("Vertical", _state.Type, _state.Id); _player.SetMoveValue(h, v); float lt = GamepadInput.GetAxis("LeftTrigger", _state.Type, _state.Id); if (lt > 0f && _prevLT == 0f) // LT Down { _player.SetRunValue(true); } else if (lt == 0f && _prevLT > 0f) // LT Up { _player.SetRunValue(false); } _prevLT = lt; switch (currentShootType) { case ShootType.WithTriggers: float rt = GamepadInput.GetAxis("RightTrigger", _state.Type, _state.Id); if (rt > 0f && _prevRT == 0f) // RT Down { _player.InstantShootAttack(); } else if (rt > 0f && _prevRT > 0f) // RT Stay { _player.InstantShootAttack(); } _prevRT = rt; if (GamepadInput.GetButtonDown("Fire6", _state.Type, _state.Id)) { _player.InitShootAttack(); } if (GamepadInput.GetButton("Fire6", _state.Type, _state.Id)) { _player.UpdateShootAttack(); } if (GamepadInput.GetButtonUp("Fire6", _state.Type, _state.Id)) { _player.FinalizeShootAttack(); } break; case ShootType.WithStick: float ah = GamepadInput.GetAxis("AltHorizontal", _state.Type, _state.Id); float av = GamepadInput.GetAxis("AltVertical", _state.Type, _state.Id); _player.InstantShootAttack(ah, av); break; } }