1 #include QMK_KEYBOARD_H
8 extern keymap_config_t keymap_config;
10 //Following line allows macro to read current RGB settings
11 extern rgblight_config_t rgblight_config;
13 // Each layer gets a name for readability, which is then used in the keymap matrix below.
14 // The underscores don't mean anything - you can have a layer called STUFF or any other name.
15 // Layer names don't all need to be of the same length, obviously, and you can also skip them
16 // entirely and just use numbers.
22 #define _MOUSECURSOR 8
25 enum preonic_keycodes {
44 #define CTL_ESC CTL_T(KC_ESC) // Tap for Esc, hold for Ctrl
45 #define CTL_TTAB CTL_T(KC_TAB) // Tap for Esc, hold for Ctrl
46 #define CTL_ENT CTL_T(KC_ENT) // Tap for Enter, hold for Ctrl
47 #define SFT_ENT SFT_T(KC_ENT) // Tap for Enter, hold for Shift
48 // Requires KC_TRNS/_______ for the trigger key in the destination layer
49 #define LT_MC(kc) LT(_MOUSECURSOR, kc) // L-ayer T-ap M-ouse C-ursor
50 #define LT_RAI(kc) LT(_RAISE, kc) // L-ayer T-ap to Raise
53 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
56 * ,------+------+------+------+------+------------------------------------------------.
57 * | Esc | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | DEL |
58 * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
59 * | Tab | Q | W | E | R | T | 7 | 8 | 9 | Y | U | I | O | P | Bksp |
60 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
61 * | CAPS | A | S | D | F | G | 4 | 5 | 6 | H | J | K | L | ;/Nav| ' |
62 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
63 * | Shift| Z | X | C | V | B | 1 | 2 | 3 | N | M | , | . | / |Ctl/Et|
64 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
65 * | ` | Ctrl | Alt | GUI |Lower |Space | 0 | . | = |Space |Raise | Left | Down | Up |Right |
66 * `--------------------------------------------------------------------------------------------------------'
69 KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_DEL,\
70 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_P7, KC_P8, KC_P9, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
71 KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_P4, KC_P5, KC_P6, KC_H, KC_J, KC_K, KC_L,LT_MC(KC_SCLN), KC_QUOT, \
72 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_P1, KC_P2, KC_P3, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, CTL_ENT, \
73 KC_GRV, KC_LCTRL, KC_LGUI, KC_LALT, LOWER, KC_SPC, KC_P0, KC_DOT, KC_EQL, KC_SPC, RAISE, KC_LEFT,KC_DOWN, KC_UP, KC_RGHT \
77 * ,------+------+------+------+------+------------------------------------------------.
78 * | Esc | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | 0 | - |
79 * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
80 * | Tab | Q | W | F | P | G | 7 | 8 | 9 | J | L | U | Y | ; | Bksp |
81 * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
82 * | CAPS | A | R | S | T | D | 4 | 5 | 6 | H | N | E | I | O | ' |
83 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
84 * | Shift| Z | X | C | V | B | 1 | 2 | 3 | K | M | , | . | / |Ctl/Et|
85 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
86 * | ` | Ctrl | Alt | GUI |Lower |Space | 0 | . | = |Space |Raise | Left | Down | Up |Right |
87 * `--------------------------------------------------------------------------------------------------------'
90 KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_DEL,\
91 KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_P7, KC_P8, KC_P9, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, \
92 KC_LCTRL, KC_A, KC_R, KC_S, KC_T, KC_D, KC_P4, KC_P5, KC_P6, KC_H, KC_N, KC_E, KC_I, LT_MC(KC_O), KC_QUOT, \
93 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_P1, KC_P2, KC_P3, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, CTL_ENT, \
94 KC_GRV, KC_LCTRL, KC_LGUI, KC_LALT, LOWER, KC_SPC, KC_P0, KC_DOT, KC_EQL, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
98 * ,------+------+------+------+------+------------------------------------------------.
99 * | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - |
100 * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
101 * | Tab | " | , | . | P | Y | 7 | 8 | 9 | F | G | C | R | L | Bksp |
102 * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
103 * | Esc | A | O | E | U | I | 4 | 5 | 6 | D | H | T | N | S | / |
104 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
105 * | Shift| ; | Q | J | K | X | 1 | 2 | 3 | B | M | W | V | Z |Ctl/Et|
106 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
107 * | ` | Ctrl | Alt | GUI |Lower |Space | 0 | . | = |Space |Raise | Left | Down | Up |Right |
108 * `--------------------------------------------------------------------------------------------------------'
111 KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_DEL,\
112 KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_P7, KC_P8, KC_P9, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC, \
113 KC_LCTL, KC_A, KC_O, KC_E, KC_U, KC_I, KC_P4, KC_P5, KC_P6, KC_D, KC_H, KC_T, KC_N, LT_MC(KC_S), KC_SLSH, \
114 KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_P1, KC_P2, KC_P3, KC_B, KC_M, KC_W, KC_V, KC_Z, CTL_ENT, \
115 KC_GRV, KC_LCTRL, KC_LGUI, KC_LALT, LOWER, KC_SPC, KC_P0, KC_DOT, KC_EQL, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
119 * ,------+------+------+------+------+------------------------------------------------.
120 * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
121 * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
122 * | ~ | ! | @ | # | $ | % | | | | ^ | & | * | ( | ) | Del |
123 * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
124 * | | F1 | F2 | F3 | F4 | F5 | | | | F6 | _ | + | { | } | | |
125 * |------+------+------+------+------+------|------+------+------+------+------+------+------+------+------|
126 * | | F7 | F8 | F9 | F10 | F11 | | | | F12 |ISO ~ |ISO | | | | |
127 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
128 * | | | | | | | | | | | | Next | Vol- | Vol+ | Play |
129 * `--------------------------------------------------------------------------------------------------------'
132 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \
133 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, _______, _______, _______, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL, \
134 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, _______, _______, _______, KC_F6, KC_UNDS, KC_PLUS, KC_LBRC, KC_RBRC, KC_PIPE, \
135 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, _______, KC_F12,S(KC_NUHS),S(KC_NUBS),_______,_______, _______, \
136 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
140 * ,------+------+------+------+------+------------------------------------------------.
141 * | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - |
142 * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
143 * | ` | 1 | 2 | 3 | 4 | 5 | | | | 6 | 7 | 8 | 9 | 0 | Del |
144 * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
145 * | Del | F1 | F2 | F3 | F4 | F5 | | | | F6 | - | = | [ | ] | \ |
146 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
147 * | | F7 | F8 | F9 | F10 | F11 | | | | F12 |ISO # |ISO / | | | |
148 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
149 * | | | | | | | | | | | | Next | Vol- | Vol+ | Play |
150 * `--------------------------------------------------------------------------------------------------------'
153 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
154 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, _______, _______, _______, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
155 KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, _______, _______, _______, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
156 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, _______, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______, \
157 _______, _______, _______, _______, _______, KC_SPC, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
160 /* Mouse Layer (semi-col)
161 * ,------+------+------+------+------+------------------------------------------------.
162 * | ACCL0| ACCL1| ACCL2| | | | | | | | | |
163 * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
164 * | | | | | | | | | Home | Wh_Up| WHL_L| M_Up | WHL_R| Macro| |
165 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
166 * | | | | | | | | | End | Wh_Dn| M_Lft| M_Dn | M_Rt | | |
167 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
168 * | | | | | | | | | | BTN2 | BTN3 | BTN4 | BTN5 | | |
169 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
170 * | | | | | | BTN1 | | | | BTN1 | | | | | |
171 * `--------------------------------------------------------------------------------------------------------'
174 [_MOUSECURSOR] = LAYOUT(
175 KC_ACL0, KC_ACL1, KC_ACL2, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
176 _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGUP, KC_WH_L, KC_MS_U, KC_WH_R,DEMOMACRO,_______, \
177 _______, _______, _______, _______, _______, _______, _______, _______, KC_END , KC_PGDN, KC_MS_L, KC_MS_D, KC_MS_R, _______, _______, \
178 _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_BTN2, KC_BTN3, KC_BTN4, KC_BTN5, _______, _______, \
179 _______, _______, _______, _______, _______, KC_BTN1, _______, _______, _______, KC_BTN1, _______, _______, _______, _______, _______ \
182 /* Adjust (Lower + Raise)
183 * ,------+------+------+------+------+------------------------------------------------.
184 * | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - |
185 * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
186 * | Reset|RGB TG|RGB ST|RGBH -|RGBH +|RGBS -|RGBS +|RGBV -|RGBV +| | | | | | Del |
187 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
188 * | | | |Aud on|Audoff|AGnorm| | | |AGswap|Qwerty|Colemk| | | |
189 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
190 * | |Voice-|Voice+|Mus on|Musoff| | | | | | | | BL + |BL ST |BL TG |
191 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
192 * | | | | | | | | | | | | | | | |
193 * `--------------------------------------------------------------------------------------------------------'
196 KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
197 RESET, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______, _______, _______, _______, _______, KC_DEL, \
198 _______, _______, _______, AU_ON, AU_OFF, AG_NORM, _______, _______, _______, AG_SWAP, QWERTY, COLEMAK, _______, _______, _______, \
199 _______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, BL_DEC, BL_INC, BL_STEP, BL_TOGG, \
200 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______\
207 // define variables for reactive RGB
208 bool RGB_INIT = false;
209 bool TOG_STATUS = false;
210 int RGB_current_mode;
212 void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
213 if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
214 rgblight_mode(RGB_current_mode);
221 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
224 if (record->event.pressed) {
225 set_single_persistent_default_layer(_QWERTY);
230 if (record->event.pressed) {
231 set_single_persistent_default_layer(_COLEMAK);
236 if (record->event.pressed) {
237 //not sure how to have keyboard check mode and set it to a variable, so my work around
238 //uses another variable that would be set to true after the first time a reactive key is pressed.
239 if (RGB_INIT) {} else {
240 RGB_current_mode = rgblight_config.mode;
243 if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
245 TOG_STATUS = !TOG_STATUS;
249 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
251 rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
254 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
259 if (record->event.pressed) {
260 //not sure how to have keyboard check mode and set it to a variable, so my work around
261 //uses another variable that would be set to true after the first time a reactive key is pressed.
262 if (RGB_INIT) {} else {
263 RGB_current_mode = rgblight_config.mode;
266 if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
268 TOG_STATUS = !TOG_STATUS;
272 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
274 rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
277 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
282 if (record->event.pressed) {
283 register_code(KC_RSFT);
284 #ifdef BACKLIGHT_ENABLE
288 unregister_code(KC_RSFT);
293 //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released
294 if (record->event.pressed) {
295 rgblight_mode(RGB_current_mode);
297 RGB_current_mode = rgblight_config.mode;
302 if (record->event.pressed) {
303 SEND_STRING("hello world");
312 #ifdef KEYBOARD_hadron_ver2
313 #include "LUFA/Drivers/Peripheral/TWI.h"
314 void matrix_init_user(void) {
318 // calls code for the SSD1306 OLED
320 TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000));
321 iota_gfx_init(); // turns on the display
330 void matrix_scan_user(void) {
332 iota_gfx_task(); // this is what updates the display continuously
336 void matrix_update(struct CharacterMatrix *dest,
337 const struct CharacterMatrix *source) {
338 if (memcmp(dest->display, source->display, sizeof(dest->display))) {
339 memcpy(dest->display, source->display, sizeof(dest->display));
343 //assign the right code to your layers for OLED display
350 #define L_NFNLAYER 192
351 #define L_MOUSECURSOR 256
352 #define L_ADJUST 65560
354 void iota_gfx_task_user(void) {
361 struct CharacterMatrix matrix;
363 matrix_clear(&matrix);
364 matrix_write_P(&matrix, PSTR("USB: "));
366 switch (USB_DeviceState) {
367 case DEVICE_STATE_Unattached:
368 matrix_write_P(&matrix, PSTR("Unattached"));
370 case DEVICE_STATE_Suspended:
371 matrix_write_P(&matrix, PSTR("Suspended"));
373 case DEVICE_STATE_Configured:
374 matrix_write_P(&matrix, PSTR("Connected"));
376 case DEVICE_STATE_Powered:
377 matrix_write_P(&matrix, PSTR("Powered"));
379 case DEVICE_STATE_Default:
380 matrix_write_P(&matrix, PSTR("Default"));
382 case DEVICE_STATE_Addressed:
383 matrix_write_P(&matrix, PSTR("Addressed"));
386 matrix_write_P(&matrix, PSTR("Invalid"));
390 // Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below
393 snprintf(buf,sizeof(buf), "Undef-%ld", layer_state);
394 matrix_write_P(&matrix, PSTR("\n\nLayer: "));
395 switch (layer_state) {
397 matrix_write_P(&matrix, PSTR("Default"));
400 matrix_write_P(&matrix, PSTR("Raise"));
403 matrix_write_P(&matrix, PSTR("Lower"));
406 matrix_write_P(&matrix, PSTR("ADJUST"));
409 matrix_write(&matrix, buf);
412 // Host Keyboard LED Status
414 snprintf(led, sizeof(led), "\n%s %s %s",
415 (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ",
416 (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
417 (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
418 matrix_write(&matrix, led);
419 matrix_update(&display, &matrix);