aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--keyboards/niu_mini/keymaps/xtonhasvim/keymap.c10
-rw-r--r--users/xtonhasvim/xtonhasvim.c43
2 files changed, 25 insertions, 28 deletions
diff --git a/keyboards/niu_mini/keymaps/xtonhasvim/keymap.c b/keyboards/niu_mini/keymaps/xtonhasvim/keymap.c
index f591786b8..6c17df52a 100644
--- a/keyboards/niu_mini/keymaps/xtonhasvim/keymap.c
+++ b/keyboards/niu_mini/keymaps/xtonhasvim/keymap.c
@@ -152,16 +152,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};
-bool process_record_user(uint16_t keycode, keyrecord_t *record) {
- if(process_record_xtonhasvim(keycode, record)) {
- // do nothing so far
- return true;
- } else {
- // already handled by vim
- return false;
- }
-}
-
/** Set just 4 LEDs closest to the user. Slightly less annoying to bystanders.*/
void rgbflag(uint8_t r, uint8_t g, uint8_t b) {
for(int i = 0; i < RGBLED_NUM; i++){
diff --git a/users/xtonhasvim/xtonhasvim.c b/users/xtonhasvim/xtonhasvim.c
index 85048401d..0ec331b68 100644
--- a/users/xtonhasvim/xtonhasvim.c
+++ b/users/xtonhasvim/xtonhasvim.c
@@ -53,24 +53,17 @@ static void ALT(uint16_t keycode) {
}
-uint16_t vstate = VIM_START;
-bool yank_was_lines = false;
-bool SHIFTED = false;
-uint32_t mod_override_layer_state = 0;
-uint16_t mod_override_triggering_key = 0;
-bool do_check_kb_clear = false;
+static uint16_t vstate = VIM_START;
+static bool yank_was_lines = false;
+static bool SHIFTED = false;
+static uint32_t mod_override_layer_state = 0;
+static uint16_t mod_override_triggering_key = 0;
-void vim_reset(void) {
- vstate = VIM_START;
- SHIFTED = false;
- yank_was_lines = false;
-}
-
-void edit(void) { vstate = VIM_START; layer_on(_EDIT); layer_off(_CMD); }
+static void edit(void) { vstate = VIM_START; layer_on(_EDIT); layer_off(_CMD); }
#define EDIT edit()
-void simple_movement(uint16_t keycode) {
+static void simple_movement(uint16_t keycode) {
switch(keycode) {
case VIM_B:
PRESS(KC_LALT);
@@ -109,18 +102,25 @@ void simple_movement(uint16_t keycode) {
}
}
-bool process_record_xtonhasvim(uint16_t keycode, keyrecord_t *record) {
+__attribute__ ((weak))
+bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
+ return true;
+}
+
+#define PASS_THRU process_record_keymap(keycode, record)
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if(record->event.pressed && layer_state_is(_CMD) && IS_MOD(keycode)) {
mod_override_layer_state = layer_state;
mod_override_triggering_key = keycode;
layer_clear();
- return true; // let the event fall through...
+ return PASS_THRU; // let the event fall through...
}
if(mod_override_layer_state && !record->event.pressed && keycode == mod_override_triggering_key) {
layer_state_set(mod_override_layer_state);
mod_override_layer_state = 0;
mod_override_triggering_key = 0;
- return true;
+ return PASS_THRU;
}
if (VIM_START <= keycode && keycode <= VIM_ESC) {
@@ -134,6 +134,13 @@ bool process_record_xtonhasvim(uint16_t keycode, keyrecord_t *record) {
// entry from anywhere
layer_on(_CMD);
vstate = VIM_START;
+
+ // reset state
+ yank_was_lines = false;
+ SHIFTED = false;
+ mod_override_layer_state = 0;
+ mod_override_triggering_key = 0;
+
return false;
}
switch(vstate) {
@@ -594,6 +601,6 @@ bool process_record_xtonhasvim(uint16_t keycode, keyrecord_t *record) {
}
return false;
} else {
- return true;
+ return PASS_THRU;
}
}