コード例 #1
0
 private Key FromXxKey(XxKey key)
 {
     if (mapping.TryGetValue(key, out var value))
     {
         return(value);
     }
     return(Key.Unknown);
 }
コード例 #2
0
        public OpenTkKeyboard()
        {
            foreach (var name in Enum.GetNames(typeof(XxKey)))
            {
                XxKey key = Enum.Parse <XxKey>(name);

                if (Enum.TryParse <Key>(name, out var value))
                {
                    mapping.Add(key, value);
                }
            }
        }
コード例 #3
0
        public bool IsKeyJustPressed(XxKey key)
        {
            var tkKey = FromXxKey(key);

            return(currentState.IsKeyDown(tkKey) && !previousState.IsKeyDown(tkKey));
        }
コード例 #4
0
        public bool IsKeyJustReleased(XxKey key)
        {
            var tkKey = FromXxKey(key);

            return(!currentState.IsKeyDown(tkKey) && previousState.IsKeyDown(tkKey));
        }
コード例 #5
0
 public bool IsKeyDown(XxKey key) => currentState.IsKeyDown(FromXxKey(key));