예제 #1
0
파일: Input.cs 프로젝트: diqost/bullet
        void form_KeyDown(object sender, KeyEventArgs e)
        {
            Keys key = e.KeyData & ~Keys.Shift;

            if (KeysDown.Contains(key) == false)
            {
                KeysPressed.Add(key);
                KeysDown.Add(key);
            }
        }
예제 #2
0
        public void KeyDown(object sender, KeyEventArgs e)
        {
            KeysPressed.Add(e.Code);
            if (Settings.Keybindings.ContainsKey(e.Code))
            {
                Settings.Keybindings[e.Code](this);
            }

            Scene.ProcessKey(e);
        }
 private static void AddOrSet(Keys key, bool value)
 {
     if (KeysPressed.ContainsKey(key))
     {
         KeysPressed[key] = value;
     }
     else
     {
         KeysPressed.Add(key, value);
     }
 }
예제 #4
0
파일: Input.cs 프로젝트: diqost/bullet
 public void Device_KeyboardInput(object sender, KeyboardInputEventArgs e)
 {
     if (e.State == KeyState.Pressed)
     {
         if (KeysDown.Contains(e.Key) == false)
         {
             KeysPressed.Add(e.Key);
             KeysDown.Add(e.Key);
         }
     }
     else if (e.State == KeyState.Released)
     {
         KeysReleased.Add(e.Key);
         KeysDown.Remove(e.Key);
     }
 }
예제 #5
0
        public void Action(string action)
        {
            var actionData = action.Split(' ');

            switch (actionData[0])
            {
            case "key_down":
            {
                Enum.TryParse <ControlActions>(actionData[1], true, out var result);
                KeysPressed.Add(result);
                break;
            }

            case "key_up":
            {
                Enum.TryParse <ControlActions>(actionData[1], true, out var result);
                KeysPressed.Remove(result);
                break;
            }
            }
        }