Beispiel #1
0
 public void SetNoControl()
 {
     m_joystickAxis   = MyJoystickAxesEnum.None;
     m_joystickButton = MyJoystickButtonsEnum.None;
     m_mouseButton    = MyMouseButtonsEnum.None;
     m_keyboardKey    = Keys.None;
     m_keyboardKey2   = Keys.None;
 }
Beispiel #2
0
 public MyControl(MyEditorControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType, MyMouseButtonsEnum?defaultControlMouse,
                  Keys?defaultControlKey, MyJoystickButtonsEnum?defaultControlJoy, MyJoystickAxesEnum?defaultControlJoyAxis)
     : this(control, text, controlType)
 {
     m_mouseButton    = defaultControlMouse.HasValue ? defaultControlMouse.Value : MyMouseButtonsEnum.None;
     m_keyboardKey    = defaultControlKey.HasValue ? defaultControlKey.Value : Keys.None;
     m_joystickButton = defaultControlJoy.HasValue ? defaultControlJoy.Value : MyJoystickButtonsEnum.None;
     m_joystickAxis   = defaultControlJoyAxis.HasValue ? defaultControlJoyAxis.Value : MyJoystickAxesEnum.None;
 }
Beispiel #3
0
 public MyControl(MyEditorControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType)
 {
     m_editorControl   = control;
     m_gameControlType = MyGuiGameControlType.EDITOR;
     m_text            = text;
     m_controlType     = controlType;
     m_joystickButton  = MyJoystickButtonsEnum.None;
     m_joystickAxis    = MyJoystickAxesEnum.None;
     m_mouseButton     = MyMouseButtonsEnum.None;
     m_keyboardKey     = Keys.None;
 }
Beispiel #4
0
        public static void NullControl(MyStringId context, MyJoystickButtonsEnum button)
        {
            MyStringId key = MyStringId.NullOrEmpty;

            foreach (var pair in m_bindings[context].Bindings)
            {
                if (pair.Value is JoystickButton && pair.Value.Code == (byte)button)
                {
                    key = pair.Key;
                    break;
                }
            }
            if (key != MyStringId.NullOrEmpty)
            {
                m_bindings[context][key] = m_nullControl;
            }
        }
        string IMyControlNameLookup.GetName(MyJoystickButtonsEnum joystickButton)
        {
            if (joystickButton == MyJoystickButtonsEnum.None)
            {
                return("");
            }

            switch (joystickButton)
            {
            case MyJoystickButtonsEnum.JDLeft:  return(MyTexts.GetString(MyCommonTexts.JoystickButtonLeft));

            case MyJoystickButtonsEnum.JDRight: return(MyTexts.GetString(MyCommonTexts.JoystickButtonRight));

            case MyJoystickButtonsEnum.JDUp:    return(MyTexts.GetString(MyCommonTexts.JoystickButtonUp));

            case MyJoystickButtonsEnum.JDDown:  return(MyTexts.GetString(MyCommonTexts.JoystickButtonDown));

            default:
                return("JB" + ((int)joystickButton - 4));
            }
        }
Beispiel #6
0
 bool IMyInput.IsJoystickButtonNewPressed(MyJoystickButtonsEnum button) { return false; }
 public string GetName(MyJoystickButtonsEnum joystickButton)
 {
     return m_nameLookup.GetName(joystickButton);
 }
Beispiel #8
0
 bool IMyInput.IsJoystickButtonValid(MyJoystickButtonsEnum button) { return false; }
Beispiel #9
0
 public void SetControl(MyJoystickButtonsEnum joyButton)
 {
     m_joystickButton = joyButton;
 }
 //  Check to see if a specific button on the joystick was released.
 public bool WasJoystickButtonReleased(MyJoystickButtonsEnum button)
 {
     bool wasReleased = false;
     //if (m_joystickConnected && button != MyJoystickButtonsEnum.None && m_previousJoystickState != null)
     if (IsJoystickConnected() && button != MyJoystickButtonsEnum.None)
     {
         GamepadButtonFlags flags = JoystickHelper.VRageToXInput(button);
         switch (button)
         {
             case MyJoystickButtonsEnum.J11:
                 wasReleased = !IsGamepadLTriggerPressed(m_previousJoystickState.Gamepad);
                 break;
             case MyJoystickButtonsEnum.J12:
                 wasReleased = !IsGamepadRTriggerPressed(m_previousJoystickState.Gamepad);
                 break;
             //default: wasReleased = (m_previousJoystickState.IsReleased((int)button - 5)); break;
             default: wasReleased = (m_previousJoystickState.Gamepad.Buttons & flags) == 0x0; break;
         }
     }
     if (!wasReleased && button == MyJoystickButtonsEnum.None)
     {
         return true;
     }
     return wasReleased;
 }
 //  Check to see if a specific button on the joystick is pressed.
 bool ModAPI.IMyInput.IsJoystickButtonPressed(MyJoystickButtonsEnum button) { return ((IMyInput)this).IsJoystickButtonPressed(button); }
 public JoystickButton(MyJoystickButtonsEnum button) { Button = button; }
