/// <summary>If XNA is being used, we need to do quite a bit of logic to make sure that the correct characters are output.</summary> private static void KeyDownHandler(Keys key) { switch (key) { case Keys.LeftShift: case Keys.RightShift: KeyboardResolver.Shift = true; KeyboardResolver.Alt = true; break; case Keys.CapsLock: KeyboardResolver.Caps = true; KeyboardResolver.Alt = true; break; } KeyboardResolver.CharReceived?.Invoke(KeyboardResolver.ResolveChar(key)); }
private static char ResolveChar(Keys key) { char @char = (char)key; if (!KeyboardResolver.Alt) { return(@char); } short pre = KeyboardResolver.VkKeyScan(@char); uint post = (uint)pre & 0xFF; byte[] arr = new byte[256]; if (KeyboardResolver.Shift) { arr[0x10] = 0x80; } if (KeyboardResolver.Caps) { arr[0x14] = 0x80; } KeyboardResolver.ToAscii(post, post, arr, out uint @out, 0); return((char)@out); }
private static void KeyHeldHandler(Keys key) { KeyboardResolver.CharReceived?.Invoke(KeyboardResolver.ResolveChar(key)); }