provide default coord_mapping from scanners
This commit is contained in:
parent
8ac497d99b
commit
e395e89864
@ -282,16 +282,11 @@ class KMKKeyboard:
|
||||
To save RAM on boards that don't use Split, we don't import Split
|
||||
and do an isinstance check, but instead do string detection
|
||||
'''
|
||||
if self.matrix and self.matrix.coord_mapping:
|
||||
self.coord_mapping = self.matrix.coord_mapping
|
||||
|
||||
if any(x.__class__.__module__ == 'kmk.modules.split' for x in self.modules):
|
||||
return
|
||||
|
||||
if not self.coord_mapping:
|
||||
rows_to_calc = len(self.row_pins)
|
||||
cols_to_calc = len(self.col_pins)
|
||||
self.coord_mapping = list(range(cols_to_calc * rows_to_calc))
|
||||
self.coord_mapping = self.matrix.coord_mapping
|
||||
|
||||
def _init_hid(self):
|
||||
if self.hid_type == HIDModes.NOOP:
|
||||
@ -420,9 +415,9 @@ class KMKKeyboard:
|
||||
self.secondary_hid_type = secondary_hid_type
|
||||
|
||||
self._init_sanity_check()
|
||||
self._init_coord_mapping()
|
||||
self._init_hid()
|
||||
self._init_matrix()
|
||||
self._init_coord_mapping()
|
||||
|
||||
for module in self.modules:
|
||||
try:
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user