Ejemplo n.º 1
0
        public static void KeyDown(KeyEventArgs e)
        {
            if (RedirectKeys && !e.KeyCode.Equals(keycodes[KeyInputs.escape]) && !e.KeyCode.Equals(keycodes[KeyInputs.console]))
            {
                if (DirectKeyCode != null)
                {
                    DirectKeyCode.Invoke(e.KeyCode);
                }
                return;
            }
            KeyInputs k = keycodes.FirstOrDefault(x => x.Value == e.KeyCode).Key; //Reverse lookup for the key based on the value given by the keycode event

            if (keysHeld.ContainsKey(k))                                          //If it's a key that should be held with others
            {
                if (!keysHeld[k])
                {
                    keysHeld[k] = true;
                    anyKeysHeld = true;
                }
            }
            else                        //If it's a one press key
            {
                if (ignoreKeys.Contains(k))
                {
                    return;
                }
                ManualKeys(new KeyInputs[] { k });
                if (InputCall != null)
                {
                    InputCall.Invoke(new KeyInputs[] { k });
                }
                ignoreKeys.Add(k);
            }
        }
Ejemplo n.º 2
0
        public static void KeyUp(KeyEventArgs e)
        {
            if (RedirectKeys && !e.KeyCode.Equals(Keys.Escape) && !e.KeyCode.Equals(Keys.Oemtilde))
            {
                return;
            }

            KeyInputs k = keycodes.FirstOrDefault(x => x.Value == e.KeyCode).Key;              //Reverse lookup for the key based on the value given by the keycode event

            if (keysHeld.ContainsKey(k))
            {
                if (keysHeld[k])
                {
                    keysHeld[k] = false;
                    bool newKeys = false;
                    foreach (KeyInputs h in keysHeld.Keys)
                    {
                        newKeys = newKeys | keysHeld[h];
                    }
                    anyKeysHeld = newKeys;
                }
            }
            else
            {
                if (ignoreKeys.Contains(k))
                {
                    ignoreKeys.Remove(k);
                }
            }
        }
Ejemplo n.º 3
0
 private void WaitForKeyDown(KeyInputs key, Button button)
 {
     setKey         = true;
     Cursor.visible = false;
     selectedKey    = key;
     button.GetComponentInChildren <Text>().text = "> <";
 }
Ejemplo n.º 4
0
    public int AddKey(List <KeyCode> newKeyCode, Action newOnKeyAction, KeyInput.KeyStateEnum newInputMode = KeyInput.KeyStateEnum.KEY_HOLD, KeyInput.CheckingModeEnum newCheckingMode = KeyInput.CheckingModeEnum.CONJUNCTION, KeyInput.OccurrenceModeEnum newOccurrenceMode = KeyInput.OccurrenceModeEnum.KEY_HAS_OCCUR)
    {
        KeyInput newKeyInput = new KeyInput(newKeyCode, newInputMode, newCheckingMode, newOnKeyAction, newOccurrenceMode);

        newKeyInput.SetId(FreeId++);
        KeyInputs.Add(newKeyInput);

        return(newKeyInput.Id);
    }
Ejemplo n.º 5
0
 public void RemoveKey(int idToRemove)
 {
     for (int i = KeyInputs.Count - 1; i >= 0; i--)
     {
         if (KeyInputs[i].Id == idToRemove)
         {
             KeyInputs.RemoveAt(i);
             return;
         }
     }
 }