Skip to content

Commit

Permalink
Switch to CAPS_WORD from upstream.
Browse files Browse the repository at this point in the history
No need to keep this custom implementation now that QMK has merged
qmk#16588
  • Loading branch information
yaunj committed Aug 22, 2022
1 parent 772b2f6 commit 4355f0d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 78 deletions.
2 changes: 2 additions & 0 deletions users/yaunj/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#undef MANUFACTURER
#define MANUFACTURER yaunj

#define BOTH_SHIFTS_TURNS_ON_CAPS_WORD

// Global tapping term (default: 200)
#ifndef TAPPING_TERM
#define TAPPING_TERM 200
Expand Down
4 changes: 4 additions & 0 deletions users/yaunj/rules.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# always want these
CAPS_WORD_ENABLE = yes
EXTRAKEY_ENABLE = yes

SRC += yaunj.c

ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
Expand Down
77 changes: 0 additions & 77 deletions users/yaunj/yaunj.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,90 +15,13 @@

#include "yaunj.h"

// CAPS_WORD: A "smart" Caps Lock key that only capitalizes the next identifier you type
// and then toggles off Caps Lock automatically when you're done.
bool caps_word_on = false;

void caps_word_enable(void) {
caps_word_on = true;
if (!(host_keyboard_led_state().caps_lock)) {
tap_code(KC_CAPS);
}
}

void caps_word_disable(void) {
caps_word_on = false;
if (host_keyboard_led_state().caps_lock) {
tap_code(KC_CAPS);
}
}

void process_caps_word(uint16_t keycode, const keyrecord_t *record) {
// Update caps word state
if (caps_word_on) {
switch (keycode) {
case QK_MOD_TAP ... QK_MOD_TAP_MAX:
case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
// Earlier return if this has not been considered tapped yet
if (record->tap.count == 0) { return; }
// Get the base tapping keycode of a mod- or layer-tap key
keycode = keycode & 0xFF;
break;
default:
break;
}

switch (keycode) {
// Keycodes to shift
case KC_A ... KC_Z:
if (record->event.pressed) {
caps_word_enable();
}
// Keycodes that enable caps word but shouldn't get shifted
case KC_MINS:
case KC_BSPC:
case KC_UNDS:
case LOWER:
case RAISE:
case KC_F24: /* The dummy keycode used in NAV_UND */
case CAPS_WORD:
// If chording mods, disable caps word
if (record->event.pressed && (get_mods() != MOD_LSFT) && (get_mods() != 0)) {
caps_word_disable();
}
break;
default:
// Any other keycode should automatically disable caps
if (record->event.pressed) {
caps_word_disable();
}
break;
}
}
}

__attribute__((weak))
bool process_record_yaunj(uint16_t keycode, keyrecord_t *record) {
return true;
}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
process_caps_word(keycode, record);

switch (keycode) {
case CAPS_WORD:
// Toggle `caps_word_on`
if (record->event.pressed) {
if (caps_word_on) {
caps_word_disable();
return false;
} else {
caps_word_enable();
return false;
}
}
break;

case QWERTY:
if (record->event.pressed) {
print("mode just switched to qwerty and this is a huge string\n");
Expand Down
1 change: 0 additions & 1 deletion users/yaunj/yaunj.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ enum yaunj_layers {
enum yaunj_keycodes {
QWERTY = SAFE_RANGE,
COLEMAK,
CAPS_WORD,
NEW_SAFE_RANGE,
};

Expand Down

0 comments on commit 4355f0d

Please sign in to comment.