Very broken, but some work done probably
This commit is contained in:
parent
d0f35100b3
commit
7ae2d18e45
@ -21,7 +21,7 @@ def main():
|
||||
KC.BACKSPACE],
|
||||
[KC.TAB, KC.A, KC.O, KC.E, KC.U, KC.I, KC.D, KC.H, KC.T, KC.N, KC.S, KC.ENTER],
|
||||
[KC.SHIFT, KC.SEMICOLON, KC.Q, KC.J, KC.K, KC.X, KC.B, KC.M, KC.W, KC.V, KC.Z, KC.SLASH],
|
||||
[KC.CTRL, KC.GUI, KC.ALT, KC.RESET, KC.A, KC.SPACE, KC.SPACE, KC.A, KC.LEFT, KC.DOWN,
|
||||
[KC.CTRL, KC.GUI, KC.ALT, KC.RESET, KC.DF, KC.SPACE, KC.SPACE, KC.A, KC.LEFT, KC.DOWN,
|
||||
KC.UP, KC.RIGHT],
|
||||
]
|
||||
|
||||
@ -31,6 +31,7 @@ def main():
|
||||
col_pins=cols,
|
||||
diode_orientation=diode_orientation,
|
||||
hid=HIDHelper,
|
||||
active_layers=[0],
|
||||
log_level=DEBUG,
|
||||
)
|
||||
|
||||
|
@ -2,7 +2,7 @@ from kmk.common.consts import DiodeOrientation
|
||||
|
||||
|
||||
class AbstractMatrixScanner():
|
||||
def __init__(self, cols, rows, diode_orientation=DiodeOrientation.COLUMNS):
|
||||
def __init__(self, cols, rows, active_layers, diode_orientation=DiodeOrientation.COLUMNS):
|
||||
raise NotImplementedError('Abstract implementation')
|
||||
|
||||
def _normalize_matrix(self, matrix):
|
||||
|
@ -5,29 +5,32 @@ KEY_DOWN_EVENT = const(2)
|
||||
INIT_FIRMWARE_EVENT = const(3)
|
||||
|
||||
|
||||
def init_firmware(keymap, row_pins, col_pins, diode_orientation):
|
||||
def init_firmware(keymap, row_pins, col_pins, diode_orientation, active_layers):
|
||||
return {
|
||||
'type': INIT_FIRMWARE_EVENT,
|
||||
'keymap': keymap,
|
||||
'row_pins': row_pins,
|
||||
'col_pins': col_pins,
|
||||
'diode_orientation': diode_orientation,
|
||||
'active_layers': active_layers,
|
||||
}
|
||||
|
||||
|
||||
def key_up_event(keycode, row, col):
|
||||
def key_up_event(keycode, row, col, active_layers):
|
||||
return {
|
||||
'type': KEY_UP_EVENT,
|
||||
'keycode': keycode,
|
||||
'row': row,
|
||||
'col': col,
|
||||
'active_layers': active_layers,
|
||||
}
|
||||
|
||||
|
||||
def key_down_event(keycode, row, col):
|
||||
def key_down_event(keycode, row, col, active_layers):
|
||||
return {
|
||||
'type': KEY_DOWN_EVENT,
|
||||
'keycode': keycode,
|
||||
'row': row,
|
||||
'col': col,
|
||||
'active_layers': active_layers,
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
def process(self, state, key):
|
||||
self.logger.warning(key)
|
||||
if key.code == 1000:
|
||||
def process(self, state, action):
|
||||
self.logger.warning(action['keycode'])
|
||||
if action['keycode'].code == 1000:
|
||||
reset(self)
|
||||
elif action['keycode'].code == 1050:
|
||||
df(self, "Filler", action)
|
||||
|
||||
|
||||
def reset(self):
|
||||
@ -9,3 +11,32 @@ def reset(self):
|
||||
import machine
|
||||
machine.bootloader()
|
||||
return self
|
||||
|
||||
|
||||
def df(self, layer, action):
|
||||
"""Switches the default layer"""
|
||||
self.logger.warning(action['active_layers'])
|
||||
|
||||
|
||||
def mo(layer):
|
||||
"""Momentarily activates layer, switches off when you let go"""
|
||||
|
||||
|
||||
def lm(layer, mod):
|
||||
"""As MO(layer) but with mod active"""
|
||||
|
||||
|
||||
def lt(layer, kc):
|
||||
"""Momentarily activates layer if held, sends kc if tapped"""
|
||||
|
||||
|
||||
def tg(layer):
|
||||
"""Toggles the layer (enables it if no active, and vise versa)"""
|
||||
|
||||
|
||||
def to(layer):
|
||||
"""Activates layer and deactivates all other layers"""
|
||||
|
||||
|
||||
def tt(layer):
|
||||
"""Momentarily activates layer if held, toggles it if tapped repeatedly"""
|
||||
|
@ -48,6 +48,7 @@ class InternalState:
|
||||
col_pins = []
|
||||
matrix = []
|
||||
diode_orientation = DiodeOrientation.COLUMNS
|
||||
active_layers = [0]
|
||||
|
||||
@property
|
||||
def __dict__(self):
|
||||
@ -58,6 +59,7 @@ class InternalState:
|
||||
'col_pins': self.col_pins,
|
||||
'row_pins': self.row_pins,
|
||||
'diode_orientation': self.diode_orientation,
|
||||
'active_layers': self.active_layers,
|
||||
}
|
||||
|
||||
def __repr__(self):
|
||||
@ -124,6 +126,7 @@ def kmk_reducer(state=None, action=None, logger=None):
|
||||
row_pins=action['row_pins'],
|
||||
col_pins=action['col_pins'],
|
||||
diode_orientation=action['diode_orientation'],
|
||||
active_layers=action['active_layers'],
|
||||
matrix=[
|
||||
[False for c in action['col_pins']]
|
||||
for r in action['row_pins']
|
||||
|
@ -321,6 +321,15 @@ class Keycodes(KeycodeCategory):
|
||||
KC_LEAD = Keycode(1005, False)
|
||||
KC_LOCK = Keycode(1006, False)
|
||||
|
||||
class Layers(KeycodeCategory):
|
||||
KC_DF = Keycode(1050, False)
|
||||
KC_MO = Keycode(1051, False)
|
||||
KC_LM = Keycode(1052, False)
|
||||
KC_LT = Keycode(1053, False)
|
||||
KC_TG = Keycode(1054, False)
|
||||
KC_TO = Keycode(1055, False)
|
||||
KC_TT = Keycode(1056, False)
|
||||
|
||||
|
||||
ALL_KEYS = KC = AttrDict({
|
||||
k.replace('KC_', ''): v
|
||||
|
@ -12,8 +12,8 @@ except ImportError:
|
||||
|
||||
class Firmware:
|
||||
def __init__(
|
||||
self, keymap, row_pins, col_pins, diode_orientation,
|
||||
hid=None, log_level=logging.NOTSET,
|
||||
self, keymap, row_pins, col_pins, active_layers,
|
||||
diode_orientation, hid=None, log_level=logging.NOTSET,
|
||||
):
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(log_level)
|
||||
@ -36,6 +36,7 @@ class Firmware:
|
||||
keymap=keymap,
|
||||
row_pins=row_pins,
|
||||
col_pins=col_pins,
|
||||
active_layers=active_layers,
|
||||
diode_orientation=diode_orientation,
|
||||
))
|
||||
|
||||
@ -50,6 +51,7 @@ class Firmware:
|
||||
self.matrix = MatrixScanner(
|
||||
state.col_pins,
|
||||
state.row_pins,
|
||||
state.active_layers,
|
||||
state.diode_orientation,
|
||||
)
|
||||
|
||||
|
@ -5,7 +5,7 @@ from kmk.common.consts import DiodeOrientation
|
||||
|
||||
|
||||
class MatrixScanner(AbstractMatrixScanner):
|
||||
def __init__(self, cols, rows, diode_orientation=DiodeOrientation.COLUMNS):
|
||||
def __init__(self, cols, rows, active_layers, diode_orientation=DiodeOrientation.COLUMNS):
|
||||
# A pin cannot be both a row and column, detect this by combining the
|
||||
# two tuples into a set and validating that the length did not drop
|
||||
#
|
||||
@ -19,6 +19,7 @@ class MatrixScanner(AbstractMatrixScanner):
|
||||
self.cols = [machine.Pin(pin) for pin in cols]
|
||||
self.rows = [machine.Pin(pin) for pin in rows]
|
||||
self.diode_orientation = diode_orientation
|
||||
self.active_layers = active_layers
|
||||
|
||||
if self.diode_orientation == DiodeOrientation.COLUMNS:
|
||||
self.outputs = self.cols
|
||||
|
@ -59,8 +59,8 @@ class HIDHelper:
|
||||
self.add_key(action['keycode'])
|
||||
self.send()
|
||||
else:
|
||||
self.logger.warning('Should be processing')
|
||||
internal_keycodes.process(self, state, action['keycode'])
|
||||
self.logger.warning('Triggering KMK keycodes')
|
||||
internal_keycodes.process(self, state, action)
|
||||
elif action['type'] == KEY_UP_EVENT:
|
||||
# If keycode is 1000 or over, these are internal keys
|
||||
if action['keycode'].code < 1000:
|
||||
|
Loading…
x
Reference in New Issue
Block a user