provide default coord_mapping from scanners

This commit is contained in:
xs5871 authored and Kyle Brown committed 2022-04-11 17:07:12 -07:00
1 parent 8ac497d99b
commit e395e89864
4 files changed
+18 -10

No files matched your search

+4
View File
@@ -24,6 +24,10 @@ class Scanner:
coord_mapping = None
@property
def key_count(self):
raise NotImplementedError
def scan_for_changes(self):
'''
Scan for key events and return a key report if an event exists.
+7 -2
View File
@@ -77,8 +77,13 @@ class MatrixScanner(Scanner):
if self.rollover_cols_every_rows is None:
self.rollover_cols_every_rows = self.len_rows
self.len_state_arrays = self.len_cols * self.len_rows
self.state = bytearray(self.len_state_arrays)
self._key_count = self.len_cols * self.len_rows
self.coord_mapping = tuple(range(self.key_count))
self.state = bytearray(self.key_count)
@property
def key_count(self):
return self._key_count
def scan_for_changes(self):
'''
+5 -1
View File
@@ -16,10 +16,14 @@ class NativeKeypadScanner(Scanner):
self.keypad = kp
# for split keyboards, the offset value will be assigned in Split module
self.offset = 0
self.coord_mapping = list(range(len(pin_map)))
self.coord_mapping = tuple(range(self.key_count))
self.curr_event = keypad.Event()
@property
def key_count(self):
return self.keypad.key_count
def scan_for_changes(self):
'''
Scan for key events and return a key report if an event exists.