Keymap: Modified like-jis keymap for crkbd (#4577)

pull/4580/head 0.6.201
marksard 6 years ago committed by Drashna Jaelre
parent 13ad650136
commit 11eaccdbce

@ -34,7 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define PREVENT_STUCK_MODIFIERS
#define TAPPING_FORCE_HOLD
#define TAPPING_TERM 150
#define TAPPING_TERM 250
#undef RGBLED_NUM
#define RGBLIGHT_ANIMATIONS

@ -7,6 +7,7 @@
#ifdef SSD1306OLED
#include "ssd1306.h"
#endif
#include "oled_helper.h"
extern keymap_config_t keymap_config;
@ -21,27 +22,35 @@ extern uint8_t is_master;
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
// Layer names don't all need to be of the same length, obviously, and you can also skip them
// entirely and just use numbers.
#define _QWERTY 0
#define _LOWER 3
#define _RAISE 4
#define _ADJUST 16
enum layer_number {
_BASE = 0,
_LOWER,
_RAISE,
_ADJUST,
};
enum custom_keycodes {
LOWER = SAFE_RANGE,
RAISE,
ADJUST,
KANJI,
RGBRST
};
#define KC______ KC_TRNS
#define KC_XXXXX KC_NO
#define KC_KANJI KC_GRV
enum tapdances{
TD_CODO = 0,
// TD_MNUB,
};
// Layer Mode aliases
#define KC_LOWER LOWER
#define KC_RAISE RAISE
#define KC_RST RESET
#define KC______ KC_TRNS
#define KC_XXXXX KC_NO
#define KC_KANJI KANJI
#define KC_RST RESET
#define KC_LRST RGBRST
#define KC_LTOG RGB_TOG
#define KC_LHUI RGB_HUI
@ -51,31 +60,41 @@ enum custom_keycodes {
#define KC_LVAI RGB_VAI
#define KC_LVAD RGB_VAD
#define KC_LMOD RGB_MOD
#define KC_KNRM AG_NORM
#define KC_KSWP AG_SWAP
#define KC_GUAP LALT_T(KC_APP)
#define KC_TBSF LSFT_T(KC_TAB)
// #define KC_SPSF LSFT_T(KC_SPC)
#define KC_ALAP LALT_T(KC_APP)
#define KC_CODO TD(TD_CODO)
// #define KC_MNUB TD(TD_MNUB)
qk_tap_dance_action_t tap_dance_actions[] = {
[TD_CODO] = ACTION_TAP_DANCE_DOUBLE(KC_COMM, KC_DOT),
// [TD_MNUB] = ACTION_TAP_DANCE_DOUBLE(KC_MINS, LSFT(KC_RO)),
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_QWERTY] = LAYOUT_kc( \
[_BASE] = LAYOUT_kc( \
//,-----------------------------------------. ,-----------------------------------------.
ESC, Q, W, E, R, T, Y, U, I, O, P, MINS,\
//|------+------+------+------+------+------| |------+------+------+------+------+------|
LSFT, A, S, D, F, G, H, J, K, L, UP, ENT,\
TBSF, A, S, D, F, G, H, J, K, L, UP, ENT,\
//|------+------+------+------+------+------| |------+------+------+------+------+------|
LCTRL, Z, X, C, V, B, N, M, COMM, LEFT, DOWN, RGHT,\
LCTRL, Z, X, C, V, B, N, M, CODO, LEFT, DOWN, RGHT,\
//|------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
LGUI, LOWER, BSPC, SPC, RAISE, GUAP \
LGUI, LOWER, BSPC, SPC, RAISE, ALAP \
//`--------------------' `--------------------'
),
[_LOWER] = LAYOUT_kc( \
//,-----------------------------------------. ,-----------------------------------------.
TAB, F1, F2, F3, F4, F5, XXXXX, MINS, EQL, JYEN, LBRC, RBRC,\
_____, F1, F2, F3, F4, F5, XXXXX, MINS, EQL, JYEN, LBRC, RBRC,\
//|------+------+------+------+------+------| |------+------+------+------+------+------|
_____, F6, F7, F8, F9, F10, XXXXX, XXXXX, XXXXX, SCLN, QUOT, BSLS,\
//|------+------+------+------+------+------| |------+------+------+------+------+------|
_____, F11, F12, XXXXX, KANJI, ENT, XXXXX, XXXXX, COMM, DOT, SLSH, RO,\
_____, F11, F12, TAB, KANJI, ENT, XXXXX, XXXXX, COMM, DOT, SLSH, RO,\
//|------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
_____, _____, DEL, _____, _____, APP \
//`--------------------' `--------------------'
@ -83,11 +102,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_RAISE] = LAYOUT_kc( \
//,-----------------------------------------. ,-----------------------------------------.
_____, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, XXXXX,\
_____, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, PSLS,\
//|------+------+------+------+------+------| |------+------+------+------+------+------|
_____, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, 4, 5, 6, QUOT, XXXXX,\
_____, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, QUOT, 4, 5, 6, PPLS, PAST,\
//|------+------+------+------+------+------| |------+------+------+------+------+------|
_____, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, 0, 1, 2, 3, DOT, XXXXX,\
_____, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, 0, 1, 2, 3, DOT, PMNS,\
//|------+------+------+------+------+------+------| |------+------+------+------+------+------+------|
_____, _____, BSPC, _____, _____, LALT \
//`--------------------' `--------------------'
@ -106,122 +125,94 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
)
};
int RGB_current_mode;
// Setting ADJUST layer RGB back to default
static inline void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
layer_on(layer3);
} else {
layer_off(layer3);
}
}
#define L_BASE _BASE
#define L_LOWER (1<<_LOWER)
#define L_RAISE (1<<_RAISE)
#define L_ADJUST (1<<_ADJUST)
#define L_ADJUST_TRI (L_ADJUST|L_RAISE|L_LOWER)
void matrix_init_user(void) {
#ifdef RGBLIGHT_ENABLE
RGB_current_mode = rgblight_config.mode;
#endif
//SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
#ifdef SSD1306OLED
iota_gfx_init(!has_usb()); // turns on the display
#endif
}
typedef struct {
uint8_t state;
char name[8];
}LAYER_DISPLAY_NAME;
#define LAYER_DISPLAY_MAX 5
const LAYER_DISPLAY_NAME layer_display_name[LAYER_DISPLAY_MAX] = {
{L_BASE, "Base"},
{L_BASE + 1, "Base"},
{L_LOWER, "Lower"},
{L_RAISE, "Raise"},
{L_ADJUST_TRI, "Adjust"}
};
//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
#ifdef SSD1306OLED
static inline const char* get_leyer_status(void) {
for (uint8_t i = 0; i < LAYER_DISPLAY_MAX; ++i) {
if (layer_state == 0 && layer_display_name[i].state == default_layer_state) {
// When add source files to SRC in rules.mk, you can use functions.
const char *read_layer_state(void);
const char *read_logo(void);
void set_keylog(uint16_t keycode, keyrecord_t *record);
const char *read_keylog(void);
const char *read_keylogs(void);
return layer_display_name[i].name;
} else if (layer_state != 0 && layer_display_name[i].state == layer_state) {
// const char *read_mode_icon(bool swap);
// const char *read_host_led_state(void);
// void set_timelog(void);
// const char *read_timelog(void);
return layer_display_name[i].name;
}
}
#ifdef RGBLIGHT_ENABLE
const char *read_rgb_info(void);
#define RENDER_RGB_INFO(m) matrix_write_ln(m, (const char*)read_rgb_info())
#else
#define RENDER_RGB_INFO(m)
#endif
return "?";
}
static char layer_status_buf[24] = "Layer state ready.\n";
static inline void update_keymap_status(void) {
void matrix_scan_user(void) {
iota_gfx_task();
snprintf(layer_status_buf, sizeof(layer_status_buf) - 1, "OS:%s Layer:%s\n",
keymap_config.swap_lalt_lgui? "win" : "mac", get_leyer_status());
}
static inline void matrix_render_user(struct CharacterMatrix *matrix) {
if (is_master) {
// If you want to change the display of OLED, you need to change here
matrix_write_ln(matrix, read_layer_state());
matrix_write_ln(matrix, read_keylog());
RENDER_RGB_INFO(matrix);
// matrix_write_ln(matrix, read_keylogs());
// matrix_write_ln(matrix, read_host_led_state());
// matrix_write_ln(matrix, read_mode_icon(keymap_config.swap_lalt_lgui));
// matrix_write_ln(matrix, read_timelog());
} else {
matrix_write(matrix, read_logo());
}
}
static inline void render_keymap_status(struct CharacterMatrix *matrix) {
static inline void matrix_update(struct CharacterMatrix *dest, const struct CharacterMatrix *source) {
if (memcmp(dest->display, source->display, sizeof(dest->display))) {
memcpy(dest->display, source->display, sizeof(dest->display));
dest->dirty = true;
}
matrix_write(matrix, layer_status_buf);
}
void iota_gfx_task_user(void) {
struct CharacterMatrix matrix;
matrix_clear(&matrix);
matrix_render_user(&matrix);
matrix_update(&display, &matrix);
}
#define UPDATE_KEYMAP_STATUS() update_keymap_status()
#define RENDER_KEYMAP_STATUS(a) render_keymap_status(a)
#else
#define UPDATE_KEYMAP_STATUS()
#define RENDER_KEYMAP_STATUS(a)
#endif
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
#ifdef SSD1306OLED
if (record->event.pressed) {
set_keylog(keycode, record);
// set_timelog();
static inline void update_change_layer(bool pressed, uint8_t layer1, uint8_t layer2, uint8_t layer3) {
pressed ? layer_on(layer1) : layer_off(layer1);
IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2) ? layer_on(layer3) : layer_off(layer3);
}
#endif
int RGB_current_mode;
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
UPDATE_KEY_STATUS(keycode, record);
bool result = false;
switch (keycode) {
case LOWER:
if (record->event.pressed) {
layer_on(_LOWER);
update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
} else {
layer_off(_LOWER);
update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
}
update_change_layer(record->event.pressed, _LOWER, _RAISE, _ADJUST);
break;
case RAISE:
update_change_layer(record->event.pressed, _RAISE, _LOWER, _ADJUST);
break;
case KANJI:
if (record->event.pressed) {
layer_on(_RAISE);
update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
if (keymap_config.swap_lalt_lgui == false) {
register_code(KC_LANG2);
} else {
layer_off(_RAISE);
update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
SEND_STRING(SS_LALT("`"));
}
break;
case ADJUST:
if (record->event.pressed) {
layer_on(_ADJUST);
} else {
layer_off(_ADJUST);
unregister_code(KC_LANG2);
}
break;
#ifdef RGBLIGHT_ENABLE
case RGB_MOD:
if (record->event.pressed) {
@ -239,8 +230,66 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
break;
#endif
default:
return true;
result = true;
break;
}
return false;
UPDATE_KEYMAP_STATUS();
return result;
}
void matrix_init_user(void) {
#ifdef RGBLIGHT_ENABLE
RGB_current_mode = rgblight_config.mode;
#endif
//SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
#ifdef SSD1306OLED
iota_gfx_init(!has_usb()); // turns on the display
#endif
}
//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
#ifdef SSD1306OLED
void matrix_scan_user(void) {
iota_gfx_task(); // this is what updates the display continuously
}
static inline void matrix_update(struct CharacterMatrix *dest,
const struct CharacterMatrix *source) {
if (memcmp(dest->display, source->display, sizeof(dest->display))) {
memcpy(dest->display, source->display, sizeof(dest->display));
dest->dirty = true;
}
}
static inline void render_status(struct CharacterMatrix *matrix) {
UPDATE_LED_STATUS();
RENDER_LED_STATUS(matrix);
RENDER_KEYMAP_STATUS(matrix);
UPDATE_LOCK_STATUS();
RENDER_LOCK_STATUS(matrix);
RENDER_KEY_STATUS(matrix);
}
void iota_gfx_task_user(void) {
struct CharacterMatrix matrix;
#if DEBUG_TO_SCREEN
if (debug_enable) {
return;
}
#endif
matrix_clear(&matrix);
if (is_master) {
render_status(&matrix);
} else {
RENDER_LOGO(&matrix);
}
matrix_update(&display, &matrix);
}
#endif

@ -0,0 +1,83 @@
#ifdef SSD1306OLED
#include QMK_KEYBOARD_H
#include "ssd1306.h"
void render_logo(struct CharacterMatrix *matrix) {
const char logo_buf[]={
0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,
0};
matrix_write(matrix, logo_buf);
}
static char keylog_buf[24] = "Key state ready.";
const char code_to_name[60] = {
' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
'R', 'E', 'B', 'T', ' ', '-', ' ', '@', ' ', ' ',
' ', ';', ':', ' ', ',', '.', '/', ' ', ' ', ' '};
void update_key_status(uint16_t keycode, keyrecord_t *record) {
if (!record->event.pressed) return;
char name = (keycode < 60) ? code_to_name[keycode] : ' ';
snprintf(keylog_buf, sizeof(keylog_buf) - 1, "Key:%dx%d %2x %c",
record->event.key.row, record->event.key.col,
(uint16_t)keycode, name);
}
void render_key_status(struct CharacterMatrix *matrix) {
matrix_write(matrix, keylog_buf);
}
static char lock_buf[24] = "Lock state ready.\n";
void update_lock_status(void) {
uint8_t leds = host_keyboard_leds();
char *num_lock = (leds & (1<<USB_LED_NUM_LOCK)) ? "Num" : "";
char *caps_lock = (leds & (1<<USB_LED_CAPS_LOCK)) ? "Caps" : "";
char *scrl_lock = (leds & (1<<USB_LED_SCROLL_LOCK)) ? "Scrn" : "";
snprintf(lock_buf, sizeof(lock_buf) - 1, "Lock:%s %s %s\n",
num_lock, caps_lock, scrl_lock);
}
void render_lock_status(struct CharacterMatrix *matrix) {
matrix_write(matrix, lock_buf);
}
#ifdef RGBLIGHT_ENABLE
extern rgblight_config_t rgblight_config;
static char led_buf[24] = "LED state ready.\n";
rgblight_config_t rgblight_config_bak;
void update_led_status(void) {
if (rgblight_config_bak.enable != rgblight_config.enable ||
rgblight_config_bak.mode != rgblight_config.mode ||
rgblight_config_bak.hue != rgblight_config.hue ||
rgblight_config_bak.sat != rgblight_config.sat ||
rgblight_config_bak.val != rgblight_config.val
) {
snprintf(led_buf, sizeof(led_buf) - 1, "LED%c:%2d hsv:%2d %2d %2d\n",
rgblight_config.enable ? '*' : '.', (uint8_t)rgblight_config.mode,
(uint8_t)(rgblight_config.hue / RGBLIGHT_HUE_STEP),
(uint8_t)(rgblight_config.sat / RGBLIGHT_SAT_STEP),
(uint8_t)(rgblight_config.val / RGBLIGHT_VAL_STEP));
rgblight_config_bak = rgblight_config;
}
}
void render_led_status(struct CharacterMatrix *matrix) {
matrix_write(matrix, led_buf);
}
#endif
#endif

@ -0,0 +1,35 @@
#ifdef SSD1306OLED
void render_logo(struct CharacterMatrix *matrix);
void update_key_status(uint16_t keycode, keyrecord_t *record);
void render_key_status(struct CharacterMatrix *matrix);
void update_lock_status(void);
void render_lock_status(struct CharacterMatrix *matrix);
#define RENDER_LOGO(a) render_logo(a)
#define UPDATE_KEY_STATUS(a, b) update_key_status(a, b)
#define RENDER_KEY_STATUS(a) render_key_status(a)
#define UPDATE_LOCK_STATUS() update_lock_status()
#define RENDER_LOCK_STATUS(a) render_lock_status(a)
#ifdef RGBLIGHT_ENABLE
void update_led_status(void);
void render_led_status(struct CharacterMatrix *matrix);
#define UPDATE_LED_STATUS() update_led_status()
#define RENDER_LED_STATUS(a) render_led_status(a)
#else
#define UPDATE_LED_STATUS()
#define RENDER_LED_STATUS(a)
#endif
#else
#define RENDER_LOGO(a)
#define UPDATE_KEY_STATUS(a, b)
#define RENDER_KEY_STATUS(a)
#define UPDATE_LOCK_STATUS()
#define RENDER_LOCK_STATUS(a)
#define UPDATE_LED_STATUS()
#define RENDER_LED_STATUS(a)
#endif

@ -16,16 +16,17 @@ 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
Link_Time_Optimization = yes # if firmware size over limit, try this option
ifeq ($(strip $(Link_Time_Optimization)),yes)
EXTRAFLAGS += -flto -DUSE_Link_Time_Optimization
endif
# If you want to change the display of OLED, you need to change here
SRC += ./lib/glcdfont.c \
./lib/rgb_state_reader.c \
./lib/layer_state_reader.c \
./lib/logo_reader.c \
./lib/keylogger.c \
# ./lib/mode_icon_reader.c \
# ./lib/host_led_state_reader.c \
# ./lib/timelogger.c \
oled_helper.c \

Loading…
Cancel
Save