From fe982caf5d69fdb2d6f1dec123a630df11a98282 Mon Sep 17 00:00:00 2001 From: epaew Date: Tue, 4 Dec 2018 01:00:00 +0900 Subject: [PATCH] Add edvorakjp kepmap for crkbd (#4537) * edvorakjp layout for crkbd * bugfix of edvorakjp QMK cannot send keycode that doesn't exists on new layer. --- keyboards/crkbd/keymaps/edvorakjp/config.h | 24 +++ keyboards/crkbd/keymaps/edvorakjp/keymap.c | 158 ++++++++++++++++++++ keyboards/crkbd/keymaps/edvorakjp/oled.c | 82 ++++++++++ keyboards/crkbd/keymaps/edvorakjp/oled.h | 24 +++ keyboards/crkbd/keymaps/edvorakjp/readme.md | 21 +++ keyboards/crkbd/keymaps/edvorakjp/rules.mk | 32 ++++ users/edvorakjp/edvorakjp_process_record.c | 18 ++- 7 files changed, 354 insertions(+), 5 deletions(-) create mode 100644 keyboards/crkbd/keymaps/edvorakjp/config.h create mode 100644 keyboards/crkbd/keymaps/edvorakjp/keymap.c create mode 100644 keyboards/crkbd/keymaps/edvorakjp/oled.c create mode 100644 keyboards/crkbd/keymaps/edvorakjp/oled.h create mode 100644 keyboards/crkbd/keymaps/edvorakjp/readme.md create mode 100644 keyboards/crkbd/keymaps/edvorakjp/rules.mk diff --git a/keyboards/crkbd/keymaps/edvorakjp/config.h b/keyboards/crkbd/keymaps/edvorakjp/config.h new file mode 100644 index 0000000000..515591a429 --- /dev/null +++ b/keyboards/crkbd/keymaps/edvorakjp/config.h @@ -0,0 +1,24 @@ +#ifndef CONFIG_USER_H +#define CONFIG_USER_H + +/* Select hand configuration */ + +#define MASTER_LEFT +// #define MASTER_RIGHT +// #define EE_HANDS + +#define SSD1306OLED +#define SWAP_SCLN + +// #define TAPPING_FORCE_HOLD +#define TAPPING_TERM 120 + +#undef RGBLED_NUM +#define RGBLIGHT_EFFECT_STATIC_GRADIENT +#define RGBLED_NUM 27 +#define RGBLIGHT_LIMIT_VAL 100 +#define RGBLIGHT_HUE_STEP 10 +#define RGBLIGHT_SAT_STEP 17 +#define RGBLIGHT_VAL_STEP 17 + +#endif // CONFIG_USER_H diff --git a/keyboards/crkbd/keymaps/edvorakjp/keymap.c b/keyboards/crkbd/keymaps/edvorakjp/keymap.c new file mode 100644 index 0000000000..ae2f710a03 --- /dev/null +++ b/keyboards/crkbd/keymaps/edvorakjp/keymap.c @@ -0,0 +1,158 @@ +#include QMK_KEYBOARD_H +#ifdef PROTOCOL_LUFA + #include "split_util.h" +#endif +#ifdef SSD1306OLED + #include "oled.h" +#endif + +#include "edvorakjp.h" + +/* + * enum custom_keycodes { + * KC_LOCK = NEW_SAFE_RANGE, + * }; + */ + +#define KC_ KC_TRNS + +#define KC_TMB1 LGUI_T(KC_TAB) +#define KC_TMB2 LSFT_T(KC_SPC) +#define KC_TMB3 TD(TD_LOWER) // act as LOWER when hold, as KC_LANG2(=English) when tapped +#define KC_TMB4 TD(TD_RAISE) // act as RAISE when hold, as KC_LANG1(=Japanese) when tapped +#define KC_TMB5 RCTL_T(KC_BSPC) +#define KC_TMB6 RALT_T(KC_ENT) +#define KC_TMB7 KC_DEL +#define KC_TMB8 RALT(KC_ENT) +#define KC_TMB9 LGUI(KC_TAB) + +#define KC_RST RESET +#define KC_DBUG DEBUG +#define KC_RTOG RGB_TOG +#define KC_EDJP EDVORAK +#define KC_QWER QWERTY + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + [_EDVORAK] = LAYOUT_kc( + //|----+----+----+----+----+----| |----+----+----+----+----+----| + ESC ,QUOT,COMM,DOT , Y , P , F , G , R , W , Q ,BSLS, + //|----+----+----+----+----+----| |----+----+----+----+----+----| + EQL , A , O , E , I , U , D , T , N , S , M ,MINS, + //|----+----+----+----+----+----| |----+----+----+----+----+----| + GRV ,SCLN, X , C , V , Z , B , H , J , K , L ,SLSH, + //`----+----+----+----+----+----+----| |----+----+----+----+----+----+----' + TMB1,TMB2,TMB3, TMB4,TMB5,TMB6 + // `----+----+----' `----+----+----' + ), + + [_EDVORAKJ1] = LAYOUT_kc( + //|----+----+----+----+----+----| |----+----+----+----+----+----| + , AI , OU , EI , , , , , , , , , + //|----+----+----+----+----+----| |----+----+----+----+----+----| + , , , , , , , , , Y , , , + //|----+----+----+----+----+----| |----+----+----+----+----+----| + ,ANN ,ONN ,ENN ,INN ,UNN , , , , , , , + //`----+----+----+----+----+----+----| |----+----+----+----+----+----+----' + , , , , , + // `----+----+----' `----+----+----' + ), + + [_EDVORAKJ2] = LAYOUT_kc( + //|----+----+----+----+----+----| |----+----+----+----+----+----| + , AI , OU , EI , , , , , , , , , + //|----+----+----+----+----+----| |----+----+----+----+----+----| + , , , , , , , Y , , , , , + //|----+----+----+----+----+----| |----+----+----+----+----+----| + ,ANN ,ONN ,ENN ,INN ,UNN , , , , , , , + //`----+----+----+----+----+----+----| |----+----+----+----+----+----+----' + , , , , , + // `----+----+----' `----+----+----' + ), + + [_QWERTY] = LAYOUT_kc( + //|----+----+----+----+----+----| |----+----+----+----+----+----| + TAB , Q , W , E , R , T , Y , U , I , O , P ,MINS, + //|----+----+----+----+----+----| |----+----+----+----+----+----| + EQL , A , S , D , F , G , H , J , K , L ,SCLN,QUOT, + //|----+----+----+----+----+----| |----+----+----+----+----+----| + GRV , Z , X , C , V , B , N , M ,COMM,DOT ,SLSH,BSLS, + //`----+----+----+----+----+----+----| |----+----+----+----+----+----+----' + , , , , , + // `----+----+----' `----+----+----' + ), + + [_LOWER] = LAYOUT_kc( + //|----+----+----+----+----+----| |----+----+----+----+----+----| + , , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , , , + //|----+----+----+----+----+----| |----+----+----+----+----+----| + , 1 ,EXLM, AT ,HASH,DLR , PERC,CIRC,AMPR,ASTR, 0 , , + //|----+----+----+----+----+----| |----+----+----+----+----+----| + , , LT ,LCBR,LPRN,LBRC, RBRC,RPRN,RCBR, GT , , , + //`----+----+----+----+----+----+----| |----+----+----+----+----+----+----' + , , , ,TMB7,TMB8 + // `----+----+----' `----+----+----' + ), + + [_RAISE] = LAYOUT_kc( + //|----+----+----+----+----+----| |----+----+----+----+----+----| + , F1 , F2 , F3 , F4 , F5 , F6 , F7 , F8 , F9 ,F10 , , + //|----+----+----+----+----+----| |----+----+----+----+----+----| + ,F11 ,F12 ,PSCR,SLCK,PAUS, ,HOME,PGDN,PGUP,END , , + //|----+----+----+----+----+----| |----+----+----+----+----+----| + , , , , , , ,LEFT,DOWN, UP ,RGHT, , + //|----+----+----+----+----+----+----| |----+----+----+----+----+----+----' + TMB9, , , , , + // `----+----+----' `----+----+----' + ), + + [_ADJUST] = LAYOUT_kc( + //|----+----+----+----+----+----| |----+----+----+----+----+----| + , , , ,EXTOFF, , ,EXTON, , , , , + //|----+----+----+----+----+----| |----+----+----+----+----+----| + , , ,QWER,WIN ,RST , RTOG,MAC ,EDJP, , , , + //|----+----+----+----+----+----| |----+----+----+----+----+----| + , , , , , , , , , , , , + //`----+----+----+----+----+----+----| |----+----+----+----+----+----+----' + , , , , , + // `----+----+----' `----+----+----' + ) +}; + +#ifdef SSD1306OLED +void matrix_init_keymap(void) { + //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h + iota_gfx_init(!has_usb()); // turns on the display +} + +void matrix_scan_user(void) { + iota_gfx_task(); // this is what updates the display continuously +} +#endif + +#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT +uint32_t layer_state_set_keymap(uint32_t state) { + rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); + switch (biton32(state)) { + case _EDVORAKJ1: + case _EDVORAKJ2: + // _EDVORAKJ1 & J2 are same colored + rgblight_sethsv_noeeprom_white(); + break; + case _LOWER: + rgblight_sethsv_noeeprom_red(); + break; + case _RAISE: + rgblight_sethsv_noeeprom_blue(); + break; + case _ADJUST: + rgblight_sethsv_noeeprom_green(); + break; + default: // for any other layers, or the default layer + rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_GRADIENT + 3); + rgblight_sethsv_noeeprom_red(); + break; + } + return state; +} +#endif diff --git a/keyboards/crkbd/keymaps/edvorakjp/oled.c b/keyboards/crkbd/keymaps/edvorakjp/oled.c new file mode 100644 index 0000000000..e4cccf3e7f --- /dev/null +++ b/keyboards/crkbd/keymaps/edvorakjp/oled.c @@ -0,0 +1,82 @@ +#include +#include "oled.h" + +// NOTE: Redefined to avoid to use snprintf(); It makes size of firmware big. +const char *read_mode_icon(bool windows_mode) { + static const char logo[][2][3] = {{{0x95, 0x96, 0}, {0xb5, 0xb6, 0}}, {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}}}; + static char mode_icon[10]; + + int mode_number = windows_mode ? 1 : 0; + strcpy(mode_icon, logo[mode_number][0]); + + strcat(mode_icon, "\n"); + strcat(mode_icon, logo[mode_number][1]); + + return mode_icon; +} + +const char *read_layer_state(void) { + static char layer_state_str[24]; + char layer_name[17]; + + switch (biton32(layer_state)) { + case L_BASE: + strcpy(layer_name, default_layer_state == 1UL<<_EDVORAK ? "EDVORAK" : "QWERTY"); + break; + case _EDVORAKJ1: + case _EDVORAKJ2: + strcpy(layer_name, "JP_EXT"); + break; + case _RAISE: + strcpy(layer_name, "Raise"); + break; + case _LOWER: + strcpy(layer_name, "Lower"); + break; + case _ADJUST: + strcpy(layer_name, "Adjust"); + break; + default: + snprintf(layer_name, sizeof(layer_name), "Undef-%ld", layer_state); + } + + strcpy(layer_state_str, "Layer: "); + + strcat(layer_state_str, layer_name); + strcat(layer_state_str, "\n"); + return layer_state_str; +} + +const char *read_host_led_state(void) { + static char led_str[24]; + bool ext_status = get_enable_jp_extra_layer() && get_japanese_mode(); + strcpy(led_str, ext_status ? "EXT" : " "); + + strcat(led_str, (host_keyboard_leds() & (1<display, source->display, sizeof(dest->display))) { + memcpy(dest->display, source->display, sizeof(dest->display)); + dest->dirty = true; + } +} + +void iota_gfx_task_user(void) { + struct CharacterMatrix matrix; + + matrix_clear(&matrix); + if (is_master) { + matrix_write(&matrix, read_mode_icon(!get_enable_kc_lang())); + matrix_write(&matrix, " "); + matrix_write(&matrix, read_layer_state()); + matrix_write(&matrix, read_host_led_state()); + } else { + matrix_write(&matrix, read_logo()); + } + matrix_update(&display, &matrix); +} diff --git a/keyboards/crkbd/keymaps/edvorakjp/oled.h b/keyboards/crkbd/keymaps/edvorakjp/oled.h new file mode 100644 index 0000000000..896347aea9 --- /dev/null +++ b/keyboards/crkbd/keymaps/edvorakjp/oled.h @@ -0,0 +1,24 @@ +#ifndef OLED_USER_H +#define OLED_USER_H + +//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h +#include "ssd1306.h" +#include "edvorakjp.h" + +//assign the right code to your layers for OLED display +#define L_BASE 0 + +extern uint8_t is_master; +extern bool japanese_mode; + +// method prototypes defined in crkbd/lib +extern const char *read_logo(void); + +const char *read_mode_icon(bool swap); +const char *read_layer_state(void); +const char *read_host_led_state(void); +void matrix_update(struct CharacterMatrix *dest, + const struct CharacterMatrix *source); +void iota_gfx_task_user(void); + +#endif // OLED_CONFIG_USER_H diff --git a/keyboards/crkbd/keymaps/edvorakjp/readme.md b/keyboards/crkbd/keymaps/edvorakjp/readme.md new file mode 100644 index 0000000000..dd406523d2 --- /dev/null +++ b/keyboards/crkbd/keymaps/edvorakjp/readme.md @@ -0,0 +1,21 @@ +# edvorakjp + +Epaew's Enhanced Dvorak layout for Japanese Programmer +see [here](/users/edvorakjp) for more informations. + +## License + +Copyright 2018 Ryo Maeda epaew.333@gmail.com @epaew + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . diff --git a/keyboards/crkbd/keymaps/edvorakjp/rules.mk b/keyboards/crkbd/keymaps/edvorakjp/rules.mk new file mode 100644 index 0000000000..b4f6d2f1f1 --- /dev/null +++ b/keyboards/crkbd/keymaps/edvorakjp/rules.mk @@ -0,0 +1,32 @@ +# Build Options +# change to "no" to disable the options, or define them in the Makefile in +# the appropriate keymap folder that will get included automatically +# +BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = no # Mouse keys(+4700) +EXTRAKEY_ENABLE = no # Audio control and System control(+450) +CONSOLE_ENABLE = no # Console for debug(+400) +COMMAND_ENABLE = no # Commands for debug and configuration +NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = no # Audio output on port C6 +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. +SWAP_HANDS_ENABLE = no # Enable one-hand typing +TAP_DANCE_ENABLE = yes + +# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend + +# If you want to change the display of OLED, you need to change here +SRC += ./lib/glcdfont.c \ + ./lib/logo_reader.c \ + oled.c \ + # ./lib/rgb_state_reader.c \ + # ./lib/layer_state_reader.c \ + # ./lib/keylogger.c \ + # ./lib/mode_icon_reader.c \ + # ./lib/host_led_state_reader.c \ + # ./lib/timelogger.c \ diff --git a/users/edvorakjp/edvorakjp_process_record.c b/users/edvorakjp/edvorakjp_process_record.c index dc70522b47..2dcdab2a25 100644 --- a/users/edvorakjp/edvorakjp_process_record.c +++ b/users/edvorakjp/edvorakjp_process_record.c @@ -37,11 +37,7 @@ bool process_record_edvorakjp_ext(uint16_t keycode, keyrecord_t *record) { } return true; - // left hand and right hand's right side - case KC_X: - case KC_C: - case KC_V: - case KC_Z: + // left hand up and right hand's right side case KC_Y: case KC_P: case KC_W: @@ -54,6 +50,18 @@ bool process_record_edvorakjp_ext(uint16_t keycode, keyrecord_t *record) { layer_on(_EDVORAKJ2); } return true; + // left hand down + // If return true, QMK sends keycode in new layer, + // but these keys are only available in old layer. + case KC_X: + case KC_C: + case KC_V: + case KC_Z: + if (record->event.pressed) { + layer_on(_EDVORAKJ2); + tap_code(keycode); + } + return false; } // vowel keys, symbol keys and modifier keys