Skip to content

Instantly share code, notes, and snippets.

@kaansoral kaansoral/keymap_kaan.c
Last active Sep 23, 2015

Embed
What would you like to do?
#include "keymap_common.h"
#include "wait.h"
#include "action_util.h"
/*
[22/09/15]
FaceW PCB:
Control/CapsLock: RCtrl
Fn: RShift
*/
/*
KEYMAP(
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS,
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9,
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS,
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3,
LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
),
*/
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
/* Layer 0: Default Layer
* ,-----------------------------------------------------------.
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `|
* |-----------------------------------------------------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs|
* |-----------------------------------------------------------|
* |Contro| A| S| D| F| G| H| J| K| L|SCLN| '|ENT |
* |-----------------------------------------------------------|
* |LSHIFT | Z| X| C| V| B| N| M| ,| .|SLSH|Shift |Fn1|
* `-----------------------------------------------------------'
* |Gui|Alt | SPC |Fn2 |Gui|
* `-------------------------------------------'
*/
[0] = \
KEYMAP(
FN6, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
TAB, Q, W, E, R, T, Y, FN11, FN5, FN12, P, FN8/**/,FN9,BSLS, DEL, END, PGDN, P7, P8, P9,
CAPS,A, FN13, D, F, FN14, H, J, K, L, SCLN, FN7, ENT, P4, P5, P6, PPLS,
LSHIFT, Z, X, FN15, V, B, N, M, FN25/*COMM*/,FN26/*DOT*/, SLSH, FN10/*right-shift/fn*/, UP, P1, P2, P3,
LCTL,LGUI,LALT, SPC, RALT,FN2/*RGUI*/, FN2, FN1/*RCTRL*/, LEFT,DOWN,RGHT, P0, PDOT,PENT
),
/* Layer 1: "Control" Layer
* ,-----------------------------------------------------------.
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
* |-----------------------------------------------------------|
* |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs|
* |-----------------------------------------------------------|
* |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter |
* |-----------------------------------------------------------|
* |Shift | | | | | | +| -|End|PgD|Dow|Shift | |
* `-----------------------------------------------------------'
* |Gui|Alt | Space |Alt |Gui|
* `-------------------------------------------'
*/
[1] = \
KEYMAP(
SYSTEM_POWER/**/, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
CAPS,C, WH_U, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS, F14, F15/*brightness*/, BSLS, DEL, END, PGDN, P7, P8, P9,
LCTL,WH_L,WH_D,WH_R,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT, ENT, P4, P5, P6, PPLS,
LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,/**/VOLD,VOLU,MUTE/**/, RSFT, MPLY/**/, P1, P2, P3,
LCTL,NLCK,LALT, F13/*lang*/, RALT,RGUI,TRNS, TRNS, MPRV/**/,DOWN,MNXT/**/, P0, PDOT,PENT
),
/* Layer 2: Left FN Layer - mainly for the FN3 tap-shift [23/09/15]
* ,-----------------------------------------------------------.
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
* |-----------------------------------------------------------|
* |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs|
* |-----------------------------------------------------------|
* |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter |
* |-----------------------------------------------------------|
* |Shift | | | | | | +| -|End|PgD|Dow|Shift | |
* `-----------------------------------------------------------'
* |Gui|Alt | Space |Alt |Gui|
* `-------------------------------------------'
*/
[2] = \
KEYMAP(
SYSTEM_POWER/**/, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
CAPS,F, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS, F14, F15/*brightness*/, BSLS, DEL, END, PGDN, P7, P8, P9,
LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT, ENT, P4, P5, P6, PPLS,
LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,/**/VOLD,VOLU,MUTE/**/, TRNS, MPLY/**/, P1, P2, P3,
LCTL,LGUI,LALT, F13/*lang*/, NO,FN3,NO, NO, MPRV/**/,DOWN,MNXT/**/, P0, PDOT,PENT
),
/* Layer 3: Right-Layer
* ,-----------------------------------------------------------.
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
* |-----------------------------------------------------------|
* |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T|
* |-----------------------------------------------------------|
* |Contro| | | | | |Mb2|McL|McD|McR|Fn | |Return |
* |-----------------------------------------------------------|
* |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | |
* `-----------------------------------------------------------'
* |Gui |Alt | Mb1 |Fn |Fn |
* `--------------------------------------------'
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel8
*/
[3] = \
KEYMAP(
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
GRV, F1, F2, F3, F4, F5, F6, F7, NO, NO, NO, FN20, FN21, DEL, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
1, R, NO, NO, NO, NO, WH_L,WH_D,MS_U,FN4/**/,FN22,FN16,FN17,FN19, DEL, END, PGDN, P7, P8, P9,
LCTL,NO,NO,FN18,NO,NO, NO, MS_L,MS_D,MS_R,TRNS,NO, FN24, P4, P5, P6, PPLS,
LSFT,NO, NO, FN23, NO, BTN3,INS,BTN1,BTN4,BTN5,NO, FN3, PGUP, P1, P2, P3,
LCTL,LGUI,LALT, BTN1, RALT,TRNS,TRNS,TRNS, HOME,PGDN,END, P0, PDOT,PENT
),
};
/*
* Macro definition
*/
enum macro_id {
MAXIMIZE,
TR_U,TR_I,TR_O,TR_S,TR_G,TR_C,
SHIFT_ESC,
BACKTICK,
CO1,CC1,
V_PREV,V_NEXT,V_DIFF,V_CHANGED,
C_PREV,C_NEXT,
IDE_COLOR,IDE_SWITCH,IDE_COMMANDS,
CO2,CC2,
};
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
switch (id) {
case V_PREV:
return (record->event.pressed?MACRO(D(LCTRL),D(LSHIFT),T(PGDN),U(LSHIFT),U(LCTRL),END):MACRO(END));
case V_NEXT:
return (record->event.pressed?MACRO(D(LCTRL),D(LSHIFT),T(PGUP),U(LSHIFT),U(LCTRL),END):MACRO(END));
case V_DIFF:
return (record->event.pressed?MACRO(D(LCTRL),D(LALT),T(D),U(LALT),U(LCTRL),END):MACRO(END));
case V_CHANGED:
return (record->event.pressed?MACRO(D(LCTRL),D(LGUI),T(U),U(LGUI),U(LCTRL),END):MACRO(END));
case C_PREV:
return (record->event.pressed?MACRO(D(LGUI),T(PGDN),U(LGUI),END):MACRO(END));
case C_NEXT:
return (record->event.pressed?MACRO(D(LGUI),T(PGUP),U(LGUI),END):MACRO(END));
case IDE_COLOR:
return (record->event.pressed?MACRO(D(LGUI),D(LSHIFT),T(C),U(LSHIFT),U(LGUI),END):MACRO(END));
case IDE_SWITCH:
return (record->event.pressed?MACRO(D(LCTRL),D(LGUI),T(P),U(LGUI),U(LCTRL),END):MACRO(END));
case IDE_COMMANDS:
return (record->event.pressed?MACRO(D(LGUI),D(LSHIFT),T(P),U(LSHIFT),U(LGUI),END):MACRO(END));
case MAXIMIZE:
if (record->event.pressed) {
/*U"LGui"+U"LCtrl"+U"LAlt"+U"LShift"+U"O"*/
register_code(KC_LGUI);
register_code(KC_LCTRL);
register_code(KC_LALT);
register_code(KC_LSHIFT);
register_code(KC_O);
wait_ms(40);
register_code(KC_SPACE);
wait_ms(10);
register_code(KC_ESC);
wait_ms(3);
unregister_code(KC_ESC);
unregister_code(KC_SPACE);
unregister_code(KC_O);
unregister_code(KC_LSHIFT);
unregister_code(KC_LALT);
unregister_code(KC_LCTRL);
unregister_code(KC_LGUI);
}
break;
}
return MACRO_NONE;
}
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
static bool TR_U_mode = false,TR_I_mode = false,TR_O_mode = false,TR_S_mode = false,TR_G_mode = false,TR_C_mode = false,SE_mode=false,BACKTICK_mode=false,CO1_mode=false,CC1_mode=false;
switch (id) {
case TR_U:
if (record->event.pressed) {
if (keyboard_report->mods & MOD_BIT(KC_LALT)) {
TR_U_mode = true;
unregister_code(KC_LALT);
register_code(KC_F13);
unregister_code(KC_F13);
wait_ms(1);
register_code(KC_RBRC);unregister_code(KC_RBRC);
register_code(KC_F13);
unregister_code(KC_F13);
register_code(KC_LALT);
} else {
register_code(KC_U);
}
} else {
if (TR_U_mode) {
TR_U_mode = false;
} else {
unregister_code(KC_U);
}
}
break;
case TR_I:
if (record->event.pressed) {
if (keyboard_report->mods & MOD_BIT(KC_LALT)) {
TR_I_mode = true;
unregister_code(KC_LALT);
register_code(KC_F13);
unregister_code(KC_F13);
wait_ms(1);
register_code(KC_I);unregister_code(KC_I);
register_code(KC_F13);
unregister_code(KC_F13);
register_code(KC_LALT);
} else {
register_code(KC_I);
}
} else {
if (TR_I_mode) {
TR_I_mode = false;
} else {
unregister_code(KC_I);
}
}
break;
case TR_O:
if (record->event.pressed) {
if (keyboard_report->mods & MOD_BIT(KC_LALT)) {
TR_O_mode = true;
unregister_code(KC_LALT);
register_code(KC_F13);
unregister_code(KC_F13);
wait_ms(1);
register_code(KC_COMM);unregister_code(KC_COMM);
register_code(KC_F13);
unregister_code(KC_F13);
register_code(KC_LALT);
} else {
register_code(KC_O);
}
} else {
if (TR_O_mode) {
TR_O_mode = false;
} else {
unregister_code(KC_O);
}
}
break;
case TR_S:
if (record->event.pressed) {
if (keyboard_report->mods & MOD_BIT(KC_LALT)) {
TR_S_mode = true;
unregister_code(KC_LALT);
register_code(KC_F13);
unregister_code(KC_F13);
wait_ms(1);
register_code(KC_SCLN);unregister_code(KC_SCLN);
register_code(KC_F13);
unregister_code(KC_F13);
register_code(KC_LALT);
} else {
register_code(KC_S);
}
} else {
if (TR_S_mode) {
TR_S_mode = false;
} else {
unregister_code(KC_S);
}
}
break;
case TR_G:
if (record->event.pressed) {
if (keyboard_report->mods & MOD_BIT(KC_LALT)) {
TR_G_mode = true;
unregister_code(KC_LALT);
register_code(KC_F13);
unregister_code(KC_F13);
wait_ms(1);
register_code(KC_LBRC);unregister_code(KC_LBRC);
register_code(KC_F13);
unregister_code(KC_F13);
register_code(KC_LALT);
} else {
register_code(KC_G);
}
} else {
if (TR_G_mode) {
TR_G_mode = false;
} else {
unregister_code(KC_G);
}
}
break;
case TR_C:
if (record->event.pressed) {
if (keyboard_report->mods & MOD_BIT(KC_LALT)) {
TR_C_mode = true;
unregister_code(KC_LALT);
register_code(KC_F13);
unregister_code(KC_F13);
wait_ms(1);
register_code(KC_DOT);unregister_code(KC_DOT);
register_code(KC_F13);
unregister_code(KC_F13);
register_code(KC_LALT);
} else {
register_code(KC_C);
}
} else {
if (TR_C_mode) {
TR_C_mode = false;
} else {
unregister_code(KC_C);
}
}
break;
case BACKTICK:
if (record->event.pressed) {
if (keyboard_report->mods & MOD_BIT(KC_LALT)) {
BACKTICK_mode = true;
unregister_code(KC_LALT);
register_code(KC_GRV);
unregister_code(KC_GRV);
register_code(KC_LALT);
} else {
register_code(KC_QUOT);
}
} else {
if (BACKTICK_mode) {
BACKTICK_mode = false;
} else {
unregister_code(KC_QUOT);
}
}
break;
case CO1:
if (record->event.pressed) {
if (keyboard_report->mods & MOD_BIT(KC_LALT)) {
CO1_mode = true;
unregister_code(KC_LALT);
register_code(KC_SLSH); unregister_code(KC_SLSH);
register_code(KC_LSHIFT); register_code(KC_8); unregister_code(KC_8); unregister_code(KC_LSHIFT);
register_code(KC_LALT);
} else {
register_code(KC_LBRC);
}
} else {
if (CO1_mode) {
CO1_mode = false;
} else {
unregister_code(KC_LBRC);
}
}
break;
case CC1:
if (record->event.pressed) {
if (keyboard_report->mods & MOD_BIT(KC_LALT)) {
CC1_mode = true;
unregister_code(KC_LALT);
register_code(KC_LSHIFT); register_code(KC_8); unregister_code(KC_8); unregister_code(KC_LSHIFT);
register_code(KC_SLSH); unregister_code(KC_SLSH);
register_code(KC_LALT);
} else {
register_code(KC_RBRC);
}
} else {
if (CC1_mode) {
CC1_mode = false;
} else {
unregister_code(KC_RBRC);
}
}
break;
case CO2:
if (record->event.pressed) {
if (keyboard_report->mods & MOD_BIT(KC_LALT)) {
CO1_mode = true;
unregister_code(KC_LALT);
register_code(KC_LSHIFT); register_code(KC_COMM); unregister_code(KC_COMM); register_code(KC_1); unregister_code(KC_1); unregister_code(KC_LSHIFT);
register_code(KC_MINS); unregister_code(KC_MINS);
register_code(KC_MINS); unregister_code(KC_MINS);
register_code(KC_LALT);
} else {
register_code(KC_COMM);
}
} else {
if (CO1_mode) {
CO1_mode = false;
} else {
unregister_code(KC_COMM);
}
}
break;
case CC2:
if (record->event.pressed) {
if (keyboard_report->mods & MOD_BIT(KC_LALT)) {
CO1_mode = true;
unregister_code(KC_LALT);
register_code(KC_MINS); unregister_code(KC_MINS);
register_code(KC_MINS); unregister_code(KC_MINS);
register_code(KC_LSHIFT); register_code(KC_DOT); unregister_code(KC_DOT); unregister_code(KC_LSHIFT);
register_code(KC_LALT);
} else {
register_code(KC_DOT);
}
} else {
if (CO1_mode) {
CO1_mode = false;
} else {
unregister_code(KC_DOT);
}
}
break;
case SHIFT_ESC:
if (record->event.pressed) {
if (keyboard_report->mods & MOD_BIT(KC_LSHIFT)) {
SE_mode = true;
register_code(KC_GRV);
unregister_code(KC_GRV);
} else {
register_code(KC_ESC);
}
} else {
if (SE_mode) {
SE_mode = false;
} else {
unregister_code(KC_ESC);
}
}
break;
}
}
/*
* Fn action definition
*/
#ifdef KEYMAP_SECTION_ENABLE
const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = {
#else
const uint16_t fn_actions[] PROGMEM = {
#endif
[0] = ACTION_DEFAULT_LAYER_SET(0), // Default layer(not used)
[1] = ACTION_LAYER_MOMENTARY(1), // HHKB layer(toggle with 5 taps)
[2] = ACTION_LAYER_MOMENTARY(3), // Mousekey layer
[3] = ACTION_MODS_ONESHOT(MOD_LSFT), // Oneshot Shift
[4] = ACTION_MACRO(MAXIMIZE), // Maximize window
[5] = ACTION_FUNCTION(TR_I),
[6] = ACTION_FUNCTION(SHIFT_ESC),
[7] = ACTION_FUNCTION(BACKTICK),
[8] = ACTION_FUNCTION(CO1),
[9] = ACTION_FUNCTION(CC1),
[10]= ACTION_LAYER_MOMENTARY(2), // Right-Fn
[11] = ACTION_FUNCTION(TR_U),
[12] = ACTION_FUNCTION(TR_O),
[13] = ACTION_FUNCTION(TR_S),
[14] = ACTION_FUNCTION(TR_G),
[15] = ACTION_FUNCTION(TR_C),
[16] = ACTION_MACRO(V_PREV), /* [ */
[17] = ACTION_MACRO(V_NEXT), /* ] */
[18] = ACTION_MACRO(V_DIFF), /* D */
[19] = ACTION_MACRO(V_CHANGED), /* \ */
[20] = ACTION_MACRO(C_PREV), /* - */
[21] = ACTION_MACRO(C_NEXT), /* = */
[22] = ACTION_MACRO(IDE_SWITCH), /* P */
[23] = ACTION_MACRO(IDE_COLOR), /* C */
[24] = ACTION_MACRO(IDE_COMMANDS), /* Enter */
[25] = ACTION_FUNCTION(CO2), /* <!-- */
[26] = ACTION_FUNCTION(CC2), /* --> */
};
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.