Refactor for nicer pointing device axes handling

This commit is contained in:
xs5871
2023-02-11 21:23:03 +00:00
committed by xs5871
parent ca800331de
commit 9e5d2c24e1
4 changed files with 35 additions and 23 deletions

View File

@@ -49,7 +49,7 @@ class KMKKeyboard:
#####
# Internal State
keys_pressed = set()
axes = {}
axes = set()
_coordkeys_pressed = {}
hid_type = HIDModes.USB
secondary_hid_type = None
@@ -102,12 +102,14 @@ class KMKKeyboard:
if debug.enabled:
debug(f'coordkeys_pressed={self._coordkeys_pressed}')
debug(f'keys_pressed={self.keys_pressed}')
# debug(f'axis={[ax for ax in self.axis.__iter__()]}')
def _send_hid(self) -> None:
if not self._hid_send_enabled:
return
if self.axes and debug.enabled:
debug(f'axes={self.axes}')
self._hid_helper.create_report(self.keys_pressed, self.axes)
try:
self._hid_helper.send()
@@ -116,10 +118,9 @@ class KMKKeyboard:
debug(f'HidNotFound(HIDReportType={e})')
self.hid_pending = False
for axis in self.axes.values():
if axis.delta != 0:
self.hid_pending = True
break
for axis in self.axes:
axis.move(self, 0)
def _handle_matrix_report(self, kevent: KeyEvent) -> None:
if kevent is not None: