diff options
Diffstat (limited to 'keyboards/bpiphany/kitten_paw/keymaps/ickerwx/keymap.c')
-rw-r--r-- | keyboards/bpiphany/kitten_paw/keymaps/ickerwx/keymap.c | 199 |
1 files changed, 199 insertions, 0 deletions
diff --git a/keyboards/bpiphany/kitten_paw/keymaps/ickerwx/keymap.c b/keyboards/bpiphany/kitten_paw/keymaps/ickerwx/keymap.c new file mode 100644 index 000000000..cc4d0bca6 --- /dev/null +++ b/keyboards/bpiphany/kitten_paw/keymaps/ickerwx/keymap.c | |||
@@ -0,0 +1,199 @@ | |||
1 | #include QMK_KEYBOARD_H | ||
2 | #include "mousekey.h" | ||
3 | |||
4 | #define MEDAPP LT(MEDIA, KC_APP) | ||
5 | |||
6 | uint8_t current_layer_global = 255; | ||
7 | |||
8 | enum layers { | ||
9 | DEFAULT, | ||
10 | PROG1, | ||
11 | PROG2, | ||
12 | MEDIA, | ||
13 | MOUSE1, | ||
14 | MOUSE2, | ||
15 | MISC, | ||
16 | }; | ||
17 | |||
18 | enum custom_keycodes { | ||
19 | LSHFT_PAREN = SAFE_RANGE, | ||
20 | RSHFT_PAREN, | ||
21 | LCTRL_BRACKET, | ||
22 | RCTRL_BRACKET, | ||
23 | LALT_CURLY, | ||
24 | RALT_CURLY, | ||
25 | CTRL_CLICK, | ||
26 | M_GRV, | ||
27 | M_CFLEX | ||
28 | }; | ||
29 | |||
30 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
31 | [DEFAULT] = LAYOUT(\ | ||
32 | KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR,KC_SLCK,KC_PAUS, \ | ||
33 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0,KC_MINS, KC_EQL,KC_BSPC, KC_INS,KC_HOME,KC_PGUP, KC_NLCK,KC_PSLS,KC_PAST,KC_PMNS, \ | ||
34 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P,KC_LBRC,KC_RBRC,KC_BSLS, KC_DEL, KC_END,KC_PGDN, KC_P7, KC_P8, KC_P9,KC_PPLS, \ | ||
35 | TT(MOUSE1), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L,KC_SCLN,KC_QUOT, KC_ENT, KC_P4, KC_P5, KC_P6, \ | ||
36 | LSHFT_PAREN,KC_NUBS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M,KC_COMM, KC_DOT,KC_SLSH, RSHFT_PAREN, KC_UP, KC_P1, KC_P2, KC_P3,KC_PENT, \ | ||
37 | LCTRL_BRACKET,KC_LGUI, LALT_CURLY, LT(MISC, KC_SPC), RALT_CURLY,TT(PROG1), MEDAPP, RCTRL_BRACKET, KC_LEFT,KC_DOWN,KC_RGHT, KC_P0,KC_PDOT), | ||
38 | /* Layer 1: Programming Layer 1, emulating US l ayout */ | ||
39 | [PROG1] = LAYOUT(\ | ||
40 | KC_ESC,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, \ | ||
41 | M_GRV,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,KC_SLSH,S(KC_0),_______, _______,_______,_______, _______,_______,_______,_______, \ | ||
42 | _______,_______,_______,_______,_______,_______, KC_Z,_______,_______,_______,_______,ALGR(KC_8),ALGR(KC_9),ALGR(KC_MINS), _______,_______,_______, _______,_______,_______,_______, \ | ||
43 | _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,S(KC_COMM),S(KC_BSLS), _______, _______,_______,_______, \ | ||
44 | MO(PROG2),_______, KC_Y,_______,_______,_______,_______,_______,_______,_______,_______, S(KC_7), MO(PROG2), _______, _______,_______,_______,_______, \ | ||
45 | _______,_______,_______, _______, _______,_______,_______,_______, _______,_______,_______, _______,_______), | ||
46 | /* Layer 2: programming layer 2 | ||
47 | all keys that are not FN keys are sent as LSFT+key on this layer | ||
48 | */ | ||
49 | [PROG2] = LAYOUT(\ | ||
50 | _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, \ | ||
51 | ALGR(KC_RBRC),_______, ALGR(KC_Q),KC_BSLS,_______,_______,M_CFLEX, S(KC_6),S(KC_RBRC), S(KC_8),S(KC_9),S(KC_SLSH),KC_RBRC,_______, _______,_______,_______, _______,_______,_______,_______, \ | ||
52 | _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, ALGR(KC_7),ALGR(KC_0),ALGR(KC_NUBS), _______,_______,_______, _______,_______,_______,_______, \ | ||
53 | _______,_______,_______,_______,_______,_______,_______,_______,_______,_______, S(KC_DOT), S(KC_2), _______, _______,_______,_______, \ | ||
54 | _______,S(KC_NUBS),_______,_______,_______,_______,_______,_______,_______,KC_NUBS,S(KC_NUBS),S(KC_MINS), _______, _______, _______,_______,_______,_______, \ | ||
55 | _______,_______,_______, _______, _______,_______,_______,_______, _______,_______,_______, _______,_______), | ||
56 | /* Layer 3: media layer */ | ||
57 | [MEDIA] = LAYOUT(\ | ||
58 | KC_PWR,KC_SLEP,KC_WAKE,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX, XXXXXXX,XXXXXXX,XXXXXXX, \ | ||
59 | XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX, KC_MPRV,KC_MPLY,KC_MNXT, XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX, \ | ||
60 | XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX, KC_VOLD,KC_MUTE,KC_VOLU, XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX, \ | ||
61 | XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX, XXXXXXX, XXXXXXX,XXXXXXX,XXXXXXX, \ | ||
62 | XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX, XXXXXXX, KC_EJCT, XXXXXXX,XXXXXXX,XXXXXXX,XXXXXXX, \ | ||
63 | XXXXXXX,XXXXXXX,XXXXXXX, XXXXXXX, XXXXXXX,XXXXXXX,_______,XXXXXXX, KC_MRWD,KC_MSTP,KC_MFFD, XXXXXXX,XXXXXXX), | ||
64 | /* Layer 4: Mouse layer */ | ||
65 | [MOUSE1] = LAYOUT(\ | ||
66 | TO(DEFAULT),_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, \ | ||
67 | _______,KC_ACL0,KC_ACL1,KC_ACL2,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, _______,_______,_______,_______, \ | ||
68 | _______,KC_BTN4,KC_WH_D,KC_MS_U,KC_WH_U,_______, C(KC_Z),_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, _______,_______,_______,_______, \ | ||
69 | _______,KC_BTN5,KC_MS_L,KC_MS_D,KC_MS_R, CTRL_CLICK,KC_WH_L,KC_WH_D,KC_WH_U,KC_WH_R,_______,_______, _______, _______,_______,_______, \ | ||
70 | MO(MOUSE2),_______,C(KC_Y),C(KC_X),C(KC_C),C(KC_V),_______,KC_BTN2,KC_BTN3,C(KC_PGUP),C(KC_PGDN),_______, KC_RSFT, _______, _______,_______,_______,_______, \ | ||
71 | KC_LCTL,_______,KC_LALT, KC_BTN1, KC_RALT,KC_RGUI, KC_APP,KC_RCTL, _______,_______,_______, _______,_______), | ||
72 | /* Layer 5: Mouse layer 2*/ | ||
73 | [MOUSE2] = LAYOUT(\ | ||
74 | _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, \ | ||
75 | _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, _______,_______,_______,_______, \ | ||
76 | _______,_______,KC_BTN2,KC_WH_U,KC_BTN3,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, _______,_______,_______,_______, \ | ||
77 | _______,_______,KC_WH_L,KC_WH_D,KC_WH_R,_______,KC_MS_L,KC_MS_D,KC_MS_U,KC_MS_R,_______,_______, _______, _______,_______,_______, \ | ||
78 | _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______, _______,_______,_______,_______, \ | ||
79 | _______,_______,_______, _______, _______,_______,_______,_______, _______,_______,_______, _______,_______), | ||
80 | /* Layer 6: Misc layer */ | ||
81 | [MISC] = LAYOUT(\ | ||
82 | _______, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_F21, KC_F22, KC_F23, KC_F24, _______,_______,_______, \ | ||
83 | _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, _______,_______,_______,_______, \ | ||
84 | _______,KC_SLCT, C(KC_W), KC_UP,_______,_______,_______,_______,KC_BSPC, KC_DEL,_______,_______,_______,_______, _______,_______,_______, _______,_______,_______,_______, \ | ||
85 | _______,_______,KC_LEFT,KC_DOWN,KC_RGHT,_______,KC_HOME,KC_PGDN,KC_PGUP,_______,_______,_______, _______, _______,_______,_______, \ | ||
86 | KC_LSFT,_______,C(KC_Y),C(KC_X),C(KC_C),C(KC_V), KC_SPC, KC_END,_______,C(KC_PGUP),C(KC_PGDN),_______, _______, _______, _______,_______,_______,_______, \ | ||
87 | _______,_______,_______, LT(MISC, KC_SPC), _______,_______,_______,_______, _______,_______,_______, _______,_______), | ||
88 | }; | ||
89 | |||
90 | void matrix_scan_user(void) { | ||
91 | uint8_t layer; | ||
92 | layer = biton32(layer_state); | ||
93 | |||
94 | if (current_layer_global != layer) { | ||
95 | current_layer_global = layer; | ||
96 | |||
97 | // unset CAPSLOCK and SCROLL LOCK LEDs | ||
98 | led_set_kb(host_keyboard_leds() & ~(1<<USB_LED_CAPS_LOCK)); | ||
99 | led_set_kb(host_keyboard_leds() & ~(1<<USB_LED_SCROLL_LOCK)); | ||
100 | // set SCROLL LOCK LED when the mouse layer is active, CAPS LOCK when PROG layer is active | ||
101 | if (layer == MOUSE1 || layer == MOUSE2) { | ||
102 | led_set_kb(host_keyboard_leds() | (1<<USB_LED_SCROLL_LOCK)); | ||
103 | } else if (layer == PROG1 || layer == PROG2) { | ||
104 | led_set_kb(host_keyboard_leds() | (1<<USB_LED_CAPS_LOCK)); | ||
105 | } | ||
106 | } | ||
107 | } | ||
108 | |||
109 | void tap_helper(keyrecord_t *record, uint16_t orig_mod, uint16_t macro_mod, uint16_t macro_kc ) { | ||
110 | if (record->event.pressed) { | ||
111 | if (record->tap.count > 0 && !record->tap.interrupted) { | ||
112 | if (record->tap.interrupted) { | ||
113 | register_mods(MOD_BIT(orig_mod)); | ||
114 | } | ||
115 | } else { | ||
116 | register_mods(MOD_BIT(orig_mod)); | ||
117 | } | ||
118 | } else { | ||
119 | if (record->tap.count > 0 && !(record->tap.interrupted)) { | ||
120 | add_weak_mods(MOD_BIT(macro_mod)); | ||
121 | send_keyboard_report(); | ||
122 | register_code(macro_kc); | ||
123 | unregister_code(macro_kc); | ||
124 | del_weak_mods(MOD_BIT(macro_mod)); | ||
125 | send_keyboard_report(); | ||
126 | record->tap.count = 0; // ad hoc: cancel tap | ||
127 | } else { | ||
128 | unregister_mods(MOD_BIT(orig_mod)); | ||
129 | } | ||
130 | } | ||
131 | } | ||
132 | |||
133 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
134 | uint8_t layer; | ||
135 | layer = biton32(layer_state); | ||
136 | if (layer == PROG2) { | ||
137 | if (keycode >= KC_A && keycode <= KC_EXSEL && \ | ||
138 | !( // do not send LSFT + these keycodes, they are needed for emulating the US layout | ||
139 | keycode == KC_NONUS_BSLASH || | ||
140 | keycode == KC_RBRC || | ||
141 | keycode == KC_BSLS || | ||
142 | keycode == KC_GRV | ||
143 | )) { | ||
144 | // LSFT is the modifier for this layer, so we set LSFT for every key to get the expected behavior | ||
145 | if (record->event.pressed) { | ||
146 | register_mods(MOD_LSFT); | ||
147 | } else { | ||
148 | unregister_mods(MOD_LSFT); | ||
149 | } | ||
150 | } | ||
151 | } | ||
152 | |||
153 | switch (keycode) { | ||
154 | case LCTRL_BRACKET: | ||
155 | tap_helper(record, KC_LCTL, KC_RALT, KC_8); | ||
156 | return false; | ||
157 | case RCTRL_BRACKET: | ||
158 | tap_helper(record, KC_RCTL, KC_RALT, KC_9); | ||
159 | return false; | ||
160 | case LALT_CURLY: | ||
161 | tap_helper(record, KC_LALT, KC_RALT, KC_7); | ||
162 | return false; | ||
163 | case RALT_CURLY: | ||
164 | tap_helper(record, KC_RALT, KC_RALT, KC_0); | ||
165 | return false; | ||
166 | case LSHFT_PAREN: | ||
167 | tap_helper(record, KC_LSFT, KC_LSFT, KC_8); | ||
168 | return false; | ||
169 | case RSHFT_PAREN: | ||
170 | tap_helper(record, KC_RSFT, KC_LSFT, KC_9); | ||
171 | return false; | ||
172 | case CTRL_CLICK: | ||
173 | if (record->event.pressed) { | ||
174 | mousekey_clear(); | ||
175 | register_mods(MOD_BIT(KC_LCTL)); | ||
176 | send_keyboard_report(); | ||
177 | wait_ms(5); | ||
178 | mousekey_on(KC_BTN1); | ||
179 | mousekey_send(); | ||
180 | wait_ms(10); | ||
181 | mousekey_off(KC_BTN1); | ||
182 | mousekey_send(); | ||
183 | wait_ms(5); | ||
184 | unregister_mods(MOD_BIT(KC_LCTL)); | ||
185 | send_keyboard_report(); | ||
186 | } | ||
187 | return false; | ||
188 | case M_GRV: | ||
189 | tap_code16(S(KC_EQL)); | ||
190 | tap_code(KC_SPC); | ||
191 | return false; | ||
192 | case M_CFLEX: | ||
193 | tap_code(KC_GRV); | ||
194 | tap_code(KC_SPC); | ||
195 | return false; | ||
196 | } | ||
197 | |||
198 | return true; | ||
199 | } | ||