forked from pysrc/remote-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
LChen
committed
Dec 2, 2021
1 parent
ef83bcc
commit 41cddef
Showing
2 changed files
with
201 additions
and
156 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
# for windows | ||
keyboardMappingWin = { | ||
0x08: 'backspace', # VK_BACK | ||
0x5B: 'super', # VK_LWIN | ||
0x09: 'tab', # VK_TAB | ||
0x0c: 'clear', # VK_CLEAR | ||
0x0d: 'enter', # VK_RETURN | ||
0x0d: 'return', # VK_RETURN | ||
0x10: 'shift', # VK_SHIFT | ||
0x11: 'ctrl', # VK_CONTROL | ||
0x12: 'alt', # VK_MENU | ||
0x13: 'pause', # VK_PAUSE | ||
0x14: 'capslock', # VK_CAPITAL | ||
0x15: 'kana', # VK_KANA | ||
0x17: 'junja', # VK_JUNJA | ||
0x18: 'final', # VK_FINAL | ||
0x19: 'hanja', # VK_HANJA | ||
0x1b: 'esc', # VK_ESCAPE | ||
0x1c: 'convert', # VK_CONVERT | ||
0x1d: 'nonconvert', # VK_NONCONVERT | ||
0x1e: 'accept', # VK_ACCEPT | ||
0x1f: 'modechange', # VK_MODECHANGE | ||
0x20: 'space', # VK_SPACE | ||
0x21: 'pgup', # VK_PRIOR | ||
0x22: 'pgdn', # VK_NEXT | ||
0x23: 'end', # VK_END | ||
0x24: 'home', # VK_HOME | ||
0x25: 'left', # VK_LEFT | ||
0x26: 'up', # VK_UP | ||
0x27: 'right', # VK_RIGHT | ||
0x28: 'down', # VK_DOWN | ||
0x29: 'select', # VK_SELECT | ||
0x2a: 'print', # VK_PRINT | ||
0x2b: 'execute', # VK_EXECUTE | ||
0x2c: 'prtsc', # VK_SNAPSHOT | ||
0x2d: 'insert', # VK_INSERT | ||
0x2e: 'del', # VK_DELETE | ||
0x2f: 'help', # VK_HELP | ||
0x30: '0', | ||
0x31: '1', | ||
0x32: '2', | ||
0x33: '3', | ||
0x34: '4', | ||
0x35: '5', | ||
0x36: '6', | ||
0x37: '7', | ||
0x38: '8', | ||
0x39: '9', | ||
0x41: 'a', | ||
0x42: 'b', | ||
0x43: 'c', | ||
0x44: 'd', | ||
0x45: 'e', | ||
0x46: 'f', | ||
0x47: 'g', | ||
0x48: 'h', | ||
0x49: 'i', | ||
0x4a: 'j', | ||
0x4b: 'k', | ||
0x4c: 'l', | ||
0x4d: 'm', | ||
0x4e: 'n', | ||
0x4f: 'o', | ||
0x50: 'p', | ||
0x51: 'q', | ||
0x52: 'r', | ||
0x53: 's', | ||
0x54: 't', | ||
0x55: 'u', | ||
0x56: 'v', | ||
0x57: 'w', | ||
0x58: 'x', | ||
0x59: 'y', | ||
0x5a: 'z', | ||
0x5b: 'win', # VK_LWIN | ||
0x5c: 'winright', # VK_RWIN | ||
0x5d: 'apps', # VK_APPS | ||
0x5f: 'sleep', # VK_SLEEP | ||
0x60: 'num0', # VK_NUMPAD0 | ||
0x61: 'num1', # VK_NUMPAD1 | ||
0x62: 'num2', # VK_NUMPAD2 | ||
0x63: 'num3', # VK_NUMPAD3 | ||
0x64: 'num4', # VK_NUMPAD4 | ||
0x65: 'num5', # VK_NUMPAD5 | ||
0x66: 'num6', # VK_NUMPAD6 | ||
0x67: 'num7', # VK_NUMPAD7 | ||
0x68: 'num8', # VK_NUMPAD8 | ||
0x69: 'num9', # VK_NUMPAD9 | ||
0x6a: 'multiply', # VK_MULTIPLY ??? Is this the numpad *? | ||
0x6b: 'add', # VK_ADD ??? Is this the numpad +? | ||
0x6c: 'separator', # VK_SEPARATOR ??? Is this the numpad enter? | ||
0x6d: 'subtract', # VK_SUBTRACT ??? Is this the numpad -? | ||
0x6e: 'decimal', # VK_DECIMAL | ||
0x6f: 'divide', # VK_DIVIDE | ||
0x70: 'f1', # VK_F1 | ||
0x71: 'f2', # VK_F2 | ||
0x72: 'f3', # VK_F3 | ||
0x73: 'f4', # VK_F4 | ||
0x74: 'f5', # VK_F5 | ||
0x75: 'f6', # VK_F6 | ||
0x76: 'f7', # VK_F7 | ||
0x77: 'f8', # VK_F8 | ||
0x78: 'f9', # VK_F9 | ||
0x79: 'f10', # VK_F10 | ||
0x7a: 'f11', # VK_F11 | ||
0x7b: 'f12', # VK_F12 | ||
0x7c: 'f13', # VK_F13 | ||
0x7d: 'f14', # VK_F14 | ||
0x7e: 'f15', # VK_F15 | ||
0x7f: 'f16', # VK_F16 | ||
0x80: 'f17', # VK_F17 | ||
0x81: 'f18', # VK_F18 | ||
0x82: 'f19', # VK_F19 | ||
0x83: 'f20', # VK_F20 | ||
0x84: 'f21', # VK_F21 | ||
0x85: 'f22', # VK_F22 | ||
0x86: 'f23', # VK_F23 | ||
0x87: 'f24', # VK_F24 | ||
0x90: 'numlock', # VK_NUMLOCK | ||
0x91: 'scrolllock', # VK_SCROLL | ||
0xa0: 'shiftleft', # VK_LSHIFT | ||
0xa1: 'shiftright', # VK_RSHIFT | ||
0xa2: 'ctrlleft', # VK_LCONTROL | ||
0xa3: 'ctrlright', # VK_RCONTROL | ||
0xa4: 'altleft', # VK_LMENU | ||
0xa5: 'altright', # VK_RMENU | ||
0xa6: 'browserback', # VK_BROWSER_BACK | ||
0xa7: 'browserforward', # VK_BROWSER_FORWARD | ||
0xa8: 'browserrefresh', # VK_BROWSER_REFRESH | ||
0xa9: 'browserstop', # VK_BROWSER_STOP | ||
0xaa: 'browsersearch', # VK_BROWSER_SEARCH | ||
0xab: 'browserfavorites', # VK_BROWSER_FAVORITES | ||
0xac: 'browserhome', # VK_BROWSER_HOME | ||
0xad: 'volumemute', # VK_VOLUME_MUTE | ||
0xae: 'volumedown', # VK_VOLUME_DOWN | ||
0xaf: 'volumeup', # VK_VOLUME_UP | ||
0xb0: 'nexttrack', # VK_MEDIA_NEXT_TRACK | ||
0xb1: 'prevtrack', # VK_MEDIA_PREV_TRACK | ||
0xb2: 'stop', # VK_MEDIA_STOP | ||
0xb3: 'playpause', # VK_MEDIA_PLAY_PAUSE | ||
0xb4: 'launchmail', # VK_LAUNCH_MAIL | ||
0xb5: 'launchmediaselect', # VK_LAUNCH_MEDIA_SELECT | ||
0xb6: 'launchapp1', # VK_LAUNCH_APP1 | ||
0xb7: 'launchapp2', # VK_LAUNCH_APP2 | ||
0xba: ";", | ||
0xbb: "=", | ||
0xbc: ",", | ||
0xbd: "-", | ||
0xbe: ".", | ||
0xbf: "/", | ||
0xc0: "`", | ||
0xdb: "[", | ||
0xdc: "\\", | ||
0xdd: "]", | ||
0xde: "'", | ||
} | ||
|
||
keycodeMappingWin = {} | ||
for k in keyboardMappingWin: | ||
keycodeMappingWin[keyboardMappingWin[k]] = k | ||
|
||
# for linux | ||
keyboardMappingX11 = {'\t': 23, '\n': 36, '\r': 36, ' ': 65, '!': 10, '"': 48, '#': 12, '$': 13, '%': 14, '&': 16, "'": 48, '(': 187, ')': 188, '*': 17, '+': 21, ',': 59, '-': 20, '.': 60, '/': 61, '0': 19, '1': 10, '2': 11, '3': 12, '4': 13, '5': 14, '6': 15, '7': 16, '8': 17, '9': 18, ':': 47, ';': 47, '<': 94, '=': 21, '>': 60, '?': 61, '@': 11, '[': 34, '\\': 51, ']': 35, '^': 15, '_': 20, '`': 49, 'a': 38, 'b': 56, 'c': 54, 'd': 40, 'e': 26, 'f': 41, 'g': 42, 'h': 43, 'i': 31, 'j': 44, 'k': 45, 'l': 46, 'm': 58, 'n': 57, 'o': 32, 'p': 33, 'q': 24, 'r': 27, 's': 39, 't': 28, 'u': 30, 'v': 55, 'w': 25, 'x': 53, 'y': 29, 'z': 52, '{': 34, '|': 51, '}': 35, '~': 49, 'accept': None, 'add': 86, 'alt': 64, 'altleft': 64, 'altright': 108, 'apps': 135, 'backspace': 22, 'browserback': None, 'browserfavorites': None, 'browserforward': None, 'browserhome': None, 'browserrefresh': None, 'browsersearch': None, 'browserstop': None, 'capslock': 66, 'clear': None, 'convert': None, 'ctrl': 37, 'ctrlleft': 37, 'ctrlright': 105, 'decimal': 129, 'del': 119, 'delete': 119, 'divide': 106, 'down': 116, 'end': 115, 'enter': 36, 'esc': 9, 'escape': 9, 'execute': 0, 'f1': 67, 'f10': 76, 'f11': 95, 'f12': 96, 'f13': 0, 'f14': 0, 'f15': 0, 'f16': 0, 'f17': 0, 'f18': 0, 'f19': 0, 'f2': 68, 'f20': 0, 'f21': 0, 'f22': 0, 'f23': 0, 'f24': 0, 'f3': 69, 'f4': 70, 'f5': 71, | ||
'f6': 72, 'f7': 73, 'f8': 74, 'f9': 75, 'final': None, 'fn': None, 'hanguel': None, 'hangul': None, 'hanja': None, 'help': 146, 'home': 110, 'insert': 118, 'junja': None, 'kana': None, 'kanji': None, 'launchapp1': None, 'launchapp2': None, 'launchmail': None, 'launchmediaselect': None, 'left': 113, 'modechange': None, 'multiply': 63, 'nexttrack': None, 'nonconvert': None, 'num0': 90, 'num1': 87, 'num2': 88, 'num3': 89, 'num4': 83, 'num5': 84, 'num6': 85, 'num7': 79, 'num8': 80, 'num9': 81, 'numlock': 77, 'pagedown': 117, 'pageup': 112, 'pause': 127, 'pgdn': 117, 'pgup': 112, 'playpause': None, 'prevtrack': None, 'print': 107, 'printscreen': 107, 'prntscrn': 107, 'prtsc': 107, 'prtscr': 107, 'return': 36, 'right': 114, 'scrolllock': 78, 'select': 0, 'separator': 0, 'shift': 50, 'shiftleft': 50, 'shiftright': 62, 'sleep': None, 'space': 65, 'stop': None, 'subtract': 82, 'tab': 23, 'up': 111, 'volumedown': None, 'volumemute': None, 'volumeup': None, 'win': None, 'winleft': 133, 'winright': 134, 'yen': None, 'command': None, 'option': None, 'optionleft': None, 'optionright': None, '\x08': 22, '\\e': 9, 'A': 38, 'B': 56, 'C': 54, 'D': 40, 'E': 26, 'F': 41, 'G': 42, 'H': 43, 'I': 31, 'J': 44, 'K': 45, 'L': 46, 'M': 58, 'N': 57, 'O': 32, 'P': 33, 'Q': 24, 'R': 27, 'S': 39, 'T': 28, 'U': 30, 'V': 55, 'W': 25, 'X': 53, 'Y': 29, 'Z': 52} | ||
|
||
keycodeMappingX11 = {} | ||
for k in keyboardMappingX11: | ||
keycodeMappingX11[keyboardMappingX11[k]] = k | ||
|
||
# for mac | ||
keyboardMappingOsx = {'\t': 48, '\n': 36, '\r': 36, ' ': 49, '!': 18, '"': 39, '#': 20, '$': 21, '%': 23, '&': 26, "'": 39, '(': 25, ')': 29, '*': 28, '+': 24, ',': 43, '-': 27, '.': 47, '/': 44, '0': 29, '1': 18, '2': 19, '3': 20, '4': 21, '5': 23, '6': 22, '7': 26, '8': 28, '9': 25, ':': 41, ';': 41, '<': 43, '=': 24, '>': 47, '?': 44, '@': 19, '[': 33, '\\': 42, ']': 30, '^': 22, '_': 27, '`': 50, 'a': 0, 'b': 11, 'c': 8, 'd': 2, 'e': 14, 'f': 3, 'g': 5, 'h': 4, 'i': 34, 'j': 38, 'k': 40, 'l': 37, 'm': 46, 'n': 45, 'o': 31, 'p': 35, 'q': 12, 'r': 15, 's': 1, 't': 17, 'u': 32, 'v': 9, 'w': 13, 'x': 7, 'y': 16, 'z': 6, '{': 33, '|': 42, '}': 30, '~': 50, 'accept': None, 'add': None, 'alt': 58, 'altleft': 58, 'altright': None, 'apps': None, 'backspace': 51, 'browserback': None, 'browserfavorites': None, 'browserforward': None, 'browserhome': None, 'browserrefresh': None, 'browsersearch': None, 'browserstop': None, 'capslock': 57, 'clear': None, 'convert': None, 'ctrl': 59, 'ctrlleft': 59, 'ctrlright': 62, 'decimal': None, 'del': 117, 'delete': 117, 'divide': None, 'down': 125, 'end': 119, 'enter': 36, 'esc': 53, 'escape': 53, 'execute': None, 'f1': 122, 'f10': 109, 'f11': 103, 'f12': 111, 'f13': 105, 'f14': 107, 'f15': 113, 'f16': 106, 'f17': 64, 'f18': 79, 'f19': 80, 'f2': 120, 'f20': 90, 'f21': None, 'f22': None, 'f23': None, 'f24': None, 'f3': 99, 'f4': 118, | ||
'f5': 96, 'f6': 97, 'f7': 98, 'f8': 100, 'f9': 101, 'final': None, 'fn': 63, 'hanguel': None, 'hangul': None, 'hanja': None, 'help': 114, 'home': 115, 'insert': None, 'junja': None, 'kana': 104, 'kanji': None, 'launchapp1': None, 'launchapp2': None, 'launchmail': None, 'launchmediaselect': None, 'left': 123, 'modechange': None, 'multiply': None, 'nexttrack': None, 'nonconvert': None, 'num0': None, 'num1': None, 'num2': None, 'num3': None, 'num4': None, 'num5': None, 'num6': None, 'num7': None, 'num8': None, 'num9': None, 'numlock': None, 'pagedown': 121, 'pageup': 116, 'pause': None, 'pgdn': 121, 'pgup': 116, 'playpause': None, 'prevtrack': None, 'print': None, 'printscreen': None, 'prntscrn': None, 'prtsc': None, 'prtscr': None, 'return': 36, 'right': 124, 'scrolllock': None, 'select': None, 'separator': None, 'shift': 56, 'shiftleft': 56, 'shiftright': 60, 'sleep': None, 'space': 49, 'stop': None, 'subtract': None, 'tab': 48, 'up': 126, 'volumedown': 73, 'volumemute': 74, 'volumeup': 72, 'win': None, 'winleft': None, 'winright': None, 'yen': 93, 'command': 55, 'option': 58, 'optionleft': 58, 'optionright': 61, '\x08': 51, 'eisu': 102, 'A': 0, 'B': 11, 'C': 8, 'D': 2, 'E': 14, 'F': 3, 'G': 5, 'H': 4, 'I': 34, 'J': 38, 'K': 40, 'L': 37, 'M': 46, 'N': 45, 'O': 31, 'P': 35, 'Q': 12, 'R': 15, 'S': 1, 'T': 17, 'U': 32, 'V': 9, 'W': 13, 'X': 7, 'Y': 16, 'Z': 6} | ||
keycodeMappingOsx = {} | ||
for k in keyboardMappingOsx: | ||
keycodeMappingOsx[keyboardMappingOsx[k]] = k | ||
|
||
def getKeycodeMapping(plat): | ||
if plat == b'win': | ||
return keycodeMappingWin; | ||
elif plat == b'x11': | ||
return keycodeMappingX11 | ||
elif plat == b'osx': | ||
return keycodeMappingOsx | ||
else: | ||
return {} |
This file contains 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