/// <summary> /// Wrap Unity's method /// </summary> /// <param name="inputName"></param> /// <returns></returns> public static float GetAxis(string inputName, OuyaSDK.OuyaPlayer player) { #if !UNITY_EDITOR && !UNITY_STANDALONE_OSX && !UNITY_STANDALONE_WIN && !UNITY_STANDALONE_LINUX switch (inputName) { case "LT": return(OuyaInputManager.getPlayerKeyState(player).m_axisLeftTrigger); case "RT": return(OuyaInputManager.getPlayerKeyState(player).m_axisRightTrigger); case "RX": return(OuyaInputManager.getPlayerKeyState(player).m_axisRightStickX); case "RY": return(OuyaInputManager.getPlayerKeyState(player).m_axisRightStickY); case "LX": return(OuyaInputManager.getPlayerKeyState(player).m_axisLeftStickX); case "LY": return(-OuyaInputManager.getPlayerKeyState(player).m_axisLeftStickY); } return(0f); #else string axisName = string.Empty; int invertFactor = GetInvertedFactor(GetControllerType(player), inputName); switch (inputName) { case "LT": axisName = OuyaInputManager.GetInput(player, AxisTypes.Horizontal, AnalogTypes.LTRT); break; case "RT": axisName = OuyaInputManager.GetInput(player, AxisTypes.Vertical, AnalogTypes.LTRT); break; case "RX": axisName = OuyaInputManager.GetInput(player, AxisTypes.Horizontal, AnalogTypes.Right); break; case "RY": axisName = OuyaInputManager.GetInput(player, AxisTypes.Vertical, AnalogTypes.Right); break; case "LX": axisName = OuyaInputManager.GetInput(player, AxisTypes.Horizontal, AnalogTypes.Left); break; case "LY": axisName = OuyaInputManager.GetInput(player, AxisTypes.Vertical, AnalogTypes.Left); break; } if (!string.IsNullOrEmpty(axisName)) { return(invertFactor * Input.GetAxis(axisName)); } return(0f); #endif }
/// <summary> /// Get Devices /// </summary> /// <returns>List<Device></returns> public static void HandleAxisEvent(OuyaSDK.InputAxisEvent inputEvent) { switch (inputEvent.getAxisCode()) { case OuyaSDK.AxisEnum.AXIS_LSTICK_X: OuyaInputManager.getPlayerKeyState(inputEvent.getPlayer()).m_axisLeftStickX = inputEvent.getAxis(); break; case OuyaSDK.AxisEnum.AXIS_LSTICK_Y: OuyaInputManager.getPlayerKeyState(inputEvent.getPlayer()).m_axisLeftStickY = inputEvent.getAxis(); break; case OuyaSDK.AxisEnum.AXIS_RSTICK_X: OuyaInputManager.getPlayerKeyState(inputEvent.getPlayer()).m_axisRightStickX = inputEvent.getAxis(); break; case OuyaSDK.AxisEnum.AXIS_RSTICK_Y: OuyaInputManager.getPlayerKeyState(inputEvent.getPlayer()).m_axisRightStickY = inputEvent.getAxis(); break; case OuyaSDK.AxisEnum.AXIS_LTRIGGER: OuyaInputManager.getPlayerKeyState(inputEvent.getPlayer()).m_axisLeftTrigger = inputEvent.getAxis(); break; case OuyaSDK.AxisEnum.AXIS_RTRIGGER: OuyaInputManager.getPlayerKeyState(inputEvent.getPlayer()).m_axisRightTrigger = inputEvent.getAxis(); break; } }
private void UpdateController() { UpdateHighlight(RendererAxisLeft, Mathf.Abs(OuyaInputManager.GetAxis("LX", player)) > 0.25f || Mathf.Abs(OuyaInputManager.GetAxis("LY", player)) > 0.25f); RendererAxisLeft.transform.localRotation = Quaternion.Euler(OuyaInputManager.GetAxis("LY", player) * 15, 0, OuyaInputManager.GetAxis("LX", player) * 15); UpdateHighlight(RendererAxisRight, Mathf.Abs(OuyaInputManager.GetAxis("RX", player)) > 0.25f || Mathf.Abs(OuyaInputManager.GetAxis("RY", player)) > 0.25f); RendererAxisRight.transform.localRotation = Quaternion.Euler(OuyaInputManager.GetAxis("RY", player) * 15, 0, OuyaInputManager.GetAxis("RX", player) * 15); if (OuyaInputManager.GetButtonDown("L3", player)) { RendererAxisLeft.transform.localPosition = Vector3.Lerp(RendererAxisLeft.transform.localPosition, new Vector3(5.503977f, 0.75f, -3.344945f), Time.fixedDeltaTime); } else { RendererAxisLeft.transform.localPosition = Vector3.Lerp(RendererAxisLeft.transform.localPosition, new Vector3(5.503977f, 1.127527f, -3.344945f), Time.fixedDeltaTime); } if (OuyaInputManager.GetButtonDown("R3", player)) { RendererAxisRight.transform.localPosition = Vector3.Lerp(RendererAxisRight.transform.localPosition, new Vector3(-2.707688f, 0.75f, -1.354063f), Time.fixedDeltaTime); } else { RendererAxisRight.transform.localPosition = Vector3.Lerp(RendererAxisRight.transform.localPosition, new Vector3(-2.707688f, 1.11295f, -1.354063f), Time.fixedDeltaTime); } }
// Using this format: // // W I // A S D J K L // // Ouya: // Y // U A // O // // ouya parameter string values // SYS, DPC, DPD, DPL, DPR, DPU, O, U, Y, A, LT, RT, LB, RB, L3, R3 //ouya axes // Left Analog: LY LX, Right Analog: RY RX, Trigger: RT, LT public static bool GetDown() { return (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S) || OuyaInputManager.GetButton("DPD", OuyaSDK.OuyaPlayer.player2) || OuyaInputManager.GetAxis("LY", OuyaSDK.OuyaPlayer.player2) < -0.25f); }
void OnDestroy() { OuyaSDK.unregisterPauseListener(this); OuyaSDK.unregisterResumeListener(this); OuyaInputManager.OuyaButtonEvent.removeButtonEventListener(HandleButtonEvent); OuyaInputManager.initKeyStates(); }
public static bool GetRight() { return (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D) || OuyaInputManager.GetButton("DPR", OuyaSDK.OuyaPlayer.player2) || OuyaInputManager.GetAxis("LX", OuyaSDK.OuyaPlayer.player2) > 0.25f); }
public static bool GetLeft() { return (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A) || OuyaInputManager.GetButton("DPL", OuyaSDK.OuyaPlayer.player2) || OuyaInputManager.GetAxis("LX", OuyaSDK.OuyaPlayer.player2) < -0.25f); }
public static bool GetUp() { return (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W) || OuyaInputManager.GetButton("DPU", OuyaSDK.OuyaPlayer.player2) || OuyaInputManager.GetAxis("LY", OuyaSDK.OuyaPlayer.player2) > 0.25f); }
/// <summary> /// Wrap Unity's method /// </summary> /// <param name="inputName"></param> /// <returns></returns> public static bool GetButton(string inputName, OuyaSDK.OuyaPlayer player) { switch (inputName) { case "SYS": //arbitrary name and mapping return(OuyaInputManager.getPlayerKeyState(player).m_buttonSystem); case "DPC": //arbitrary name and mapping return(OuyaInputManager.getPlayerKeyState(player).m_buttonDPadCenter); case "DPD": //arbitrary name and mapping return(OuyaInputManager.getPlayerKeyState(player).m_buttonDPadDown); case "DPL": //arbitrary name and mapping return(OuyaInputManager.getPlayerKeyState(player).m_buttonDPadLeft); case "DPR": //arbitrary name and mapping return(OuyaInputManager.getPlayerKeyState(player).m_buttonDPadRight); case "DPU": //arbitrary name and mapping return(OuyaInputManager.getPlayerKeyState(player).m_buttonDPadUp); case "O": //arbitrary name and mapping return(OuyaInputManager.getPlayerKeyState(player).m_buttonO); case "U": //arbitrary name and mapping return(OuyaInputManager.getPlayerKeyState(player).m_buttonU); case "Y": //arbitrary name and mapping return(OuyaInputManager.getPlayerKeyState(player).m_buttonY); case "A": //arbitrary name and mapping return(OuyaInputManager.getPlayerKeyState(player).m_buttonA); case "LT": //arbitrary name and mapping return(OuyaInputManager.getPlayerKeyState(player).m_buttonLT); case "RT": //arbitrary name and mapping return(OuyaInputManager.getPlayerKeyState(player).m_buttonRT); case "LB": //arbitrary name and mapping return(OuyaInputManager.getPlayerKeyState(player).m_buttonLB); case "RB": //arbitrary name and mapping return(OuyaInputManager.getPlayerKeyState(player).m_buttonRB); case "L3": return(OuyaInputManager.getPlayerKeyState(player).m_buttonL3); case "R3": return(OuyaInputManager.getPlayerKeyState(player).m_buttonR3); } return(false); }
void Update() { if (joystickCanTrigger && enabled && NGUITools.GetActive(gameObject)) { float greatestX = 0.0f; float greatestY = 0.0f; float leastX = 0.0f; float leastY = 0.0f; //foreach (OuyaSDK.OuyaPlayer player in Enum.GetValues(typeof(OuyaSDK.OuyaPlayer))) // TODO: Use once input lag is fixed for (int i = 1; i <= 4; ++i) // HACK: check a hard-coded number of players { OuyaSDK.OuyaPlayer player = (OuyaSDK.OuyaPlayer)i; float joystickX = OuyaInputManager.GetAxis("LX", player); float joystickY = OuyaInputManager.GetAxis("LY", player); greatestX = Math.Max(joystickX, greatestX); greatestY = Math.Max(joystickY, greatestY); leastX = Math.Min(joystickX, leastX); leastY = Math.Min(joystickY, leastY); } if (greatestX > JoystickThreshold) { StartJoystickResetTimer(); OnKey(KeyCode.RightArrow); } if (greatestY > JoystickThreshold) { StartJoystickResetTimer(); OnKey(KeyCode.UpArrow); } if (leastX < -JoystickThreshold) { StartJoystickResetTimer(); OnKey(KeyCode.LeftArrow); } if (leastY < -JoystickThreshold) { StartJoystickResetTimer(); OnKey(KeyCode.DownArrow); } } }
void Update() { //Get Joystick points and calculate deadzone. Vector2 point = convertRawJoystickCoordinates(OuyaInputManager.GetAxis("LX", player), OuyaInputManager.GetAxis("LY", player), .25f); //Debug.Log(string.Format("Player:{0}, Axis:{1}",player,point)); //Rotate character to where it is looking. transform.Rotate(0f, point.x * turnSpeed * Time.deltaTime, 0f); //only move if we are grounded. if (controller.isGrounded) { //get the move direction from the controller axis; moveDirection = transform.forward * point.y; //Set the speed moveDirection *= speed; } //Apply any gravity factors moveDirection.y -= gravity * Time.deltaTime; //Move the character; controller.Move(moveDirection * Time.deltaTime); //Handle animation if we are moving. if (point.x != 0f && point.y != 0f) { //If axis is not 0 then play run animation. this.animation.Play("run"); } //if no animation is playing, then play the idle animation. if (!this.animation.isPlaying) { string anim = "idle"; if (isBattleStance) { anim = "waitingforbattle"; } this.animation.Play(anim); } }
private void OnGUI() { try { // UpdateCamera(); OuyaNGUIHandler nguiHandler = GameObject.Find("_NGUIHandler").GetComponent <OuyaNGUIHandler>(); if (nguiHandler != null) { string[] joystickNames = Input.GetJoystickNames(); //foreach (string joystick in Input.GetJoystickNames()) for (int i = 0; i < joystickNames.Length && i < 4; i++) { if (i == 1) { nguiHandler.controller1.text = joystickNames[i]; } if (i == 2) { nguiHandler.controller1.text = joystickNames[i]; } if (i == 3) { nguiHandler.controller1.text = joystickNames[i]; } if (i == 4) { nguiHandler.controller1.text = joystickNames[i]; } } nguiHandler.genericEvent.text = m_inputAction + " : " + m_keyEnum; nguiHandler.joystickLeft.text = string.Format("{0},{1}", OuyaInputManager.GetAxis("LX", player), OuyaInputManager.GetAxis("LY", player)); nguiHandler.joystickRight.text = string.Format("{0},{1}", OuyaInputManager.GetAxis("RX", player), OuyaInputManager.GetAxis("RY", player)); nguiHandler.trigger.text = string.Format("{0},{1}", OuyaInputManager.GetAxis("LT", player), OuyaInputManager.GetAxis("RT", player)); nguiHandler.rawOut.text = OuyaGameObject.InputData; } } catch (System.Exception) { } }
/// <summary> /// Wrap Unity's method /// </summary> /// <param name="inputName"></param> /// <returns></returns> public static bool GetButtonUp(string inputName, OuyaSDK.OuyaPlayer player) { // these will map to the Unity game's existing button names // the text cases are placeholders return(!OuyaInputManager.GetButton(inputName, player)); }
public static void SetButton(string inputName, OuyaSDK.OuyaPlayer player, bool state) { switch (inputName) { case "SYS": //arbitrary name and mapping OuyaInputManager.getPlayerKeyState(player).m_buttonSystem = state; break; case "DPC": //arbitrary name and mapping OuyaInputManager.getPlayerKeyState(player).m_buttonDPadCenter = state; break; case "DPD": //arbitrary name and mapping OuyaInputManager.getPlayerKeyState(player).m_buttonDPadDown = state; break; case "DPL": //arbitrary name and mapping OuyaInputManager.getPlayerKeyState(player).m_buttonDPadLeft = state; break; case "DPR": //arbitrary name and mapping OuyaInputManager.getPlayerKeyState(player).m_buttonDPadRight = state; break; case "DPU": //arbitrary name and mapping OuyaInputManager.getPlayerKeyState(player).m_buttonDPadUp = state; break; case "O": //arbitrary name and mapping OuyaInputManager.getPlayerKeyState(player).m_buttonO = state; break; case "U": //arbitrary name and mapping OuyaInputManager.getPlayerKeyState(player).m_buttonU = state; break; case "Y": //arbitrary name and mapping OuyaInputManager.getPlayerKeyState(player).m_buttonY = state; break; case "A": //arbitrary name and mapping OuyaInputManager.getPlayerKeyState(player).m_buttonA = state; break; case "LT": //arbitrary name and mapping OuyaInputManager.getPlayerKeyState(player).m_buttonLT = state; break; case "RT": //arbitrary name and mapping OuyaInputManager.getPlayerKeyState(player).m_buttonRT = state; break; case "LB": //arbitrary name and mapping OuyaInputManager.getPlayerKeyState(player).m_buttonLB = state; break; case "RB": //arbitrary name and mapping OuyaInputManager.getPlayerKeyState(player).m_buttonRB = state; break; case "L3": //arbitrary name and mapping OuyaInputManager.getPlayerKeyState(player).m_buttonL3 = state; break; case "R3": //arbitrary name and mapping OuyaInputManager.getPlayerKeyState(player).m_buttonR3 = state; break; } }
public static void HandleButtonEvent(OuyaSDK.InputButtonEvent inputEvent) { OuyaInputManager.OuyaKeyState keyState = OuyaInputManager.getPlayerKeyState(inputEvent.getPlayer()); if (null == keyState) { return; } switch (inputEvent.getKeyAction()) { case OuyaSDK.InputAction.KeyDown: case OuyaSDK.InputAction.KeyUp: switch (inputEvent.getKeyCode()) { case OuyaSDK.KeyEnum.BUTTON_O: keyState.m_buttonO = inputEvent.getKeyAction() == OuyaSDK.InputAction.KeyDown; break; case OuyaSDK.KeyEnum.BUTTON_U: keyState.m_buttonU = inputEvent.getKeyAction() == OuyaSDK.InputAction.KeyDown; break; case OuyaSDK.KeyEnum.BUTTON_Y: keyState.m_buttonY = inputEvent.getKeyAction() == OuyaSDK.InputAction.KeyDown; break; case OuyaSDK.KeyEnum.BUTTON_A: keyState.m_buttonA = inputEvent.getKeyAction() == OuyaSDK.InputAction.KeyDown; break; case OuyaSDK.KeyEnum.BUTTON_LB: keyState.m_buttonLB = inputEvent.getKeyAction() == OuyaSDK.InputAction.KeyDown; break; case OuyaSDK.KeyEnum.BUTTON_LT: keyState.m_buttonLT = inputEvent.getKeyAction() == OuyaSDK.InputAction.KeyDown; break; case OuyaSDK.KeyEnum.BUTTON_L3: keyState.m_buttonL3 = inputEvent.getKeyAction() == OuyaSDK.InputAction.KeyDown; break; case OuyaSDK.KeyEnum.BUTTON_RB: keyState.m_buttonRB = inputEvent.getKeyAction() == OuyaSDK.InputAction.KeyDown; break; case OuyaSDK.KeyEnum.BUTTON_RT: keyState.m_buttonRT = inputEvent.getKeyAction() == OuyaSDK.InputAction.KeyDown; break; case OuyaSDK.KeyEnum.BUTTON_R3: keyState.m_buttonR3 = inputEvent.getKeyAction() == OuyaSDK.InputAction.KeyDown; break; case OuyaSDK.KeyEnum.BUTTON_SYSTEM: keyState.m_buttonSystem = inputEvent.getKeyAction() == OuyaSDK.InputAction.KeyDown; break; case OuyaSDK.KeyEnum.BUTTON_DPAD_DOWN: keyState.m_buttonDPadDown = inputEvent.getKeyAction() == OuyaSDK.InputAction.KeyDown; break; case OuyaSDK.KeyEnum.BUTTON_DPAD_LEFT: keyState.m_buttonDPadLeft = inputEvent.getKeyAction() == OuyaSDK.InputAction.KeyDown; break; case OuyaSDK.KeyEnum.BUTTON_DPAD_RIGHT: keyState.m_buttonDPadRight = inputEvent.getKeyAction() == OuyaSDK.InputAction.KeyDown; break; case OuyaSDK.KeyEnum.BUTTON_DPAD_UP: keyState.m_buttonDPadUp = inputEvent.getKeyAction() == OuyaSDK.InputAction.KeyDown; break; default: return; } OuyaButtonEvent.buttonPressEvent(inputEvent.getPlayer(), inputEvent.getKeyCode(), inputEvent.getKeyAction()); break; } }
public static bool GetPlayerInteractDown() { return(Input.GetKeyDown(KeyCode.L) || OuyaInputManager.GetButtonDown("A", OuyaSDK.OuyaPlayer.player2)); }
static OuyaInputManager() { OuyaInputManager.initKeyStates(); }
// Player Action public static bool GetPlayerInspectDown() { return(Input.GetKeyDown(KeyCode.K) || OuyaInputManager.GetButtonDown("O", OuyaSDK.OuyaPlayer.player1)); }