]> git.donarmstrong.com Git - qmk_firmware.git/blob - layouts/community/ergodox/reset_eeprom/keymap.c
Add user-overridable callback for cancelling UCIS input (#5564)
[qmk_firmware.git] / layouts / community / ergodox / reset_eeprom / keymap.c
1 #include QMK_KEYBOARD_H
2 #include "debug.h"
3 #include "action_layer.h"
4 #include "version.h"
5
6 #define BASE 0 // default layer
7 #define SYMB 1 // symbols
8 #define MDIA 2 // media keys
9
10 enum custom_keycodes {
11   PLACEHOLDER = SAFE_RANGE, // can always be here
12   EPRM,
13   VRSN,
14   RGB_SLD
15 };
16
17 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
18 /* Keymap 0: Basic layer
19  *
20  * ,--------------------------------------------------.           ,--------------------------------------------------.
21  * |   =    |   1  |   2  |   3  |   4  |   5  | LEFT |           | RIGHT|   6  |   7  |   8  |   9  |   0  |   -    |
22  * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
23  * | Del    |   Q  |   W  |   E  |   R  |   T  |  L1  |           |  L1  |   Y  |   U  |   I  |   O  |   P  |   \    |
24  * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
25  * | BkSp   |   A  |   S  |   D  |   F  |   G  |------|           |------|   H  |   J  |   K  |   L  |; / L2|' / Cmd |
26  * |--------+------+------+------+------+------| Hyper|           | Meh  |------+------+------+------+------+--------|
27  * | LShift |Z/Ctrl|   X  |   C  |   V  |   B  |      |           |      |   N  |   M  |   ,  |   .  |//Ctrl| RShift |
28  * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
29  *   |Grv/L1|  '"  |AltShf| Left | Right|                                       |  Up  | Down |   [  |   ]  | ~L1  |
30  *   `----------------------------------'                                       `----------------------------------'
31  *                                        ,-------------.       ,-------------.
32  *                                        | App  | LGui |       | Alt  |Ctrl/Esc|
33  *                                 ,------|------|------|       |------+--------+------.
34  *                                 |      |      | Home |       | PgUp |        |      |
35  *                                 | Space|Backsp|------|       |------|  Tab   |Enter |
36  *                                 |      |ace   | End  |       | PgDn |        |      |
37  *                                 `--------------------'       `----------------------'
38  */
39 // If it accepts an argument (i.e, is a function), it doesn't need KC_.
40 // Otherwise, it needs KC_*
41 [BASE] = LAYOUT_ergodox(  // layer 0 : default
42         // left hand
43         EPRM,         EPRM,         EPRM,   EPRM,   EPRM,   EPRM,   EPRM,
44         EPRM,        EPRM,         EPRM,   EPRM,   EPRM,   EPRM,   EPRM,
45         EPRM,        EPRM,         EPRM,   EPRM,   EPRM,   EPRM,
46         EPRM,        EPRM,  EPRM,   EPRM,   EPRM,   EPRM,   EPRM,
47         EPRM,        EPRM,      EPRM,  EPRM,EPRM,
48                                               EPRM,  EPRM,
49                                                               EPRM,
50                                                EPRM,EPRM,EPRM,
51         // right hand
52              EPRM,     EPRM,   EPRM,  EPRM,   EPRM,   EPRM,             EPRM,
53              EPRM,    EPRM,   EPRM,  EPRM,   EPRM,   EPRM,             EPRM,
54                           EPRM,   EPRM,  EPRM,   EPRM,   EPRM,EPRM,
55              EPRM,EPRM,   EPRM,  EPRM,EPRM, EPRM,   EPRM,
56                                   EPRM, EPRM,EPRM,EPRM,          EPRM,
57              EPRM,        EPRM,
58              EPRM,
59              EPRM,EPRM, EPRM
60     )
61 };
62
63 const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
64 {
65   // MACRODOWN only works in this function
66       switch(id) {
67         case 0:
68         if (record->event.pressed) {
69           SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
70         }
71         break;
72         case 1:
73         if (record->event.pressed) { // For resetting EEPROM
74           eeconfig_init();
75         }
76         break;
77       }
78     return MACRO_NONE;
79 };
80
81 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
82   switch (keycode) {
83     // dynamically generate these.
84     case EPRM:
85       if (record->event.pressed) {
86         eeconfig_init();
87       }
88       return false;
89       break;
90     case VRSN:
91       if (record->event.pressed) {
92         SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
93       }
94       return false;
95       break;
96     case RGB_SLD:
97       if (record->event.pressed) {
98         #ifdef RGBLIGHT_ENABLE
99           rgblight_mode(1);
100         #endif
101       }
102       return false;
103       break;
104   }
105   return true;
106 }
107
108 // Runs just one time when the keyboard initializes.
109 void matrix_init_user(void) {
110   eeconfig_init();
111 };
112
113
114 // Runs constantly in the background, in a loop.
115 void matrix_scan_user(void) {
116
117     uint8_t layer = biton32(layer_state);
118
119     ergodox_board_led_off();
120     ergodox_right_led_1_off();
121     ergodox_right_led_2_off();
122     ergodox_right_led_3_off();
123     switch (layer) {
124       // TODO: Make this relevant to the ErgoDox EZ.
125         case 1:
126             ergodox_right_led_1_on();
127             break;
128         case 2:
129             ergodox_right_led_2_on();
130             break;
131         default:
132             // none
133             break;
134     }
135
136 };