1
0
Fork 0

[deadcyclo layout] Refactoring. Use custom functions and macros

This commit is contained in:
Brendan Johan Lee 2017-01-30 19:42:27 +01:00
parent f400ac1d7d
commit f70758622b

View file

@ -8,11 +8,21 @@
#define MDIA 2 // media keys
#define NAVG 3 // navigation
enum custom_keycodes {
PLACEHOLDER = SAFE_RANGE, // can always be here
enum macros {
RUN
};
enum function_ids {
EMOJI,
EMOJI2,
EPRM,
VRSN,
RGB_SLD,
GO_GROUP
};
/* opt can only be 0-15 */
enum emojis {
SHRUG,
YAY,
HUG,
@ -28,13 +38,56 @@ enum custom_keycodes {
FACE1,
FACE2,
UHU,
SMRK1,
SMRK1
};
enum emojis2 {
SMRK2,
LOVE
};
// TODO: Get rid of of keys I don't want. Make others that I do. Set up lots of makros (Using hyper (and meh)) keys (where to put them?)
enum progmem_ids {
EMOJI_SHRUG,
EMOJI_YAY,
EMOJI_HUG,
EMOJI_SMILE,
EMOJI_SMILE2,
EMOJI_HMM1,
EMOJI_HMM2,
EMOJI_BEAR1,
EMOJI_BEAR2,
EMOJI_FUU,
EMOJI_EGGY1,
EMOJI_EGGY2,
EMOJI_FACE1,
EMOJI_FACE2,
EMOJI_UHU,
EMOJI_SMRK1,
EMOJI_SMRK2,
EMOJI_LOVE,
F_EPRM,
F_VRSN,
F_RGB_SLD,
I3_GO_GROUP_10,
I3_GO_GROUP_1,
I3_GO_GROUP_2,
I3_GO_GROUP_3,
I3_GO_GROUP_4,
I3_GO_GROUP_5,
I3_GO_GROUP_6,
I3_GO_GROUP_7,
I3_GO_GROUP_8,
I3_GO_GROUP_9,
};
// TODO: Finish the macros for i3 (Macros should potentially be own function instead to make things easier? some of them at least, f. ex. the ones that use 1-0 keys so we can have a single switch)
// TODO: Do stuff with hyper and meh keys
// TODO: Add macros for lots of stuff. (Lastpass cli, pushbullet cli, other push service cli, linode cli, more?)
// TODO: Make macros for gnu screen and i3wm
// TODO: Need to change hotkeys for lastpass, and potentially make my own keys for them on one of my layers
// TODO: Look into using tap dance
// TODO: Use leader key for stuff. See https://github.com/qmk/qmk_firmware/wiki
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap 0: Basic layer
*
@ -47,7 +100,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* |--------+------+------+------+------+------| Hyper| | Meh |------+------+------+------+------+--------|
* | LShift |Z/Ctrl| X | C | V | B | | | | N | M | , | . |//Ctrl| RShift |
* `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
* |Grv/L1| UNI |AltShf| Lalt | Ralt | | Lalt | Ralt | [ | UNI | ~/L1 |
* |Grv/L1| UNI |AltShf| Lalt | Ralt | | Lalt | Ralt | LEAD | UNI | ~/L1 |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | App | Home | | PgUp | Ins |
@ -74,7 +127,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
TG(SYMB), KC_Y, KC_U, KC_I, KC_O, KC_P, LT(SYMB, KC_BSLS),
KC_H, KC_J, KC_K, KC_L, LT(MDIA, KC_SCLN),CTL_T(KC_QUOT),
MEH_T(KC_NO),KC_N, KC_M, KC_COMM,KC_DOT, CTL_T(KC_SLSH), KC_RSFT,
KC_LALT, KC_RALT,KC_LBRC,LCTL(LSFT(KC_U)), LT(SYMB,KC_TILD),
KC_LALT, KC_RALT,KC_LEAD,LCTL(LSFT(KC_U)), LT(SYMB,KC_TILD),
KC_PGUP, KC_INS,
KC_PGDN,
KC_RBRC,KC_BSPC, KC_ENT
@ -109,7 +162,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_TRNS,KC_PERC,KC_CIRC,KC_LBRC,KC_RBRC,KC_TILD,KC_TRNS,
KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,
RGB_TOG,RGB_MOD,
RGB_SLD,
F(F_RGB_SLD),
RGB_VAD,RGB_VAI,KC_TRNS,
// right hand
KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,
@ -119,14 +172,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_TRNS,KC_DOT, KC_0, KC_EQL, KC_TRNS,
RGB_HUD, RGB_HUI,
KC_TRNS,
EPRM, KC_DEL, KC_TRNS
F(F_EPRM), KC_DEL, KC_TRNS
),
/* Keymap 2: Media, mouse and navigation
*
* ,--------------------------------------------------. ,--------------------------------------------------.
* | | | | | | | | | | | | | | | |
* | | gg(1)| | | | | | | | | | | | | |
* |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
* | | | | MsUp | | | | | | | | Up | | | |
* | | | | MsUp | RUN | | | | | | | Up | | | |
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
* | | |MsLeft|MsDown|MsRght| |------| |------| | Left | Down | Right| | Play |
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
@ -144,8 +197,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
*/
// MEDIA , MOUSE and NAVIGATION
[MDIA] = KEYMAP(
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, F(I3_GO_GROUP_1), F(I3_GO_GROUP_2), F(I3_GO_GROUP_3), F(I3_GO_GROUP_4), F(I3_GO_GROUP_5), F(I3_GO_GROUP_6),
KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, M(RUN), KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN1, KC_BTN2,
@ -153,7 +206,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
// right hand
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
F(I3_GO_GROUP_6), F(I3_GO_GROUP_7), F(I3_GO_GROUP_8), F(I3_GO_GROUP_9), F(I3_GO_GROUP_10), KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_LEFT, KC_DOWN, KC_RIGHT, KC_TRNS, KC_MPLY,
KC_TRNS, KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS,
@ -187,10 +240,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
// Unicode
[NAVG] = KEYMAP(
KC_TRNS, UC(0x250c), UC(0x2510), UC(0x2514), UC(0x2518), UC(0x2502), UC(0x2500),
KC_TRNS, SHRUG, YAY, HUG, SMILE, SMILE2, KC_TRNS,
KC_TRNS, HMM1, HMM2, BEAR1, BEAR2, FUU,
KC_TRNS, EGGY1, EGGY2, FACE1, FACE2, UHU, KC_TRNS,
KC_TRNS, SMRK1, SMRK2, LOVE, VRSN,
KC_TRNS, F(EMOJI_SHRUG), F(EMOJI_YAY), F(EMOJI_HUG), F(EMOJI_SMILE), F(EMOJI_SMILE2), KC_TRNS,
KC_TRNS, F(EMOJI_HMM1), F(EMOJI_HMM2), F(EMOJI_BEAR1), F(EMOJI_BEAR2), F(EMOJI_FUU),
KC_TRNS, F(EMOJI_EGGY1), F(EMOJI_EGGY2), F(EMOJI_FACE1), F(EMOJI_FACE2), F(EMOJI_UHU), KC_TRNS,
KC_TRNS, F(EMOJI_SMRK1), F(EMOJI_SMRK2), F(EMOJI_LOVE), F(F_VRSN),
KC_TRNS, KC_TRNS,
KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS,
@ -207,56 +260,69 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};
const uint16_t PROGMEM fn_actions[] = {
[1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols)
[EMOJI_SHRUG] = ACTION_FUNCTION_OPT(EMOJI, SHRUG),
[EMOJI_YAY] = ACTION_FUNCTION_OPT(EMOJI, YAY),
[EMOJI_HUG] = ACTION_FUNCTION_OPT(EMOJI,HUG),
[EMOJI_SMILE] = ACTION_FUNCTION_OPT(EMOJI,SMILE),
[EMOJI_SMILE2] = ACTION_FUNCTION_OPT(EMOJI,SMILE2),
[EMOJI_HMM1] = ACTION_FUNCTION_OPT(EMOJI,HMM1),
[EMOJI_HMM2] = ACTION_FUNCTION_OPT(EMOJI,HMM2),
[EMOJI_BEAR1] = ACTION_FUNCTION_OPT(EMOJI,BEAR1),
[EMOJI_BEAR2] = ACTION_FUNCTION_OPT(EMOJI,BEAR2),
[EMOJI_FUU] = ACTION_FUNCTION_OPT(EMOJI,FUU),
[EMOJI_EGGY1] = ACTION_FUNCTION_OPT(EMOJI,EGGY1),
[EMOJI_EGGY2] = ACTION_FUNCTION_OPT(EMOJI,EGGY2),
[EMOJI_FACE1] = ACTION_FUNCTION_OPT(EMOJI,FACE1),
[EMOJI_FACE2] = ACTION_FUNCTION_OPT(EMOJI,FACE2),
[EMOJI_UHU] = ACTION_FUNCTION_OPT(EMOJI,UHU),
[EMOJI_SMRK1] = ACTION_FUNCTION_OPT(EMOJI,SMRK1),
[EMOJI_SMRK2] = ACTION_FUNCTION_OPT(EMOJI2,SMRK2),
[EMOJI_LOVE] = ACTION_FUNCTION_OPT(EMOJI2,LOVE),
[F_EPRM] = ACTION_FUNCTION(EPRM),
[F_VRSN] = ACTION_FUNCTION(VRSN),
[F_RGB_SLD] = ACTION_FUNCTION(RGB_SLD),
[I3_GO_GROUP_10]= ACTION_FUNCTION_OPT(GO_GROUP,0),
[I3_GO_GROUP_1] = ACTION_FUNCTION_OPT(GO_GROUP,1),
[I3_GO_GROUP_2] = ACTION_FUNCTION_OPT(GO_GROUP,2),
[I3_GO_GROUP_3] = ACTION_FUNCTION_OPT(GO_GROUP,3),
[I3_GO_GROUP_4] = ACTION_FUNCTION_OPT(GO_GROUP,4),
[I3_GO_GROUP_5] = ACTION_FUNCTION_OPT(GO_GROUP,5),
[I3_GO_GROUP_6] = ACTION_FUNCTION_OPT(GO_GROUP,6),
[I3_GO_GROUP_7] = ACTION_FUNCTION_OPT(GO_GROUP,7),
[I3_GO_GROUP_8] = ACTION_FUNCTION_OPT(GO_GROUP,8),
[I3_GO_GROUP_9] = ACTION_FUNCTION_OPT(GO_GROUP,9),
};
#define TAP_ONCE(code) \
register_code (code); \
unregister_code (code)
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
// MACRODOWN only works in this function
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {
if (record->event.pressed) {
switch(id) {
case 0:
if (record->event.pressed) {
SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
}
break;
case 1:
if (record->event.pressed) { // For resetting EEPROM
eeconfig_init();
}
break;
}
return MACRO_NONE;
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
// dynamically generate these.
case EPRM:
if (record->event.pressed) {
eeconfig_init();
}
return false;
break;
case VRSN:
if (record->event.pressed) {
SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
}
return false;
break;
case RGB_SLD:
if (record->event.pressed) {
#ifdef RGBLIGHT_ENABLE
#ifdef RGBLIGHT_ENABLE
rgblight_mode(1);
#endif
}
return false;
#endif
break;
case GO_GROUP:
register_code(KC_LCTL); TAP_ONCE(KC_I); unregister_code(KC_LCTL);
TAP_ONCE(KC_G);
if (opt == 0) {
TAP_ONCE(39);
} else {
TAP_ONCE(29+opt);
}
break;
case EMOJI:
switch(opt) {
case SHRUG:
if (record->event.pressed) {
unicode_input_start(); register_hex(0xaf); unicode_input_finish();
TAP_ONCE (KC_BSLS);
register_code (KC_RSFT); TAP_ONCE (KC_MINS); TAP_ONCE (KC_9); unregister_code (KC_RSFT);
@ -264,17 +330,11 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
register_code (KC_RSFT); TAP_ONCE (KC_0); TAP_ONCE (KC_MINS); unregister_code (KC_RSFT);
TAP_ONCE (KC_SLSH);
unicode_input_start (); register_hex(0xaf); unicode_input_finish();
}
return false;
break;
case YAY:
if (record->event.pressed) {
SEND_STRING ("\\o/");
}
return false;
break;
case HUG:
if (record->event.pressed) {
unicode_input_start(); register_hex(0x0f3c); unicode_input_finish();
TAP_ONCE (KC_SPC);
unicode_input_start(); register_hex(0x3064); unicode_input_finish();
@ -285,67 +345,46 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
TAP_ONCE (KC_SPC);
unicode_input_start(); register_hex(0x0f3d); unicode_input_finish();
unicode_input_start(); register_hex(0x3064); unicode_input_finish();
}
return false;
break;
case SMILE:
if (record->event.pressed) {
unicode_input_start(); register_hex(0x0298); unicode_input_finish();
unicode_input_start(); register_hex(0x203f); unicode_input_finish();
unicode_input_start(); register_hex(0x0298); unicode_input_finish();
}
return false;
break;
case SMILE2:
if (record->event.pressed) {
unicode_input_start(); register_hex(0x0028); unicode_input_finish();
unicode_input_start(); register_hex(0x0298); unicode_input_finish();
unicode_input_start(); register_hex(0x203f); unicode_input_finish();
unicode_input_start(); register_hex(0x0298); unicode_input_finish();
unicode_input_start(); register_hex(0x0029); unicode_input_finish();
}
return false;
break;
case HMM1:
if (record->event.pressed) {
unicode_input_start(); register_hex(0x0ca0); unicode_input_finish();
unicode_input_start(); register_hex(0x005f); unicode_input_finish();
unicode_input_start(); register_hex(0x0ca0); unicode_input_finish();
}
return false;
break;
case HMM2:
if (record->event.pressed) {
unicode_input_start(); register_hex(0x0028); unicode_input_finish();
unicode_input_start(); register_hex(0x0ca0); unicode_input_finish();
unicode_input_start(); register_hex(0x005f); unicode_input_finish();
unicode_input_start(); register_hex(0x0ca0); unicode_input_finish();
unicode_input_start(); register_hex(0x0029); unicode_input_finish();
}
return false;
break;
case BEAR1:
if (record->event.pressed) {
unicode_input_start(); register_hex(0x0295); unicode_input_finish();
unicode_input_start(); register_hex(0x2022); unicode_input_finish();
unicode_input_start(); register_hex(0x1d25); unicode_input_finish();
unicode_input_start(); register_hex(0x2022); unicode_input_finish();
unicode_input_start(); register_hex(0x0294); unicode_input_finish();
}
return false;
break;
case BEAR2:
if (record->event.pressed) {
unicode_input_start(); register_hex(0x0028); unicode_input_finish();
unicode_input_start(); register_hex(0x1d54); unicode_input_finish();
unicode_input_start(); register_hex(0x1d25); unicode_input_finish();
unicode_input_start(); register_hex(0x1d54); unicode_input_finish();
unicode_input_start(); register_hex(0x0029); unicode_input_finish();
}
return false;
break;
case FUU:
if (record->event.pressed) {
unicode_input_start(); register_hex(0x256d); unicode_input_finish();
unicode_input_start(); register_hex(0x2229); unicode_input_finish();
unicode_input_start(); register_hex(0x256e); unicode_input_finish();
@ -357,11 +396,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
unicode_input_start(); register_hex(0x256d); unicode_input_finish();
unicode_input_start(); register_hex(0x2229); unicode_input_finish();
unicode_input_start(); register_hex(0x256e); unicode_input_finish();
}
return false;
break;
case EGGY1:
if (record->event.pressed) {
unicode_input_start(); register_hex(0x0028); unicode_input_finish();
unicode_input_start(); register_hex(0x256f); unicode_input_finish();
unicode_input_start(); register_hex(0x00b0); unicode_input_finish();
@ -369,11 +405,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
unicode_input_start(); register_hex(0x00b0); unicode_input_finish();
unicode_input_start(); register_hex(0xff09); unicode_input_finish();
unicode_input_start(); register_hex(0x256f); unicode_input_finish();
}
return false;
break;
case EGGY2:
if (record->event.pressed) {
unicode_input_start(); register_hex(0x30ce); unicode_input_finish();
unicode_input_start(); register_hex(0x0028); unicode_input_finish();
unicode_input_start(); register_hex(0x0020); unicode_input_finish();
@ -382,67 +415,64 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
unicode_input_start(); register_hex(0x309c); unicode_input_finish();
unicode_input_start(); register_hex(0x30ce); unicode_input_finish();
unicode_input_start(); register_hex(0x0029); unicode_input_finish();
}
return false;
break;
case FACE1:
if (record->event.pressed) {
unicode_input_start(); register_hex(0x0028); unicode_input_finish();
unicode_input_start(); register_hex(0x002d); unicode_input_finish();
unicode_input_start(); register_hex(0x005f); unicode_input_finish();
unicode_input_start(); register_hex(0x002d); unicode_input_finish();
unicode_input_start(); register_hex(0x0029); unicode_input_finish();
}
return false;
break;
case FACE2:
if (record->event.pressed) {
unicode_input_start(); register_hex(0x0028); unicode_input_finish();
unicode_input_start(); register_hex(0x2022); unicode_input_finish();
unicode_input_start(); register_hex(0x005f); unicode_input_finish();
unicode_input_start(); register_hex(0x2022); unicode_input_finish();
unicode_input_start(); register_hex(0x0029); unicode_input_finish();
}
return false;
break;
case UHU:
if (record->event.pressed) {
unicode_input_start(); register_hex(0x2299); unicode_input_finish();
unicode_input_start(); register_hex(0xfe4f); unicode_input_finish();
unicode_input_start(); register_hex(0x2299); unicode_input_finish();
}
return false;
break;
case SMRK1:
if (record->event.pressed) {
unicode_input_start(); register_hex(0x005e); unicode_input_finish();
unicode_input_start(); register_hex(0x032e); unicode_input_finish();
unicode_input_start(); register_hex(0x005e); unicode_input_finish();
}
return false;
break;
}
break;
case EMOJI2:
switch(opt) {
case SMRK2:
if (record->event.pressed) {
unicode_input_start(); register_hex(0x0028); unicode_input_finish();
unicode_input_start(); register_hex(0x005e); unicode_input_finish();
unicode_input_start(); register_hex(0x032e); unicode_input_finish();
unicode_input_start(); register_hex(0x005e); unicode_input_finish();
unicode_input_start(); register_hex(0x0029); unicode_input_finish();
}
return false;
break;
case LOVE:
if (record->event.pressed) {
unicode_input_start(); register_hex(0x2665); unicode_input_finish();
unicode_input_start(); register_hex(0x203f); unicode_input_finish();
unicode_input_start(); register_hex(0x2665); unicode_input_finish();
}
return false;
break;
}
return true;
break;
}
}
}
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
if (record->event.pressed) {
switch(id) {
case RUN:
return MACRO( D(LCTL), T(I), U(LCTL), T(R), END );
break;
}
}
return MACRO_NONE;
};
// Runs just one time when the keyboard initializes.
void matrix_init_user(void) {
set_unicode_input_mode(UC_LNX);
@ -450,7 +480,6 @@ void matrix_init_user(void) {
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {
uint8_t layer = biton32(layer_state);
ergodox_board_led_off();