public bool GetButton(int joystick, ref JoystickButton button, params JoystickButton[] excludeButtons) { for (int i = 0; i < numJoysticks; ++i) { if (IsConnected(i)) { JoystickState state = Joystick.GetState(i); foreach (JoystickButton enumVal in Enum.GetValues(typeof(JoystickButton))) { if (state.GetButton(enumVal) == ButtonState.Pressed) { bool cont = false; foreach (JoystickButton exclude in excludeButtons) { if (exclude == enumVal) { cont = true; break; } } if (cont) { continue; } button = enumVal; return(true); } } } } return(false); }
public void Poll() { for (int i = 0; i < 4; i++) { JoystickCapabilities caps = Joystick.GetCapabilities(i); if (caps.IsConnected && joysticks[i].Description == DisconnectedName) { // New joystick connected joysticks[i] = new LegacyJoystickDevice(i, caps.AxisCount, caps.ButtonCount); //device.Description = Joystick.GetName(i); joysticks[i].Description = ConnectedName; } else if (!caps.IsConnected && joysticks[i].Description != DisconnectedName) { // Joystick disconnected joysticks[i] = new LegacyJoystickDevice(i, 0, 0); joysticks[i].Description = DisconnectedName; } JoystickState state = Joystick.GetState(i); for (int axis_index = 0; axis_index < (int)caps.AxisCount; axis_index++) { JoystickAxis axis = JoystickAxis.Axis0 + axis_index; joysticks[i].SetAxis(axis, state.GetAxis(axis)); } for (int button_index = 0; button_index < (int)caps.ButtonCount; button_index++) { JoystickButton button = JoystickButton.Button0 + button_index; joysticks[i].SetButton(button, state.GetButton(button) == ButtonState.Pressed); } } }
private void JoystickButtonPressed(JoystickButton Button, bool Pressed) { if (Button == JoystickButton.Move) { if (Pressed) { MouseDownP.Invoke(null, new MouseEventArgs(MouseButtons.Right, 0, 0, 0, 0)); } else { MouseUpP.Invoke(null, new MouseEventArgs(MouseButtons.Right, 0, 0, 0, 0)); } } if (Button == JoystickButton.Shoot) { if (Pressed) { MouseDownP.Invoke(null, new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0)); } else { MouseUpP.Invoke(null, new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0)); } } }
public void UpdateSensorValues(string[] rawValues) { if (rawValues == null || rawValues.Length == 0) { throw new Exception("Incomming data is incomplete"); } Slider.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.SliderOrder])); LightSensor.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.LightSensorOrder])); Temperature.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.TemperatureOrder])); Microphone.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.MicrophoneOrder])); JoystickSwitch.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.JoystickSwitchOrder])); JoystickButton.UpdateValue(rawValues[SensorValuesOrderTable.JoystickButtonOrder] != "1"); AccelerometerX.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.AccelerometerXOrder])); AccelerometerY.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.AccelerometerYOrder])); AccelerometerZ.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.AccelerometerZOrder])); ButtonDown.UpdateValue(rawValues[SensorValuesOrderTable.ButtonDownOrder] != "1"); ButtonLeft.UpdateValue(rawValues[SensorValuesOrderTable.ButtonLeftOrder] != "1"); ButtonUp.UpdateValue(rawValues[SensorValuesOrderTable.ButtonUpOrder] != "1"); ButtonRight.UpdateValue(rawValues[SensorValuesOrderTable.ButtonRightOrder] != "1"); JoystickX.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.JoystickXOrder])); JoystickY.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.JoystickYOrder])); LedRed.UpdateValue(Convert.ToByte(rawValues[SensorValuesOrderTable.LedRedOrder])); LedGreen.UpdateValue(Convert.ToByte(rawValues[SensorValuesOrderTable.LedGreenOrder])); LedBlue.UpdateValue(Convert.ToByte(rawValues[SensorValuesOrderTable.LedBlueOrder])); }
/// <returns>The value of the key</returns> private static bool EnsureKeyIsPresent(uint joystickNumber, JoystickButton button) { // Joysticks start counting at 1, while index starts at 0 int joystickIndex = (int)joystickNumber - 1; // Check if exists in list if (buttonDataPerJoystick.Count < joystickNumber) { buttonDataPerJoystick.ResizeList(joystickIndex + 1); buttonDataPerJoystick[joystickIndex] = new Dictionary <JoystickButton, bool> { { button, false } }; return(false); } // Dictionary might be null if (buttonDataPerJoystick[joystickIndex] != null) { return(buttonDataPerJoystick[joystickIndex][button]); } // Add it with default value if it is null buttonDataPerJoystick[joystickIndex] = new Dictionary <JoystickButton, bool> { { button, false } }; return(false); }
static Input() { //Fill dict with Key States Input.keys = new Dictionary <KeyCode, ButtonState>(); foreach (var item in Enum.GetValues(typeof(KeyCode))) { KeyCode key = (KeyCode)item; Input.keys.Add(key, new ButtonState()); } //Fill dict with Mouse States Input.mouseButtons = new Dictionary <MouseButton, ButtonState>(); foreach (var item in Enum.GetValues(typeof(MouseButton))) { MouseButton button = (MouseButton)item; Input.mouseButtons.Add(button, new ButtonState()); } //Fill dict with Joystick States Input.joystickButtons = new Dictionary <JoystickButton, List <ButtonState> >(); foreach (var item in Enum.GetValues(typeof(JoystickButton))) { JoystickButton button = (JoystickButton)item; Input.joystickButtons.Add(button, new List <ButtonState>()); for (int i = 0; i < Input.joysticks; i++) { Input.joystickButtons[button].Add(new ButtonState()); } } }
private int getKeyButtonIndex(string key) { // if (key == null) { // return -1; // } for (int i = 0; i < gameObject.transform.childCount; i++) { Transform t = gameObject.transform.GetChild(i); JoystickButton script = t.GetComponent <JoystickButton> (); //script.keyHandler +=OnCustomerKeySelected; JoystickRadio radio = t.GetComponent <JoystickRadio>(); if (script != null || radio != null) { if (script != null && script.keySrc == key) { return(i); } if (radio != null && t.name == key) { return(i); } //return -1; } else { return(-1); } } return(-1); }
private Transform getChildByKey(string key) { //if (this.gameObject == null) { if (this._isNew == true) { return(null); } for (int i = 0; i < gameObject.transform.childCount; i++) { Transform t = gameObject.transform.GetChild(i); JoystickButton script = t.GetComponent <JoystickButton> (); if (script != null && script.keySrc == key) { return(t); } JoystickRadio radio = t.GetComponent <JoystickRadio> (); if (radio != null && radio.keySrc == key) { return(t); } } return(null); }
/// <summary> /// Gets if button is pressed. Null if not the same as requested. /// </summary> /// <param name="button"></param> /// <param name="state"></param> /// <returns></returns> public static bool?GetButtonPressDirectInput(JoystickButton button, JoystickUpdate state) { if (button == null) { return(null); } if ((JoystickOffset)button.Button != state.Offset) { return(null); } // POV if (button.Button >= 32 && button.Button <= 44) { if (state.Value == button.PovDirection) { return(true); } return(false); } // Normal button if (button.Button >= 48 && button.Button <= 175) { return(state.Value != 0); } return(null); }
public JoystickAxisButtonHandler(int trackedAxis) { this.trackedAxis = (JoystickAxisSource)trackedAxis; positiveAxisButton = JoystickButton.FirstAxisPositive + trackedAxis; negativeAxisButton = JoystickButton.FirstAxisNegative + trackedAxis; Size = new Vector2(100, 50); InternalChildren = new[] { background = new Container { RelativeSizeAxes = Axes.Both, Colour = Color4.Transparent, Child = new Box { RelativeSizeAxes = Axes.Both } }, new SpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, Text = $"AX{trackedAxis + 1}" }, rawValue = new SpriteText { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, Text = "-" } }; }
public bool commit() { for (int i = 0; i < gameObject.transform.childCount; i++) { Transform child = gameObject.transform.GetChild(i); JoystickButton btn = child.GetComponent <JoystickButton> (); if (btn != null) { if (isContain(availableKeys, btn.keySrc)) { PlayerPrefs.SetString(btn.keySrc, btn.keyDefine); } } JoystickRadio radio = child.GetComponent <JoystickRadio> (); if (radio != null) { if (isContain(availableKeys, radio.keySrc)) { PlayerPrefs.SetString(radio.keySrc, radio.isSelect.ToString()); } } } return(true); //PlayerPrefs pref = new PlayerPrefs (); }
public JoystickAxisButtonHandler(int axisIndex) { this.axisIndex = axisIndex; positiveAxisButton = JoystickButton.FirstAxisPositive + axisIndex; negativeAxisButton = JoystickButton.FirstAxisNegative + axisIndex; Size = new Vector2(50); InternalChildren = new[] { background = new Container { RelativeSizeAxes = Axes.Both, Colour = Color4.Transparent, Child = new Box { RelativeSizeAxes = Axes.Both } }, new SpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, Text = $"AX{axisIndex + 1}" }, rawValue = new SpriteText { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, Text = "-" } }; }
private static SteamVR_Action_Boolean.ChangeHandler CreateButtonHandler(JoystickButton button) { return((SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource, bool newState) => { _buttons[button] = newState ? 1 : 0; }); }
public static InputKey FromJoystickButton(JoystickButton button) { if (button >= JoystickButton.FirstHatRight) { return(InputKey.FirstJoystickHatRightButton + (button - JoystickButton.FirstHatRight)); } if (button >= JoystickButton.FirstHatLeft) { return(InputKey.FirstJoystickHatLeftButton + (button - JoystickButton.FirstHatLeft)); } if (button >= JoystickButton.FirstHatDown) { return(InputKey.FirstJoystickHatDownButton + (button - JoystickButton.FirstHatDown)); } if (button >= JoystickButton.FirstHatUp) { return(InputKey.FirstJoystickHatUpButton + (button - JoystickButton.FirstHatUp)); } if (button >= JoystickButton.FirstAxisPositive) { return(InputKey.FirstJoystickAxisPositiveButton + (button - JoystickButton.FirstAxisPositive)); } if (button >= JoystickButton.FirstAxisNegative) { return(InputKey.FirstJoystickAxisNegativeButton + (button - JoystickButton.FirstAxisNegative)); } return(InputKey.FirstJoystickButton + (button - JoystickButton.FirstButton)); }
public JoystickButtonHandler(int buttonIndex) { button = JoystickButton.FirstButton + buttonIndex; Size = new Vector2(50); InternalChildren = new[] { background = new Container { RelativeSizeAxes = Axes.Both, Colour = Color4.DarkGreen, Alpha = 0, Child = new Box { RelativeSizeAxes = Axes.Both } }, new SpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, Text = $"B{buttonIndex + 1}" } }; }
public static bool IsJoystickButtonPressed(JoystickButton button) { switch (button) { case JoystickButton.A: #if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX return Input.GetKeyDown("joystick button 16"); #else return Input.GetKeyDown("joystick button 0"); #endif case JoystickButton.B: #if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX return Input.GetKeyDown("joystick button 17"); #else return Input.GetKeyDown("joystick button 1"); #endif case JoystickButton.X: #if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX return Input.GetKeyDown("joystick button 18"); #else return Input.GetKeyDown("joystick button 2"); #endif case JoystickButton.Y: #if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX return Input.GetKeyDown("joystick button 19"); #else return Input.GetKeyDown("joystick button 3"); #endif } return false; }
static string GetButtonValue(JoystickButton realButton) { int button = (int)realButton; //return "Joystick1Button " + button.ToString();///////////////25/08 return("Joystick1Button" + button.ToString()); }
private void GenerateCommands(TypeInfo commandType) { foreach (var attr in commandType.GetCustomAttributes <RunCommandAtPhaseStartAttribute>()) { if (!m_phaseCommands.ContainsKey(attr.Phase)) { m_phaseCommands.Add(attr.Phase, new List <Command>()); } m_phaseCommands[attr.Phase].Add(CreateCommand(commandType)); } foreach (var attr in commandType.GetCustomAttributes <RunCommandOnJoystickAttribute>()) { var button = m_buttons.OfType <JoystickButton>().Where(btn => btn.Joystick is Joystick) .FirstOrDefault(btn => (btn.Joystick as Joystick).Port == attr.ControllerId && btn.ButtonNumber == attr.ButtonId); if (button == null) { m_buttons.Add(button = new JoystickButton(new Joystick(attr.ControllerId), attr.ButtonId)); } AttachCommandToButton(commandType, button, attr.ButtonMethod); } foreach (var attr in commandType.GetCustomAttributes <RunCommandOnNetworkKeyAttribute>()) { var button = m_buttons.OfType <NetworkButton>().FirstOrDefault(btn => btn.SourceTable == NetworkTable.GetTable(attr.TableName) && btn.Field == attr.Key); if (button == null) { m_buttons.Add(button = new NetworkButton(attr.TableName, attr.Key)); } AttachCommandToButton(commandType, button, attr.ButtonMethod); } }
private Button ParseButtonID(string id) { if (id == null) { return(null); } try { Button b = null; if (id.StartsWith("key")) { b = new Key(id); } if (id.StartsWith("hat")) { b = new HatButton(id); } if (id.StartsWith("joy")) { b = new JoystickButton(id); } if (b != null) { return(b); } return(null); } catch (Exception e) { Debug.Log("[ACM]: Error while loading a button:"); Debug.LogException(e); return(null); } }
/// <summary> /// Initializes a new instance of the <see cref="Input"/> struct. /// </summary> /// <param name="actionName">The name of the action.</param> /// <param name="joystickButton">The joystick button.</param> public Input(string actionName, JoystickButton joystickButton) { ActionName = actionName; key = null; joystickAxis = null; this.joystickButton = joystickButton; joystickHat = null; }
static JoystickButton ParseButton(string item) { // item is in the format "b#" where # a zero-based integer nubmer JoystickButton button = JoystickButton.Button0; int id = Int32.Parse(item.Substring(1)); return(button + id); }
private bool handleJoystickPress(InputState state, JoystickButton button) { IEnumerable <Drawable> queue = inputQueue; if (!unfocusIfNoLongerValid()) { queue = new[] { FocusedDrawable } }
// Use this for initialization void Start() { joystick = FindObjectOfType <Joystick>(); joybutton = FindObjectOfType <JoystickButton>(); cursor = GameObject.FindWithTag("Cursor").transform; player = GameObject.FindWithTag("Player").transform; rigidbody = GetComponent <Rigidbody>(); }
public int GetButtonNumber(JoystickButton g_button) { if (myButtonDictionary == null || !myButtonDictionary.ContainsKey(g_button)) { return(-1); } return(myButtonDictionary [g_button]); }
public static string JoystickButtonName( JoystickNumber joystickNumber, JoystickButton joystickButton, string joystickName = UnityJoystickName, string joystickButtonName = UnityJoystickButtonName) { return(JoystickName(joystickNumber, joystickName) + " " + JoystickButtonName(joystickButton, joystickButtonName)); }
internal static string GetString(JoystickButton buttonName) { if (!StringPerButton.TryGetValue(buttonName, out string button)) { throw new InvalidEnumArgumentException($"There is no string assigned for {buttonName}!\n Assign one through JoystickButtonToStringConverter"); } return(button); }
public bool this[JoystickButton button] { get { if (this.ButtonCount > (int)button) return this.state.IsButtonDown(GetOpenTKJoystickButton(button)); else return false; } }
public bool this[JoystickButton button] { get { if (this.device.Button.Count > (int)button) return this.device.Button[button]; else return false; } }
public InputScanResult(InputScanSetting st, InputResultType rt) { ResultType = rt; setting = st; KeyCode = KeyCode.None; JoystickButton = JoystickButton.None; JoystickIndex = -1; Axis = -1; }
public bool GetButton(ButtonMethodName g_input, int g_joystickNumber, JoystickButton g_button) { //check if it use simulator if (useSimulator) { if (mySimulatorDictionary.ContainsKey(g_joystickNumber) && mySimulatorDictionary [g_joystickNumber].GetButton(g_input, g_button)) { return(true); } } //get the input function ButtonMethod t_InputFunction; if (g_input == ButtonMethodName.Up) { t_InputFunction = Input.GetKeyUp; } else if (g_input == ButtonMethodName.Hold) { t_InputFunction = Input.GetKey; } else { t_InputFunction = Input.GetKeyDown; } //0 -> all; 1-8 -> joystick1-8 g_joystickNumber = Mathf.Clamp(g_joystickNumber, 0, NUMBER_MAX_JOYSTICK); if (g_joystickNumber != 0) { JellyJoystickInputLayout t_layout = GetInputLayout(g_joystickNumber); int t_buttonNumber = t_layout.GetButtonNumber(g_button); if (t_buttonNumber == -1) { return(false); } return(t_InputFunction(GetKeyCode(t_buttonNumber, g_joystickNumber))); } else { for (int i = 1; i <= NUMBER_MAX_JOYSTICK; i++) { if (GetButton(g_input, i, g_button)) { return(true); } } } return(false); }
public virtual void HandleJoystickButtonStateChange(InputState state, JoystickButton button, ButtonStateChangeKind kind) { if (kind == ButtonStateChangeKind.Pressed) { handleJoystickPress(state, button); } else { handleJoystickRelease(state, button); } }
/// <summary> /// Create a new instance of <see cref="JoystickInput"/> that handles specified joystick axis for a target joystick. /// </summary> /// <param name="axis">Joystick axis.</param> /// <param name="target">Target joystick.</param> public JoystickInput(JoystickAxis axis, Joystick target=Joystick.AllJoysticks) { if (axis==JoystickAxis.None) { Debug.LogError("axis can't be JoystickAxis.None"); } mAxis = axis; mButton = JoystickButton.None; mTarget = target; }
/// <summary> /// Create a new instance of <see cref="JoystickInput"/> that handles specified joystick button for a target joystick. /// </summary> /// <param name="button">Joystick button.</param> /// <param name="target">Target joystick.</param> public JoystickInput(JoystickButton button, Joystick target=Joystick.AllJoysticks) { if (button==JoystickButton.None) { Debug.LogError("button can't be JoystickButton.None"); } mAxis = JoystickAxis.None; mButton = button; mTarget = target; }
private static SteamVR_Action_Boolean.ChangeHandler CreateButtonHandler(JoystickButton button, Func <bool> predicate = null) { return((SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource, bool newState) => { if (predicate != null && !predicate()) { return; } _buttons[button] = newState ? 1 : 0; }); }
public bool this[JoystickButton button] { get { return this.button_state[(int) button]; } internal set { this.button_state[(int) button] = value; } }
public bool this[JoystickButton button] { get { return(this.button_state[(int)button]); } internal set { this.button_state[(int)button] = value; } }
/// <summary> /// Create a new instance of <see cref="JoystickInput"/> that handles specified joystick button for a target joystick. /// </summary> /// <param name="button">Joystick button.</param> /// <param name="target">Target joystick.</param> /// <param name="modifiers">Key modifiers.</param> public JoystickInput(JoystickButton button, Joystick target = Joystick.AllJoysticks, KeyModifier modifiers = KeyModifier.NoModifier) { if (button == JoystickButton.None) { Debug.LogError("button can't be JoystickButton.None"); } mAxis = JoystickAxis.None; mButton = button; mTarget = target; mModifiers = modifiers; mCachedToString = null; mCachedInputName = null; }
public JoystickButtonMenu(int numOfButtons,Rect[] rectangles,string[] labels, string inputActionButton,JoyAxis axis) { if(axis == JoyAxis.Horizontal){ joystickInputName = "Horizontal"; }else if(axis == JoyAxis.Vertical){ joystickInputName = "Vertical"; } numberOfButtons = numOfButtons; actionButton = inputActionButton; buttons = new JoystickButton[numOfButtons]; for (int i = 0; i<numOfButtons; i++){ buttons[i] = new JoystickButton(rectangles[i],labels[i]); } buttons[0].Focus(); currentFocus = 0; }
public bool IsUp(JoystickButton Button) { return State.IsButtonUp(Button); }
private string GetButtonText(JoystickButton button) { var buttonValue = _currentState.GetButton(button); return string.Format("{0}={1}", button, buttonValue); }
public bool this[JoystickButton button] { get { return this.device.Button[button]; } }
internal void SetButton(JoystickButton button, bool value) { if (this.button_collection[button] == value) return; this.button_args.Button = button; this.button_collection[button] = this.button_args.Pressed = value; if (value) this.ButtonDown((object) this, this.button_args); else this.ButtonUp((object) this, this.button_args); }
public JoystickButtonEventArgs(JoystickInput inputChannel, JoystickButton button, bool pressed) : base(inputChannel) { this.button = button; this.pressed = pressed; }
private void GenerateCommands(TypeInfo commandType) { foreach (var attr in commandType.GetCustomAttributes<RunCommandAtPhaseStartAttribute>()) { if (!m_phaseCommands.ContainsKey(attr.Phase)) m_phaseCommands.Add(attr.Phase, new List<Command>()); m_phaseCommands[attr.Phase].Add(CreateCommand(commandType)); } foreach (var attr in commandType.GetCustomAttributes<RunCommandOnJoystickAttribute>()) { var button = m_buttons.OfType<JoystickButton>().Where(btn => btn.Joystick is Joystick) .FirstOrDefault(btn => (btn.Joystick as Joystick).Port == attr.ControllerId && btn.ButtonNumber == attr.ButtonId); if (button == null) { m_buttons.Add(button = new JoystickButton(new Joystick(attr.ControllerId), attr.ButtonId)); } AttachCommandToButton(commandType, button, attr.ButtonMethod); } foreach (var attr in commandType.GetCustomAttributes<RunCommandOnNetworkKeyAttribute>()) { var button = m_buttons.OfType<NetworkButton>().FirstOrDefault(btn => btn.SourceTable == NetworkTable.GetTable(attr.TableName) && btn.Field == attr.Key); if(button == null) { m_buttons.Add(button = new NetworkButton(attr.TableName, attr.Key)); } AttachCommandToButton(commandType, button, attr.ButtonMethod); } }
/// <summary> /// Returns whether the specified button is currently pressed. /// </summary> /// <param name="button"></param> /// <returns></returns> public bool ButtonPressed(JoystickButton button) { return this.currentState.ButtonPressed[(int)button]; }
/// <summary> /// [GET] Returns whether the specified device button is currently pressed. /// </summary> /// <param name="button"></param> /// <returns></returns> public bool this[JoystickButton button] { get { return this.currentState.ButtonPressed[(int)button]; } }
/// <summary> /// Called when a joystick button is pressed or released. /// </summary> /// <param name="button">The joystick button.</param> public virtual void OnJoystickButton(JoystickButton button) { }
private static OpenTK.Input.JoystickButton GetOpenTKJoystickButton(JoystickButton button) { switch (button) { case JoystickButton.Button0: return OpenTK.Input.JoystickButton.Button0; case JoystickButton.Button1: return OpenTK.Input.JoystickButton.Button1; case JoystickButton.Button2: return OpenTK.Input.JoystickButton.Button2; case JoystickButton.Button3: return OpenTK.Input.JoystickButton.Button3; case JoystickButton.Button4: return OpenTK.Input.JoystickButton.Button4; case JoystickButton.Button5: return OpenTK.Input.JoystickButton.Button5; case JoystickButton.Button6: return OpenTK.Input.JoystickButton.Button6; case JoystickButton.Button7: return OpenTK.Input.JoystickButton.Button7; case JoystickButton.Button8: return OpenTK.Input.JoystickButton.Button8; case JoystickButton.Button9: return OpenTK.Input.JoystickButton.Button9; case JoystickButton.Button10: return OpenTK.Input.JoystickButton.Button10; case JoystickButton.Button11: return OpenTK.Input.JoystickButton.Button11; case JoystickButton.Button12: return OpenTK.Input.JoystickButton.Button12; case JoystickButton.Button13: return OpenTK.Input.JoystickButton.Button13; case JoystickButton.Button14: return OpenTK.Input.JoystickButton.Button14; case JoystickButton.Button15: return OpenTK.Input.JoystickButton.Button15; case JoystickButton.Button16: return OpenTK.Input.JoystickButton.Button16; case JoystickButton.Button17: return OpenTK.Input.JoystickButton.Button17; case JoystickButton.Button18: return OpenTK.Input.JoystickButton.Button18; case JoystickButton.Button19: return OpenTK.Input.JoystickButton.Button19; case JoystickButton.Button20: return OpenTK.Input.JoystickButton.Button20; case JoystickButton.Button21: return OpenTK.Input.JoystickButton.Button21; case JoystickButton.Button22: return OpenTK.Input.JoystickButton.Button22; case JoystickButton.Button23: return OpenTK.Input.JoystickButton.Button23; case JoystickButton.Button24: return OpenTK.Input.JoystickButton.Button24; case JoystickButton.Button25: return OpenTK.Input.JoystickButton.Button25; case JoystickButton.Button26: return OpenTK.Input.JoystickButton.Button26; case JoystickButton.Button27: return OpenTK.Input.JoystickButton.Button27; case JoystickButton.Button28: return OpenTK.Input.JoystickButton.Button28; case JoystickButton.Button29: return OpenTK.Input.JoystickButton.Button29; case JoystickButton.Button30: return OpenTK.Input.JoystickButton.Button30; case JoystickButton.Button31: return OpenTK.Input.JoystickButton.Button31; } return OpenTK.Input.JoystickButton.Last; }
public static void AddControl(MyStringId context, MyStringId stringId, MyJoystickButtonsEnum button) { m_bindings[context][stringId] = new JoystickButton(button); }
public bool IsReleased(JoystickButton Button) { return State.IsButtonUp(Button) && PreviousState.IsButtonDown(Button); }
public bool IsDown(JoystickButton Button) { return State.IsButtonDown(Button); }
/// <summary> /// Returns whether the specified button was released this frame. /// </summary> /// <param name="button"></param> /// <returns></returns> public bool ButtonReleased(JoystickButton button) { return !this.currentState.ButtonPressed[(int)button] && this.lastState.ButtonPressed[(int)button]; }
public bool GetButton(int joystick, ref JoystickButton button, params JoystickButton[] excludeButtons) { for (int i = 0; i < numJoysticks; ++i) { if (IsConnected(i)) { JoystickState state = Joystick.GetState(i); foreach (JoystickButton enumVal in Enum.GetValues(typeof(JoystickButton))) { if (state.GetButton(enumVal) == ButtonState.Pressed) { bool cont = false; foreach (JoystickButton exclude in excludeButtons) { if (exclude == enumVal) { cont = true; break; } } if (cont) { continue; } button = enumVal; return true; } } } } return false; }
public bool this[JoystickButton button] { get { return this.realInput[button]; } }
public JoystickEventArgs(JoystickButton buttons, double x1, double y1, double x2, double y2) { mvarButtons = buttons; }
public GamePadConfigurationSource(JoystickButton button) : this() { Type = ConfigurationType.Button; Button = button; }
internal void SetButton(JoystickButton button, bool @value) { if (button_collection[button] != @value) { button_args.Button = button; button_collection[button] = button_args.Pressed = @value; if (@value) ButtonDown(this, button_args); else ButtonUp(this, button_args); } }
/// <summary> /// Initializes a new instance of the <see cref="JoystickButtonEventArgs"/> class. /// </summary> /// <param name="button">The index of the joystick button for the event.</param> /// <param name="pressed">The current state of the button.</param> public JoystickButtonEventArgs(JoystickButton button, bool pressed) { this.button = button; this.pressed = pressed; }