Beispiel #13
0
 public void SetNoControl()
 {
     m_joystickAxis = MyJoystickAxesEnum.None;
     m_joystickButton = MyJoystickButtonsEnum.None;
     m_mouseButton = MyMouseButtonsEnum.None;
     m_keyboardKey = Keys.None;
     m_keyboardKey2 = Keys.None;
 }
 public static void NullControl(MyStringId context, MyJoystickButtonsEnum button)
 {
     MyStringId key = MyStringId.NullOrEmpty;
     foreach (var pair in m_bindings[context].Bindings)
     {
         if (pair.Value is JoystickButton && pair.Value.Code == (byte)button)
         {
             key = pair.Key;
             break;
         }
     }
     if (key != MyStringId.NullOrEmpty)
         m_bindings[context][key] = m_nullControl;
 }
Beispiel #15
0
 public MyControl(MyEditorControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType)
 {
     m_editorControl = control;
     m_gameControlType = MyGuiGameControlType.EDITOR;
     m_text = text;
     m_controlType = controlType;
     m_joystickButton = MyJoystickButtonsEnum.None;
     m_joystickAxis = MyJoystickAxesEnum.None;
     m_mouseButton = MyMouseButtonsEnum.None;
     m_keyboardKey = Keys.None;
 }
Beispiel #16
0
 public void SetControl(MyJoystickButtonsEnum joyButton)
 {
     m_joystickButton = joyButton;
 }
Beispiel #17
0
 public MyControl(MyEditorControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType, MyMouseButtonsEnum? defaultControlMouse,
     Keys? defaultControlKey, MyJoystickButtonsEnum? defaultControlJoy, MyJoystickAxesEnum? defaultControlJoyAxis)
     : this(control, text, controlType)
 {
     m_mouseButton = defaultControlMouse.HasValue ? defaultControlMouse.Value : MyMouseButtonsEnum.None;
     m_keyboardKey = defaultControlKey.HasValue ? defaultControlKey.Value : Keys.None;
     m_joystickButton = defaultControlJoy.HasValue ? defaultControlJoy.Value : MyJoystickButtonsEnum.None;
     m_joystickAxis = defaultControlJoyAxis.HasValue ? defaultControlJoyAxis.Value : MyJoystickAxesEnum.None;
 }
Beispiel #18
0
 public MyControl(MyEditorControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType, MyJoystickButtonsEnum defaultControl)
     : this(control, text, controlType, null, null, defaultControl, null)
 {
 }
Beispiel #19
0
        string IMyControlNameLookup.GetName(MyJoystickButtonsEnum joystickButton)
        {
            if (joystickButton == MyJoystickButtonsEnum.None)
                return "";

            switch (joystickButton)
            {
                case MyJoystickButtonsEnum.JDLeft:  return MyTexts.GetString(MyCommonTexts.JoystickButtonLeft);
                case MyJoystickButtonsEnum.JDRight: return MyTexts.GetString(MyCommonTexts.JoystickButtonRight);
                case MyJoystickButtonsEnum.JDUp:    return MyTexts.GetString(MyCommonTexts.JoystickButtonUp);
                case MyJoystickButtonsEnum.JDDown:  return MyTexts.GetString(MyCommonTexts.JoystickButtonDown);

                default:
                    return "JB" + ((int)joystickButton - 4);
            }
        }
 //  Check to see if a specific button on the joystick is currently pressed and was not pressed during the last update. 
 bool ModAPI.IMyInput.IsJoystickButtonNewPressed(MyJoystickButtonsEnum button) { return IsJoystickButtonNewPressed(button); }
 //  Check to see if a specific button on the joystick was released.
 public bool WasJoystickButtonReleased(MyJoystickButtonsEnum button)
 {
     bool wasReleased = false;
     if (m_joystickConnected && button != MyJoystickButtonsEnum.None && m_previousJoystickState != null)
     {
         switch (button)
         {
             case MyJoystickButtonsEnum.JDLeft: wasReleased = !WasGamepadKeyLeftPressed(); break;
             case MyJoystickButtonsEnum.JDRight: wasReleased = !WasGamepadKeyRightPressed(); break;
             case MyJoystickButtonsEnum.JDUp: wasReleased = !WasGamepadKeyUpPressed(); break;
             case MyJoystickButtonsEnum.JDDown: wasReleased = !WasGamepadKeyDownPressed(); break;
             default: wasReleased = (m_previousJoystickState.IsReleased((int)button - 5)); break;
         }
     }
     if (!wasReleased && button == MyJoystickButtonsEnum.None)
     {
         return true;
     }
     return wasReleased;
 }
 //  Return true if joystick button is valid for user controls
 bool ModAPI.IMyInput.IsJoystickButtonValid(MyJoystickButtonsEnum button) { return IsJoystickButtonValid(button); }
