provide default coord_mapping from scanners

This commit is contained in:
xs5871
2022-04-09 23:54:23 +00:00
committed by Kyle Brown
parent 8ac497d99b
commit e395e89864
4 changed files with 18 additions and 10 deletions

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.

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):
'''

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.