provide default coord_mapping from scanners
This commit is contained in:
@@ -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.
|
||||
|
@@ -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):
|
||||
'''
|
||||
|
@@ -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.
|
||||
|
Reference in New Issue
Block a user