Beispiel #23
0
 //  Return true if joystick button is valid for user controls
 bool ModAPI.IMyInput.IsJoystickButtonValid(MyJoystickButtonsEnum button)
 {
     return(((IMyInput)this).IsJoystickButtonValid(button));
 }
 //  Check to see if a specific button on the joystick is currently pressed and was not pressed during the last update.
 bool ModAPI.IMyInput.IsJoystickButtonNewPressed(MyJoystickButtonsEnum button)
 {
     return(IsJoystickButtonNewPressed(button));
 }
 //  Check to see if a specific button on the joystick is pressed.
 public bool IsJoystickButtonPressed(MyJoystickButtonsEnum button)
 {
     bool isPressed = false;
     if (IsJoystickConnected() && button != MyJoystickButtonsEnum.None)
     {
         switch (button)
         {
             case MyJoystickButtonsEnum.J11:
                 isPressed = IsGamepadLTriggerPressed(m_actualJoystickState.Gamepad);
                 break;
             case MyJoystickButtonsEnum.J12:
                 isPressed = IsGamepadRTriggerPressed(m_actualJoystickState.Gamepad);
                 break;
             default: isPressed = (m_actualJoystickState.Gamepad.Buttons & JoystickHelper.VRageToXInput(button)) != 0x0; break;
         }
     }
     if (!isPressed && button == MyJoystickButtonsEnum.None)
     {
         return true;
     }
     return isPressed;
 }
 public static void AddControl(MyStringId context, MyStringId stringId, MyJoystickButtonsEnum button)
 {
     m_bindings[context][stringId] = new JoystickButton(button);
 }
Beispiel #27
0
 public MyControl(MyEditorControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType, MyJoystickButtonsEnum defaultControl)
     : this(control, text, controlType, null, null, defaultControl, null)
 {
 }
 public bool IsJoystickButtonReleased(MyJoystickButtonsEnum button)
 {
     bool isReleased = false;
     if (m_joystickConnected && button != MyJoystickButtonsEnum.None && m_actualJoystickState != null)
     {
         switch (button)
         {
             case MyJoystickButtonsEnum.JDLeft: isReleased = !IsGamepadKeyLeftPressed(); break;
             case MyJoystickButtonsEnum.JDRight: isReleased = !IsGamepadKeyRightPressed(); break;
             case MyJoystickButtonsEnum.JDUp: isReleased = !IsGamepadKeyUpPressed(); break;
             case MyJoystickButtonsEnum.JDDown: isReleased = !IsGamepadKeyDownPressed(); break;
             default: isReleased = m_actualJoystickState.IsReleased((int)button - 5); break;
         }
     }
     if (!isReleased && button == MyJoystickButtonsEnum.None)
     {
         return true;
     }
     return isReleased;
 }
Beispiel #29
0
 public static void AppendName(ref StringBuilder output, MyJoystickButtonsEnum joystickButton)
 {
     EnsureExists(ref output);
     output.Append(MyInput.Static.GetName(joystickButton));
 }
Beispiel #30
0
 bool ModAPI.IMyInput.IsNewJoystickButtonReleased(MyJoystickButtonsEnum button)
 {
     return(((IMyInput)this).IsNewJoystickButtonReleased(button));
 }
