Add different keylist support and fix shifted_keys bug

This commit is contained in:
Sofia 2018-12-11 02:17:22 +02:00
parent 2e9c7579d8
commit 5c7d294a19
4 changed files with 89 additions and 56 deletions

View File

@ -3,64 +3,19 @@ class InputManager:
currently_pressed_keys = [] currently_pressed_keys = []
left_paw_keys = [ left_paw_keys = []
"1", "2", "3", "4", "5", right_paw_keys = []
"Q", "W", "E", "R", "T", "Y", shifted_keys = {}
"A", "S", "D", "F", "G", "H",
"Z", "X", "C", "V", "B",
"Espace", "Oem_5", "Tab", "Capital", "Lshift", def init(self, linux):
"Lcontrol", "Lwin", "Lmenu", "Space", if linux:
"F1", "F2", "F3", "F4", "F5" import keylist_linux_fi as keys
] else:
import keylist_win_fi as keys
right_paw_keys = [ self.right_paw_keys = keys.right_paw_keys
"6", "7", "8", "9", "0", "Oem_Plus", "Oem_4", "Back", self.left_paw_keys = keys.left_paw_keys
"U", "I", "O", "P", "Oem_6", "Oem_1", "Return", self.shifted_keys = keys.shifted_keys
"J", "K", "L", "Oem_3", "Oem_7", "Oem_2",
"N", "M", "Oem_Comma", "Oem_Period", "Oem_Minus", "Rshift",
"Rmenu", "Rwin", "Rcontrol",
"Up", "Left", "Down", "Right",
"Insert", "Home", "Prior", "Delete", "End", "Next",
"Snapshot", "Scroll", "Pause",
"Numpad0", "Numpad1", "Numpad2", "Numpad3", "Numpad4", "Numpad5", "Numpad6", "Numpad7", "Numpad8", "Numpad9",
"Numlock", "Divide", "Multiply", "Subtract", "Add", "Decimal",
"F6", "F7", "F8", "F9", "F10", "F11", "F12"
]
left_paw_keys_linux_fi = [
"1", "2", "3", "4", "5",
"exclam", "quotedbl", "numbersign", "currency", "percent",
"q", "w", "e", "r", "t", "y",
"a", "s", "d", "f", "g", "h",
"z", "x", "c", "v", "b"
"Escape", "section", "Tab", "Caps_Lock", "Shift_L",
"Control_L", "Super_L", "Alt_L", "space",
"F1", "F2", "F3", "F4", "F5"
]
right_paw_keys_linux_fi = [
"6", "7", "8", "9", "0", "plus", "[65105]", "BackSpace",
"ampersand", "slash", "parenleft", "parenright", "equal",
"u", "i", "o", "p", "aring", "[65111]", "Return",
"j", "k", "l", "odiaresis", "adiaresis", "apostrophe", "asterisk",
"n", "m", "comma", "period", "minus", "Shift_R", "semicolon", "colon", "underscore",
"[65027]", "Menu", "Control_R",
"Up", "Left", "Down", "Right",
"Insert", "Home", "Page_Up", "Delete", "End", "Next",
"Print", "Scroll_Lock", "Pause",
"P_Insert", "P_End", "P_Down", "P_Next", "P_Left", "P_Begin", "P_Right", "P_Home", "P_Up", "P_Page_Up",
"Num_Lock", "P_Divide", "P_Multiply", "P_Subtract", "P_Add", "P_Delete", "P_Enter",
"F6", "F7", "F8", "F9", "F10", "F11", "F12"
]
pyxhook_shifted_numbers = [
"exclam", "quotedbl", "numbersign", "currency", "percent",
"ampersand", "slash", "parenleft", "parenright", "equal",
]
def on_update(self, down): def on_update(self, down):
pass pass
@ -75,6 +30,11 @@ class InputManager:
self.currently_pressed_keys.remove(key) self.currently_pressed_keys.remove(key)
self.on_update(False) self.on_update(False)
shifted = self.shifted_keys.get(key)
if shifted in self.currently_pressed_keys:
self.currently_pressed_keys.remove(key)
self.on_update(False)
def left_keys_pressed(self): def left_keys_pressed(self):
pressed = False pressed = False
for key in self.currently_pressed_keys: for key in self.currently_pressed_keys:

