コード例 #1
0
        // if XNA is being used, we need to do quite a bit of logic to make sure that the correct characters are output
        private static void KeyDownHandler(Keys key)
        {
            switch (key)
            {
            case Keys.LeftShift:
            case Keys.RightShift:
                KeyboardInputResolver.Shift = true;
                KeyboardInputResolver.Alt   = true;
                break;

            case Keys.CapsLock:
                KeyboardInputResolver.Caps = true;
                KeyboardInputResolver.Alt  = true;
                break;
            }

            KeyboardInputResolver.CharReceived?.Invoke(KeyboardInputResolver.ResolveChar(key));
        }
コード例 #2
0
        private static char ResolveChar(Keys key)
        {
            char @char = (char)key;

            if (!KeyboardInputResolver.Alt)
            {
                return(@char);
            }
            short pre  = KeyboardInputResolver.VkKeyScan(@char);
            uint  post = (uint)pre & 0xFF;

            byte[] arr = new byte[256];
            if (KeyboardInputResolver.Shift)
            {
                arr[0x10] = 0x80;
            }
            if (KeyboardInputResolver.Caps)
            {
                arr[0x14] = 0x80;
            }
            KeyboardInputResolver.ToAscii(post, post, arr, out uint @out, 0);
            return((char)@out);
        }
コード例 #3
0
 private static void KeyHeldHandler(Keys key)
 {
     KeyboardInputResolver.CharReceived?.Invoke(KeyboardInputResolver.ResolveChar(key));
 }