public JoystickAxis(string axisName, float threshold) { this.axisName = axisName; this.joystick = InputUtility.AxisToJoystick(axisName); this.axis = InputUtility.AxisToJoystickAxis(axisName); this.threshold = threshold; }
private void closeApp() { Settings.Default.Save(); Joysticks.Close(); Dispose(); Events.QuitApplication(); }
public JoystickAxis(Joysticks joystick, JoystickAxes axis, float threshold) { this.joystick = joystick; this.axis = axis; this.axisName = InputUtility.JoystickInputToAxis(joystick, axis); this.threshold = threshold; }
public void SpawnBallCall(Vector3 pos, Joysticks Side) { for (int i = 0; i < BallObjectPoolAmount; i++) { if (!BallObjectPool[i].activeInHierarchy) { switch (Side) { case Joysticks.White: BallObjectPool[i].GetComponent <Rigidbody2D>().gravityScale = 1; Debug.LogWarning("1"); break; case Joysticks.Black: BallObjectPool[i].GetComponent <Rigidbody2D>().gravityScale = -1; Debug.LogWarning("-----1"); break; default: break; } BallObjectPool[i].transform.position = pos; BallObjectPool[i].SetActive(true); break; } } }
public JoystickAxis(string axisName, float threshold) { this.axisName = axisName; this.joystick = InputUtility.AxisToJoystick(axisName); this.axis = InputUtility.AxisToJoystickAxis(axisName); this.threshold = threshold; }
public static void LoadShortcuts() { if (Settings.Key_Shortcuts_UseJoystick) { Joysticks.Initialize(); if (Joysticks.IsValidJoystickNumber(Settings.Key_Shortcuts_JoystickIndex)) { joyState = Joysticks.OpenJoystick(Settings.Key_Shortcuts_JoystickIndex); } } Enum.TryParse <Key>(Settings.Key_SoftReset, out Key_SoftReset); Enum.TryParse <Key>(Settings.Key_HardReset, out Key_HardReset); Enum.TryParse <Key>(Settings.Key_SwitchFullscreen, out Key_SwitchFullscreen); Enum.TryParse <Key>(Settings.Key_TakeSnap, out Key_TakeSnap); Enum.TryParse <Key>(Settings.Key_SaveState, out Key_SaveState); Enum.TryParse <Key>(Settings.Key_LoadState, out Key_LoadState); Enum.TryParse <Key>(Settings.Key_StateSlot0, out Key_StateSlot0); Enum.TryParse <Key>(Settings.Key_StateSlot1, out Key_StateSlot1); Enum.TryParse <Key>(Settings.Key_StateSlot2, out Key_StateSlot2); Enum.TryParse <Key>(Settings.Key_StateSlot3, out Key_StateSlot3); Enum.TryParse <Key>(Settings.Key_StateSlot4, out Key_StateSlot4); Enum.TryParse <Key>(Settings.Key_StateSlot5, out Key_StateSlot5); Enum.TryParse <Key>(Settings.Key_StateSlot6, out Key_StateSlot6); Enum.TryParse <Key>(Settings.Key_StateSlot7, out Key_StateSlot7); Enum.TryParse <Key>(Settings.Key_StateSlot8, out Key_StateSlot8); Enum.TryParse <Key>(Settings.Key_StateSlot9, out Key_StateSlot9); Enum.TryParse <Key>(Settings.Key_ShutdownEmu, out Key_ShutdownEmu); Enum.TryParse <Key>(Settings.Key_TogglePause, out Key_TogglePause); Enum.TryParse <Key>(Settings.Key_ToggleTurbo, out Key_ToggleTurbo); Enum.TryParse <Key>(Settings.Key_RecordSound, out Key_RecordSound); Enum.TryParse <Key>(Settings.Key_ToggleFrameSkip, out Key_ToggleFrameSkip); Enum.TryParse <Key>(Settings.Key_ShowGameStatus, out Key_ShowGameStatus); }
public JoystickAxis(Joysticks joystick, JoystickAxes axis, float threshold) { this.joystick = joystick; this.axis = axis; this.axisName = InputUtility.JoystickInputToAxis(joystick, axis); this.threshold = threshold; }
public JoystickInfo(string name, Joysticks joystick, JoystickButton[] buttons, JoystickAxis[] axes, IInputListener[] listeners) : base(name, listeners) { _joystick = joystick; _buttons = new List<JoystickButton>(buttons); _axes = new List<JoystickAxis>(axes); }
public JoystickAxis(string name, Joysticks joystick, JoystickAxes axis) { this.name = name; this.joystick = joystick; this.axis = axis; axisName = InputSystem.JoystickInputToAxis(joystick, axis); }
public JoystickAxis(string name, string axisName) { this.name = name; this.axisName = axisName; joystick = InputSystem.AxisToJoystick(axisName); axis = InputSystem.AxisToJoystickAxis(axisName); }
public void InitJoystick() { Joysticks.Close(); //Assert.IsFalse(Joysticks.IsInitialized); Joysticks.Initialize(); //Assert.IsTrue(Joysticks.IsInitialized); Joysticks.Close(); }
public JoystickButton(string name, KeyCode key) { this.name = name; this.key = key; joystick = InputSystem.KeyToJoystick(key); button = InputSystem.KeyToJoystickButton(key); }
public JoystickButton(string name, Joysticks joystick, JoystickButtons button) { this.name = name; this.joystick = joystick; this.button = button; key = InputSystem.JoystickInputToKey(joystick, button); }
/// <summary> /// Checks to see if the inputted joystick has been moved down /// </summary> /// <param name="controller">Joystick to check</param> /// <returns>true or false</returns> public static bool JoystickDown(Joysticks controller) { if (Input.GetAxisRaw(controller.ToString() + "UD") > .15f) { return(true); } else { return(false); } }
/// <summary> /// Checks to see if the inputted joystick has been moved left /// </summary> /// <param name="controller">Joystick to check</param> /// <returns>true or false</returns> public static bool JoystickLeft(Joysticks controller) { if (Input.GetAxisRaw(controller.ToString() + "LR") < -.15f) { return(true); } else { return(false); } }
/// <summary> /// Checks to see if the button has been released on the desired player /// </summary> /// <param name="controller">controller to check</param> /// <param name="button">Button to check</param> /// <returns>true or false</returns> public static bool ButtonReleased(Joysticks controller, Buttons button) { if (Input.GetButtonUp(controller.ToString() + button.ToString())) { return(true); } else { return(false); } }
/// <summary> /// Checks to see if the button has been pressed on the desired player /// </summary> /// <param name="controller">controller to check</param> /// <param name="button">Button to check</param> /// <returns>true or false</returns> public static bool ButtonPress(Joysticks controller, Buttons button) { if (Input.GetButtonDown(controller.ToString() + button.ToString())) { return(true); } else { return(false); } }
/// <summary> /// Checks to see if the inputted joystick has been moved to the south west position /// </summary> /// <param name="controller">Joystick to check</param> /// <returns>true or false</returns> public static bool JoystickSouthWest(Joysticks controller) { if ((Input.GetAxisRaw(controller.ToString() + "UD") > .15f) && (Input.GetAxisRaw(controller.ToString() + "LR") < -.15f)) { return(true); } else { return(false); } }
public void Start() { network = new Network(); network.screenReceived += new ScreenReceived(network_screenReceived); network.keyEventReceived += new KeyEventReceived(network_keyEventReceived); network.joyEventReceived += new JoyEventReceived(network_joyEventReceived); network.clientConnected += new ClientConnected(network_clientConnected); network.clientConnectFailed += new ClientConnectFailed(network_clientConnectFailed); network.clientDisconnected += new ClientDisconnected(network_clientDisconnected); network.incomingClient += new IncomingClient(network_incomingClient); network.partedClient += new PartedClient(network_partedClient); Video.WindowIcon(Resources.c64icon); Video.WindowCaption = "Pipkinsoft C64 Emulator"; renderer = new RendererSDL(); menu = new Menu(renderer, network); menu.menuReturn += new MenuReturn(menu_menuReturn); menu.menuQuit += new MenuQuit(menu_menuQuit); try { C64.Start(renderer, network); } catch (Exception ex) { renderer.DrawError(ex.Message); Events.Quit += new EventHandler <QuitEventArgs>(Quit); Events.Run(); return; } Joysticks.Initialize(); if (Joysticks.NumberOfJoysticks > 0) { joy1 = Joysticks.OpenJoystick(0); } if (Joysticks.NumberOfJoysticks > 1) { joy2 = Joysticks.OpenJoystick(1); } Events.Quit += new EventHandler <QuitEventArgs>(Quit); Events.KeyboardDown += new EventHandler <KeyboardEventArgs>(KeyboardEvent); Events.KeyboardUp += new EventHandler <KeyboardEventArgs>(KeyboardEvent); Events.JoystickAxisMotion += new EventHandler <JoystickAxisEventArgs>(JoystickAxisMotion); Events.JoystickButtonDown += new EventHandler <JoystickButtonEventArgs>(JoystickButtonEvent); Events.JoystickButtonUp += new EventHandler <JoystickButtonEventArgs>(JoystickButtonEvent); Events.Run(); }
private void ScoreOnHit(Joysticks player) { switch (player) { case Joysticks.White: gameManager.Player1Stats.Score += scoreIncrement; break; case Joysticks.Black: gameManager.Player2Stats.Score += scoreIncrement; break; } }
void ChangeActiveShipSelection(Joysticks Player) { switch (Player) { case Joysticks.White: for (int i = 0; i < ShipSelectionOptions.Count; i++) { if (i == SS.Player1Pos) { if (!ShipSelectionOptions[i].activeInHierarchy) { ShipSelectionOptions[i].SetActive(true); } } else { if (ShipSelectionOptions[i].activeInHierarchy) { ShipSelectionOptions[i].SetActive(false); } } } break; case Joysticks.Black: for (int i = 0; i < ShipSelectionOptions.Count; i++) { if (i == SS.Player2Pos) { if (!ShipSelectionOptions[i].activeInHierarchy) { ShipSelectionOptions[i].SetActive(true); } } else { if (ShipSelectionOptions[i].activeInHierarchy) { ShipSelectionOptions[i].SetActive(false); } } } break; } }
/// <summary> /// /// </summary> public void Go() { string filePath = Path.Combine("..", ".."); string fileDirectory = "Data"; string fileName = "cursor.png"; if (File.Exists(fileName)) { filePath = ""; fileDirectory = ""; } else if (File.Exists(Path.Combine(fileDirectory, fileName))) { filePath = ""; } string file = Path.Combine(Path.Combine(filePath, fileDirectory), fileName); Events.Tick += new EventHandler <TickEventArgs>(Tick); Events.KeyboardDown += new EventHandler <KeyboardEventArgs>(this.KeyboardDown); Events.Quit += new EventHandler <QuitEventArgs>(this.Quit); Events.JoystickAxisMotion += new EventHandler <JoystickAxisEventArgs>(this.JoystickAxisChanged); Events.JoystickButtonDown += new EventHandler <JoystickButtonEventArgs>(this.JoystickButtonDown); joystick = Joysticks.OpenJoystick(0); try { Video.WindowIcon(); Video.WindowCaption = "SdlDotNet - Joystick Example"; screen = Video.SetVideoMode(width, height, true); Mouse.ShowCursor = false; // hide the cursor Surface surf = screen.CreateCompatibleSurface(width, height, true); surf.Fill(new Rectangle(new Point(0, 0), surf.Size), System.Drawing.Color.Black); cursor = new Surface(file); Events.Run(); } catch { throw; } }
public void InstantiatePlayerFishInAquarium() { GameObject fish = (GameObject)Instantiate(fishPrefab, fishPrefab.transform.position, fishPrefab.transform.rotation); fish.transform.parent = aquariumBehavior.fishHolder.transform; fish.transform.localPosition = new Vector3(Random.Range(-0.3f, 0.3f), Random.Range(0.08f, 0.3f), Random.Range(-0.18f, 0.15f)); while (Vector3.Distance(fish.transform.localPosition, aquariumBehavior.forbiddenArea.transform.localPosition) < 0.2f) { fish.transform.localPosition = new Vector3(Random.Range(-0.3f, 0.3f), Random.Range(0.08f, 0.3f), Random.Range(-0.18f, 0.15f)); } fish.transform.localScale = new Vector3(2, 2, 2); Joysticks joysticks = GameObject.Find("Joysticks").transform.GetChild(0).GetComponent <Joysticks>(); joysticks.gameObject.SetActive(true); joysticks.fishPlayer = fish; joysticks.enableMovement = true; }
public Input(Game game) { this.game = game; keyStatus = new KeyStatus(); keyStatus.Up = false; keyStatus.Right = false; keyStatus.Down = false; keyStatus.Left = false; keyStatus.Button = false; keyStatus.Center = true; Joysticks.Initialize(); Events.KeyboardDown += new EventHandler <KeyboardEventArgs>(KeyboardEvent); Events.KeyboardUp += new EventHandler <KeyboardEventArgs>(KeyboardEvent); Events.JoystickAxisMotion += new EventHandler <JoystickAxisEventArgs>(JoystickAxisMotion); Events.JoystickButtonDown += new EventHandler <JoystickButtonEventArgs>(JoystickButtonEvent); Events.JoystickButtonUp += new EventHandler <JoystickButtonEventArgs>(JoystickButtonEvent); }
public void CleanUpTank() { if (fishHolder.transform.childCount > 0) { foreach (Transform t in fishHolder.transform) { Joysticks joysticks = FindObjectOfType <Joysticks>(); if (joysticks != null) { if (joysticks.fishPlayer.name == t.gameObject.name) { joysticks.enableMovement = false; joysticks.gameObject.SetActive(false); } } Destroy(t.gameObject); } } }
// When Ball is enabled (from OBJ-POOL) void OnEnable() { // Stops the gravity switcher from flipping gravity on the ball when its first made JustSpawned = true; if (!IsIn) { // runs the ball init function which sets up the starting vector and gravity BallInit(); } else { IsIn = false; } // starts the cooldown corutine which toggles thr JustSpawned bool to false after 1 second StartCoroutine(SpawnCoolDown()); // sets the last hit no none LastHit = Joysticks.None; C = 2 * Mathf.PI * 1.3f; }
public void SetJoystick(Joysticks joystick) { _joystick = joystick; InitializeJoystickInput(); }
void UndoConfirmOption(Joysticks PlayerInput) { switch (PlayerInput) { case Joysticks.White: switch (ControllerType) { case SupportedControllers.ArcadeBoard: if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B7)) { Player1Selected = false; } break; case SupportedControllers.GamePadBoth: if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.B)) { Player1Selected = false; } break; case SupportedControllers.KeyboardBoth: if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7)) { Player1Selected = false; } break; case SupportedControllers.KeyboardP1ControllerP2: if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7)) { Player1Selected = false; } break; case SupportedControllers.KeyboardP2ControllerP1: if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.B)) { Player1Selected = false; } break; default: break; } Player1Confirmed.enabled = false; break; case Joysticks.Black: switch (ControllerType) { case SupportedControllers.ArcadeBoard: if (ArcadeControls.ButtonPress(Joysticks.Black, Buttons.B7)) { Player2Selected = false; } break; case SupportedControllers.GamePadBoth: if (ControllerControls.ButtonPress(Players.P2, ControllerButtons.B)) { Player2Selected = false; } break; case SupportedControllers.KeyboardBoth: if (KeyboardControls.ButtonPress(Players.P2, Buttons.B7)) { Player2Selected = false; } break; case SupportedControllers.KeyboardP1ControllerP2: if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.B)) { Player2Selected = false; } break; case SupportedControllers.KeyboardP2ControllerP1: if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7)) { Player2Selected = false; } break; default: break; } Player2Confirmed.enabled = false; break; } }
public InputAction CreateSimpleAction (Joysticks joystick, JoystickAxis joystickAxis, JoystickPosition joystickPosition) { return new InputAction (InputCode.toCode (joystick, joystickAxis, joystickPosition), InputActionType.SINGLE); }
public JoystickButton(string name, Joysticks joystick, JoystickButtons button) : base(name, InputSystem.JoystickInputToKey(joystick, button)) { _joystick = joystick; _button = button; }
public static KeyCode[] GetJoystickKeys(Joysticks joystick) { return joystickKeysDict[(int)joystick]; }
Players ConvertToPlayers(Joysticks Input) { return((Players)Input); }
public JoystickButton(KeyCode key) { this.key = key; this.joystick = InputUtility.KeyToJoystick(key); this.button = InputUtility.KeyToJoystickButton(key); }
public JoystickAxis(string name, string axisName) : base(name, axisName) { _joystick = InputSystem.AxisToJoystick(axisName); _axisInput = InputSystem.AxisToJoystickAxis(axisName); }
public override void OnOpen() { // Load joystick stuff Joysticks.Initialize(); bool joyKeys = false; if (Joysticks.NumberOfJoysticks > 0) { Items[0].Options.Clear(); Items[0].Options.Add("NO"); Items[0].Options.Add("YES"); Items[0].SelectedOptionIndex = Settings.Key_P4_UseJoystick ? 1 : 0; useJoystick = Settings.Key_P4_UseJoystick; Items[1].Options.Clear(); if (Settings.Key_P4_JoystickIndex < Joysticks.NumberOfJoysticks) { for (int i = 0; i < Joysticks.NumberOfJoysticks; i++) { Items[1].Options.Add(i.ToString()); } Items[1].SelectedOptionIndex = Settings.Key_P4_JoystickIndex; } else { Items[1].SelectedOptionIndex = 0; } joystick = Joysticks.OpenJoystick(Items[1].SelectedOptionIndex); joyKeys = true; } else { useJoystick = false; Items[0].Options.Clear(); Items[0].Options.Add("N/A"); Items[0].SelectedOptionIndex = 0; Items[1].Options.Clear(); Items[1].Options.Add("N/A"); Items[1].SelectedOptionIndex = 0; } if (!(joyKeys && Settings.Key_P4_UseJoystick)) { Items[2].Options.Clear(); Items[2].Options.Add(Settings.Key_P4_ButtonA); Items[3].Options.Clear(); Items[3].Options.Add(Settings.Key_P4_ButtonB); Items[4].Options.Clear(); Items[4].Options.Add(Settings.Key_P4_ButtonTurboA); Items[5].Options.Clear(); Items[5].Options.Add(Settings.Key_P4_ButtonTurboB); Items[6].Options.Clear(); Items[6].Options.Add(Settings.Key_P4_ButtonStart); Items[7].Options.Clear(); Items[7].Options.Add(Settings.Key_P4_ButtonSelect); Items[8].Options.Clear(); Items[8].Options.Add(Settings.Key_P4_ButtonUp); Items[9].Options.Clear(); Items[9].Options.Add(Settings.Key_P4_ButtonDown); Items[10].Options.Clear(); Items[10].Options.Add(Settings.Key_P4_ButtonLeft); Items[11].Options.Clear(); Items[11].Options.Add(Settings.Key_P4_ButtonRight); } else { Items[2].Options.Clear(); Items[2].Options.Add(Settings.JoyKey_P4_ButtonA); Items[3].Options.Clear(); Items[3].Options.Add(Settings.JoyKey_P4_ButtonB); Items[4].Options.Clear(); Items[4].Options.Add(Settings.JoyKey_P4_ButtonTurboA); Items[5].Options.Clear(); Items[5].Options.Add(Settings.JoyKey_P4_ButtonTurboB); Items[6].Options.Clear(); Items[6].Options.Add(Settings.JoyKey_P4_ButtonStart); Items[7].Options.Clear(); Items[7].Options.Add(Settings.JoyKey_P4_ButtonSelect); Items[8].Options.Clear(); Items[8].Options.Add(Settings.JoyKey_P4_ButtonUp); Items[9].Options.Clear(); Items[9].Options.Add(Settings.JoyKey_P4_ButtonDown); Items[10].Options.Clear(); Items[10].Options.Add(Settings.JoyKey_P4_ButtonLeft); Items[11].Options.Clear(); Items[11].Options.Add(Settings.JoyKey_P4_ButtonRight); } }
public JoystickButton(string name, KeyCode key) : base(name, key) { _joystick = InputSystem.KeyToJoystick(key); _button = InputSystem.KeyToJoystickButton(key); }
public static string JoystickInputToAxis(Joysticks joystick, JoystickAxes axis) { return joystick.ToString() + axis; }
public static KeyCode JoystickInputToKey(Joysticks joystick, JoystickButtons button) { return KeyCode.JoystickButton0 + ((int)joystick * 20 + (int)button); }
/// <summary> /// Tos the code. /// </summary> /// <returns>The code.</returns> /// <param name="joy">Joy.</param> /// <param name="axis">Axis.</param> /// <param name="data">Data. JoystickPovPosition </param> public static int toCode (Joysticks joy, JoystickAxis axis, JoystickPovPosition pos) { return toCode (joy, axis, (int)pos); //return toCode (joy, axis,(int)pos ); }
public JoystickInput(string joystickName, Joysticks joystick, string inputName) { this.joystickName = joystickName; this.joystick = joystick; this.inputName = inputName; }
/// <summary> /// Tos the code. /// </summary> /// <returns>The code.</returns> /// <param name="joy">Joy.</param> /// <param name="axis">Axis.</param> /// <param name="data">Data.</param> public static int toCode (Joysticks joy, int axis, int data) { // UnityEngine.Debug.Log("Test"+joy+" "+axis+" "+data); return InputCode.MAX_KEY_CODE + ((((int)joy << CODE_AXIS_SHIFT | axis) << CODE_DATA_SHIFT) | data); }
/// <summary> /// Tos the code. /// </summary> /// <returns>The code.</returns> /// <param name="joy">Joy.</param> /// <param name="axis">Axis.</param> /// <param name="data">Data. JoystickPovPosition </param> public static int toCode (Joysticks joy, int axis, JoystickPovPosition pos) { return toCode (joy, axis, (int)pos); //return toCode (joy, axis,((int)pos/9000-1) ); }
public static KeyCode JoystickInputToKey(Joysticks joystick, JoystickButtons button) { return(KeyCode.JoystickButton0 + ((int)joystick * 20 + (int)button)); }
public InputActionFactory Create (Joysticks joystick, JoystickAxis joystickAxis, JoystickPosition joystickPosition) { __factoryConstructor = (type) => new InputAction (InputCode.toCode (joystick, joystickAxis, joystickPosition), type); return instance; }
public static string JoystickInputToAxis(Joysticks joystick, JoystickAxes axis) { return(joystick.ToString() + axis); }
public static KeyCode[] GetJoystickKeys(Joysticks joystick) { return(joystickKeysDict[(int)joystick]); }
public static KeyCode[] GetJoystickKeys(Joysticks joystick) { return (KeyCode[])JoystickKeysDict[(int)joystick].Clone(); }
void ConfirmOption(Joysticks PlayerInput) { switch (PlayerInput) { case Joysticks.White: switch (ControllerType) { case SupportedControllers.ArcadeBoard: if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B8)) { MenuAM.Play("Menu_Select"); Player1Selected = true; } break; case SupportedControllers.GamePadBoth: if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.A)) { MenuAM.Play("Menu_Select"); Player1Selected = true; } break; case SupportedControllers.KeyboardBoth: if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8)) { MenuAM.Play("Menu_Select"); Player1Selected = true; } break; case SupportedControllers.KeyboardP1ControllerP2: if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8)) { MenuAM.Play("Menu_Select"); Player1Selected = true; } break; case SupportedControllers.KeyboardP2ControllerP1: if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.A)) { MenuAM.Play("Menu_Select"); Player1Selected = true; } break; default: break; } break; case Joysticks.Black: switch (ControllerType) { case SupportedControllers.ArcadeBoard: if (ArcadeControls.ButtonPress(Joysticks.Black, Buttons.B8)) { MenuAM.Play("Menu_Select"); Player2Selected = true; } break; case SupportedControllers.GamePadBoth: if (ControllerControls.ButtonPress(Players.P2, ControllerButtons.A)) { MenuAM.Play("Menu_Select"); Player2Selected = true; } break; case SupportedControllers.KeyboardBoth: if (KeyboardControls.ButtonPress(Players.P2, Buttons.B8)) { MenuAM.Play("Menu_Select"); Player2Selected = true; } break; case SupportedControllers.KeyboardP1ControllerP2: if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.A)) { MenuAM.Play("Menu_Select"); Player2Selected = true; } break; case SupportedControllers.KeyboardP2ControllerP1: if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8)) { MenuAM.Play("Menu_Select"); Player2Selected = true; } break; default: break; } break; } }
public static KeyCode JoystickInputToKey(Joysticks joystick, JoystickButtons button) { return GetJoystickKeys(joystick)[(int)button]; }
void PlayerSelectionMovement(Joysticks PlayerInput) { switch (PlayerInput) { case Joysticks.White: switch (ControllerType) { case SupportedControllers.ArcadeBoard: if ((ArcadeControls.JoystickLeft(PlayerInput)) && (!Player1Inputted)) { MenuAM.Play("Menu_Click", .4f); --Player1Pos; if (Player1Pos < 0) { Player1Pos = Player1MaxPos - 1; } StartCoroutine(InputLagP1(.2f)); } else if ((ArcadeControls.JoystickRight(PlayerInput)) && (!Player1Inputted)) { MenuAM.Play("Menu_Click", .4f); ++Player1Pos; if (Player1Pos > Player1MaxPos - 1) { Player1Pos = 0; } StartCoroutine(InputLagP1(.2f)); } break; case SupportedControllers.GamePadBoth: if ((ControllerControls.ControllerLeft(Players.P1)) && (!Player1Inputted)) { MenuAM.Play("Menu_Click", .4f); --Player1Pos; if (Player1Pos < 0) { Player1Pos = Player1MaxPos - 1; } StartCoroutine(InputLagP1(.2f)); } else if ((ControllerControls.ControllerRight(Players.P1)) && (!Player1Inputted)) { MenuAM.Play("Menu_Click", .4f); ++Player1Pos; if (Player1Pos > Player1MaxPos - 1) { Player1Pos = 0; } StartCoroutine(InputLagP1(.2f)); } break; case SupportedControllers.KeyboardBoth: if ((KeyboardControls.KeyboardLeft(Players.P1)) && (!Player1Inputted)) { MenuAM.Play("Menu_Click", .4f); --Player1Pos; if (Player1Pos < 0) { Player1Pos = Player1MaxPos - 1; } StartCoroutine(InputLagP1(.2f)); } else if ((KeyboardControls.KeyboardRight(Players.P1)) && (!Player1Inputted)) { MenuAM.Play("Menu_Click", .4f); ++Player1Pos; if (Player1Pos > Player1MaxPos - 1) { Player1Pos = 0; } StartCoroutine(InputLagP1(.2f)); } break; case SupportedControllers.KeyboardP1ControllerP2: if ((KeyboardControls.KeyboardLeft(Players.P1)) && (!Player1Inputted)) { MenuAM.Play("Menu_Click", .4f); --Player1Pos; if (Player1Pos < 0) { Player1Pos = Player1MaxPos - 1; } StartCoroutine(InputLagP1(.2f)); } else if ((KeyboardControls.KeyboardRight(Players.P1)) && (!Player1Inputted)) { MenuAM.Play("Menu_Click", .4f); ++Player1Pos; if (Player1Pos > Player1MaxPos - 1) { Player1Pos = 0; } StartCoroutine(InputLagP1(.2f)); } break; case SupportedControllers.KeyboardP2ControllerP1: if ((ControllerControls.ControllerLeft(Players.P1)) && (!Player1Inputted)) { MenuAM.Play("Menu_Click", .4f); --Player1Pos; if (Player1Pos < 0) { Player1Pos = Player1MaxPos - 1; } StartCoroutine(InputLagP1(.2f)); } else if ((ControllerControls.ControllerRight(Players.P1)) && (!Player1Inputted)) { MenuAM.Play("Menu_Click", .4f); ++Player1Pos; if (Player1Pos > Player1MaxPos - 1) { Player1Pos = 0; } StartCoroutine(InputLagP1(.2f)); } break; default: break; } break; case Joysticks.Black: switch (ControllerType) { case SupportedControllers.ArcadeBoard: if ((ArcadeControls.JoystickLeft(PlayerInput)) && (!Player2Inputted)) { MenuAM.Play("Menu_Click", .4f); --Player2Pos; if (Player2Pos < 0) { Player2Pos = Player2MaxPos - 1; } StartCoroutine(InputLagP2(.2f)); } else if ((ArcadeControls.JoystickRight(PlayerInput)) && (!Player2Inputted)) { MenuAM.Play("Menu_Click", .4f); ++Player2Pos; if (Player2Pos > Player2MaxPos - 1) { Player2Pos = 0; } StartCoroutine(InputLagP2(.2f)); } break; case SupportedControllers.GamePadBoth: if ((ControllerControls.ControllerLeft(Players.P2)) && (!Player2Inputted)) { MenuAM.Play("Menu_Click", .4f); --Player2Pos; if (Player2Pos < 0) { Player2Pos = Player2MaxPos - 1; } StartCoroutine(InputLagP2(.2f)); } else if ((ControllerControls.ControllerRight(Players.P2)) && (!Player2Inputted)) { MenuAM.Play("Menu_Click", .4f); ++Player2Pos; if (Player2Pos > Player2MaxPos - 1) { Player2Pos = 0; } StartCoroutine(InputLagP2(.2f)); } break; case SupportedControllers.KeyboardBoth: if ((KeyboardControls.KeyboardLeft(Players.P2)) && (!Player2Inputted)) { MenuAM.Play("Menu_Click", .4f); --Player2Pos; if (Player2Pos < 0) { Player2Pos = Player2MaxPos - 1; } StartCoroutine(InputLagP2(.2f)); } else if ((KeyboardControls.KeyboardRight(Players.P2)) && (!Player2Inputted)) { MenuAM.Play("Menu_Click", .4f); ++Player2Pos; if (Player2Pos > Player2MaxPos - 1) { Player2Pos = 0; } StartCoroutine(InputLagP2(.2f)); } break; case SupportedControllers.KeyboardP1ControllerP2: if ((ControllerControls.ControllerLeft(Players.P1)) && (!Player2Inputted)) { MenuAM.Play("Menu_Click", .4f); --Player2Pos; if (Player2Pos < 0) { Player2Pos = Player2MaxPos - 1; } StartCoroutine(InputLagP2(.2f)); } else if ((ControllerControls.ControllerRight(Players.P1)) && (!Player2Inputted)) { MenuAM.Play("Menu_Click", .4f); ++Player2Pos; if (Player2Pos > Player2MaxPos - 1) { Player2Pos = 0; } StartCoroutine(InputLagP2(.2f)); } break; case SupportedControllers.KeyboardP2ControllerP1: if ((KeyboardControls.KeyboardLeft(Players.P1)) && (!Player2Inputted)) { MenuAM.Play("Menu_Click", .4f); --Player2Pos; if (Player2Pos < 0) { Player2Pos = Player2MaxPos - 1; } StartCoroutine(InputLagP2(.2f)); } else if ((KeyboardControls.KeyboardRight(Players.P1)) && (!Player2Inputted)) { MenuAM.Play("Menu_Click", .4f); ++Player2Pos; if (Player2Pos > Player2MaxPos - 1) { Player2Pos = 0; } StartCoroutine(InputLagP2(.2f)); } break; default: break; } break; } }
protected override void OnMenuOptionChanged() { if (SelectedMenuIndex == 0) { if (Items[0].Options[0] != "N/A") { if (Items[0].SelectedOptionIndex == 0)// NO { useJoystick = false; Items[2].Options.Clear(); Items[2].Options.Add(Settings.Key_HardReset); Items[3].Options.Clear(); Items[3].Options.Add(Settings.Key_SoftReset); Items[4].Options.Clear(); Items[4].Options.Add(Settings.Key_SwitchFullscreen); Items[5].Options.Clear(); Items[5].Options.Add(Settings.Key_TakeSnap); Items[6].Options.Clear(); Items[6].Options.Add(Settings.Key_SaveState); Items[7].Options.Clear(); Items[7].Options.Add(Settings.Key_LoadState); Items[8].Options.Clear(); Items[8].Options.Add(Settings.Key_ShutdownEmu); Items[9].Options.Clear(); Items[9].Options.Add(Settings.Key_TogglePause); Items[10].Options.Clear(); Items[10].Options.Add(Settings.Key_ToggleTurbo); Items[11].Options.Clear(); Items[11].Options.Add(Settings.Key_RecordSound); Items[12].Options.Clear(); Items[12].Options.Add(Settings.Key_ToggleFrameSkip); Items[13].Options.Clear(); Items[13].Options.Add(Settings.Key_StateSlot0); Items[14].Options.Clear(); Items[14].Options.Add(Settings.Key_StateSlot1); Items[15].Options.Clear(); Items[15].Options.Add(Settings.Key_StateSlot2); Items[16].Options.Clear(); Items[16].Options.Add(Settings.Key_StateSlot3); Items[17].Options.Clear(); Items[17].Options.Add(Settings.Key_StateSlot4); Items[18].Options.Clear(); Items[18].Options.Add(Settings.Key_StateSlot5); Items[19].Options.Clear(); Items[19].Options.Add(Settings.Key_StateSlot6); Items[20].Options.Clear(); Items[20].Options.Add(Settings.Key_StateSlot7); Items[21].Options.Clear(); Items[21].Options.Add(Settings.Key_StateSlot8); Items[22].Options.Clear(); Items[22].Options.Add(Settings.Key_StateSlot9); Items[23].Options.Clear(); Items[23].Options.Add(Settings.Key_ShowGameStatus); } else { useJoystick = true; Items[2].Options.Clear(); Items[2].Options.Add(Settings.JoyKey_HardReset); Items[3].Options.Clear(); Items[3].Options.Add(Settings.JoyKey_SoftReset); Items[4].Options.Clear(); Items[4].Options.Add(Settings.JoyKey_SwitchFullscreen); Items[5].Options.Clear(); Items[5].Options.Add(Settings.JoyKey_TakeSnap); Items[6].Options.Clear(); Items[6].Options.Add(Settings.JoyKey_SaveState); Items[7].Options.Clear(); Items[7].Options.Add(Settings.JoyKey_LoadState); Items[8].Options.Clear(); Items[8].Options.Add(Settings.JoyKey_ShutdownEmu); Items[9].Options.Clear(); Items[9].Options.Add(Settings.JoyKey_TogglePause); Items[10].Options.Clear(); Items[10].Options.Add(Settings.JoyKey_ToggleTurbo); Items[11].Options.Clear(); Items[11].Options.Add(Settings.JoyKey_RecordSound); Items[12].Options.Clear(); Items[12].Options.Add(Settings.JoyKey_ToggleFrameSkip); Items[13].Options.Clear(); Items[13].Options.Add(Settings.JoyKey_StateSlot0); Items[14].Options.Clear(); Items[14].Options.Add(Settings.JoyKey_StateSlot1); Items[15].Options.Clear(); Items[15].Options.Add(Settings.JoyKey_StateSlot2); Items[16].Options.Clear(); Items[16].Options.Add(Settings.JoyKey_StateSlot3); Items[17].Options.Clear(); Items[17].Options.Add(Settings.JoyKey_StateSlot4); Items[18].Options.Clear(); Items[18].Options.Add(Settings.JoyKey_StateSlot5); Items[19].Options.Clear(); Items[19].Options.Add(Settings.JoyKey_StateSlot6); Items[20].Options.Clear(); Items[20].Options.Add(Settings.JoyKey_StateSlot7); Items[21].Options.Clear(); Items[21].Options.Add(Settings.JoyKey_StateSlot8); Items[22].Options.Clear(); Items[22].Options.Add(Settings.JoyKey_StateSlot9); Items[23].Options.Clear(); Items[23].Options.Add(Settings.JoyKey_ShowGameStatus); } } } if (SelectedMenuIndex == 1) { if (Items[1].Options[0] != "N/A") { joystick = Joysticks.OpenJoystick(Items[1].SelectedOptionIndex); } } }
public SDL_Joystick_Joypad(int joystickIndex, int playerIndex) { this.playerIndex = playerIndex; LoadSettings(); state = Joysticks.OpenJoystick(joystickIndex); }
public JoystickButton(Joysticks joystick, JoystickButtons button) { this.joystick = joystick; this.button = button; this.key = InputUtility.JoystickInputToKey(joystick, button); }
protected override void OnMenuOptionChanged() { if (SelectedMenuIndex == 0) { if (Items[0].Options[0] != "N/A") { if (Items[0].SelectedOptionIndex == 0)// NO { useJoystick = false; Items[2].Options.Clear(); Items[2].Options.Add(Settings.Key_P4_ButtonA); Items[3].Options.Clear(); Items[3].Options.Add(Settings.Key_P4_ButtonB); Items[4].Options.Clear(); Items[4].Options.Add(Settings.Key_P4_ButtonTurboA); Items[5].Options.Clear(); Items[5].Options.Add(Settings.Key_P4_ButtonTurboB); Items[6].Options.Clear(); Items[6].Options.Add(Settings.Key_P4_ButtonStart); Items[7].Options.Clear(); Items[7].Options.Add(Settings.Key_P4_ButtonSelect); Items[8].Options.Clear(); Items[8].Options.Add(Settings.Key_P4_ButtonUp); Items[9].Options.Clear(); Items[9].Options.Add(Settings.Key_P4_ButtonDown); Items[10].Options.Clear(); Items[10].Options.Add(Settings.Key_P4_ButtonLeft); Items[11].Options.Clear(); Items[11].Options.Add(Settings.Key_P4_ButtonRight); } else { useJoystick = true; Items[2].Options.Clear(); Items[2].Options.Add(Settings.JoyKey_P4_ButtonA); Items[3].Options.Clear(); Items[3].Options.Add(Settings.JoyKey_P4_ButtonB); Items[4].Options.Clear(); Items[4].Options.Add(Settings.JoyKey_P4_ButtonTurboA); Items[5].Options.Clear(); Items[5].Options.Add(Settings.JoyKey_P4_ButtonTurboB); Items[6].Options.Clear(); Items[6].Options.Add(Settings.JoyKey_P4_ButtonStart); Items[7].Options.Clear(); Items[7].Options.Add(Settings.JoyKey_P4_ButtonSelect); Items[8].Options.Clear(); Items[8].Options.Add(Settings.JoyKey_P4_ButtonUp); Items[9].Options.Clear(); Items[9].Options.Add(Settings.JoyKey_P4_ButtonDown); Items[10].Options.Clear(); Items[10].Options.Add(Settings.JoyKey_P4_ButtonLeft); Items[11].Options.Clear(); Items[11].Options.Add(Settings.JoyKey_P4_ButtonRight); } } } if (SelectedMenuIndex == 1) { if (Items[1].Options[0] != "N/A") { joystick = Joysticks.OpenJoystick(Items[1].SelectedOptionIndex); } } }
public JoystickAxis(string name, Joysticks joystick, JoystickAxes axis) : base(name, InputSystem.JoystickInputToAxis(joystick, axis)) { _joystick = joystick; _axisInput = axis; }