45
keylist_linux_fi.py Normal file
View File

@ -0,0 +1,45 @@
left_paw_keys = [
"1", "2", "3", "4", "5",
"exclam", "quotedbl", "numbersign", "currency", "percent",
"q", "w", "e", "r", "t", "y",
"a", "s", "d", "f", "g", "h",
"z", "x", "c", "v", "b"
"Escape", "section", "Tab", "Caps_Lock", "Shift_L",
"Control_L", "Super_L", "Alt_L", "space",
"F1", "F2", "F3", "F4", "F5"
]
right_paw_keys = [
"6", "7", "8", "9", "0", "plus", "[65105]", "BackSpace",
"ampersand", "slash", "parenleft", "parenright", "equal",
"u", "i", "o", "p", "aring", "[65111]", "Return",
"j", "k", "l", "odiaresis", "adiaresis", "apostrophe", "asterisk",
"n", "m", "comma", "period", "minus", "Shift_R", "semicolon", "colon", "underscore",
"[65027]", "Menu", "Control_R",
"Up", "Left", "Down", "Right",
"Insert", "Home", "Page_Up", "Delete", "End", "Next",
"Print", "Scroll_Lock", "Pause",
"P_Insert", "P_End", "P_Down", "P_Next", "P_Left", "P_Begin", "P_Right", "P_Home", "P_Up", "P_Page_Up",
"Num_Lock", "P_Divide", "P_Multiply", "P_Subtract", "P_Add", "P_Delete", "P_Enter",
"F6", "F7", "F8", "F9", "F10", "F11", "F12"
]
# pyxhook_shifted_numbers = [
# "exclam", "quotedbl", "numbersign", "currency", "percent",
# "ampersand", "slash", "parenleft", "parenright", "equal",
# ]
shifted_keys = {
"1": "exclam",
"2": "quotedbl",
"3": "numbersign",
"4": "currency",
"5": "percent",
"6": "ampersand",
"7": "slash",
"8": "parenleft",
"9": "parenright",
"0": "equal"
}

27
keylist_win_fi.py Normal file
View File

@ -0,0 +1,27 @@
left_paw_keys = [
"1", "2", "3", "4", "5",
"Q", "W", "E", "R", "T", "Y",
"A", "S", "D", "F", "G", "H",
"Z", "X", "C", "V", "B",
"Espace", "Oem_5", "Tab", "Capital", "Lshift",
"Lcontrol", "Lwin", "Lmenu", "Space",
"F1", "F2", "F3", "F4", "F5"
]
right_paw_keys = [
"6", "7", "8", "9", "0", "Oem_Plus", "Oem_4", "Back",
"U", "I", "O", "P", "Oem_6", "Oem_1", "Return",
"J", "K", "L", "Oem_3", "Oem_7", "Oem_2",
"N", "M", "Oem_Comma", "Oem_Period", "Oem_Minus", "Rshift",
"Rmenu", "Rwin", "Rcontrol",
"Up", "Left", "Down", "Right",
"Insert", "Home", "Prior", "Delete", "End", "Next",
"Snapshot", "Scroll", "Pause",
"Numpad0", "Numpad1", "Numpad2", "Numpad3", "Numpad4", "Numpad5", "Numpad6", "Numpad7", "Numpad8", "Numpad9",
"Numlock", "Divide", "Multiply", "Subtract", "Add", "Decimal",
"F6", "F7", "F8", "F9", "F10", "F11", "F12"
]
shifted_keys = {}

View File

@ -48,6 +48,7 @@ class Main:
self.font = pygame.font.SysFont('Iosevka', 15) self.font = pygame.font.SysFont('Iosevka', 15)
self.bongocat.load() self.bongocat.load()
self.clackmanager.load() self.clackmanager.load()
self.input_manager.init(linux)
self.input_manager.on_update = self.update_bongocat self.input_manager.on_update = self.update_bongocat