Skip to content

Instantly share code, notes, and snippets.

@kiwec kiwec/keymap_kiwec.c
Last active Sep 19, 2017

Embed
What would you like to do?
Current planck keymap
#include "planck.h"
// Readability
#define _______ KC_TRNS
#define XXXXXXX KC_NO
// Layers
#define DVORAK_LAYER 0
#define GAMING_LAYER 1
#define GMGTAB_LAYER 2
#define GMGDVK_LAYER 3
#define LOWER_LAYER 4
#define UPPER_LAYER 5
// Function keys
#define PLAYCTR FUNC(1) // Play/pause on tap, LCTRL on hold
#define COMPCTR FUNC(2) // Compose on tap, RCTRL on hold
#define LALTESC FUNC(3) // Escape on tap, LALT on hold
#define L_GMING FUNC(4) // Toggle gaming layer
// Compose key must be enabled for most macros
#define KC_COMP KC_RALT // Compose key
#define KC_CDIL M(0) // Cedilla
#define KC_AIGU M(1) // Acute accent
#define KC_GRVE M(2) // Grave accent
#define KC_CCRC M(3) // Circumflex accent
#define KC_EURO M(4) // Euro sign
#define KC_CTRC LCTL(KC_C) // Ctrl-C
#define KC_CTRV LCTL(KC_V) // Ctrl-V
#define KC_QUST S(KC_SLSH) // ?
// Layer switches
#define L_YDVRK M(6) // Y and enable temp dvorak layer
#define L_UDvRK M(7) // U and enable temp dvorak layer
#define L_DELDK M(8) // Del and enable temp dvorak layer
#define L_ESCDK M(9) // Esc and disable temp dvorak layer
#define L_ENTDK M(10) // Enter and disable temp dvorak layer
#define L_GGTAB M(11) // On hold, use gaming tab layer
#define L_LOWER MO(LOWER_LAYER) // On hold, use lower layer
#define L_UPPER MO(UPPER_LAYER) // On hold, use upper layer
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[DVORAK_LAYER] = {
{ KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC },
{ LALTESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_ENT },
{ KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_DEL },
{ PLAYCTR, KC_PGUP, KC_PGDN, KC_LGUI, L_LOWER, KC_SPC, KC_SPC, L_UPPER, KC_AIGU, KC_GRVE, KC_CCRC, COMPCTR }
},
[GAMING_LAYER] = {
{ KC_BSPC, KC_Q, KC_W, KC_E, KC_R, KC_T, L_YDVRK, L_UDvRK, KC_I, KC_O, KC_P, KC_ESC },
{ KC_LSFT, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_QUOT, KC_ENT },
{ KC_LCTL, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_HOME, KC_UP, KC_END, L_DELDK },
{ L_GGTAB, KC_DOT, KC_COMM, KC_SCLN, KC_SLSH, KC_SPC, KC_SPC, L_UPPER, KC_LEFT, KC_DOWN, KC_RGHT, KC_INS }
},
[GMGTAB_LAYER] = {
{ KC_0, KC_4, KC_5, KC_6, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX },
{ XXXXXXX, KC_1, KC_2, KC_3, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX },
{ XXXXXXX, KC_7, KC_8, KC_9, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX },
{ _______, KC_BSLS, KC_LBRC, KC_RBRC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX }
},
[GMGDVK_LAYER] = {
{ XXXXXXX, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC },
{ L_ESCDK, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, L_ENTDK },
{ KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, L_DELDK },
{ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, L_LOWER, KC_SPC, KC_SPC, XXXXXXX, KC_AIGU, KC_GRVE, KC_CCRC, COMPCTR }
},
[LOWER_LAYER] = {
{ XXXXXXX, XXXXXXX, KC_HOME, KC_UP, KC_END, KC_CTRC, XXXXXXX, KC_NLCK, KC_P7, KC_P8, KC_P9, KC_BSPC },
{ XXXXXXX, XXXXXXX, KC_LEFT, KC_DOWN, KC_RGHT, KC_CTRV, XXXXXXX, XXXXXXX, KC_P4, KC_P5, KC_P6, KC_PMNS },
{ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_P1, KC_P2, KC_P3, KC_PPLS },
{ KC_MNXT, KC_MPRV, KC_VOLU, KC_VOLD, _______, KC_MUTE, KC_MUTE, XXXXXXX, KC_PDOT, KC_P0, KC_PEQL, KC_PENT }
},
[UPPER_LAYER] = {
{ KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12 },
{ LALTESC, KC_AMPR, KC_EXLM, KC_EQL, KC_PLUS, KC_HASH, KC_DLR, KC_LPRN, KC_LBRC, KC_LCBR, KC_SLSH, _______ },
{ KC_LSFT, KC_ASTR, KC_QUST, KC_PIPE, KC_MINS, KC_AT, KC_EURO, KC_RPRN, KC_RBRC, KC_RCBR, KC_BSLS, _______ },
{ PLAYCTR, KC_TILD, KC_PERC, KC_UNDS, L_GMING, _______, _______, _______, KC_GRV, KC_CIRC, KC_CDIL, KC_F13 }
},
};
const uint16_t PROGMEM fn_actions[] = {
[1] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_MPLY),
[2] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_COMP),
[3] = ACTION_MODS_TAP_KEY(MOD_LALT, KC_ESC),
[4] = ACTION_LAYER_TOGGLE(GAMING_LAYER)
};
/**
* Sends a key
*/
void send_key(uint16_t key) {
register_code(key);
unregister_code(key);
}
/**
* Toggles a layer
*/
void toggle_layer(uint16_t layer) {
if(IS_LAYER_ON(layer)) {
layer_off(layer);
} else {
layer_on(layer);
}
}
/**
* Enable layer while holding key
* As opposed to ACTION_LAYER_MOMENTARY, this actually sends the key
*/
const macro_t* layer_momentary_send(keyrecord_t *record, uint16_t layer, uint16_t key) {
if(record->event.pressed) {
layer_on(layer);
register_code(key);
} else {
layer_off(layer);
unregister_code(key);
}
return MACRO_NONE;
}
/**
* Sends the specified key and toggles the layer
*/
const macro_t* tap_toggle_layer(keyrecord_t *record, uint16_t layer, uint16_t key) {
if(record->event.pressed) {
toggle_layer(layer);
send_key(key);
}
return MACRO_NONE;
}
const macro_t* action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
switch(id) {
case 0: return MACRODOWN(T(COMP), T(COMM), END);
case 1: return MACRODOWN(T(COMP), T(QUOTE), END);
case 2: return MACRODOWN(T(COMP), T(GRV), END);
case 3: return MACRODOWN(T(COMP), D(LSFT), T(6), U(LSFT), END);
case 4: return MACRODOWN(T(COMP), T(C), T(EQL), END);
case 6: return tap_toggle_layer(record, GMGDVK_LAYER, KC_Y);
case 7: return tap_toggle_layer(record, GMGDVK_LAYER, KC_U);
case 8: return tap_toggle_layer(record, GMGDVK_LAYER, KC_DEL);
case 9: return tap_toggle_layer(record, GMGDVK_LAYER, KC_ESC);
case 10: return tap_toggle_layer(record, GMGDVK_LAYER, KC_ENT);
case 11: return layer_momentary_send(record, GMGTAB_LAYER, KC_TAB);
default: return MACRO_NONE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.