コード例 #1
0
 override protected void KeyPressing()
 {
     if (KeyboardUtility.WasClicked(Keys.Escape) == true || XboxControllerUtility.WasClicked(PlayerIndex.One, Buttons.B))
     {
         MenuSelected(this, EventArgs.Empty);
     }
 }
コード例 #2
0
        private void CharacterHotkeyWindow_KeyDown(object sender, KeyEventArgs e)
        {
            KeyList.Clear();
            ModifierKeyList.Clear();
            var    downKeys = KeyboardUtility.GetDownKeys().ToList();
            string s        = string.Empty;

            if (downKeys.Count() > 1)
            {
                var firstKey = GetModifierKey(downKeys[0]);
                if (firstKey != ModifierKeys.None)
                {
                    s += firstKey;
                    ModifierKeyList.Add(firstKey);
                }
                else
                {
                    s += downKeys[0];
                    KeyList.Add(downKeys[0]);
                }

                // Convert to ModifierKeys and Keys
                for (int i = 1; i < downKeys.Count; i++)
                {
                    var key = downKeys[i];

                    var modifierKeys = GetModifierKey(key);
                    if (modifierKeys != ModifierKeys.None)
                    {
                        s += " + " + modifierKeys;
                        ModifierKeyList.Add(modifierKeys);
                    }
                    else
                    {
                        s += " + " + key;
                        KeyList.Add(key);
                    }
                }
            }
            else
            {
                foreach (var downKey in downKeys)
                {
                    var modifierKeys = GetModifierKey(downKey);
                    if (modifierKeys != ModifierKeys.None)
                    {
                        s += modifierKeys;
                        ModifierKeyList.Add(modifierKeys);
                    }
                    else
                    {
                        s += downKey;
                        KeyList.Add(downKey);
                    }
                }
            }
            TestingLabel.Content = s;
        }
コード例 #3
0
        private void IOTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            Key  key   = e.Key;
            char input = KeyboardUtility.GetCharFromKey(key);

            if (input == ' ' && !(e.Key == Key.Space || e.SystemKey == Key.Space))
            {
                return;
            }

            m_appModel.VirtualMachine.ProcessInput(input);
        }
コード例 #4
0
ファイル: iPhoneInputSim.cs プロジェクト: pdwright/VRGameJam
    // ----------------------------------------------------------------------------------------------------
    // Returns a vector representing the difference between last touch's position and current position
    // ----------------------------------------------------------------------------------------------------
    private static Vector2 GetDeltaPosition(int _touchIndex, Vector2 _newTouchPosition)
    {
        if (_touchIndex == 0)
        {
            return(MouseUtility.GetDeltaPosition(_newTouchPosition));
        }
        else if (_touchIndex == 1)
        {
            return(KeyboardUtility.GetDeltaPosition(_newTouchPosition));
        }

        return(new Vector2(0.0f, 0.0f));
    }
コード例 #5
0
ファイル: MainMenu.cs プロジェクト: Andy0903/AIPacmanLab1.3
 override protected void KeyPressing()
 {
     if (KeyboardUtility.WasClicked(Keys.Enter) || XboxControllerUtility.WasClicked(PlayerIndex.One, Buttons.A))
     {
         StartSelected(this, EventArgs.Empty);
     }
     else if (KeyboardUtility.WasClicked(Keys.Space) || XboxControllerUtility.WasClicked(PlayerIndex.One, Buttons.Y))
     {
         HighscoreSelected(this, EventArgs.Empty);
     }
     else if (KeyboardUtility.WasClicked(Keys.O)) //EJ stöd av XboxControll.
     {
         OptionsSelected(this, EventArgs.Empty);
     }
     else if (KeyboardUtility.WasClicked(Keys.Escape) || XboxControllerUtility.WasClicked(PlayerIndex.One, Buttons.B))
     {
         ExitSelected(this, EventArgs.Empty);
     }
 }
コード例 #6
0
ファイル: iPhoneInputSim.cs プロジェクト: pdwright/VRGameJam
    // ----------------------------------------------------------------------------------------------------
    // Returns an array of iPhoneTouchSim representing all touches that are currently active
    // ----------------------------------------------------------------------------------------------------
    private static void UpdateTouches()
    {
        // Put the touches in an array to have same code behavior as on iPhone
        m_TouchCount = 0;
        if (Input.GetMouseButton(0) || Input.GetMouseButtonUp(0))
        {
            m_Touches[m_TouchCount]   = new iPhoneTouchSim(GetDeltaPosition(m_TouchCount, Input.mousePosition), Input.mousePosition, iPhoneTouchSim.FingerId.Mouse, MouseUtility.GetMousePhase());
            MouseUtility.LastPosition = m_Touches[m_TouchCount].position;
            m_TouchCount++;
        }

        // Also move the jump button to the suggested position so it does not interact with other control setups
        if (KeyboardUtility.KeyboardTouched())
        {
            m_Touches[m_TouchCount]      = new iPhoneTouchSim(GetDeltaPosition(m_TouchCount, KeyboardUtility.Position), KeyboardUtility.Position, iPhoneTouchSim.FingerId.Arrows, KeyboardUtility.GetKeyboardPhase());
            KeyboardUtility.LastPosition = m_Touches[m_TouchCount].position;
            m_TouchCount++;
        }

        // On the iPhone, taps are ordered
        if (Input.GetMouseButtonDown(0))
        {
            m_LastPcFingerId = iPhoneTouchSim.FingerId.Mouse;
        }
        else if (KeyboardUtility.KeyboardJustPressed())
        {
            m_LastPcFingerId = iPhoneTouchSim.FingerId.Arrows;
        }

        // Swap mouse & keyboard if mouse is last
        if (m_TouchCount == 2 && m_LastPcFingerId == iPhoneTouchSim.FingerId.Mouse)
        {
            iPhoneTouchSim touch = m_Touches[0];
            m_Touches[0] = m_Touches[1];
            m_Touches[1] = touch;
        }
    }
コード例 #7
0
ファイル: iPhoneInputSim.cs プロジェクト: pdwright/VRGameJam
    // ----------------------------------------------------------------------------------------------------
    // Must be called at the beginning of each frame so the touches are updated
    // ----------------------------------------------------------------------------------------------------
    public static void Tick()
    {
        KeyboardUtility.UpdateKeyboardTouchPosition();

        UpdateTouches();
    }
コード例 #8
0
 private void UpdateUtilities()
 {
     KeyboardUtility.Update();
     XboxControllerUtility.Update();
 }