X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=keyboard%2Fergodox%2Fkeymap_cub.h;h=f6b87dcf3041383a2b51a7a73613cab72ae8700c;hb=76c7ebebd7a7b55d2eddabc7bb7978a904f5706f;hp=e3a636b8fb249fbb2a43dcc4c667100c82e35839;hpb=2381945e3079ab92ffb752e1fc9a3e4723d3530b;p=max%2Ftmk_keyboard.git diff --git a/keyboard/ergodox/keymap_cub.h b/keyboard/ergodox/keymap_cub.h index e3a636b8..f6b87dcf 100644 --- a/keyboard/ergodox/keymap_cub.h +++ b/keyboard/ergodox/keymap_cub.h @@ -93,7 +93,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KEYMAP( // Layer0: default, leftled:none // left hand GRV, 1, 2, 3, 4, 5, BSLS, - TAB, Q, W, E, R, T, FN23, + FN2, Q, W, E, R, T, FN23, FN11,FN28,FN29,FN30,FN31,G, FN12,FN24,FN25,FN26,FN27,B, HOME, FN21,FN20,CAPS,FN13,FN14, @@ -186,15 +186,15 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { TRNS,TRNS,TRNS, /* in Workman right hand will be: - + - ^ { } ( ) = + { } ( ) + + ^ ! ? = ' ! $ " ; \ # [ < > ] \ */ // right hand - NO, NO, NO, NO, NO, NO, PPLS, - TRNS,MINS,4, 5, 9, 0, EQL, + NO, NO, 4, 5, 9, 0, PPLS, + TRNS,MINS,2, FN5, 9, 0, EQL, BSLS,2, P, FN1, 1, FN2, TRNS,3, 6, FN3, FN4, 7, FN2, TRNS,TRNS,TRNS,TRNS,TRNS, @@ -251,8 +251,8 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KEYMAP( // Layer7: F-keys only, leftled:top/white // left hand - TRNS,NO, NO, NO, NO, NO, NO, - TRNS,F13, F14, F15, F16, NO, TRNS, + FN0, NO, NO, NO, NO, NO, NO, + FN1, F13, F14, F15, F16, NO, FN23, TRNS,F17, F18, F19, F20, NO, TRNS,F21, F22, F23, F24, NO, TRNS, TRNS,TRNS,TRNS,TRNS,TRNS, @@ -261,7 +261,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { TRNS,TRNS,TRNS, // right hand NO, NO, NO, NO, NO, NO, TRNS, - TRNS,NO, F1, F2, F3, F4, TRNS, + FN23,NO, F1, F2, F3, F4, TRNS, NO, F5, F6, F7, F8, TRNS, TRNS,NO, F9, F10, F11, F12, TRNS, TRNS,TRNS,TRNS,TRNS,TRNS, @@ -282,10 +282,10 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { TRNS,TRNS,TRNS, // right hand - TRNS,MPLY,MPRV,MNXT,VOLD,VOLU,MUTE, - TRNS,BTN2,WH_L,WH_U,WH_D,WH_R,PGUP, + F16, MPLY,MPRV,MNXT,VOLD,VOLU,MUTE, + F14, BTN2,WH_L,WH_U,WH_D,WH_R,PGUP, BTN1,MS_L,MS_U,MS_D,MS_R,PGDN, - TRNS,BTN3,HOME,END, DEL, INS, NO, + F15, BTN3,HOME,END, DEL, INS, NO, TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS, TRNS, @@ -339,13 +339,21 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { }; -/* id for user defined functions */ +/* id for user defined functions & macros */ enum function_id { TEENSY_KEY, + CUSTOM_KEY, L_CTRL_ALT_ENT, R_CTRL_ALT_ENT, }; +enum macro_id { + XMONAD_RESET, + PASSWORD1, + PASSWORD2, + PASSWORD3, +}; + /* * Fn action definition */ @@ -385,6 +393,9 @@ static const uint16_t PROGMEM fn_actions[] = { // i'd like to remove this - will try to get used to live without this and convert them to usual keys [20] = ACTION_LAYER_MOMENTARY(2), // FN20 - momentary Layer2, to use with Numpad keys +// or +// [20] = ACTION_FUNCTION_TAP(CUSTOM_KEY), // FN20 - use custom key, with tapping support + [23] = ACTION_LAYER_TAP_KEY(7, KC_BSLS), // FN23 - momentary Layer7 on ' , to use with F* keys (F1-F24) [24] = ACTION_LAYER_TAP_KEY(4, KC_Z), // FN24 = momentary Layer4 on Z key, to use with unconvenient keys @@ -393,6 +404,21 @@ static const uint16_t PROGMEM fn_actions[] = { [27] = ACTION_LAYER_TAP_KEY(2, KC_V), // FN27 = momentary Layer2 on V key, to use with Numpad keys }; +static const uint16_t PROGMEM fn_actions_4[] = { + [1] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS), // FN1 = Shifted BackSlash // " in Workman + [2] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS), // FN2 = Shifted Minus // \ in Workman + [3] = ACTION_MODS_KEY(MOD_LSFT, KC_COMM), // FN3 = Shifted comma // < in Workman + [4] = ACTION_MODS_KEY(MOD_LSFT, KC_DOT), // FN4 = Shifted dot // > in Workman + [5] = ACTION_MODS_KEY(MOD_LSFT, KC_SLSH), // FN5 = Shifted slash // ? in Workman +}; + +static const uint16_t PROGMEM fn_actions_7[] = { + [0] = ACTION_MACRO(XMONAD_RESET), // FN0 = xmonad-reanimator + [1] = ACTION_MACRO(PASSWORD1), // FN1 = default password + [2] = ACTION_MACRO(PASSWORD1), // FN2 = other password + [3] = ACTION_MACRO(PASSWORD1), // FN3 = mega password +}; + void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) { // print("action_function called\n"); @@ -437,5 +463,88 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) } } } + + +/* + * just an example of custom key implementation + * not really needed with custom keymap_fn_to_action(), + * because it will allow you to have 32 FN** keys on EACH layer + */ + +/* + keyevent_t event = record->event; + + if (id == CUSTOM_KEY) { + uint8_t layer = biton32(layer_state); + uint8_t col = event.key.col; + uint8_t row = event.key.row; + uint8_t handled = 0; + + if (event.pressed) { + if (layer == XXX && col == XXX && row == XXX) { + action_macro_play( + MACRO( + ........... + END) + ); + handled++; + } + } + } + + if (!handled) { + print("custom key not handled"); + print(": layer "); pdec(layer); + print(", col "); pdec(col); + print(", row "); pdec(row); + print("\n"); + } + } +*/ + +} + +#include "keymap_passwords.h" +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { + if (record->event.pressed) { + switch (id) { + case XMONAD_RESET: return MACRO_XMONAD_RESET; + case PASSWORD1: return MACRO_PASSWORD1; + } + } + return MACRO_NONE; +} + +#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0])) +#define FN_ACTIONS_4_SIZE (sizeof(fn_actions_4) / sizeof(fn_actions_4[0])) +#define FN_ACTIONS_7_SIZE (sizeof(fn_actions_7) / sizeof(fn_actions_7[0])) + +/* + * translates Fn keycode to action + * for some layers, use different translation table + */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + uint8_t layer = biton32(layer_state); + + action_t action; + action.code = ACTION_NO; + + if (layer == 4 && FN_INDEX(keycode) < FN_ACTIONS_4_SIZE) { + action.code = pgm_read_word(&fn_actions_4[FN_INDEX(keycode)]); + } + + if (layer == 7 && FN_INDEX(keycode) < FN_ACTIONS_7_SIZE) { + action.code = pgm_read_word(&fn_actions_7[FN_INDEX(keycode)]); + } + + // by default, use fn_actions from default layer 0 + // this is needed to get mapping for same key, that was used switch to some layer, + // to have possibility to switch layers back + if (action.code == ACTION_NO && FN_INDEX(keycode) < FN_ACTIONS_SIZE) { + action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]); + } + + return action; }