2 Copyright 2018 Yann Hodique <yann.hodique@gmail.com> @sigma
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 userspace_config_t runtime_userspace_config
;
20 userspace_config_t stored_userspace_config
;
22 __attribute__ ((weak
))
23 void matrix_init_keymap(void) {}
25 __attribute__ ((weak
))
26 void startup_keymap(void) {}
28 __attribute__ ((weak
))
29 void shutdown_keymap(void) {}
31 __attribute__ ((weak
))
32 void suspend_power_down_keymap(void) {}
34 __attribute__ ((weak
))
35 void suspend_wakeup_init_keymap(void) {}
37 __attribute__ ((weak
))
38 void matrix_scan_keymap(void) {}
40 __attribute__ ((weak
))
41 bool process_record_keymap(uint16_t keycode
, keyrecord_t
*record
) {
45 __attribute__ ((weak
))
46 bool process_record_secrets(uint16_t keycode
, keyrecord_t
*record
) {
51 __attribute__ ((weak
))
52 uint32_t layer_state_set_keymap (uint32_t state
) {
56 __attribute__ ((weak
))
57 uint32_t default_layer_state_set_keymap (uint32_t state
) {
61 __attribute__ ((weak
))
62 void led_set_keymap(uint8_t usb_led
) {}
64 void set_os(uint8_t os
) {
65 runtime_userspace_config
.os_target
= os
;
69 set_unicode_input_mode(UC_OSX
);
72 set_unicode_input_mode(UC_LNX
);
75 set_unicode_input_mode(UC_WIN
);
80 void matrix_init_user(void) {
81 stored_userspace_config
.raw
= eeconfig_read_user();
82 runtime_userspace_config
.raw
= stored_userspace_config
.raw
;
84 set_os(runtime_userspace_config
.os_target
);
87 void store_userspace_config(void) {
88 eeconfig_update_user(stored_userspace_config
.raw
);
93 void matrix_scan_user(void) {
98 SEQ_TWO_KEYS(KC_F1
, KC_L
) {
101 SEQ_TWO_KEYS(KC_F1
, KC_M
) {
104 SEQ_TWO_KEYS(KC_F1
, KC_W
) {
107 SEQ_TWO_KEYS(KC_F1
, KC_S
) {
108 stored_userspace_config
.raw
= runtime_userspace_config
.raw
;
109 store_userspace_config();
114 bool process_record_user(uint16_t keycode
, keyrecord_t
*record
) {
115 uint8_t os_target
= runtime_userspace_config
.os_target
;
116 bool pressed
= record
->event
.pressed
;
121 set_single_persistent_default_layer(_QWERTY
);
126 case KC_MAKE
: // Compiles the firmware, and adds the flash command based on keyboard bootloader
128 send_string_with_delay_P(PSTR("make " QMK_KEYBOARD
":" QMK_KEYMAP
131 #elif defined(BOOTLOADER_DFU)
133 #elif defined(BOOTLOADER_HALFKAY)
135 #elif defined(BOOTLOADER_CATERINA)
137 #endif // bootloader options
138 SS_TAP(X_ENTER
)), 10);
143 case EPRM
: // Resets EEPROM
146 default_layer_set(1UL<<eeconfig_read_default_layer());
147 layer_state_set(layer_state
);
149 store_userspace_config();
153 case VRSN
: // Prints firmware version
155 send_string_with_delay_P(PSTR(QMK_KEYBOARD
"/" QMK_KEYMAP
" @ " QMK_VERSION
", Built on: " QMK_BUILDDATE
), MACRO_TIMER
);
164 SEND_STRING(SS_LGUI("x"));
168 register_code(KC_CUT
)
169 : unregister_code(KC_CUT
);
173 SEND_STRING(SS_LCTRL("x"));
182 SEND_STRING(SS_LGUI("c"));
186 register_code(KC_COPY
)
187 : unregister_code(KC_COPY
);
191 SEND_STRING(SS_LCTRL("c"));
200 SEND_STRING(SS_LGUI("v"));
204 register_code(KC_PASTE
)
205 : unregister_code(KC_PASTE
);
209 SEND_STRING(SS_LCTRL("v"));
218 SEND_STRING(SS_LGUI("z"));
222 register_code(KC_UNDO
)
223 : unregister_code(KC_UNDO
);
227 SEND_STRING(SS_LCTRL("z"));
236 SEND_STRING(SS_LGUI(SS_LSFT("z")));
240 register_code(KC_AGAIN
)
241 : unregister_code(KC_AGAIN
);
245 SEND_STRING(SS_LCTRL(SS_LSFT("z")));
254 SEND_STRING(SS_LGUI(SS_LCTRL("q")));
258 register_code(KC_PWR
)
259 : unregister_code(KC_PWR
);
263 SEND_STRING(SS_LGUI("l"));
270 SEND_STRING(SS_LGUI("`"));
275 return process_record_keymap(keycode
, record
);