Created
July 19, 2019 20:24
-
-
Save nesrak1/4794ec04d1b9be87b5a159dbb7989962 to your computer and use it in GitHub Desktop.
Xenko Keys to char
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections.Generic; | |
| using Xenko.Input; | |
| namespace GREENHOUSEF | |
| { | |
| class GreenOSInput | |
| { | |
| private static Dictionary<Keys, char> keyToChar = new Dictionary<Keys, char>() | |
| { | |
| {Keys.OemTilde , '`'}, | |
| {Keys.D1 , '1'}, | |
| {Keys.D2 , '2'}, | |
| {Keys.D3 , '3'}, | |
| {Keys.D4 , '4'}, | |
| {Keys.D5 , '5'}, | |
| {Keys.D6 , '6'}, | |
| {Keys.D7 , '7'}, | |
| {Keys.D8 , '8'}, | |
| {Keys.D9 , '9'}, | |
| {Keys.D0 , '0'}, | |
| {Keys.NumPad1 , '1'}, | |
| {Keys.NumPad2 , '2'}, | |
| {Keys.NumPad3 , '3'}, | |
| {Keys.NumPad4 , '4'}, | |
| {Keys.NumPad5 , '5'}, | |
| {Keys.NumPad6 , '6'}, | |
| {Keys.NumPad7 , '7'}, | |
| {Keys.NumPad8 , '8'}, | |
| {Keys.NumPad9 , '9'}, | |
| {Keys.NumPad0 , '0'}, | |
| {Keys.Divide , '/'}, | |
| {Keys.Multiply , '*'}, | |
| {Keys.Subtract , '-'}, | |
| {Keys.Add , '+'}, | |
| {Keys.A , 'A'}, | |
| {Keys.B , 'B'}, | |
| {Keys.C , 'C'}, | |
| {Keys.D , 'D'}, | |
| {Keys.E , 'E'}, | |
| {Keys.F , 'F'}, | |
| {Keys.G , 'G'}, | |
| {Keys.H , 'H'}, | |
| {Keys.I , 'I'}, | |
| {Keys.J , 'J'}, | |
| {Keys.K , 'K'}, | |
| {Keys.L , 'L'}, | |
| {Keys.M , 'M'}, | |
| {Keys.N , 'N'}, | |
| {Keys.O , 'O'}, | |
| {Keys.P , 'P'}, | |
| {Keys.Q , 'Q'}, | |
| {Keys.R , 'R'}, | |
| {Keys.S , 'S'}, | |
| {Keys.T , 'T'}, | |
| {Keys.U , 'U'}, | |
| {Keys.V , 'V'}, | |
| {Keys.W , 'W'}, | |
| {Keys.X , 'X'}, | |
| {Keys.Y , 'Y'}, | |
| {Keys.Z , 'Z'}, | |
| //{Keys.A , 'a'}, | |
| //{Keys.B , 'b'}, | |
| //{Keys.C , 'c'}, | |
| //{Keys.D , 'd'}, | |
| //{Keys.E , 'e'}, | |
| //{Keys.F , 'f'}, | |
| //{Keys.G , 'g'}, | |
| //{Keys.H , 'h'}, | |
| //{Keys.I , 'i'}, | |
| //{Keys.J , 'j'}, | |
| //{Keys.K , 'k'}, | |
| //{Keys.L , 'l'}, | |
| //{Keys.M , 'm'}, | |
| //{Keys.N , 'n'}, | |
| //{Keys.O , 'o'}, | |
| //{Keys.P , 'p'}, | |
| //{Keys.Q , 'q'}, | |
| //{Keys.R , 'r'}, | |
| //{Keys.S , 's'}, | |
| //{Keys.T , 't'}, | |
| //{Keys.U , 'u'}, | |
| //{Keys.V , 'v'}, | |
| //{Keys.W , 'w'}, | |
| //{Keys.X , 'x'}, | |
| //{Keys.Y , 'y'}, | |
| //{Keys.Z , 'z'}, | |
| {Keys.Tab , '\t'}, | |
| {Keys.OemMinus , '-'}, | |
| {Keys.OemPlus , '='}, | |
| {Keys.OemOpenBrackets , '['}, | |
| {Keys.OemCloseBrackets, ']'}, | |
| {Keys.OemPipe , '\\'}, | |
| {Keys.OemSemicolon , ';'}, | |
| {Keys.OemQuotes , '\''}, | |
| {Keys.OemComma , ','}, | |
| {Keys.OemPeriod , '.'}, | |
| {Keys.OemQuestion , '/'}, | |
| {Keys.Space , ' '}, | |
| {Keys.Decimal , '.'}, | |
| {Keys.Return , '\n'}, | |
| {Keys.Back , '\b'} | |
| }; | |
| private static Dictionary<Keys, char> keyToCharShift = new Dictionary<Keys, char>() | |
| { | |
| {Keys.OemTilde , '~'}, | |
| {Keys.D1 , '!'}, | |
| {Keys.D2 , '@'}, | |
| {Keys.D3 , '#'}, | |
| {Keys.D4 , '$'}, | |
| {Keys.D5 , '%'}, | |
| {Keys.D6 , '^'}, | |
| {Keys.D7 , '&'}, | |
| {Keys.D8 , '*'}, | |
| {Keys.D9 , '('}, | |
| {Keys.D0 , ')'}, | |
| {Keys.Divide , '/'}, | |
| {Keys.Multiply , '*'}, | |
| {Keys.Subtract , '-'}, | |
| {Keys.Add , '+'}, | |
| {Keys.A , 'A'}, | |
| {Keys.B , 'B'}, | |
| {Keys.C , 'C'}, | |
| {Keys.D , 'D'}, | |
| {Keys.E , 'E'}, | |
| {Keys.F , 'F'}, | |
| {Keys.G , 'G'}, | |
| {Keys.H , 'H'}, | |
| {Keys.I , 'I'}, | |
| {Keys.J , 'J'}, | |
| {Keys.K , 'K'}, | |
| {Keys.L , 'L'}, | |
| {Keys.M , 'M'}, | |
| {Keys.N , 'N'}, | |
| {Keys.O , 'O'}, | |
| {Keys.P , 'P'}, | |
| {Keys.Q , 'Q'}, | |
| {Keys.R , 'R'}, | |
| {Keys.S , 'S'}, | |
| {Keys.T , 'T'}, | |
| {Keys.U , 'U'}, | |
| {Keys.V , 'V'}, | |
| {Keys.W , 'W'}, | |
| {Keys.X , 'X'}, | |
| {Keys.Y , 'Y'}, | |
| {Keys.Z , 'Z'}, | |
| {Keys.OemMinus , '_'}, | |
| {Keys.OemPlus , '+'}, | |
| {Keys.OemOpenBrackets , '{'}, | |
| {Keys.OemCloseBrackets, '}'}, | |
| {Keys.OemPipe , '|'}, | |
| {Keys.OemSemicolon , ':'}, | |
| {Keys.OemQuotes , '\"'}, | |
| {Keys.OemComma , '<'}, | |
| {Keys.OemPeriod , '>'}, | |
| {Keys.OemQuestion , '?'}, | |
| {Keys.Space , ' '}, | |
| {Keys.Return , '\n'}, | |
| {Keys.Back , '\b'} | |
| }; | |
| public static char GetPressedKey(Keys key, bool shift = false) | |
| { | |
| if (!shift) | |
| { | |
| if (keyToChar.ContainsKey(key)) | |
| { | |
| return keyToChar[key]; | |
| } | |
| } | |
| else | |
| { | |
| if (keyToCharShift.ContainsKey(key)) | |
| { | |
| return keyToCharShift[key]; | |
| } | |
| } | |
| return '\0'; | |
| } | |
| public static char GetPressedKeyModifier(Keys key) | |
| { | |
| bool shift = (key & (Keys)0b100000000) != Keys.None; | |
| key &= (Keys)0b11111111; | |
| if (!shift) | |
| { | |
| if (keyToChar.ContainsKey(key)) | |
| { | |
| return keyToChar[key]; | |
| } | |
| } | |
| else | |
| { | |
| if (keyToCharShift.ContainsKey(key)) | |
| { | |
| return keyToCharShift[key]; | |
| } | |
| } | |
| return '\0'; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment