Move all remaining state into the single store, woot!
This commit is contained in:
@@ -4,18 +4,22 @@ from kmk.common.event_defs import key_down_event, key_up_event
|
||||
class Keymap:
|
||||
def __init__(self, map):
|
||||
self.map = map
|
||||
self.state = [
|
||||
[False for _ in row]
|
||||
for row in self.map
|
||||
]
|
||||
|
||||
def parse(self, matrix, store):
|
||||
state = store.get_state()
|
||||
|
||||
for ridx, row in enumerate(matrix):
|
||||
for cidx, col in enumerate(row):
|
||||
if col != self.state[ridx][cidx]:
|
||||
if col != state.matrix[ridx][cidx]:
|
||||
if col:
|
||||
store.dispatch(key_down_event(self.map[ridx][cidx]))
|
||||
store.dispatch(key_down_event(
|
||||
row=ridx,
|
||||
col=cidx,
|
||||
keycode=self.map[ridx][cidx],
|
||||
))
|
||||
else:
|
||||
store.dispatch(key_up_event(self.map[ridx][cidx]))
|
||||
|
||||
self.state = matrix
|
||||
store.dispatch(key_up_event(
|
||||
row=ridx,
|
||||
col=cidx,
|
||||
keycode=self.map[ridx][cidx],
|
||||
))
|
||||
|
Reference in New Issue
Block a user