aboutsummaryrefslogtreecommitdiff
path: root/qmk/keyboards/sofle_choc/keymaps/custom
diff options
context:
space:
mode:
Diffstat (limited to 'qmk/keyboards/sofle_choc/keymaps/custom')
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/callbacks.c7
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c37
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/keymap.c8
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/lighting.c44
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/shift_dance.c2
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/tap_hold_dance.c62
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/tap_hold_dance.h5
7 files changed, 75 insertions, 90 deletions
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/callbacks.c b/qmk/keyboards/sofle_choc/keymaps/custom/callbacks.c
index 842e4f7..e97fe3e 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/callbacks.c
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/callbacks.c
@@ -11,9 +11,9 @@ uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) {
// case KEY_LOK:
// case TD_ENTER:
// return 2 * TAPPING_TERM;
- case KEY_F:
- case KEY_J:
- return tap_hold_dance_tapping_term(keycode, record);
+// case KEY_F:
+// case KEY_J:
+// return tap_hold_dance_tapping_term(keycode, record);
default:
return TAPPING_TERM;
}
@@ -39,7 +39,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
star_key_process_record(keycode, record);
shift_dance_process_record(keycode, record);
enter_dance_process_record(keycode, record);
- //tap_hold_dance_process_record(keycode, record);
return keycodes_process_record(keycode, record);
}
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c b/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c
index e2fb583..76b6b91 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c
@@ -3,12 +3,39 @@
bool keycodes_process_record(uint16_t keycode, keyrecord_t *record) {
+ static bool kc_lgui = false;
+ static bool kc_ralt = false;
switch (keycode) {
case KC_ESC:
+ /* By default, send the ESC code to the host.
+ * This code will be muted if there is a specific state to remove firts.
+
+ * The keys L_GUI and R_ALT activate a layer automatically, but can be
+ * used in a combo with the ESC key, I do not want to ignore the key press
+ * in this case.
+ */
+ bool handle_key = true;
+ if (get_oneshot_mods()) {
+ clear_oneshot_mods();
+ handle_key = false;
+ }
+ if ( (! kc_ralt) \
+ && (! kc_lgui) \
+ && (layer_state_is(LAYER_KEYPAD) || layer_state_is(LAYER_ARROW) )) {
+ // Remove the layer the key is released.
+ layer_clear();
+ handle_key = false;
+ }
+ if (host_keyboard_led_state().caps_lock) {
+ tap_code16(KC_CAPS_LOCK);
+ handle_key = false;
+ }
+ return handle_key;
case AL_ENT:
- if (!record->event.pressed && \
- (layer_state_is(LAYER_KEYPAD) || layer_state_is(LAYER_ARROW) )) {
+ if (!record->event.pressed \
+ && (! kc_lgui) \
+ && (layer_state_is(LAYER_KEYPAD) || layer_state_is(LAYER_ARROW) )) {
// Remove the layer the key is released.
layer_clear();
}
@@ -17,16 +44,20 @@ bool keycodes_process_record(uint16_t keycode, keyrecord_t *record) {
// Override the key APP when hold into AltGR + Layer 1 when hold
case KEY_APP:
if (!record->tap.count && record->event.pressed) {
- layer_on(LAYER_ARROW);
+ kc_ralt = record->event.pressed;
register_code(KC_RIGHT_ALT);
+ layer_on(LAYER_ARROW);
return false;
} else if (!record->tap.count && !record->event.pressed) {
+ kc_ralt = record->event.pressed;
unregister_code(KC_RIGHT_ALT);
layer_off(LAYER_ARROW);
return false;
}
+ return true;
case KC_LGUI:
+ kc_lgui = record->event.pressed;
if (record->event.pressed) {
layer_on(LAYER_ARROW);
}
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/keymap.c b/qmk/keyboards/sofle_choc/keymaps/custom/keymap.c
index a1b5142..85082f5 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/keymap.c
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/keymap.c
@@ -33,8 +33,10 @@ tap_dance_action_t tap_dance_actions[] = {
[TD_CAPSLOCK] = ACTION_TAP_DANCE_FN_ADVANCED_WITH_RELEASE(NULL, right_shift_released, right_shift_finished, right_shift_reset),
[TD_LAYER_KEYPAD] = ACTION_TAP_DANCE_LAYER(LAYER_KEYPAD),
[TD_LAYER_ARROW] = ACTION_TAP_DANCE_LAYER(LAYER_ARROW),
- [TD_KEY_F] = ACTION_TAP_HOLD_DANCE(KC_F, KC_LCTL, 1),
- [TD_KEY_J] = ACTION_TAP_HOLD_DANCE(KC_J, KC_RCTL, 0),
+ [TD_KEY_F] = ACTION_TAP_HOLD_DANCE(KC_F, KC_LCTL),
+ [TD_KEY_J] = ACTION_TAP_HOLD_DANCE(KC_J, KC_RCTL),
+// [TD_LCTL] = ACTION_TAP_HOLD_DANCE(KC_LCTL),
+// [TD_RCTL] = ACTION_TAP_HOLD_DANCE(KC_RCTL),
[TD_ENTER] = ACTION_TAP_DANCE_FN_ADVANCED_WITH_RELEASE(NULL, enter_released, enter_finished, enter_reset),
};
@@ -64,7 +66,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_GRV, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_MUTE, KC_MPLY,KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KEY_LOK,
- OS_LCTL, KC_DELETE,KC_LGUI,LY_ARROW, AL_SPC, TD_ENTR,LY_KEYPAD, KEY_APP, KEY_INS, OS_RCTL
+ OS_LCTL, KC_DELETE,KC_LGUI,LY_ARROW, AL_SPC, TD_ENTR,LY_KEYPAD,KEY_APP, KEY_INS, OS_RCTL
),
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c b/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c
index f4a58d7..df729cc 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c
@@ -27,26 +27,33 @@ void lighting_init(void) {
static uint8_t last_flags;
-static bool one_shot_alt_flag = 0;
-
-void oneshot_mods_changed_lighting(uint8_t mods) {
- one_shot_alt_flag = mods & MOD_MASK_ALT;
-}
-
-uint8_t get_flags(void) {
+static uint8_t one_shot_flags = 0;
+
+// Build a bit set depending of the active mods.
+// The bit set is intended to match colors (see below)
+//
+// There is a special case for the caps_lock state, because the function can
+// be called either from the active mods on the keyboard, or from the active
+// oneshot mods and I do not want to report the capslock in the evaluation of
+// the oneshot flags.
+uint8_t get_flags(uint8_t mods, bool with_caps) {
uint8_t flags = 0;
- if (get_mods() & MOD_MASK_CTRL) {
+ if (mods & MOD_MASK_CTRL) {
flags |= 0b001;
}
- if (one_shot_alt_flag || (get_mods() & MOD_MASK_ALT)) {
+ if (mods & MOD_MASK_ALT) {
flags |= 0b010;
}
- if ((get_mods() & MOD_MASK_SHIFT) || host_keyboard_led_state().caps_lock) {
+ if ((mods & MOD_MASK_SHIFT) || (with_caps && host_keyboard_led_state().caps_lock)) {
flags |= 0b100;
}
return flags;
}
+void oneshot_mods_changed_lighting(uint8_t mods) {
+ one_shot_flags = get_flags(mods, false);
+}
+
void housekeeping_task_lighting(void) {
// Colors for the mods
@@ -61,10 +68,11 @@ void housekeeping_task_lighting(void) {
hsv_of_color(HSV_WHITE), // 111
};
- uint8_t flags = get_flags();
+ uint8_t flags = get_flags(get_mods(), true) | one_shot_flags;
uint8_t matrix_mode = rgb_matrix_get_mode();
- if (matrix_mode != RGB_MATRIX_BREATHING && host_keyboard_led_state().caps_lock) {
+ if (matrix_mode != RGB_MATRIX_BREATHING && \
+ (host_keyboard_led_state().caps_lock || one_shot_flags)) {
rgb_matrix_mode_noeeprom(RGB_MATRIX_BREATHING);
}
@@ -93,7 +101,11 @@ bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
uint8_t current_layer = get_highest_layer(layer_state);
// The value `layer_state` is global
- if (! (flags || current_layer || is_star || one_shot_alt_flag)) {
+ if (! (flags
+ || current_layer
+ || is_star
+ || one_shot_flags
+ || host_keyboard_led_state().caps_lock)) {
return false;
}
@@ -140,6 +152,7 @@ bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
case KC_HOME:
case KC_END:
case KC_TAB:
+ case KEY_INS:
set_color(index, HSV_GREEN);
break;
case KC_LSFT:
@@ -159,7 +172,10 @@ bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
case QK_RGB_MATRIX_VALUE_DOWN:
set_color(index, HSV_SPRINGGREEN);
break;
-
+ case OS_LCTL:
+ case OS_RCTL:
+ set_color(index, 55, 255, 255);
+ break;
}
}
}
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/shift_dance.c b/qmk/keyboards/sofle_choc/keymaps/custom/shift_dance.c
index 618968f..717e7f5 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/shift_dance.c
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/shift_dance.c
@@ -40,8 +40,6 @@ void shift_dance_process_record(uint16_t keycode, keyrecord_t *record) {
if (lshift_interrupted) {
break;
}
- // Continue on the next block
- case KC_ESC:
if (host_keyboard_led_state().caps_lock) {
tap_code16(KC_CAPS_LOCK);
}
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/tap_hold_dance.c b/qmk/keyboards/sofle_choc/keymaps/custom/tap_hold_dance.c
index 907a0f2..1008ffc 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/tap_hold_dance.c
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/tap_hold_dance.c
@@ -2,66 +2,6 @@
#include "quad_tapdance.h"
#include "tap_hold_dance.h"
-/* timer for last keyboard activity, use 32bit value and function to make
- * longer idle time possible
- */
-static uint32_t key_timer;
-
-uint16_t tap_hold_dance_tapping_term(uint16_t keycode, keyrecord_t *record) {
- /*
- * If no keys where pressed before, reduce the time before activating the
- * tapdance.
- * The feedback is given with the LED in the keyboard.
- */
- if (timer_elapsed32(key_timer) > (TAPPING_TERM * 2)) {
- return TAPPING_TERM / 2;
- }
- return TAPPING_TERM;
-}
-
-bool is_blocking_keycode(uint16_t keycode) {
-
- uint8_t current_layer = get_highest_layer(layer_state);
- if (current_layer != LAYER_BASE) {
- return false;
- }
-
- switch (keycode) {
- /* List the keys to ignore and should not considered inside a typing
- * session.
- */
- case LY_KEYPAD:
- case LY_ARROW:
- case KC_ESC:
- case KC_RIGHT:
- case KEY_DOWN:
- case KC_LEFT ... KC_UP:
- case KC_PGUP:
- case KC_PGDN:
- case KEY_PGDN:
- case KC_HOME:
- case KC_END:
- case KC_TAB:
- return false;
- case AL_ENT:
- case KC_BSPC:
- case KC_DELETE:
- case KC_A ... KC_0:
- default:
- return true;
- }
-
-}
-
-void tap_hold_dance_process_record(uint16_t keycode, keyrecord_t *record) {
-
- if (record->event.pressed) {
- return;
- }
- if (is_blocking_keycode(keycode))
- key_timer = timer_read32();
-}
-
void tap_hold_dance_released(tap_dance_state_t *state, void *user_data) {
if (state->finished || state->interrupted) return;
tap_hold_dance_t *tap_hold_dance = (tap_hold_dance_t *)user_data;
@@ -77,7 +17,7 @@ void tap_hold_dance_finished(tap_dance_state_t *state, void *user_data) {
/* If a key is pressed before the TAPPING_TERM delay, consider a
* tap instead of switching to the mod.
*/
- if (state->interrupted && is_blocking_keycode(state->interrupting_keycode)) {
+ if (state->interrupted) {
tap_hold_dance->held = tap_hold_dance->tap;
} else {
tap_hold_dance->held = tap_hold_dance->hold;
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/tap_hold_dance.h b/qmk/keyboards/sofle_choc/keymaps/custom/tap_hold_dance.h
index 4c895d5..67fb332 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/tap_hold_dance.h
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/tap_hold_dance.h
@@ -7,7 +7,6 @@ typedef struct {
const uint16_t tap;
const uint16_t hold;
uint16_t held;
- bool left;
} tap_hold_dance_t;
void tap_hold_dance_each(tap_dance_state_t *state, void *user_data);
@@ -17,9 +16,9 @@ void tap_hold_dance_released(tap_dance_state_t *state, void *user_data);
void tap_hold_dance_process_record(uint16_t keycode, keyrecord_t *record);
uint16_t tap_hold_dance_tapping_term(uint16_t keycode, keyrecord_t *record);
-#define ACTION_TAP_HOLD_DANCE(tap, hold, left) \
+#define ACTION_TAP_HOLD_DANCE(tap, hold) \
{ \
.fn = {NULL, tap_hold_dance_finished, tap_hold_dance_reset, tap_hold_dance_released}, \
- .user_data = (void *)&((tap_hold_dance_t){TD_NONE, tap, hold, 0, 0}), \
+ .user_data = (void *)&((tap_hold_dance_t){TD_NONE, tap, hold, 0}), \
}