Save a shit ton of perf, turns out making huge dicts every keystroke was AWFUL
This commit is contained in:
parent
712b0e4888
commit
fa195a3e3d
@ -120,21 +120,20 @@ class HIDHelper:
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def add_modifier(self, modifier):
|
def add_modifier(self, modifier):
|
||||||
if modifier.is_modifier and Keycodes.Modifiers.contains(modifier):
|
if modifier.is_modifier:
|
||||||
self._evt[0] |= modifier.code
|
self._evt[0] |= modifier.code
|
||||||
return self
|
return self
|
||||||
|
|
||||||
raise ValueError('Attempted to use non-modifier as a modifier')
|
raise ValueError('Attempted to use non-modifier as a modifier')
|
||||||
|
|
||||||
def remove_modifier(self, modifier):
|
def remove_modifier(self, modifier):
|
||||||
if modifier.is_modifier and Keycodes.Modifiers.contains(modifier):
|
if modifier.is_modifier:
|
||||||
self._evt[0] ^= modifier.code
|
self._evt[0] ^= modifier.code
|
||||||
return self
|
return self
|
||||||
|
|
||||||
raise ValueError('Attempted to use non-modifier as a modifier')
|
raise ValueError('Attempted to use non-modifier as a modifier')
|
||||||
|
|
||||||
def add_key(self, key):
|
def add_key(self, key):
|
||||||
if key and Keycodes.contains(key):
|
|
||||||
# Try to find the first empty slot in the key report, and fill it
|
# Try to find the first empty slot in the key report, and fill it
|
||||||
placed = False
|
placed = False
|
||||||
for pos in range(2, 8):
|
for pos in range(2, 8):
|
||||||
@ -148,10 +147,7 @@ class HIDHelper:
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
raise ValueError('Invalid keycode?')
|
|
||||||
|
|
||||||
def remove_key(self, key):
|
def remove_key(self, key):
|
||||||
if key and Keycodes.contains(key):
|
|
||||||
removed = False
|
removed = False
|
||||||
for pos in range(2, 8):
|
for pos in range(2, 8):
|
||||||
if self._evt[pos] == key.code:
|
if self._evt[pos] == key.code:
|
||||||
@ -162,5 +158,3 @@ class HIDHelper:
|
|||||||
self.logger.warning('Tried to remove key that was not added')
|
self.logger.warning('Tried to remove key that was not added')
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
raise ValueError('Invalid keycode?')
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user