Beispiel #31
0
 public static void AppendName(ref StringBuilder output, MyJoystickButtonsEnum joystickButton)
 {
     EnsureExists(ref output);
     output.Append(MyInput.Static.GetName(joystickButton));
 }
Beispiel #32
0
 string ModAPI.IMyInput.GetName(MyJoystickButtonsEnum joystickButton)
 {
     return(((IMyInput)this).GetName(joystickButton));
 }
Beispiel #33
0
 static public uint VRageToXInput(MyJoystickButtonsEnum button)
 {
     return (uint)(kArrVRageToXInput[(byte)button]);
 }
 public bool IsNewJoystickButtonReleased(MyJoystickButtonsEnum button)
 {
     bool isReleased = false;
     //if (m_joystickConnected && button != MyJoystickButtonsEnum.None && m_actualJoystickState != null && m_previousJoystickState != null)
     if (IsJoystickConnected() && button != MyJoystickButtonsEnum.None) // && m_actualJoystickState != null && m_previousJoystickState != null)
     {
         GamepadButtonFlags flags = JoystickHelper.VRageToXInput(button);
         switch (button)
         {
             case MyJoystickButtonsEnum.J11:
                 isReleased = (!IsGamepadLTriggerPressed(m_actualJoystickState.Gamepad)) &&
                     IsGamepadLTriggerPressed(m_previousJoystickState.Gamepad);
                 break;
             case MyJoystickButtonsEnum.J12:
                 isReleased = (!IsGamepadRTriggerPressed(m_actualJoystickState.Gamepad)) &&
                     IsGamepadRTriggerPressed(m_previousJoystickState.Gamepad);
                 break;
             //default: isReleased = ((m_actualJoystickState.IsReleased((int)button - 5)) && (m_previousJoystickState.IsPressed((int)button - 5))); break;
             default: isReleased = ((m_actualJoystickState.Gamepad.Buttons & flags) == 0x0) &&
                 ((m_previousJoystickState.Gamepad.Buttons & flags) != 0x0); break;
         }
     }
     if (!isReleased && button == MyJoystickButtonsEnum.None)
     {
         return true;
     }
     return isReleased;
 }
Beispiel #35
0
 bool IMyInput.IsJoystickButtonNewPressed(MyJoystickButtonsEnum button)
 {
     return(false);
 }
 //  Return true if joystick button is valid for user controls
 public bool IsJoystickButtonValid(MyJoystickButtonsEnum button)
 {
     foreach (var item in m_validJoystickButtons)
     {
         if (item == button) return true;
     }
     return false;
 }
Beispiel #37
0
 bool IMyInput.IsNewJoystickButtonReleased(MyJoystickButtonsEnum button)
 {
     return(false);
 }
 static public GamepadButtonFlags VRageToXInput(MyJoystickButtonsEnum button)
 {
     return kArrVRageToXInput[(byte)button];
 }
Beispiel #39
0
 bool IMyInput.IsJoystickButtonValid(MyJoystickButtonsEnum button)
 {
     return(false);
 }
Beispiel #40
0
 string IMyInput.GetName(MyJoystickButtonsEnum joystickButton) { return ""; }
Beispiel #41
0
 string IMyInput.GetName(MyJoystickButtonsEnum joystickButton)
 {
     return("");
 }
Beispiel #42
0
 bool IMyInput.IsNewJoystickButtonReleased(MyJoystickButtonsEnum button) { return false; }
Beispiel #43
0
 public JoystickButton(MyJoystickButtonsEnum button)
 {
     Button = button;
 }
 bool ModAPI.IMyInput.IsNewJoystickButtonReleased(MyJoystickButtonsEnum button) { return IsNewJoystickButtonReleased(button); }
Beispiel #45
0
 public static void AddControl(MyStringId context, MyStringId stringId, MyJoystickButtonsEnum button)
 {
     m_bindings[context][stringId] = new JoystickButton(button);
 }
 string ModAPI.IMyInput.GetName(MyJoystickButtonsEnum joystickButton) { return GetName(joystickButton); }
Beispiel #47
0
 //  Return true if joystick button is used by some user control
 public MyControl GetControl(MyJoystickButtonsEnum button, MyGuiGameControlType gameControlType)
 {
     MyControl[] controlsList = GetControlsListByGameControlType(gameControlType);
     foreach (var item in m_gameControlsList)
     {
         if (item.GetJoystickControl() == button) return item;
     }
     return null;
 }