Keymap: Refactor edvorakjp user library (#4480)
* Refactor edvorakjp user library * add tap dance support * update keymaps * edvorakjp: add SWAP_SCLN option * fix behavior of SWAP_SCLN
This commit is contained in:
parent
0031e46191
commit
f3ffd6ad50
@ -4,6 +4,7 @@
|
|||||||
#undef TAPPING_FORCE_HOLD
|
#undef TAPPING_FORCE_HOLD
|
||||||
#undef TAPPING_TERM
|
#undef TAPPING_TERM
|
||||||
#define TAPPING_TERM 120
|
#define TAPPING_TERM 120
|
||||||
|
#define SWAP_SCLN
|
||||||
|
|
||||||
// If you need more program area, try select and reduce rgblight modes to use.
|
// If you need more program area, try select and reduce rgblight modes to use.
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
|
|||||||
switch(keycode) {
|
switch(keycode) {
|
||||||
case KC_LOCK:
|
case KC_LOCK:
|
||||||
if (record->event.pressed) {
|
if (record->event.pressed) {
|
||||||
if (edvorakjp_config.enable_kc_lang) {
|
if (get_enable_kc_lang()) {
|
||||||
SEND_STRING( SS_LCTRL(SS_LSFT(SS_TAP(X_POWER))) );
|
SEND_STRING( SS_LCTRL(SS_LSFT(SS_TAP(X_POWER))) );
|
||||||
} else {
|
} else {
|
||||||
SEND_STRING( SS_LGUI("l") );
|
SEND_STRING( SS_LGUI("l") );
|
||||||
|
@ -5,7 +5,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||||||
|
|
||||||
[_EDVORAK] = LAYOUT_kc(
|
[_EDVORAK] = LAYOUT_kc(
|
||||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||||
LBRC,RBRC,COMM,DOT , P , Y , F , G , R , W , Q ,BSLS,
|
LBRC,RBRC,COMM,DOT , Y , P , F , G , R , W , Q ,BSLS,
|
||||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||||
EQL , A , O , E , I , U , D , T , N , S , M ,MINS,
|
EQL , A , O , E , I , U , D , T , N , S , M ,MINS,
|
||||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||||
|
@ -7,7 +7,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||||
GRV ,EXLM, AT ,HASH,DLR ,PERC, CIRC,AMPR,ASTR,LPRN,RPRN,BSPC,
|
GRV ,EXLM, AT ,HASH,DLR ,PERC, CIRC,AMPR,ASTR,LPRN,RPRN,BSPC,
|
||||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||||
LBRC,RBRC,COMM,DOT , P , Y , F , G , R , W , Q ,BSLS,
|
LBRC,RBRC,COMM,DOT , Y , P , F , G , R , W , Q ,BSLS,
|
||||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||||
EQL , A , O , E , I , U , D , T , N , S , M ,MINS,
|
EQL , A , O , E , I , U , D , T , N , S , M ,MINS,
|
||||||
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
|
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
|
||||||
|
@ -23,15 +23,10 @@ void render_status(struct CharacterMatrix *matrix) {
|
|||||||
|
|
||||||
// Render to mode icon
|
// Render to mode icon
|
||||||
static char logo[][2][3] = {{{0x95,0x96,0},{0xb5,0xb6,0}},{{0x97,0x98,0},{0xb7,0xb8,0}}};
|
static char logo[][2][3] = {{{0x95,0x96,0},{0xb5,0xb6,0}},{{0x97,0x98,0},{0xb7,0xb8,0}}};
|
||||||
if (edvorakjp_config.enable_kc_lang) {
|
int mode_number = get_enable_kc_lang() ? 0 : 1;
|
||||||
matrix_write(matrix, logo[0][0]);
|
matrix_write(matrix, logo[mode_number][0]);
|
||||||
matrix_write_P(matrix, PSTR("\n"));
|
matrix_write(matrix, "\n");
|
||||||
matrix_write(matrix, logo[0][1]);
|
matrix_write(matrix, logo[mode_number][1]);
|
||||||
} else {
|
|
||||||
matrix_write(matrix, logo[1][0]);
|
|
||||||
matrix_write_P(matrix, PSTR("\n"));
|
|
||||||
matrix_write(matrix, logo[1][1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below
|
// Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below
|
||||||
char buf[40];
|
char buf[40];
|
||||||
@ -63,7 +58,7 @@ void render_status(struct CharacterMatrix *matrix) {
|
|||||||
// Host Keyboard LED Status
|
// Host Keyboard LED Status
|
||||||
char led[40];
|
char led[40];
|
||||||
snprintf(led, sizeof(led), "\n%s %s %s %s",
|
snprintf(led, sizeof(led), "\n%s %s %s %s",
|
||||||
edvorakjp_config.enable_jp_extra_layer && japanese_mode ? "EXT" : " ",
|
get_enable_jp_extra_layer() && get_japanese_mode() ? "EXT" : " ",
|
||||||
(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NMLK" : " ",
|
(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NMLK" : " ",
|
||||||
(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
|
(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
|
||||||
(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
|
(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
|
||||||
|
@ -26,5 +26,6 @@
|
|||||||
#define MOUSEKEY_WHEEL_TIME_TO_MAX 20
|
#define MOUSEKEY_WHEEL_TIME_TO_MAX 20
|
||||||
|
|
||||||
#define TAPPING_TERM 120
|
#define TAPPING_TERM 120
|
||||||
|
#define SWAP_SCLN
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
#include QMK_KEYBOARD_H
|
#include QMK_KEYBOARD_H
|
||||||
#include "action_layer.h"
|
|
||||||
#include "eeconfig.h"
|
|
||||||
|
|
||||||
#include "edvorakjp.h"
|
#include "edvorakjp.h"
|
||||||
|
|
||||||
enum custom_keycodes {
|
enum custom_keycodes {
|
||||||
@ -32,7 +29,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||||
GRV ,EXLM, AT ,HASH,DLR ,PERC, CIRC,AMPR,ASTR,LPRN,RPRN,BSPC,
|
GRV ,EXLM, AT ,HASH,DLR ,PERC, CIRC,AMPR,ASTR,LPRN,RPRN,BSPC,
|
||||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||||
LBRC,RBRC,COMM,DOT , P , Y , F , G , R , W , Q ,BSLS,
|
LBRC,RBRC,COMM,DOT , Y , P , F , G , R , W , Q ,BSLS,
|
||||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||||
EQL , A , O , E , I , U , D , T , N , S , M ,MINS,
|
EQL , A , O , E , I , U , D , T , N , S , M ,MINS,
|
||||||
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
|
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
|
||||||
@ -134,7 +131,7 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
|
|||||||
switch(keycode) {
|
switch(keycode) {
|
||||||
case KC_LOCK:
|
case KC_LOCK:
|
||||||
if (record->event.pressed) {
|
if (record->event.pressed) {
|
||||||
if (edvorakjp_config.enable_kc_lang) {
|
if (get_enable_kc_lang()) {
|
||||||
SEND_STRING( SS_LCTRL(SS_LSFT(SS_TAP(X_POWER))) );
|
SEND_STRING( SS_LCTRL(SS_LSFT(SS_TAP(X_POWER))) );
|
||||||
} else {
|
} else {
|
||||||
SEND_STRING( SS_LGUI("l") );
|
SEND_STRING( SS_LGUI("l") );
|
||||||
|
@ -1,47 +1,12 @@
|
|||||||
#include "eeprom.h"
|
|
||||||
#include "edvorakjp.h"
|
#include "edvorakjp.h"
|
||||||
|
|
||||||
bool japanese_mode;
|
|
||||||
uint16_t time_on_pressed;
|
|
||||||
|
|
||||||
edvorakjp_config_t edvorakjp_config;
|
|
||||||
|
|
||||||
uint8_t eeconfig_read_edvorakjp(void) {
|
|
||||||
return eeprom_read_byte(EECONFIG_EDVORAK);
|
|
||||||
}
|
|
||||||
|
|
||||||
void eeconfig_update_edvorakjp(uint8_t val) {
|
|
||||||
eeprom_update_byte(EECONFIG_EDVORAK, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void dvorakj_layer_off(void) {
|
void dvorakj_layer_off(void) {
|
||||||
layer_off(_EDVORAKJ1);
|
layer_off(_EDVORAKJ1);
|
||||||
layer_off(_EDVORAKJ2);
|
layer_off(_EDVORAKJ2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_japanese_mode(bool new_state) {
|
|
||||||
japanese_mode = new_state;
|
|
||||||
if (japanese_mode) {
|
|
||||||
if (edvorakjp_config.enable_kc_lang) {
|
|
||||||
SEND_STRING(SS_TAP(X_LANG1));
|
|
||||||
} else {
|
|
||||||
SEND_STRING(SS_LALT("`"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
dvorakj_layer_off();
|
|
||||||
if (edvorakjp_config.enable_kc_lang) {
|
|
||||||
SEND_STRING(SS_TAP(X_LANG2));
|
|
||||||
} else {
|
|
||||||
SEND_STRING(SS_LALT("`"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void matrix_init_user(void) {
|
void matrix_init_user(void) {
|
||||||
japanese_mode = false;
|
edvorakjp_status_init();
|
||||||
time_on_pressed = 0;
|
|
||||||
edvorakjp_config.raw = eeconfig_read_edvorakjp();
|
|
||||||
|
|
||||||
matrix_init_keymap();
|
matrix_init_keymap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,189 +23,16 @@ uint32_t layer_state_set_keymap(uint32_t state) {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Each process_record_* methods defined here are
|
|
||||||
* return false if handle edvorak_keycodes, or return true others.
|
|
||||||
*/
|
|
||||||
__attribute__ ((weak))
|
|
||||||
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool process_record_edvorakjp_ext(uint16_t keycode, keyrecord_t *record) {
|
|
||||||
if (!(edvorakjp_config.enable_jp_extra_layer &&\
|
|
||||||
(default_layer_state == 1UL<<_EDVORAK) &&\
|
|
||||||
japanese_mode &&\
|
|
||||||
record->event.pressed)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// consonant keys
|
|
||||||
// layer_on(J1) or layer_on(J2) are defined based on key positions.
|
|
||||||
switch (keycode) {
|
|
||||||
// right hand's left side w/o N
|
|
||||||
case KC_F:
|
|
||||||
case KC_G:
|
|
||||||
case KC_R:
|
|
||||||
case KC_D:
|
|
||||||
case KC_T:
|
|
||||||
case KC_B:
|
|
||||||
case KC_H:
|
|
||||||
case KC_J:
|
|
||||||
layer_on(_EDVORAKJ1);
|
|
||||||
register_code(keycode);
|
|
||||||
unregister_code(keycode);
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// N: toggle layer
|
|
||||||
case KC_N:
|
|
||||||
biton32(layer_state) == _EDVORAK ? layer_on(_EDVORAKJ1) : dvorakj_layer_off();
|
|
||||||
register_code(keycode);
|
|
||||||
unregister_code(keycode);
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// left hand and right hand's right side
|
|
||||||
case KC_X:
|
|
||||||
case KC_C:
|
|
||||||
case KC_V:
|
|
||||||
case KC_Z:
|
|
||||||
case KC_P:
|
|
||||||
case KC_Y:
|
|
||||||
case KC_W:
|
|
||||||
case KC_Q:
|
|
||||||
case KC_S:
|
|
||||||
case KC_M:
|
|
||||||
case KC_K:
|
|
||||||
case KC_L:
|
|
||||||
layer_on(_EDVORAKJ2);
|
|
||||||
register_code(keycode);
|
|
||||||
unregister_code(keycode);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// vowel keys, symbol keys and modifier keys
|
|
||||||
dvorakj_layer_off();
|
|
||||||
switch (keycode) {
|
|
||||||
// combination vowel keys
|
|
||||||
case KC_AI:
|
|
||||||
SEND_STRING("ai");
|
|
||||||
return false;
|
|
||||||
case KC_OU:
|
|
||||||
SEND_STRING("ou");
|
|
||||||
return false;
|
|
||||||
case KC_EI:
|
|
||||||
SEND_STRING("ei");
|
|
||||||
return false;
|
|
||||||
case KC_ANN:
|
|
||||||
SEND_STRING("ann");
|
|
||||||
return false;
|
|
||||||
case KC_ONN:
|
|
||||||
SEND_STRING("onn");
|
|
||||||
return false;
|
|
||||||
case KC_ENN:
|
|
||||||
SEND_STRING("enn");
|
|
||||||
return false;
|
|
||||||
case KC_INN:
|
|
||||||
SEND_STRING("inn");
|
|
||||||
return false;
|
|
||||||
case KC_UNN:
|
|
||||||
SEND_STRING("unn");
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// AOEIU and other (symbol, modifier) keys
|
|
||||||
default:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool process_record_edvorakjp_config(uint16_t keycode, keyrecord_t *record) {
|
|
||||||
switch (keycode) {
|
|
||||||
case KC_MAC:
|
|
||||||
edvorakjp_config.enable_kc_lang = true;
|
|
||||||
eeconfig_update_edvorakjp(edvorakjp_config.raw);
|
|
||||||
return false;
|
|
||||||
case KC_WIN:
|
|
||||||
edvorakjp_config.enable_kc_lang = false;
|
|
||||||
eeconfig_update_edvorakjp(edvorakjp_config.raw);
|
|
||||||
return false;
|
|
||||||
case KC_EXTON:
|
|
||||||
edvorakjp_config.enable_jp_extra_layer = true;
|
|
||||||
eeconfig_update_edvorakjp(edvorakjp_config.raw);
|
|
||||||
return false;
|
|
||||||
case KC_EXTOFF:
|
|
||||||
edvorakjp_config.enable_jp_extra_layer = false;
|
|
||||||
eeconfig_update_edvorakjp(edvorakjp_config.raw);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool process_record_layer(uint16_t keycode, keyrecord_t *record) {
|
|
||||||
switch (keycode) {
|
|
||||||
case EDVORAK:
|
|
||||||
if (record->event.pressed) {
|
|
||||||
set_single_persistent_default_layer(_EDVORAK);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
case QWERTY:
|
|
||||||
if (record->event.pressed) {
|
|
||||||
dvorakj_layer_off();
|
|
||||||
set_single_persistent_default_layer(_QWERTY);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
case LOWER:
|
|
||||||
if (record->event.pressed) {
|
|
||||||
layer_on(_LOWER);
|
|
||||||
time_on_pressed = record->event.time;
|
|
||||||
} else {
|
|
||||||
layer_off(_LOWER);
|
|
||||||
|
|
||||||
if (TIMER_DIFF_16(record->event.time, time_on_pressed) < TAPPING_TERM) {
|
|
||||||
update_japanese_mode(false);
|
|
||||||
}
|
|
||||||
time_on_pressed = 0;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
case RAISE:
|
|
||||||
if (record->event.pressed) {
|
|
||||||
layer_on(_RAISE);
|
|
||||||
time_on_pressed = record->event.time;
|
|
||||||
} else {
|
|
||||||
layer_off(_RAISE);
|
|
||||||
|
|
||||||
if (TIMER_DIFF_16(record->event.time, time_on_pressed) < TAPPING_TERM) {
|
|
||||||
update_japanese_mode(true);
|
|
||||||
}
|
|
||||||
time_on_pressed = 0;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
default:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool process_record_ime(uint16_t keycode, keyrecord_t *record) {
|
|
||||||
switch (keycode) {
|
|
||||||
case KC_JPN:
|
|
||||||
if (record->event.pressed) {
|
|
||||||
update_japanese_mode(true);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
case KC_ENG:
|
|
||||||
if (record->event.pressed) {
|
|
||||||
update_japanese_mode(false);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
default:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
|
||||||
return process_record_keymap(keycode, record) &&\
|
return process_record_keymap(keycode, record) &&\
|
||||||
process_record_edvorakjp_ext(keycode, record) &&\
|
process_record_edvorakjp_ext(keycode, record) &&\
|
||||||
|
process_record_edvorakjp_swap_scln(keycode, record) &&\
|
||||||
process_record_edvorakjp_config(keycode, record) &&\
|
process_record_edvorakjp_config(keycode, record) &&\
|
||||||
process_record_layer(keycode, record) &&\
|
process_record_layer(keycode, record) &&\
|
||||||
process_record_ime(keycode, record);
|
process_record_ime(keycode, record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__attribute__ ((weak))
|
||||||
|
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef USERSPACE
|
#ifndef EDVORAKJP
|
||||||
#define USERSPACE
|
#define EDVORAKJP
|
||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
#include "action_layer.h"
|
#include "action_layer.h"
|
||||||
@ -8,15 +8,6 @@
|
|||||||
|
|
||||||
extern keymap_config_t keymap_config;
|
extern keymap_config_t keymap_config;
|
||||||
|
|
||||||
typedef union {
|
|
||||||
uint8_t raw;
|
|
||||||
struct {
|
|
||||||
bool enable_jp_extra_layer : 1;
|
|
||||||
bool enable_kc_lang : 1; // for macOS
|
|
||||||
};
|
|
||||||
} edvorakjp_config_t;
|
|
||||||
extern edvorakjp_config_t edvorakjp_config;
|
|
||||||
|
|
||||||
enum edvorakjp_layers {
|
enum edvorakjp_layers {
|
||||||
_EDVORAK = 0,
|
_EDVORAK = 0,
|
||||||
_EDVORAKJ1,
|
_EDVORAKJ1,
|
||||||
@ -50,26 +41,38 @@ enum edvorakjp_keycodes {
|
|||||||
NEW_SAFE_RANGE
|
NEW_SAFE_RANGE
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t eeconfig_read_edvorakjp(void);
|
enum tap_dance_code {
|
||||||
void eeconfig_update_edvorakjp(uint8_t val);
|
TD_LOWER = 0,
|
||||||
|
TD_RAISE
|
||||||
|
};
|
||||||
|
|
||||||
|
// base
|
||||||
void dvorakj_layer_off(void);
|
void dvorakj_layer_off(void);
|
||||||
void update_japanese_mode(bool new_state);
|
|
||||||
void matrix_init_user(void);
|
void matrix_init_user(void);
|
||||||
void matrix_init_keymap(void);
|
void matrix_init_keymap(void);
|
||||||
uint32_t layer_state_set_user(uint32_t state);
|
uint32_t layer_state_set_user(uint32_t state);
|
||||||
uint32_t layer_state_set_keymap(uint32_t state);
|
uint32_t layer_state_set_keymap(uint32_t state);
|
||||||
|
bool process_record_user(uint16_t keycode, keyrecord_t *record);
|
||||||
|
bool process_record_keymap(uint16_t keycode, keyrecord_t *record);
|
||||||
|
|
||||||
|
// status
|
||||||
|
void edvorakjp_status_init(void);
|
||||||
|
bool get_enable_jp_extra_layer(void);
|
||||||
|
void set_enable_jp_extra_layer(bool new_state);
|
||||||
|
bool get_enable_kc_lang(void);
|
||||||
|
void set_enable_kc_lang(bool new_state);
|
||||||
|
bool get_japanese_mode(void);
|
||||||
|
void set_japanese_mode(bool new_state);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Each process_record_* methods defined here are
|
* Each process_record_* methods defined here are
|
||||||
* return false if processed, or return true if not processed.
|
* return false if processed, or return true if not processed.
|
||||||
* You can add your original macros in process_record_keymap() in keymap.c.
|
* You can add your original macros in process_record_keymap() in keymap.c.
|
||||||
*/
|
*/
|
||||||
bool process_record_keymap(uint16_t keycode, keyrecord_t *record);
|
|
||||||
bool process_record_edvorakjp_ext(uint16_t keycode, keyrecord_t *record);
|
bool process_record_edvorakjp_ext(uint16_t keycode, keyrecord_t *record);
|
||||||
|
bool process_record_edvorakjp_swap_scln(uint16_t keycode, keyrecord_t *record);
|
||||||
bool process_record_edvorakjp_config(uint16_t keycode, keyrecord_t *record);
|
bool process_record_edvorakjp_config(uint16_t keycode, keyrecord_t *record);
|
||||||
bool process_record_layer(uint16_t keycode, keyrecord_t *record);
|
bool process_record_layer(uint16_t keycode, keyrecord_t *record);
|
||||||
bool process_record_ime(uint16_t keycode, keyrecord_t *record);
|
bool process_record_ime(uint16_t keycode, keyrecord_t *record);
|
||||||
bool process_record_user(uint16_t keycode, keyrecord_t *record);
|
|
||||||
|
|
||||||
#endif
|
#endif // EDVORAKJP
|
||||||
|
206
users/edvorakjp/edvorakjp_process_record.c
Normal file
206
users/edvorakjp/edvorakjp_process_record.c
Normal file
@ -0,0 +1,206 @@
|
|||||||
|
#include "edvorakjp.h"
|
||||||
|
|
||||||
|
#if TAP_DANCE_ENABLE != yes
|
||||||
|
static uint16_t time_on_pressed;
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* Each process_record_* methods defined here are
|
||||||
|
* return false if handle edvorak_keycodes, or return true others.
|
||||||
|
*/
|
||||||
|
bool process_record_edvorakjp_ext(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
if (!(default_layer_state == 1UL<<_EDVORAK &&
|
||||||
|
get_enable_jp_extra_layer() && get_japanese_mode())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// consonant keys
|
||||||
|
// layer_on(J1) or layer_on(J2) are defined based on key positions.
|
||||||
|
switch (keycode) {
|
||||||
|
// right hand's left side w/o N
|
||||||
|
case KC_F:
|
||||||
|
case KC_G:
|
||||||
|
case KC_R:
|
||||||
|
case KC_D:
|
||||||
|
case KC_T:
|
||||||
|
case KC_B:
|
||||||
|
case KC_H:
|
||||||
|
case KC_J:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
layer_on(_EDVORAKJ1);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// N: toggle layer
|
||||||
|
case KC_N:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
biton32(layer_state) == _EDVORAK ? layer_on(_EDVORAKJ1) : dvorakj_layer_off();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// left hand and right hand's right side
|
||||||
|
case KC_X:
|
||||||
|
case KC_C:
|
||||||
|
case KC_V:
|
||||||
|
case KC_Z:
|
||||||
|
case KC_Y:
|
||||||
|
case KC_P:
|
||||||
|
case KC_W:
|
||||||
|
case KC_Q:
|
||||||
|
case KC_S:
|
||||||
|
case KC_M:
|
||||||
|
case KC_K:
|
||||||
|
case KC_L:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
layer_on(_EDVORAKJ2);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// vowel keys, symbol keys and modifier keys
|
||||||
|
if (record->event.pressed) {
|
||||||
|
dvorakj_layer_off();
|
||||||
|
}
|
||||||
|
switch (keycode) {
|
||||||
|
// combination vowel keys
|
||||||
|
case KC_AI:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
SEND_STRING("ai");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case KC_OU:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
SEND_STRING("ou");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case KC_EI:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
SEND_STRING("ei");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case KC_ANN:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
SEND_STRING("ann");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case KC_ONN:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
SEND_STRING("onn");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case KC_ENN:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
SEND_STRING("enn");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case KC_INN:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
SEND_STRING("inn");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case KC_UNN:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
SEND_STRING("unn");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// AOEIU and other (symbol, modifier) keys
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool process_record_edvorakjp_swap_scln(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
#ifdef SWAP_SCLN
|
||||||
|
static const uint8_t shift_bits = MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT);
|
||||||
|
static uint8_t last_mods_status;
|
||||||
|
if (keycode == KC_SCLN) {
|
||||||
|
if (record->event.pressed) {
|
||||||
|
last_mods_status = get_mods();
|
||||||
|
|
||||||
|
// invert shift_bits
|
||||||
|
if (last_mods_status & shift_bits) {
|
||||||
|
set_mods(last_mods_status & ~shift_bits);
|
||||||
|
} else {
|
||||||
|
set_mods(last_mods_status | MOD_BIT(KC_LSFT));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
set_mods(last_mods_status);
|
||||||
|
last_mods_status = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool process_record_edvorakjp_config(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
switch (keycode) {
|
||||||
|
case KC_MAC:
|
||||||
|
case KC_WIN:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
set_enable_kc_lang(keycode == KC_MAC);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case KC_EXTON:
|
||||||
|
case KC_EXTOFF:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
set_enable_jp_extra_layer(keycode == KC_EXTON);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool process_record_layer(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
switch (keycode) {
|
||||||
|
case EDVORAK:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
set_single_persistent_default_layer(_EDVORAK);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case QWERTY:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
dvorakj_layer_off();
|
||||||
|
set_single_persistent_default_layer(_QWERTY);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
#if TAP_DANCE_ENABLE != yes
|
||||||
|
case LOWER:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
layer_on(_LOWER);
|
||||||
|
time_on_pressed = record->event.time;
|
||||||
|
} else {
|
||||||
|
layer_off(_LOWER);
|
||||||
|
|
||||||
|
if (TIMER_DIFF_16(record->event.time, time_on_pressed) < TAPPING_TERM) {
|
||||||
|
set_japanese_mode(false);
|
||||||
|
}
|
||||||
|
time_on_pressed = 0;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case RAISE:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
layer_on(_RAISE);
|
||||||
|
time_on_pressed = record->event.time;
|
||||||
|
} else {
|
||||||
|
layer_off(_RAISE);
|
||||||
|
|
||||||
|
if (TIMER_DIFF_16(record->event.time, time_on_pressed) < TAPPING_TERM) {
|
||||||
|
set_japanese_mode(true);
|
||||||
|
}
|
||||||
|
time_on_pressed = 0;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool process_record_ime(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
switch (keycode) {
|
||||||
|
case KC_JPN:
|
||||||
|
case KC_ENG:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
set_japanese_mode(keycode == KC_JPN);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
75
users/edvorakjp/edvorakjp_status.c
Normal file
75
users/edvorakjp/edvorakjp_status.c
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
#include "eeprom.h"
|
||||||
|
#include "edvorakjp.h"
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
uint8_t raw;
|
||||||
|
struct {
|
||||||
|
bool enable_jp_extra_layer : 1;
|
||||||
|
bool enable_kc_lang : 1; // for macOS
|
||||||
|
};
|
||||||
|
} edvorakjp_config_t;
|
||||||
|
static edvorakjp_config_t edvorakjp_config;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
bool japanese_mode;
|
||||||
|
} edvorakjp_state_t;
|
||||||
|
static edvorakjp_state_t edvorakjp_state;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* private methods
|
||||||
|
*/
|
||||||
|
uint8_t eeconfig_read_edvorakjp(void) {
|
||||||
|
return eeprom_read_byte(EECONFIG_EDVORAK);
|
||||||
|
}
|
||||||
|
|
||||||
|
void eeconfig_update_edvorakjp(uint8_t val) {
|
||||||
|
eeprom_update_byte(EECONFIG_EDVORAK, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* public methods
|
||||||
|
*/
|
||||||
|
void edvorakjp_status_init(void) {
|
||||||
|
edvorakjp_state.japanese_mode = false;
|
||||||
|
edvorakjp_config.raw = eeconfig_read_edvorakjp();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get_enable_jp_extra_layer(void) {
|
||||||
|
return edvorakjp_config.enable_jp_extra_layer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_enable_jp_extra_layer(bool new_state) {
|
||||||
|
edvorakjp_config.enable_jp_extra_layer = new_state;
|
||||||
|
eeconfig_update_edvorakjp(edvorakjp_config.raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get_enable_kc_lang(void) {
|
||||||
|
return edvorakjp_config.enable_kc_lang;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_enable_kc_lang(bool new_state) {
|
||||||
|
edvorakjp_config.enable_kc_lang = new_state;
|
||||||
|
eeconfig_update_edvorakjp(edvorakjp_config.raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get_japanese_mode(void) {
|
||||||
|
return edvorakjp_state.japanese_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_japanese_mode(bool new_state) {
|
||||||
|
edvorakjp_state.japanese_mode = new_state;
|
||||||
|
if (edvorakjp_state.japanese_mode) {
|
||||||
|
if (edvorakjp_config.enable_kc_lang) {
|
||||||
|
SEND_STRING(SS_TAP(X_LANG1));
|
||||||
|
} else {
|
||||||
|
SEND_STRING(SS_LALT("`"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dvorakj_layer_off();
|
||||||
|
if (edvorakjp_config.enable_kc_lang) {
|
||||||
|
SEND_STRING(SS_TAP(X_LANG2));
|
||||||
|
} else {
|
||||||
|
SEND_STRING(SS_LALT("`"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
71
users/edvorakjp/edvorakjp_tap_dance.c
Normal file
71
users/edvorakjp/edvorakjp_tap_dance.c
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
#include "edvorakjp.h"
|
||||||
|
#include "process_keycode/process_tap_dance.h"
|
||||||
|
|
||||||
|
enum tap_state {
|
||||||
|
NONE = 0,
|
||||||
|
SINGLE_TAP = 1,
|
||||||
|
DOUBLE_TAP = 2,
|
||||||
|
HOLD
|
||||||
|
};
|
||||||
|
|
||||||
|
static int td_status_lower = NONE;
|
||||||
|
static int td_status_raise = NONE;
|
||||||
|
|
||||||
|
int cur_dance(qk_tap_dance_state_t *state) {
|
||||||
|
if (state->interrupted || !state->pressed) {
|
||||||
|
return state->count == 1 ? SINGLE_TAP : DOUBLE_TAP;
|
||||||
|
} else {
|
||||||
|
return HOLD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void td_lower_finished(qk_tap_dance_state_t *state, void *user_data) {
|
||||||
|
td_status_lower = cur_dance(state);
|
||||||
|
switch(td_status_lower) {
|
||||||
|
case SINGLE_TAP:
|
||||||
|
set_japanese_mode(false);
|
||||||
|
register_code(KC_ESC);
|
||||||
|
break;
|
||||||
|
case DOUBLE_TAP:
|
||||||
|
set_japanese_mode(false);
|
||||||
|
break;
|
||||||
|
case HOLD:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
layer_on(_LOWER);
|
||||||
|
}
|
||||||
|
|
||||||
|
void td_lower_reset(qk_tap_dance_state_t *state, void *user_data) {
|
||||||
|
if (td_status_lower == SINGLE_TAP) {
|
||||||
|
unregister_code(KC_ESC);
|
||||||
|
}
|
||||||
|
layer_off(_LOWER);
|
||||||
|
td_status_lower = NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void td_raise_finished(qk_tap_dance_state_t *state, void *user_data) {
|
||||||
|
td_status_raise = cur_dance(state);
|
||||||
|
switch(td_status_raise) {
|
||||||
|
case SINGLE_TAP:
|
||||||
|
case DOUBLE_TAP:
|
||||||
|
set_japanese_mode(true);
|
||||||
|
break;
|
||||||
|
case HOLD:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
layer_on(_RAISE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void td_raise_reset(qk_tap_dance_state_t *state, void *user_data) {
|
||||||
|
layer_off(_RAISE);
|
||||||
|
td_status_raise = NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
qk_tap_dance_action_t tap_dance_actions[] = {
|
||||||
|
[TD_LOWER] = ACTION_TAP_DANCE_FN_ADVANCED_TIME(
|
||||||
|
NULL, td_lower_finished, td_lower_reset, TAPPING_TERM * 1.5
|
||||||
|
),
|
||||||
|
[TD_RAISE] = ACTION_TAP_DANCE_FN_ADVANCED_TIME(
|
||||||
|
NULL, td_raise_finished, td_raise_reset, TAPPING_TERM * 1.5
|
||||||
|
)
|
||||||
|
};
|
@ -10,7 +10,7 @@ This is a sample. You can swap any symbol keys and modifier keys.
|
|||||||
//+----+----+----+----+----+----+----+----+----+----+----+----+----+---------+
|
//+----+----+----+----+----+----+----+----+----+----+----+----+----+---------+
|
||||||
` , ! , @ , # , $ , % , ^ , & , * , ( , ) , [ , ] , BSPC ,
|
` , ! , @ , # , $ , % , ^ , & , * , ( , ) , [ , ] , BSPC ,
|
||||||
//+----+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+-------+
|
//+----+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+-------+
|
||||||
TAB , ' , , , . , P , Y , F , G , R , W , Q , / , = , \ ,
|
TAB , ' , , , . , Y , P , F , G , R , W , Q , / , = , \ ,
|
||||||
//+------++---++---++---++---++---++---++---++---++---++---++---++---+-------+
|
//+------++---++---++---++---++---++---++---++---++---++---++---++---+-------+
|
||||||
CAPS , A , O , E , I , U , D , T , N , S , M , - , ENT ,
|
CAPS , A , O , E , I , U , D , T , N , S , M , - , ENT ,
|
||||||
//+-------+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-----------+
|
//+-------+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-----------+
|
||||||
@ -25,7 +25,7 @@ This is a sample. You can swap any symbol keys and modifier keys.
|
|||||||
//+----+----+----+----+----+----+----+----+----+----+----+----+----+---------+
|
//+----+----+----+----+----+----+----+----+----+----+----+----+----+---------+
|
||||||
` , ! , @ , # , $ , % , ^ , & , * , ( , ) , [ , ] , BSPC ,
|
` , ! , @ , # , $ , % , ^ , & , * , ( , ) , [ , ] , BSPC ,
|
||||||
//+----+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+-------+
|
//+----+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+-------+
|
||||||
TAB , ' , , , . , P , Y , F , G , R , W , C , / , = ,
|
TAB , ' , , , . , Y , P , F , G , R , W , C , / , = ,
|
||||||
//+------++---++---++---++---++---++---++---++---++---++---++---++---++
|
//+------++---++---++---++---++---++---++---++---++---++---++---++---++
|
||||||
CAPS , A , O , E , I , U , D , T , N , S , M , ; , - , ENT ,
|
CAPS , A , O , E , I , U , D , T , N , S , M , ; , - , ENT ,
|
||||||
//+-------+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+------+
|
//+-------+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+------+
|
||||||
@ -78,11 +78,15 @@ This is a sample. You can swap any symbol keys and modifier keys.
|
|||||||
## for Programmer
|
## for Programmer
|
||||||
|
|
||||||
- Dvorak 配列をベースに、ショートカットでよく利用される XCV は QWERTY 配列の位置を維持
|
- Dvorak 配列をベースに、ショートカットでよく利用される XCV は QWERTY 配列の位置を維持
|
||||||
- Vimユーザのために、HJKL キーを横並びで配置
|
- 一部にVimユーザ用のキー配置を実施
|
||||||
|
- HJKL キーを横並びで配置
|
||||||
|
- Shift押下時と非押下時で、";"キーの挙動を入れ替え(`config.h` 内で `#define SWAP_SCLN` の宣言が必要です)
|
||||||
- デフォルトレイヤーには、数字キーの代わりに記号 `!@#$%^&*()` を配置
|
- デフォルトレイヤーには、数字キーの代わりに記号 `!@#$%^&*()` を配置
|
||||||
|
|
||||||
- mainly based on Dvorak layout, but XCV is available in the same position of QWERTY layout
|
- mainly based on Dvorak layout, but XCV is available in the same position of QWERTY layout
|
||||||
- HJKL is lining side by side, for Vim users
|
- for Vim users
|
||||||
|
- HJKL is lining side by side
|
||||||
|
- swap the ";" key behavior. i.e. send ":" normally and send ";" when you hold shift. (need `#define SWAP_SCLN` in your `config.h`)
|
||||||
- we can type `!@#$%^&*()` keys without shift keys in base layer
|
- we can type `!@#$%^&*()` keys without shift keys in base layer
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
@ -1 +1,7 @@
|
|||||||
SRC += edvorakjp.c
|
SRC += edvorakjp.c \
|
||||||
|
edvorakjp_process_record.c \
|
||||||
|
edvorakjp_status.c
|
||||||
|
|
||||||
|
ifeq ($(TAP_DANCE_ENABLE), yes)
|
||||||
|
SRC += edvorakjp_tap_dance.c
|
||||||
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user