// Check if a gamepad is connected. If yes, identify it. private void IdentifyGamepadIfConnected() { // TODO analytics ? gamepadUsed = GamepadType.NONE; string[] devices = Input.GetJoystickNames(); if (devices.Length == 0) { return; } foreach (string s in devices) { if (s.Equals("")) { continue; } if (s.Contains("XBOX")) { gamepadUsed = GamepadType.XBOX; } else { gamepadUsed = GamepadType.OTHER; } } }
public void SetGamepad() //Using in Dropdown { if (drop.value == 0) { gamepadType = GamepadType.AndroidGamepad; } else if (drop.value == 1) { gamepadType = GamepadType.XBoxGamepad; } else if (drop.value == 2) { gamepadType = GamepadType.PlayStationGamepad; } for (i = 0; i < gamepad.Length; i++) { if (drop.value == i) { gamepad[i].SetActive(true); } else { gamepad[i].SetActive(false); } } }
public static string GetPromptImagePath(this GamepadJoystick axis, GamepadType type) { if (type == GamepadType.Unknown) { type = GamepadType.Xbox360; } string buttonName; switch (axis) { case GamepadJoystick.Left: { buttonName = "left_stick"; break; } case GamepadJoystick.Right: { buttonName = "right_stick"; break; } default: { buttonName = axis.ToString().ToLowerUnderscored(); break; } } return(AssetPath.Combine( "gui/prompts/" + type.ToString().ToLowerUnderscored(), buttonName + ".png" )); }
public static string GetPrompt(this GamepadAxis axis, GamepadType type) { if (axis == GamepadAxis.None) { return("?"); } return('[' + axis.GetPromptImagePath(type) + ']'); }
protected override void OnInit() { m_lastInputMethod = Screen.InputMethod; m_lastPadType = (Screen.Gamepad != null) ? Screen.Gamepad.Type : GamepadType.Unknown; m_lastSteamController = Screen.SteamController; m_text.Anchor = Anchor; m_text.LocalPosition = LocalPosition; m_text.Parent = this.Parent; m_text.Init(Screen); }
protected override void OnUpdate(float dt) { var inputMethod = Screen.InputMethod; var padType = (Screen.Gamepad != null) ? Screen.Gamepad.Type : GamepadType.Unknown; var steamController = Screen.SteamController; if (inputMethod != m_lastInputMethod || padType != m_lastPadType || (inputMethod == InputMethod.SteamController)) // Steam controller bindings can change without warning { m_lastInputMethod = inputMethod; m_lastPadType = padType; m_lastSteamController = steamController; RequestRebuild(); } m_text.Visible = Visible; m_text.Update(dt); }
public static string GetPrompt(this GamepadButton button, GamepadType type) { if (button == GamepadButton.None) { return("?"); } var imagePath = button.GetPromptImagePath(type); if (imagePath != null) { return('[' + imagePath + ']'); } else { return(button.ToString().ToProperSpaced()); } }
public GamepadSetup(GamepadType type) { this.type = type; Sprite s; if (type == GamepadType.LOGITECHF310 || type == GamepadType.XBOX360 || type == GamepadType.KEYBOARD) { s = Resources.Load<Sprite>("UI/Gamepad/Gamepad_XBOX360_A"); lookup.Add(GamepadAction.A, s); s = Resources.Load<Sprite>("UI/Gamepad/Gamepad_XBOX360_B"); lookup.Add(GamepadAction.B, s); s = Resources.Load<Sprite>("UI/Gamepad/Gamepad_XBOX360_X"); lookup.Add(GamepadAction.X, s); s = Resources.Load<Sprite>("UI/Gamepad/Gamepad_XBOX360_Y"); lookup.Add(GamepadAction.Y, s); s = Resources.Load<Sprite>("UI/Gamepad/Gamepad_XBOX360_LB"); lookup.Add(GamepadAction.BUMPER_L, s); s = Resources.Load<Sprite>("UI/Gamepad/Gamepad_XBOX360_RB"); lookup.Add(GamepadAction.BUMPER_R, s); } }
private static string GetPromptImagePath(this GamepadButton button, GamepadType type) { if (type == GamepadType.Unknown || type == GamepadType.XboxOne) { type = GamepadType.Xbox360; } else if (type == GamepadType.PS4) { type = GamepadType.PS3; } string buttonName; switch (button) { case GamepadButton.LeftStickUp: case GamepadButton.LeftStickDown: case GamepadButton.LeftStickLeft: case GamepadButton.LeftStickRight: { buttonName = "left_stick"; break; } case GamepadButton.RightStickUp: case GamepadButton.RightStickDown: case GamepadButton.RightStickLeft: case GamepadButton.RightStickRight: { buttonName = "right_stick"; break; } case GamepadButton.A: { switch (type) { case GamepadType.PS3: case GamepadType.PS4: { buttonName = "cross"; break; } default: { buttonName = "a"; break; } } break; } case GamepadButton.B: { switch (type) { case GamepadType.PS3: case GamepadType.PS4: { buttonName = "circle"; break; } default: { buttonName = "b"; break; } } break; } case GamepadButton.X: { switch (type) { case GamepadType.PS3: case GamepadType.PS4: { buttonName = "square"; break; } default: { buttonName = "x"; break; } } break; } case GamepadButton.Y: { switch (type) { case GamepadType.PS3: case GamepadType.PS4: { buttonName = "triangle"; break; } default: { buttonName = "y"; break; } } break; } case GamepadButton.Back: { switch (type) { case GamepadType.PS3: { buttonName = "select"; break; } case GamepadType.PS4: { buttonName = "share"; break; } case GamepadType.XboxOne: { buttonName = "view"; break; } default: { buttonName = "back"; break; } } break; } case GamepadButton.Start: { switch (type) { case GamepadType.PS4: { buttonName = "options"; break; } case GamepadType.XboxOne: { buttonName = "menu"; break; } default: { buttonName = "start"; break; } } break; } default: { buttonName = button.ToString().ToLowerUnderscored(); break; } } var path = AssetPath.Combine( "gui/prompts/" + type.ToString().ToLowerUnderscored(), buttonName + ".png" ); if (Assets.Assets.Exists <Texture>(path)) { return(path); } return(null); }
public static string GetPrompt(this GamepadJoystick axis, GamepadType type) { return('[' + axis.GetPromptImagePath(type) + ']'); }