Initial attempt to merge internal_state with kmk_keyboard. Seems to work on Plank so far
fix formatting Example of new "Extension"/plugin system, using LED Cleanup of RGB code staticmethod to proper, normal methods Needs cleanup, but: migrate Leader to Extension API remove useless self reurns fix an AttributeError with Leader key removal Checkpoint from the weekend: split as an Extension (not working or done yet) wip
This commit is contained in:
@@ -6,23 +6,23 @@ def passthrough(key, state, *args, **kwargs):
|
||||
|
||||
|
||||
def default_pressed(key, state, KC, coord_int=None, coord_raw=None):
|
||||
state.hid_pending = True
|
||||
state._hid_pending = True
|
||||
|
||||
if coord_int is not None:
|
||||
state.coord_keys_pressed[coord_int] = key
|
||||
state._coord_keys_pressed[coord_int] = key
|
||||
|
||||
state.keys_pressed.add(key)
|
||||
state._keys_pressed.add(key)
|
||||
|
||||
return state
|
||||
|
||||
|
||||
def default_released(key, state, KC, coord_int=None, coord_raw=None):
|
||||
state.hid_pending = True
|
||||
state.keys_pressed.discard(key)
|
||||
state._hid_pending = True
|
||||
state._keys_pressed.discard(key)
|
||||
|
||||
if coord_int is not None:
|
||||
state.keys_pressed.discard(state.coord_keys_pressed.get(coord_int, None))
|
||||
state.coord_keys_pressed[coord_int] = None
|
||||
state._keys_pressed.discard(state._coord_keys_pressed.get(coord_int, None))
|
||||
state._coord_keys_pressed[coord_int] = None
|
||||
|
||||
return state
|
||||
|
||||
@@ -53,12 +53,12 @@ def bootloader(*args, **kwargs):
|
||||
|
||||
|
||||
def debug_pressed(key, state, KC, *args, **kwargs):
|
||||
if state.config.debug_enabled:
|
||||
if state.debug_enabled:
|
||||
print('DebugDisable()')
|
||||
else:
|
||||
print('DebugEnable()')
|
||||
|
||||
state.config.debug_enabled = not state.config.debug_enabled
|
||||
state.debug_enabled = not state.debug_enabled
|
||||
|
||||
return state
|
||||
|
||||
@@ -66,48 +66,48 @@ def debug_pressed(key, state, KC, *args, **kwargs):
|
||||
def gesc_pressed(key, state, KC, *args, **kwargs):
|
||||
GESC_TRIGGERS = {KC.LSHIFT, KC.RSHIFT, KC.LGUI, KC.RGUI}
|
||||
|
||||
if GESC_TRIGGERS.intersection(state.keys_pressed):
|
||||
if GESC_TRIGGERS.intersection(state._keys_pressed):
|
||||
# First, release GUI if already pressed
|
||||
state.config._send_hid()
|
||||
state._send_hid()
|
||||
# if Shift is held, KC_GRAVE will become KC_TILDE on OS level
|
||||
state.keys_pressed.add(KC.GRAVE)
|
||||
state.hid_pending = True
|
||||
state._keys_pressed.add(KC.GRAVE)
|
||||
state._hid_pending = True
|
||||
return state
|
||||
|
||||
# else return KC_ESC
|
||||
state.keys_pressed.add(KC.ESCAPE)
|
||||
state.hid_pending = True
|
||||
state._keys_pressed.add(KC.ESCAPE)
|
||||
state._hid_pending = True
|
||||
|
||||
return state
|
||||
|
||||
|
||||
def gesc_released(key, state, KC, *args, **kwargs):
|
||||
state.keys_pressed.discard(KC.ESCAPE)
|
||||
state.keys_pressed.discard(KC.GRAVE)
|
||||
state.hid_pending = True
|
||||
state._keys_pressed.discard(KC.ESCAPE)
|
||||
state._keys_pressed.discard(KC.GRAVE)
|
||||
state._hid_pending = True
|
||||
return state
|
||||
|
||||
|
||||
def bkdl_pressed(key, state, KC, *args, **kwargs):
|
||||
BKDL_TRIGGERS = {KC.LGUI, KC.RGUI}
|
||||
|
||||
if BKDL_TRIGGERS.intersection(state.keys_pressed):
|
||||
state.config._send_hid()
|
||||
state.keys_pressed.add(KC.DEL)
|
||||
state.hid_pending = True
|
||||
if BKDL_TRIGGERS.intersection(state._keys_pressed):
|
||||
state._send_hid()
|
||||
state._keys_pressed.add(KC.DEL)
|
||||
state._hid_pending = True
|
||||
return state
|
||||
|
||||
# else return KC_ESC
|
||||
state.keys_pressed.add(KC.BKSP)
|
||||
state.hid_pending = True
|
||||
state._keys_pressed.add(KC.BKSP)
|
||||
state._hid_pending = True
|
||||
|
||||
return state
|
||||
|
||||
|
||||
def bkdl_released(key, state, KC, *args, **kwargs):
|
||||
state.keys_pressed.discard(KC.BKSP)
|
||||
state.keys_pressed.discard(KC.DEL)
|
||||
state.hid_pending = True
|
||||
state._keys_pressed.discard(KC.BKSP)
|
||||
state._keys_pressed.discard(KC.DEL)
|
||||
state._hid_pending = True
|
||||
return state
|
||||
|
||||
|
||||
@@ -117,15 +117,11 @@ def sleep_pressed(key, state, KC, *args, **kwargs):
|
||||
|
||||
|
||||
def uc_mode_pressed(key, state, *args, **kwargs):
|
||||
state.config.unicode_mode = key.meta.mode
|
||||
state.unicode_mode = key.meta.mode
|
||||
|
||||
return state
|
||||
|
||||
|
||||
def leader_pressed(key, state, *args, **kwargs):
|
||||
return state._begin_leader_mode()
|
||||
|
||||
|
||||
def td_pressed(key, state, *args, **kwargs):
|
||||
return state._process_tap_dance(key, True)
|
||||
|
||||
@@ -135,137 +131,83 @@ def td_released(key, state, *args, **kwargs):
|
||||
|
||||
|
||||
def rgb_tog(key, state, *args, **kwargs):
|
||||
if state.config.pixels.animation_mode == 'static_standby':
|
||||
state.config.pixels.animation_mode = 'static'
|
||||
state.config.pixels.enabled = not state.config.pixels.enabled
|
||||
if state.pixels.animation_mode == 'static_standby':
|
||||
state.pixels.animation_mode = 'static'
|
||||
state.pixels.enabled = not state.pixels.enabled
|
||||
return state
|
||||
|
||||
|
||||
def rgb_hui(key, state, *args, **kwargs):
|
||||
state.config.pixels.increase_hue()
|
||||
state.pixels.increase_hue()
|
||||
return state
|
||||
|
||||
|
||||
def rgb_hud(key, state, *args, **kwargs):
|
||||
state.config.pixels.decrease_hue()
|
||||
state.pixels.decrease_hue()
|
||||
return state
|
||||
|
||||
|
||||
def rgb_sai(key, state, *args, **kwargs):
|
||||
state.config.pixels.increase_sat()
|
||||
state.pixels.increase_sat()
|
||||
return state
|
||||
|
||||
|
||||
def rgb_sad(key, state, *args, **kwargs):
|
||||
state.config.pixels.decrease_sat()
|
||||
state.pixels.decrease_sat()
|
||||
return state
|
||||
|
||||
|
||||
def rgb_vai(key, state, *args, **kwargs):
|
||||
state.config.pixels.increase_val()
|
||||
state.pixels.increase_val()
|
||||
return state
|
||||
|
||||
|
||||
def rgb_vad(key, state, *args, **kwargs):
|
||||
state.config.pixels.decrease_val()
|
||||
state.pixels.decrease_val()
|
||||
return state
|
||||
|
||||
|
||||
def rgb_ani(key, state, *args, **kwargs):
|
||||
state.config.pixels.increase_ani()
|
||||
state.pixels.increase_ani()
|
||||
return state
|
||||
|
||||
|
||||
def rgb_and(key, state, *args, **kwargs):
|
||||
state.config.pixels.decrease_ani()
|
||||
state.pixels.decrease_ani()
|
||||
return state
|
||||
|
||||
|
||||
def rgb_mode_static(key, state, *args, **kwargs):
|
||||
state.config.pixels.effect_init = True
|
||||
state.config.pixels.animation_mode = 'static'
|
||||
state.pixels.effect_init = True
|
||||
state.pixels.animation_mode = 'static'
|
||||
return state
|
||||
|
||||
|
||||
def rgb_mode_breathe(key, state, *args, **kwargs):
|
||||
state.config.pixels.effect_init = True
|
||||
state.config.pixels.animation_mode = 'breathing'
|
||||
state.pixels.effect_init = True
|
||||
state.pixels.animation_mode = 'breathing'
|
||||
return state
|
||||
|
||||
|
||||
def rgb_mode_breathe_rainbow(key, state, *args, **kwargs):
|
||||
state.config.pixels.effect_init = True
|
||||
state.config.pixels.animation_mode = 'breathing_rainbow'
|
||||
state.pixels.effect_init = True
|
||||
state.pixels.animation_mode = 'breathing_rainbow'
|
||||
return state
|
||||
|
||||
|
||||
def rgb_mode_rainbow(key, state, *args, **kwargs):
|
||||
state.config.pixels.effect_init = True
|
||||
state.config.pixels.animation_mode = 'rainbow'
|
||||
state.pixels.effect_init = True
|
||||
state.pixels.animation_mode = 'rainbow'
|
||||
return state
|
||||
|
||||
|
||||
def rgb_mode_swirl(key, state, *args, **kwargs):
|
||||
state.config.pixels.effect_init = True
|
||||
state.config.pixels.animation_mode = 'swirl'
|
||||
state.pixels.effect_init = True
|
||||
state.pixels.animation_mode = 'swirl'
|
||||
return state
|
||||
|
||||
|
||||
def rgb_mode_knight(key, state, *args, **kwargs):
|
||||
state.config.pixels.effect_init = True
|
||||
state.config.pixels.animation_mode = 'knight'
|
||||
return state
|
||||
|
||||
|
||||
def led_tog(key, state, *args, **kwargs):
|
||||
if state.config.led.animation_mode == 'static_standby':
|
||||
state.config.led.animation_mode = 'static'
|
||||
state.config.led.enabled = not state.config.led.enabled
|
||||
return state
|
||||
|
||||
|
||||
def led_inc(key, state, *args, **kwargs):
|
||||
state.config.led.increase_brightness()
|
||||
return state
|
||||
|
||||
|
||||
def led_dec(key, state, *args, **kwargs):
|
||||
state.config.led.decrease_brightness()
|
||||
return state
|
||||
|
||||
|
||||
def led_ani(key, state, *args, **kwargs):
|
||||
state.config.led.increase_ani()
|
||||
return state
|
||||
|
||||
|
||||
def led_and(key, state, *args, **kwargs):
|
||||
state.config.led.decrease_ani()
|
||||
return state
|
||||
|
||||
|
||||
def led_mode_static(key, state, *args, **kwargs):
|
||||
state.config.led.effect_init = True
|
||||
state.config.led.animation_mode = 'static'
|
||||
return state
|
||||
|
||||
|
||||
def led_mode_breathe(key, state, *args, **kwargs):
|
||||
state.config.led.effect_init = True
|
||||
state.config.led.animation_mode = 'breathing'
|
||||
return state
|
||||
|
||||
|
||||
def bt_clear_bonds(key, state, *args, **kwargs):
|
||||
state.config._hid_helper_inst.clear_bonds()
|
||||
return state
|
||||
|
||||
|
||||
def bt_next_conn(key, state, *args, **kwargs):
|
||||
state.config._hid_helper_inst.next_connection()
|
||||
return state
|
||||
|
||||
|
||||
def bt_prev_conn(key, state, *args, **kwargs):
|
||||
state.config._hid_helper_inst.previous_connection()
|
||||
state.pixels.effect_init = True
|
||||
state.pixels.animation_mode = 'knight'
|
||||
return state
|
||||
|
Reference in New Issue
Block a user