public Joystick(IntPtr windowHandle, int index, JoystickType type) { range = new InputRange(0, 250); this.type = type; createJoystick(index); configureJoystick(windowHandle); }
public ETCJoystick() { joystickType = JoystickType.Static; allowJoystickOverTouchPad = false; radiusBase = RadiusBase.Width; axisX = new ETCAxis("Horizontal"); axisY = new ETCAxis("Vertical"); _visible = true; _activated = true; joystickArea = JoystickArea.FullScreen; isDynamicActif = false; isOnDrag = false; isOnTouch = false; axisX.unityAxis = "Horizontal"; axisY.unityAxis = "Vertical"; enableKeySimulation = true; isNoReturnThumb = false; showPSInspector = false; showAxesInspector = false; showEventInspector = false; showSpriteInspector = false; }
protected JoystickDataProvider(JoystickType type, int vendorId) { Type = type; VendorId = vendorId; JoystickDataParser = JoystickDataParserFactory.GetJoystickDataParser(type); }
public ETCJoystick() { joystickType = JoystickType.Static; allowJoystickOverTouchPad = false; radiusBase = RadiusBase.Width; axisX = new ETCAxis("Horizontal"); axisY = new ETCAxis("Vertical"); _visible = true; _activated = true; joystickArea = JoystickArea.FullScreen; isDynamicActif = false; isOnDrag = false; isOnTouch = false; axisX.positivekey = KeyCode.RightArrow; axisX.negativeKey = KeyCode.LeftArrow; axisY.positivekey = KeyCode.UpArrow; axisY.negativeKey = KeyCode.DownArrow; enableKeySimulation = true; showPSInspector = true; showAxesInspector = false; showEventInspector = false; showSpriteInspector = false; }
/// <summary> /// Builds a string to get the controller by player. /// </summary> /// <param name="player"></param> /// <param name="axis"></param> /// <param name="type"></param> /// <param name="atype"></param> /// <returns></returns> public static string GetInput(OuyaSDK.OuyaPlayer player, AxisTypes axis, AnalogTypes atype) { Vector2 point; JoystickType joystickType = GetControllerType(player); switch (joystickType) { case JoystickType.ps3: //Note We don't care if the axis is X or Y, we just want to check for input from normalized. #region PS3 Controller point = new Vector2(Input.GetAxis(CheckInput(player, axis, JoystickType.ps3, AnalogTypes.Left)), Input.GetAxis(CheckInput(player, axis, JoystickType.ps3, AnalogTypes.Right))); if (point.x != 0f || point.y != 0f) { return(CheckInput(player, axis, JoystickType.ps3, atype)); } if (atype.Equals(AnalogTypes.DPad)) { return(CheckInput(player, axis, JoystickType.ps3, atype)); } #endregion return(string.Empty); case JoystickType.xbox: #region xbox360 point = new Vector2(Input.GetAxis(CheckInput(player, axis, JoystickType.xbox, AnalogTypes.Left)), Input.GetAxis(CheckInput(player, axis, JoystickType.xbox, AnalogTypes.Right))); if (point.x != 0f || point.y != 0f) { return(CheckInput(player, axis, JoystickType.xbox, atype)); } if (atype.Equals(AnalogTypes.DPad)) { return(CheckInput(player, axis, JoystickType.xbox, atype)); } if (atype.Equals(AnalogTypes.LTRT)) { return(CheckInput(player, axis, JoystickType.xbox, atype)); } #endregion return(string.Empty); case JoystickType.ouya: point = new Vector2(Input.GetAxis(CheckInput(player, axis, JoystickType.ouya, AnalogTypes.Left)), Input.GetAxis(CheckInput(player, axis, JoystickType.ouya, AnalogTypes.Right))); if (point.x != 0f || point.y != 0f) { return(CheckInput(player, axis, JoystickType.ouya, atype)); } if (atype.Equals(AnalogTypes.DPad)) { return(CheckInput(player, axis, JoystickType.ouya, atype)); } if (atype.Equals(AnalogTypes.LTRT)) { return(CheckInput(player, axis, JoystickType.ouya, atype)); } return(string.Empty); default: return("Horizontal"); } }
public Joystick(IntPtr windowHandle, int rangeFrom, int rangeTo) { range = new InputRange(rangeFrom, rangeTo); type = JoystickType.MainController; createJoystick(); configureJoystick(windowHandle); }
public Joystick(IntPtr windowHandle, int rangeFrom, int rangeTo, JoystickType type) { range = new InputRange(rangeFrom, rangeTo); this.type = type; createJoystick(); configureJoystick(windowHandle); }
public Joystick(IntPtr windowHandle) { range = new InputRange(1, 255); type = JoystickType.MainController; createJoystick(); configureJoystick(windowHandle); }
protected override void Start() { base.Start(); _fixedPosition = _background.anchoredPosition; Type = _joystickType; MoveTreshold = _moveTreshold; }
void Start() { LookType = (JoystickType)LoadInt("LookType", (int)JoystickType.Move); Sensitivity = LoadFloat("Sensitivity", 3); UIScale = LoadFloat("UIScale", 1); FPS60 = LoadInt("60FPS", 0) != 0; CodeDropType = (CodeDropType)LoadInt("CodeDrop", 3); UpdateGUI(); }
public void SetMode(JoystickType joystickType) { this.joystickType = joystickType; if (joystickType == JoystickType.Fixed) { background.anchoredPosition = fixedPosition; background.gameObject.SetActive(true); } //else //background.gameObject.SetActive(false); }
public void StoreState(byte[] statePacket, JoystickType type) { switch(type) { case(JoystickType.MainController) : Main = statePacket; break; case (JoystickType.ManipulatorRight) : ManipulatorRight = statePacket; break; } }
public static IJoystickDataParser GetJoystickDataParser(JoystickType type) { switch (type) { case JoystickType.XBox: return new XBoxJoystickDataParser(); case JoystickType.Playstation: return new PlaystationJoystickDataParser(); } return null; }
public static int GetInvertedFactor(JoystickType joystickType, string axis) { switch (joystickType) { case JoystickType.ps3: switch (axis) { case "RY": return(-1); case "DPL": return(-1); } break; case JoystickType.xbox: switch (axis) { case "RX": return(-1); } break; case JoystickType.ouya: switch (axis) { case "RX": //case "RY": switch (OuyaGameObject.Singleton.GetDeviceType()) { case OuyaGameObject.DEVICE_OUYA: case OuyaGameObject.DEVICE_ANDROID: return(1); default: return(-1); } } break; case JoystickType.none: switch (axis) { case "RX": return(-1); } break; } return(1); }
private void SetType(JoystickType joystickType) { this._joystickType = joystickType; if ((JoystickType.Fixed == _joystickType) || (JoystickType.LocalFloating == _joystickType)) { _background.anchoredPosition = _fixedPosition; _background.gameObject.SetActive(true); } else { _background.gameObject.SetActive(false); } }
/// <summary> /// Use the button mapping to retrieve the mapped button /// </summary> /// <param name="id"></param> /// <returns></returns> public static int findButton(int id, JoystickType joystickType) { List <ButtonMap> buttons = new List <ButtonMap>(); buttons = buttonMap.FindAll((e) => { return(e.ButtonID == id && e.type == joystickType); }); if (buttons.Count > 0) { return((int)buttons[0].button); } else { return(0); } }
public void SetMode(JoystickType joystickType) { this.joystickType = joystickType; if (joystickType == JoystickType.Fixed) { background.anchoredPosition = fixedPosition; } switch (displayType) { case DisplayType.Show: background.gameObject.SetActive(true); break; case DisplayType.AutoHide: background.gameObject.SetActive(false); break; case DisplayType.Hide: background.gameObject.SetActive(false); break; } }
//====================================================== public void Initialize() { string[] joystickNames = Input.GetJoystickNames(); string joystickName = ""; if (joystickNames.Length > 0) { joystickName = joystickNames[0]; } if (!string.IsNullOrEmpty(joystickName)) { joystickType = (joystickName == "Wireless Controller") ? JoystickType.PS4 : JoystickType.XBOX; Log.Debug("Joystick name: '" + joystickName + "' ...name: " + joystickName + " ..type: " + joystickType.ToString()); } else { Log.Debug("Joystick not found."); } }
public void ControllerModeChanged(int index) { PlayerPrefs.SetInt("ControllerMode", index); switch (index) { case 0: joystickType = JoystickType.Fixed; break; case 1: joystickType = JoystickType.Floating; break; case 2: joystickType = JoystickType.Dynamic; break; default: joystickType = JoystickType.Fixed; break; } }
/// <summary> /// Instantiates a new IJoystick object /// </summary> /// <param name="type"></param> /// <param name="playerNumber"></param> /// <returns></returns> public IJoystick InstantiateJoystick(JoystickType type, int playerNumber) { switch (type) { case JoystickType.Kempston: return(new KempstonJoystick(this, playerNumber)); case JoystickType.Cursor: return(new CursorJoystick(this, playerNumber)); case JoystickType.SinclairLEFT: return(new SinclairJoystick1(this, playerNumber)); case JoystickType.SinclairRIGHT: return(new SinclairJoystick2(this, playerNumber)); case JoystickType.NULL: return(new NullJoystick(this, playerNumber)); } return(null); }
public bool IsUsePressed(string controller) { int index = 666; if (controller.Contains("Joystick")) { index = Convert.ToInt32(controller.Replace("Joystick", string.Empty)); } JoystickType type = GetJoystickType(index); string keyBinding = ""; if (type == JoystickType.PS) { keyBinding = DefaultBindings_PS4.Use; } else if (type == JoystickType.Xbox) { keyBinding = DefaultBindings_Xbox.Use; } if (keyBinding != "") { KeyCode keyCode = (KeyCode)System.Enum.Parse(typeof(KeyCode), controller + keyBinding); if (Input.GetKeyDown(keyCode)) { return(true); } } else { if ((controller == "Keyboard1" && Input.GetKey(KeyCode.Space)) || (controller == "Keyboard2" && Input.GetKey(KeyCode.Return))) { return(true); } } return(false); }
public JoystickDevice(IntPtr sdlHandle) { this.sdlHandle = sdlHandle; joystickType = (JoystickType)SDL.SDL_JoystickGetType(sdlHandle); deviceId = SDL.SDL_JoystickName(sdlHandle); deviceName = string.Format("{0} ({1})", deviceId, joystickType.ToString()); totalButtons = SDL.SDL_JoystickNumButtons(sdlHandle); totalAxis = SDL.SDL_JoystickNumAxes(sdlHandle); totalBalls = SDL.SDL_JoystickNumBalls(sdlHandle); totalHats = SDL.SDL_JoystickNumHats(sdlHandle); for (int i = 0; i < statesDoubleBuffer.Length; ++i) { statesDoubleBuffer[i] = new JoystickState() { buttonsDown = new bool[totalButtons], axisValues = new float[totalAxis], ballValues = new Vector2[totalBalls], hatPositions = new HatPosition[totalHats], }; } }
public static int GetInvertedFactor(JoystickType joystickType, string axis) { switch (joystickType) { case JoystickType.ps3: switch (axis) { case "RY": return -1; case "DPL": return -1; } break; case JoystickType.xbox: switch (axis) { case "RX": return -1; } break; case JoystickType.ouya: switch (axis) { case "RX": //case "RY": switch (OuyaGameObject.Singleton.GetDeviceType()) { case OuyaGameObject.DEVICE_OUYA: case OuyaGameObject.DEVICE_ANDROID: return 1; default: return -1; } } break; case JoystickType.none: switch (axis) { case "RX": return -1; } break; } return 1; }
/// <summary> /// This needs to be setup for each joystick type being supported. I have not setup the USB controller or the I:Droid:CON /// For the most part you won't need to modify this section. /// </summary> /// <param name="player"></param> /// <param name="axis"></param> /// <param name="joystick"></param> /// <param name="atype"></param> /// <returns></returns> private static string CheckInput(OuyaSDK.OuyaPlayer player, AxisTypes axis, JoystickType joystick, AnalogTypes atype) { //Debug.Log(string.Format("Player:{0} Axis:{1} Joystick:{2} AnalogType:{3}",player,axis,joystick,atype)); //REF: player1, DPadH, PS3, Dpad //Note: It is your responsibility to make sure that Unity Inputs are setup correctly or you will get an error on your controller. int axisNumber=0; switch (joystick) { case JoystickType.ps3: //Get The Joystick name from Project Settings --> Input for Controllers #region PS3 Controller if (atype.Equals(AnalogTypes.Left)) { ControllerType cType = OuyaControllerMapping.getController("ps3"); if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.leftAnalogH; } else { axisNumber = cType.leftAnalogV; } return "Joy" + (int)player + " Axis " + axisNumber.ToString(); } else if (atype.Equals(AnalogTypes.Right)) { ControllerType cType = OuyaControllerMapping.getController("ps3"); if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.rightAnalogH; } else { axisNumber = cType.rightAnalogV; } return "Joy" + (int)player + " Axis " + axisNumber.ToString(); } else if (atype.Equals(AnalogTypes.DPad)) { ControllerType cType = OuyaControllerMapping.getController("ps3"); if (axis.Equals(AxisTypes.DPadH)) { axisNumber = cType.dpadH; } else { axisNumber = cType.dpadV; } return "Joy" + (int)player + " Axis " + axisNumber.ToString(); } #endregion break; case JoystickType.xbox: #region xbox ( usually 360 / untested with normal xbox ) if (atype.Equals(AnalogTypes.Left)) { ControllerType cType = OuyaControllerMapping.getController("xbox360"); if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.leftAnalogH; } else { axisNumber = cType.leftAnalogV; } return "Joy" + (int)player + " Axis " + axisNumber.ToString(); } else if (atype.Equals(AnalogTypes.Right)) { ControllerType cType = OuyaControllerMapping.getController("xbox360"); if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.rightAnalogH; } else { axisNumber = cType.rightAnalogV; } return "Joy" + (int)player + " Axis " + axisNumber.ToString(); } else if (atype.Equals(AnalogTypes.DPad)) { ControllerType cType = OuyaControllerMapping.getController("xbox360"); if (axis.Equals(AxisTypes.DPadH)) { axisNumber = cType.dpadH; } else { axisNumber = cType.dpadV; } return "Joy" + (int)player + " Axis " + axisNumber.ToString(); } else if (atype.Equals(AnalogTypes.LTRT)) { ControllerType cType = OuyaControllerMapping.getController("xbox360"); axisNumber = cType.triggers; return "Joy" + (int)player + " Axis " + axisNumber.ToString(); } #endregion break; case JoystickType.ouya: #region OUYA - Not Tested until I get a bluetooth dongle if (atype.Equals(AnalogTypes.Left)) { ControllerType cType = OuyaControllerMapping.getController("ouya"); if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.leftAnalogH; } else { axisNumber = cType.leftAnalogV; } return "Joy" + (int)player + " Axis " + axisNumber.ToString(); } else if (atype.Equals(AnalogTypes.Right)) { ControllerType cType = OuyaControllerMapping.getController("ouya"); if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.rightAnalogH; } else { axisNumber = cType.rightAnalogV; } return "Joy" + (int)player + " Axis " + axisNumber.ToString(); } else if (atype.Equals(AnalogTypes.DPad)) { ControllerType cType = OuyaControllerMapping.getController("ouya"); if (axis.Equals(AxisTypes.DPadH)) { axisNumber = cType.dpadH; } else { axisNumber = cType.dpadV; } return "Joy" + (int)player + " Axis " + axisNumber.ToString(); } #endregion break; } //most likely we will never reach here, but If we do Return basic Horizontal Axis return "Horizontal"; }
/// <summary> /// Static constructor /// </summary> static OuyaControllerMapping() { controllers = new Dictionary <string, ControllerType>(); buttonMap = new List <ButtonMap>(); JoystickType joystickType = JoystickType.none; #region PS3 mapping ControllerType ps3 = new ControllerType(); ps3.name = "ps3"; ps3.leftAnalogH = 1; ps3.leftAnalogV = 2; ps3.rightAnalogH = 3; //4 was gyro ps3.rightAnalogV = 6; //5 was gyro ps3.dpadH = 9; ps3.dpadV = 10; joystickType = JoystickType.ps3; //Start PS3 ButtonMap ( only has 13 buttons ) buttonMap.Add(new ButtonMap(joystickType, 350, OuyaSDK.KeyEnum.BUTTON_Y)); buttonMap.Add(new ButtonMap(joystickType, 351, OuyaSDK.KeyEnum.BUTTON_A)); buttonMap.Add(new ButtonMap(joystickType, 352, OuyaSDK.KeyEnum.BUTTON_O)); buttonMap.Add(new ButtonMap(joystickType, 353, OuyaSDK.KeyEnum.BUTTON_U)); buttonMap.Add(new ButtonMap(joystickType, 354, OuyaSDK.KeyEnum.BUTTON_LB)); buttonMap.Add(new ButtonMap(joystickType, 355, OuyaSDK.KeyEnum.BUTTON_RB)); buttonMap.Add(new ButtonMap(joystickType, 356, OuyaSDK.KeyEnum.BUTTON_LT)); buttonMap.Add(new ButtonMap(joystickType, 357, OuyaSDK.KeyEnum.BUTTON_RT)); buttonMap.Add(new ButtonMap(joystickType, 358, OuyaSDK.KeyEnum.BUTTON_SELECT)); buttonMap.Add(new ButtonMap(joystickType, 359, OuyaSDK.KeyEnum.BUTTON_L3)); buttonMap.Add(new ButtonMap(joystickType, 360, OuyaSDK.KeyEnum.BUTTON_R3)); buttonMap.Add(new ButtonMap(joystickType, 361, OuyaSDK.KeyEnum.BUTTON_START)); buttonMap.Add(new ButtonMap(joystickType, 362, OuyaSDK.KeyEnum.BUTTON_SYSTEM)); //4 button dpad mappings buttonMap.Add(new ButtonMap(joystickType, 363, OuyaSDK.KeyEnum.BUTTON_DPAD_LEFT)); buttonMap.Add(new ButtonMap(joystickType, 364, OuyaSDK.KeyEnum.BUTTON_DPAD_RIGHT)); buttonMap.Add(new ButtonMap(joystickType, 365, OuyaSDK.KeyEnum.BUTTON_DPAD_UP)); buttonMap.Add(new ButtonMap(joystickType, 366, OuyaSDK.KeyEnum.BUTTON_DPAD_DOWN)); controllers.Add(ps3.name, ps3); #endregion #region XBOX mapping ControllerType xbox360 = new ControllerType(); xbox360.name = "xbox360"; xbox360.leftAnalogH = 1; xbox360.leftAnalogV = 2; xbox360.rightAnalogH = 4; xbox360.rightAnalogV = 5; xbox360.triggers = 3; xbox360.dpadH = 6; xbox360.dpadV = 7; joystickType = JoystickType.xbox; #region Values are different on windows, sometimes they are these //Start XBOX 360 ButtonMap ( only has 13 buttons ) buttonMap.Add(new ButtonMap(joystickType, 350, OuyaSDK.KeyEnum.BUTTON_O)); buttonMap.Add(new ButtonMap(joystickType, 351, OuyaSDK.KeyEnum.BUTTON_A)); buttonMap.Add(new ButtonMap(joystickType, 352, OuyaSDK.KeyEnum.BUTTON_U)); buttonMap.Add(new ButtonMap(joystickType, 353, OuyaSDK.KeyEnum.BUTTON_Y)); buttonMap.Add(new ButtonMap(joystickType, 354, OuyaSDK.KeyEnum.BUTTON_LB)); buttonMap.Add(new ButtonMap(joystickType, 355, OuyaSDK.KeyEnum.BUTTON_RB)); buttonMap.Add(new ButtonMap(joystickType, 356, OuyaSDK.KeyEnum.BUTTON_SELECT)); buttonMap.Add(new ButtonMap(joystickType, 357, OuyaSDK.KeyEnum.BUTTON_START)); buttonMap.Add(new ButtonMap(joystickType, 358, OuyaSDK.KeyEnum.BUTTON_L3)); buttonMap.Add(new ButtonMap(joystickType, 359, OuyaSDK.KeyEnum.BUTTON_R3)); buttonMap.Add(new ButtonMap(joystickType, 10, OuyaSDK.KeyEnum.BUTTON_LT)); //Doesn't Show up buttonMap.Add(new ButtonMap(joystickType, 11, OuyaSDK.KeyEnum.BUTTON_RT)); //Doesn't Show up buttonMap.Add(new ButtonMap(joystickType, 12, OuyaSDK.KeyEnum.BUTTON_SYSTEM)); //Dowsn't Show up //4 button dpad mappings buttonMap.Add(new ButtonMap(joystickType, 13, OuyaSDK.KeyEnum.BUTTON_DPAD_LEFT)); buttonMap.Add(new ButtonMap(joystickType, 14, OuyaSDK.KeyEnum.BUTTON_DPAD_RIGHT)); buttonMap.Add(new ButtonMap(joystickType, 15, OuyaSDK.KeyEnum.BUTTON_DPAD_UP)); buttonMap.Add(new ButtonMap(joystickType, 16, OuyaSDK.KeyEnum.BUTTON_DPAD_DOWN)); #endregion #region And sometimes they are these, just on windows #if UNITY_EDITOR || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX //Start XBOX 360 ButtonMap ( only has 13 buttons ) buttonMap.Add(new ButtonMap(joystickType, 370, OuyaSDK.KeyEnum.BUTTON_O)); buttonMap.Add(new ButtonMap(joystickType, 371, OuyaSDK.KeyEnum.BUTTON_A)); buttonMap.Add(new ButtonMap(joystickType, 372, OuyaSDK.KeyEnum.BUTTON_U)); buttonMap.Add(new ButtonMap(joystickType, 373, OuyaSDK.KeyEnum.BUTTON_Y)); buttonMap.Add(new ButtonMap(joystickType, 374, OuyaSDK.KeyEnum.BUTTON_LB)); buttonMap.Add(new ButtonMap(joystickType, 375, OuyaSDK.KeyEnum.BUTTON_RB)); buttonMap.Add(new ButtonMap(joystickType, 376, OuyaSDK.KeyEnum.BUTTON_SELECT)); buttonMap.Add(new ButtonMap(joystickType, 377, OuyaSDK.KeyEnum.BUTTON_START)); buttonMap.Add(new ButtonMap(joystickType, 378, OuyaSDK.KeyEnum.BUTTON_L3)); buttonMap.Add(new ButtonMap(joystickType, 379, OuyaSDK.KeyEnum.BUTTON_R3)); buttonMap.Add(new ButtonMap(joystickType, 380, OuyaSDK.KeyEnum.BUTTON_LT)); //Doesn't Show up buttonMap.Add(new ButtonMap(joystickType, 381, OuyaSDK.KeyEnum.BUTTON_RT)); //Doesn't Show up buttonMap.Add(new ButtonMap(joystickType, 382, OuyaSDK.KeyEnum.BUTTON_SYSTEM)); //Dowsn't Show up //4 button dpad mappings buttonMap.Add(new ButtonMap(joystickType, 383, OuyaSDK.KeyEnum.BUTTON_DPAD_LEFT)); buttonMap.Add(new ButtonMap(joystickType, 384, OuyaSDK.KeyEnum.BUTTON_DPAD_RIGHT)); buttonMap.Add(new ButtonMap(joystickType, 385, OuyaSDK.KeyEnum.BUTTON_DPAD_UP)); buttonMap.Add(new ButtonMap(joystickType, 386, OuyaSDK.KeyEnum.BUTTON_DPAD_DOWN)); #endif #endregion controllers.Add(xbox360.name, xbox360); #endregion #region PS2 controller mapping ControllerType ps2 = new ControllerType(); ps2.name = "ps2"; ps2.leftAnalogH = 1; ps2.leftAnalogV = 2; ps2.rightAnalogH = 3; //4 was gyro ps2.rightAnalogV = 6; //5 was gyro ps2.dpadH = 9; ps2.dpadV = 10; joystickType = JoystickType.ps2; //Start PS3 ButtonMap ( only has 13 buttons ) buttonMap.Add(new ButtonMap(joystickType, 350, OuyaSDK.KeyEnum.BUTTON_Y)); buttonMap.Add(new ButtonMap(joystickType, 351, OuyaSDK.KeyEnum.BUTTON_A)); buttonMap.Add(new ButtonMap(joystickType, 352, OuyaSDK.KeyEnum.BUTTON_O)); buttonMap.Add(new ButtonMap(joystickType, 373, OuyaSDK.KeyEnum.BUTTON_U)); buttonMap.Add(new ButtonMap(joystickType, 354, OuyaSDK.KeyEnum.BUTTON_LB)); buttonMap.Add(new ButtonMap(joystickType, 355, OuyaSDK.KeyEnum.BUTTON_RB)); buttonMap.Add(new ButtonMap(joystickType, 356, OuyaSDK.KeyEnum.BUTTON_LT)); buttonMap.Add(new ButtonMap(joystickType, 357, OuyaSDK.KeyEnum.BUTTON_RT)); buttonMap.Add(new ButtonMap(joystickType, 358, OuyaSDK.KeyEnum.BUTTON_SELECT)); buttonMap.Add(new ButtonMap(joystickType, 359, OuyaSDK.KeyEnum.BUTTON_L3)); buttonMap.Add(new ButtonMap(joystickType, 360, OuyaSDK.KeyEnum.BUTTON_R3)); buttonMap.Add(new ButtonMap(joystickType, 361, OuyaSDK.KeyEnum.BUTTON_START)); buttonMap.Add(new ButtonMap(joystickType, 362, OuyaSDK.KeyEnum.BUTTON_SYSTEM)); //4 button dpad mappings buttonMap.Add(new ButtonMap(joystickType, 363, OuyaSDK.KeyEnum.BUTTON_DPAD_LEFT)); buttonMap.Add(new ButtonMap(joystickType, 364, OuyaSDK.KeyEnum.BUTTON_DPAD_RIGHT)); buttonMap.Add(new ButtonMap(joystickType, 365, OuyaSDK.KeyEnum.BUTTON_DPAD_UP)); buttonMap.Add(new ButtonMap(joystickType, 366, OuyaSDK.KeyEnum.BUTTON_DPAD_DOWN)); controllers.Add(ps2.name, ps2); #endregion #region OUYA mapping ControllerType ouya = new ControllerType(); ouya.name = "ouya"; ouya.leftAnalogH = 1; ouya.leftAnalogV = 2; ouya.rightAnalogH = 4; ouya.rightAnalogV = 5; ouya.triggers = 6; ouya.dpadH = 9; ouya.dpadV = 10; joystickType = JoystickType.ouya; #region Values are different on windows, sometimes they are these //Start OUYA CONTROLLER ButtonMap ( only has 11 buttons ) buttonMap.Add(new ButtonMap(joystickType, 350, OuyaSDK.KeyEnum.BUTTON_O)); buttonMap.Add(new ButtonMap(joystickType, 353, OuyaSDK.KeyEnum.BUTTON_A)); buttonMap.Add(new ButtonMap(joystickType, 351, OuyaSDK.KeyEnum.BUTTON_U)); buttonMap.Add(new ButtonMap(joystickType, 352, OuyaSDK.KeyEnum.BUTTON_Y)); buttonMap.Add(new ButtonMap(joystickType, 354, OuyaSDK.KeyEnum.BUTTON_LB)); buttonMap.Add(new ButtonMap(joystickType, 355, OuyaSDK.KeyEnum.BUTTON_RB)); buttonMap.Add(new ButtonMap(joystickType, 356, OuyaSDK.KeyEnum.BUTTON_L3)); buttonMap.Add(new ButtonMap(joystickType, 357, OuyaSDK.KeyEnum.BUTTON_R3)); buttonMap.Add(new ButtonMap(joystickType, 362, OuyaSDK.KeyEnum.BUTTON_LT)); //Doesn't Show up buttonMap.Add(new ButtonMap(joystickType, 363, OuyaSDK.KeyEnum.BUTTON_RT)); //Doesn't Show up buttonMap.Add(new ButtonMap(joystickType, 364, OuyaSDK.KeyEnum.BUTTON_SYSTEM)); //Dowsn't Show up //4 button dpad mappings buttonMap.Add(new ButtonMap(joystickType, 360, OuyaSDK.KeyEnum.BUTTON_DPAD_LEFT)); buttonMap.Add(new ButtonMap(joystickType, 361, OuyaSDK.KeyEnum.BUTTON_DPAD_RIGHT)); buttonMap.Add(new ButtonMap(joystickType, 358, OuyaSDK.KeyEnum.BUTTON_DPAD_UP)); buttonMap.Add(new ButtonMap(joystickType, 359, OuyaSDK.KeyEnum.BUTTON_DPAD_DOWN)); #endregion controllers.Add(ouya.name, ouya); #endregion }
/// <summary> /// Returns a IJoystick object depending on the type (or null if not found) /// </summary> /// <param name="type"></param> /// <returns></returns> protected IJoystick LocateUniqueJoystick(JoystickType type) { return(JoystickCollection.Where(a => a.JoyType == type).FirstOrDefault()); }
public ButtonMap(JoystickType type, int buttonID, OuyaSDK.KeyEnum button) { this.type = type; this.ButtonID = buttonID; this.button = button; }
public void UpdateLookType() { LookType = lookTypeToggle.isOn ? JoystickType.Joystick : JoystickType.Move; PlayerPrefs.SetInt("LookType", (int)LookType); UpdateGUI(); }
/// <summary> /// Use the button mapping to retrieve the mapped button /// </summary> /// <param name="id"></param> /// <returns></returns> public static int findButton(int id, JoystickType joystickType) { List<ButtonMap> buttons = new List<ButtonMap>(); buttons = buttonMap.FindAll((e) => { return (e.ButtonID == id && e.type == joystickType); }); if (buttons.Count > 0) { return (int) buttons[0].button; } else { return 0; } }
private void Start() { MovementType = (JoystickType)PlayerPrefs.GetInt(nameof(MovementType), (int)JoystickType.Fixed); AttackType = (JoystickType)PlayerPrefs.GetInt(nameof(AttackType), (int)JoystickType.Fixed); }
void Awake() { OuyaSDK.registerMenuButtonUpListener(this); OuyaSDK.registerMenuAppearingListener(this); OuyaSDK.registerPauseListener(this); OuyaSDK.registerResumeListener(this); OuyaInputManager.OuyaButtonEvent.addButtonEventListener(HandleButtonEvent); //Get our character controller; controller = GetComponent <CharacterController>(); #if UNITY_EDITOR //If you find that your controller does not work properly in the Unity Editor, You can add a custom controller mapping as seen below. /* Here is some code to find keycodes for devices that are mapped to your InputManager.asset * List<OuyaGameObject.Device> devices = OuyaInputManager.GetDevices(); * for (int iPlayerJoystick = 1; iPlayerJoystick <= devices.Count; iPlayerJoystick++) * { * OuyaGameObject.Device device = devices.Find(delegate(OuyaGameObject.Device d) { return (null == d || null == devices) ? false : (d.id == devices[iPlayerJoystick - 1].id); }); * for (int i = 0; i < 13; i++) * { * //Controller Name: * string fireBtnName = string.Format("Joystick{0}Button{1}", iPlayerJoystick, i); * KeyCode keycode = (KeyCode)System.Enum.Parse(typeof(KeyCode), fireBtnName); * Debug.Log(string.Format("Button Name:{0}, Keycode:{1}",keycode,int(keycode)); * } * } */ //Custom Controller Mapping. List <ButtonMap> buttonMap = new List <ButtonMap>(); ControllerType xbox360 = new ControllerType(); xbox360.name = "xbox360"; xbox360.leftAnalogH = 1; xbox360.leftAnalogV = 2; xbox360.rightAnalogH = 4; xbox360.rightAnalogV = 5; xbox360.triggers = 3; xbox360.dpadH = 6; xbox360.dpadV = 7; JoystickType joystickType = JoystickType.xbox; //Start XBOX 360 ButtonMap ( only has 13 buttons ) buttonMap.Add(new ButtonMap(joystickType, 370, OuyaSDK.KeyEnum.BUTTON_O)); buttonMap.Add(new ButtonMap(joystickType, 371, OuyaSDK.KeyEnum.BUTTON_A)); buttonMap.Add(new ButtonMap(joystickType, 372, OuyaSDK.KeyEnum.BUTTON_U)); buttonMap.Add(new ButtonMap(joystickType, 373, OuyaSDK.KeyEnum.BUTTON_Y)); buttonMap.Add(new ButtonMap(joystickType, 374, OuyaSDK.KeyEnum.BUTTON_LB)); buttonMap.Add(new ButtonMap(joystickType, 375, OuyaSDK.KeyEnum.BUTTON_RB)); buttonMap.Add(new ButtonMap(joystickType, 376, OuyaSDK.KeyEnum.BUTTON_SELECT)); buttonMap.Add(new ButtonMap(joystickType, 377, OuyaSDK.KeyEnum.BUTTON_START)); buttonMap.Add(new ButtonMap(joystickType, 378, OuyaSDK.KeyEnum.BUTTON_L3)); buttonMap.Add(new ButtonMap(joystickType, 379, OuyaSDK.KeyEnum.BUTTON_R3)); buttonMap.Add(new ButtonMap(joystickType, 380, OuyaSDK.KeyEnum.BUTTON_LT)); //Doesn't Show up buttonMap.Add(new ButtonMap(joystickType, 381, OuyaSDK.KeyEnum.BUTTON_RT)); //Doesn't Show up buttonMap.Add(new ButtonMap(joystickType, 382, OuyaSDK.KeyEnum.BUTTON_SYSTEM)); //Dowsn't Show up /* * //4 button dpad mappings * buttonMap.Add(new ButtonMap(joystickType, 13, OuyaSDK.KeyEnum.BUTTON_DPAD_LEFT)); * buttonMap.Add(new ButtonMap(joystickType, 14, OuyaSDK.KeyEnum.BUTTON_DPAD_RIGHT)); * buttonMap.Add(new ButtonMap(joystickType, 15, OuyaSDK.KeyEnum.BUTTON_DPAD_UP)); * buttonMap.Add(new ButtonMap(joystickType, 16, OuyaSDK.KeyEnum.BUTTON_DPAD_DOWN)); */ //controllers.Add(xbox360.name,xbox360) //OuyaControllerMapping.RegisterCustomControllerMapping(xbox360, buttonMap); //duplicate of existing #endif }
/// <summary> /// This needs to be setup for each joystick type being supported. I have not setup the USB controller or the I:Droid:CON /// For the most part you won't need to modify this section. /// </summary> /// <param name="player"></param> /// <param name="axis"></param> /// <param name="joystick"></param> /// <param name="atype"></param> /// <returns></returns> private static string CheckInput(OuyaSDK.OuyaPlayer player, AxisTypes axis, JoystickType joystick, AnalogTypes atype) { //Debug.Log(string.Format("Player:{0} Axis:{1} Joystick:{2} AnalogType:{3}",player,axis,joystick,atype)); //REF: player1, DPadH, PS3, Dpad //Note: It is your responsibility to make sure that Unity Inputs are setup correctly or you will get an error on your controller. int axisNumber = 0; switch (joystick) { case JoystickType.ps3: //Get The Joystick name from Project Settings --> Input for Controllers #region PS3 Controller if (atype.Equals(AnalogTypes.Left)) { ControllerType cType = OuyaControllerMapping.getController("ps3"); if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.leftAnalogH; } else { axisNumber = cType.leftAnalogV; } return("Joy" + (int)player + " Axis " + axisNumber.ToString()); } else if (atype.Equals(AnalogTypes.Right)) { ControllerType cType = OuyaControllerMapping.getController("ps3"); if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.rightAnalogH; } else { axisNumber = cType.rightAnalogV; } return("Joy" + (int)player + " Axis " + axisNumber.ToString()); } else if (atype.Equals(AnalogTypes.DPad)) { ControllerType cType = OuyaControllerMapping.getController("ps3"); if (axis.Equals(AxisTypes.DPadH)) { axisNumber = cType.dpadH; } else { axisNumber = cType.dpadV; } return("Joy" + (int)player + " Axis " + axisNumber.ToString()); } #endregion break; case JoystickType.xbox: #region xbox ( usually 360 / untested with normal xbox ) if (atype.Equals(AnalogTypes.Left)) { ControllerType cType = OuyaControllerMapping.getController("xbox360"); if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.leftAnalogH; } else { axisNumber = cType.leftAnalogV; } return("Joy" + (int)player + " Axis " + axisNumber.ToString()); } else if (atype.Equals(AnalogTypes.Right)) { ControllerType cType = OuyaControllerMapping.getController("xbox360"); if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.rightAnalogH; } else { axisNumber = cType.rightAnalogV; } return("Joy" + (int)player + " Axis " + axisNumber.ToString()); } else if (atype.Equals(AnalogTypes.DPad)) { ControllerType cType = OuyaControllerMapping.getController("xbox360"); if (axis.Equals(AxisTypes.DPadH)) { axisNumber = cType.dpadH; } else { axisNumber = cType.dpadV; } return("Joy" + (int)player + " Axis " + axisNumber.ToString()); } else if (atype.Equals(AnalogTypes.LTRT)) { ControllerType cType = OuyaControllerMapping.getController("xbox360"); axisNumber = cType.triggers; return("Joy" + (int)player + " Axis " + axisNumber.ToString()); } #endregion break; case JoystickType.ouya: #region OUYA - Not Tested until I get a bluetooth dongle if (atype.Equals(AnalogTypes.Left)) { ControllerType cType = OuyaControllerMapping.getController("ouya"); if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.leftAnalogH; } else { axisNumber = cType.leftAnalogV; } return("Joy" + (int)player + " Axis " + axisNumber.ToString()); } else if (atype.Equals(AnalogTypes.Right)) { ControllerType cType = OuyaControllerMapping.getController("ouya"); if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.rightAnalogH; } else { axisNumber = cType.rightAnalogV; } return("Joy" + (int)player + " Axis " + axisNumber.ToString()); } else if (atype.Equals(AnalogTypes.DPad)) { ControllerType cType = OuyaControllerMapping.getController("ouya"); if (axis.Equals(AxisTypes.DPadH)) { axisNumber = cType.dpadH; } else { axisNumber = cType.dpadV; } return("Joy" + (int)player + " Axis " + axisNumber.ToString()); } #endregion break; } //most likely we will never reach here, but If we do Return basic Horizontal Axis return("Horizontal"); }