Add personal userspace, update keymaps (#4845)
* Add kbd6x:konstantin keymap * Prevent tap dance from sending LShift as a weak mod in KBD6X * Move config.h and rules.mk definitions into userspace * Add UC_WIN to UNICODE_SELECTED_MODES * Temporarily use Bootmagic until Command is fixed * Move common behavior from keyboards into userspace * Update kbd6x:konstantin keymap and userspace * Make a RCTRL layer in kbd6x:konstantin * Make KC_ESC turn off layers * KC_ESC turns L_FN off only if it was locked on * Add missing record->event.pressed checks * Move numpad toggling logic into function * Disable Bootmagic, enable KEYBOARD_SHARED_EP with Command
This commit is contained in:
		
							parent
							
								
									ee96b7a89d
								
							
						
					
					
						commit
						9105bf2434
					
				
					 13 changed files with 400 additions and 169 deletions
				
			
		
							
								
								
									
										24
									
								
								users/konstantin/config.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								users/konstantin/config.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,24 @@
 | 
			
		|||
#pragma once
 | 
			
		||||
 | 
			
		||||
#define FORCE_NKRO
 | 
			
		||||
 | 
			
		||||
#define MAGIC_KEY_LAYER0_ALT1 BSLS
 | 
			
		||||
#define MAGIC_KEY_BOOTLOADER  ESC
 | 
			
		||||
 | 
			
		||||
#define MOUSEKEY_DELAY             50
 | 
			
		||||
#define MOUSEKEY_INTERVAL          15
 | 
			
		||||
#define MOUSEKEY_MAX_SPEED         4
 | 
			
		||||
#define MOUSEKEY_TIME_TO_MAX       50
 | 
			
		||||
#define MOUSEKEY_WHEEL_MAX_SPEED   1
 | 
			
		||||
#define MOUSEKEY_WHEEL_TIME_TO_MAX 50
 | 
			
		||||
 | 
			
		||||
#define NO_ACTION_FUNCTION
 | 
			
		||||
#define NO_ACTION_MACRO
 | 
			
		||||
 | 
			
		||||
#define PERMISSIVE_HOLD
 | 
			
		||||
#define TAPPING_TERM    200
 | 
			
		||||
#define TAPPING_TOGGLE  2
 | 
			
		||||
 | 
			
		||||
#define UNICODE_CYCLE_PERSIST  false
 | 
			
		||||
#define UNICODE_SELECTED_MODES UC_WINC, UC_WIN, UC_LNX
 | 
			
		||||
#define UNICODE_WINC_KEY       KC_RGUI
 | 
			
		||||
							
								
								
									
										77
									
								
								users/konstantin/konstantin.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								users/konstantin/konstantin.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,77 @@
 | 
			
		|||
#include "konstantin.h"
 | 
			
		||||
 | 
			
		||||
#ifdef LAYER_NUMPAD
 | 
			
		||||
static void toggle_numpad(void) {
 | 
			
		||||
  layer_invert(L_NUMPAD);
 | 
			
		||||
  bool num_lock = host_keyboard_leds() & 1<<USB_LED_NUM_LOCK;
 | 
			
		||||
  if (num_lock != (bool)IS_LAYER_ON(L_NUMPAD)) {
 | 
			
		||||
    tap_code(KC_NLCK); // Toggle Num Lock to match layer state
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
__attribute__((weak))
 | 
			
		||||
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
 | 
			
		||||
  if (!process_record_keymap(keycode, record)) {
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  switch (keycode) {
 | 
			
		||||
  case CLEAR:
 | 
			
		||||
    if (record->event.pressed) {
 | 
			
		||||
      SEND_STRING(SS_LCTRL("a") SS_TAP(X_DELETE));
 | 
			
		||||
    }
 | 
			
		||||
    return false;
 | 
			
		||||
 | 
			
		||||
#ifdef LAYER_FN
 | 
			
		||||
  static bool fn_lock;
 | 
			
		||||
 | 
			
		||||
  case FN_FNLK:
 | 
			
		||||
    if (record->event.pressed && record->tap.count == TAPPING_TOGGLE) {
 | 
			
		||||
      fn_lock = !IS_LAYER_ON(L_FN); // Fn layer will be toggled after this
 | 
			
		||||
    }
 | 
			
		||||
    return true;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef LAYER_NUMPAD
 | 
			
		||||
  case NUMPAD:
 | 
			
		||||
    if (record->event.pressed) {
 | 
			
		||||
      toggle_numpad();
 | 
			
		||||
    }
 | 
			
		||||
    return false;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  case KC_ESC:
 | 
			
		||||
    if (record->event.pressed) {
 | 
			
		||||
#ifdef LAYER_NUMPAD
 | 
			
		||||
      if (IS_LAYER_ON(L_NUMPAD)) {
 | 
			
		||||
        toggle_numpad();
 | 
			
		||||
        return false;
 | 
			
		||||
      }
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef LAYER_FN
 | 
			
		||||
      if (IS_LAYER_ON(L_FN) && fn_lock) {
 | 
			
		||||
        layer_off(L_FN);
 | 
			
		||||
        return fn_lock = false;
 | 
			
		||||
      }
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
    return true;
 | 
			
		||||
 | 
			
		||||
  default:
 | 
			
		||||
    return true;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
__attribute__((weak))
 | 
			
		||||
uint32_t layer_state_set_keymap(uint32_t state) {
 | 
			
		||||
  return state;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint32_t layer_state_set_user(uint32_t state) {
 | 
			
		||||
  return layer_state_set_keymap(state);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										50
									
								
								users/konstantin/konstantin.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								users/konstantin/konstantin.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,50 @@
 | 
			
		|||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "quantum.h"
 | 
			
		||||
#ifdef TAP_DANCE_ENABLE
 | 
			
		||||
  #include "tap_dance.h"
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef UNICODE_ENABLE
 | 
			
		||||
  #include "unicode.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef LAYER_FN
 | 
			
		||||
  #define FN      MO(L_FN)
 | 
			
		||||
  #define FN_CAPS LT(L_FN, KC_CAPS)
 | 
			
		||||
  #define FN_FNLK TT(L_FN)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define MV_UP   LCTL(KC_UP)
 | 
			
		||||
#define MV_DOWN LCTL(KC_DOWN)
 | 
			
		||||
#define MV_LEFT LCTL(KC_LEFT)
 | 
			
		||||
#define MV_RGHT LCTL(KC_RGHT)
 | 
			
		||||
#define TOP     LCTL(KC_HOME)
 | 
			
		||||
#define BOTTOM  LCTL(KC_END)
 | 
			
		||||
#define PRV_TAB LCTL(KC_PGUP)
 | 
			
		||||
#define NXT_TAB LCTL(KC_PGDN)
 | 
			
		||||
 | 
			
		||||
#define LCT_CPS LCTL_T(KC_CAPS)
 | 
			
		||||
 | 
			
		||||
enum keycodes_user {
 | 
			
		||||
  CLEAR = SAFE_RANGE,
 | 
			
		||||
#ifdef LAYER_NUMPAD
 | 
			
		||||
  NUMPAD,
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  RANGE_KEYMAP,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum layers_user {
 | 
			
		||||
  L_BASE,
 | 
			
		||||
#ifdef LAYER_FN
 | 
			
		||||
  L_FN,
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef LAYER_NUMPAD
 | 
			
		||||
  L_NUMPAD,
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  L_RANGE_KEYMAP,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
bool process_record_keymap(uint16_t keycode, keyrecord_t *record);
 | 
			
		||||
uint32_t layer_state_set_keymap(uint32_t state);
 | 
			
		||||
							
								
								
									
										16
									
								
								users/konstantin/rules.mk
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								users/konstantin/rules.mk
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,16 @@
 | 
			
		|||
BOOTMAGIC_ENABLE   = no
 | 
			
		||||
COMMAND_ENABLE     = yes
 | 
			
		||||
CONSOLE_ENABLE     = yes
 | 
			
		||||
EXTRAKEY_ENABLE    = yes
 | 
			
		||||
KEYBOARD_SHARED_EP = yes # TODO: Disable once Command is fixed
 | 
			
		||||
MOUSEKEY_ENABLE    = yes
 | 
			
		||||
NKRO_ENABLE        = yes
 | 
			
		||||
TAP_DANCE_ENABLE   = yes
 | 
			
		||||
UNICODE_ENABLE     = yes
 | 
			
		||||
 | 
			
		||||
SRC += konstantin.c
 | 
			
		||||
ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
 | 
			
		||||
  SRC += tap_dance.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
EXTRAFLAGS += -flto
 | 
			
		||||
							
								
								
									
										93
									
								
								users/konstantin/tap_dance.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								users/konstantin/tap_dance.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,93 @@
 | 
			
		|||
#include "tap_dance.h"
 | 
			
		||||
#include "konstantin.h"
 | 
			
		||||
 | 
			
		||||
#define ACTION_TAP_DANCE_DOUBLE_MODS(mod1, mod2) { \
 | 
			
		||||
    .fn = { td_double_mods_each, NULL, td_double_mods_reset }, \
 | 
			
		||||
    .user_data = &(qk_tap_dance_pair_t){ mod1, mod2 }, \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
void td_double_mods_each(qk_tap_dance_state_t *state, void *user_data) {
 | 
			
		||||
  qk_tap_dance_pair_t *mods = (qk_tap_dance_pair_t *)user_data;
 | 
			
		||||
  // Single tap → mod1, double tap → mod2, triple tap etc. → mod1+mod2
 | 
			
		||||
  if (state->count == 1 || state->count == 3) {
 | 
			
		||||
    register_code(mods->kc1);
 | 
			
		||||
  } else if (state->count == 2) {
 | 
			
		||||
    unregister_code(mods->kc1);
 | 
			
		||||
    register_code(mods->kc2);
 | 
			
		||||
  }
 | 
			
		||||
  // Prevent tap dance from sending kc1 and kc2 as weak mods
 | 
			
		||||
  state->weak_mods &= ~(MOD_BIT(mods->kc1) | MOD_BIT(mods->kc2));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void td_double_mods_reset(qk_tap_dance_state_t *state, void *user_data) {
 | 
			
		||||
  qk_tap_dance_pair_t *mods = (qk_tap_dance_pair_t *)user_data;
 | 
			
		||||
  if (state->count == 1 || state->count >= 3) {
 | 
			
		||||
    unregister_code(mods->kc1);
 | 
			
		||||
  }
 | 
			
		||||
  if (state->count >= 2) {
 | 
			
		||||
    unregister_code(mods->kc2);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct {
 | 
			
		||||
  bool fn_on; // Layer state when tap dance started
 | 
			
		||||
  bool started;
 | 
			
		||||
} td_fn_rctrl_data;
 | 
			
		||||
 | 
			
		||||
void td_fn_rctrl_each(qk_tap_dance_state_t *state, void *user_data) {
 | 
			
		||||
  if (!td_fn_rctrl_data.started) {
 | 
			
		||||
    td_fn_rctrl_data.fn_on = IS_LAYER_ON(L_FN);
 | 
			
		||||
    td_fn_rctrl_data.started = true;
 | 
			
		||||
  }
 | 
			
		||||
  // Single tap → Fn, double tap → RCtrl, triple tap etc. → Fn+RCtrl
 | 
			
		||||
  if (state->count == 1 || state->count == 3) {
 | 
			
		||||
    layer_on(L_FN);
 | 
			
		||||
  } else if (state->count == 2) {
 | 
			
		||||
    if (!td_fn_rctrl_data.fn_on) {
 | 
			
		||||
      layer_off(L_FN);
 | 
			
		||||
    }
 | 
			
		||||
    register_code(KC_RCTL);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void td_fn_rctrl_reset(qk_tap_dance_state_t *state, void *user_data) {
 | 
			
		||||
  if ((state->count == 1 || state->count >= 3) && !td_fn_rctrl_data.fn_on) {
 | 
			
		||||
    layer_off(L_FN);
 | 
			
		||||
  }
 | 
			
		||||
  if (state->count >= 2) {
 | 
			
		||||
    unregister_code(KC_RCTL);
 | 
			
		||||
  }
 | 
			
		||||
  td_fn_rctrl_data.started = false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void td_lsft_fn_each(qk_tap_dance_state_t *state, void *user_data) {
 | 
			
		||||
  // Single tap → LShift, double tap → Fn, triple tap etc. → Fn+LShift
 | 
			
		||||
  if (state->count == 1 || state->count == 3) {
 | 
			
		||||
    register_code(KC_LSFT);
 | 
			
		||||
  } else if (state->count == 2) {
 | 
			
		||||
    unregister_code(KC_LSFT);
 | 
			
		||||
    // Prevent tap dance from sending LShift as a weak mod
 | 
			
		||||
    state->weak_mods &= ~MOD_BIT(KC_LSFT);
 | 
			
		||||
    layer_on(L_FN);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void td_lsft_fn_reset(qk_tap_dance_state_t *state, void *user_data) {
 | 
			
		||||
  if (state->count == 1 || state->count >= 3) {
 | 
			
		||||
    unregister_code(KC_LSFT);
 | 
			
		||||
  }
 | 
			
		||||
  if (state->count >= 2) {
 | 
			
		||||
    layer_off(L_FN);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
qk_tap_dance_action_t tap_dance_actions[] = {
 | 
			
		||||
  [TD_DESKTOP] = ACTION_TAP_DANCE_DOUBLE(LCTL(LGUI(KC_D)), LCTL(LGUI(KC_F4))), // Add/close virtual desktop
 | 
			
		||||
 | 
			
		||||
  [TD_RAL_LAL] = ACTION_TAP_DANCE_DOUBLE_MODS(KC_RALT, KC_LALT),
 | 
			
		||||
  [TD_RAL_RGU] = ACTION_TAP_DANCE_DOUBLE_MODS(KC_RALT, KC_RGUI),
 | 
			
		||||
  [TD_RCT_RSF] = ACTION_TAP_DANCE_DOUBLE_MODS(KC_RCTL, KC_RSFT),
 | 
			
		||||
 | 
			
		||||
  [TD_FN_RCTL] = ACTION_TAP_DANCE_FN_ADVANCED(td_fn_rctrl_each, NULL, td_fn_rctrl_reset),
 | 
			
		||||
  [TD_LSFT_FN] = ACTION_TAP_DANCE_FN_ADVANCED(td_lsft_fn_each, NULL, td_lsft_fn_reset),
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										25
									
								
								users/konstantin/tap_dance.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								users/konstantin/tap_dance.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,25 @@
 | 
			
		|||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "quantum.h"
 | 
			
		||||
 | 
			
		||||
#define DESKTOP TD(TD_DESKTOP)
 | 
			
		||||
#define DSKTP_L LCTL(LGUI(KC_LEFT))
 | 
			
		||||
#define DSKTP_R LCTL(LGUI(KC_RGHT))
 | 
			
		||||
 | 
			
		||||
#define RAL_LAL TD(TD_RAL_LAL)
 | 
			
		||||
#define RAL_RGU TD(TD_RAL_RGU)
 | 
			
		||||
#define RCT_RSF TD(TD_RCT_RSF)
 | 
			
		||||
 | 
			
		||||
#define FN_RCTL TD(TD_FN_RCTL)
 | 
			
		||||
#define LSFT_FN TD(TD_LSFT_FN)
 | 
			
		||||
 | 
			
		||||
enum tap_dance {
 | 
			
		||||
  TD_DESKTOP,
 | 
			
		||||
 | 
			
		||||
  TD_RAL_LAL,
 | 
			
		||||
  TD_RAL_RGU,
 | 
			
		||||
  TD_RCT_RSF,
 | 
			
		||||
 | 
			
		||||
  TD_FN_RCTL,
 | 
			
		||||
  TD_LSFT_FN,
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										11
									
								
								users/konstantin/unicode.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								users/konstantin/unicode.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,11 @@
 | 
			
		|||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "quantum.h"
 | 
			
		||||
 | 
			
		||||
#define COMMA   UC(0x002C)
 | 
			
		||||
#define L_PAREN UC(0x0028)
 | 
			
		||||
#define R_PAREN UC(0x0029)
 | 
			
		||||
#define EQUALS  UC(0x003D)
 | 
			
		||||
#define TIMES   UC(0x00D7)
 | 
			
		||||
#define DIVIDE  UC(0x00F7)
 | 
			
		||||
#define MINUS   UC(0x2212)
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue