aboutsummaryrefslogtreecommitdiff
path: root/users/csc027/csc027.c
diff options
context:
space:
mode:
authorcsc027 <csc_dev@protonmail.com>2020-01-13 17:41:13 +0000
committerDrashna Jaelre <drashna@live.com>2020-01-13 09:41:13 -0800
commit1b8cb95f2e56acf09bb66e779b800ae14aa074e5 (patch)
tree2ffc478e6fa0f3a79290126588853f9d9cab1996 /users/csc027/csc027.c
parent390a4fdc9d9a7c65c202d69eb40fbfcfcb070bb0 (diff)
downloadqmk_firmware-1b8cb95f2e56acf09bb66e779b800ae14aa074e5.tar.gz
qmk_firmware-1b8cb95f2e56acf09bb66e779b800ae14aa074e5.zip
[Keymap] csc027/macro-sync-keymap (#7873)
* Basic functionality to synchronize the strings and enums using C preprocessor macros. * Updated all the custom convenience macros to work. * Removed some duplicate update_tri_layer calls. * Simplified the convenience accelerator macros for synchronizing enums and strings by removing the short enum names. * Updated the CUSTOM_MACROS macro to use SS_LCTL instead of SS_LCTRL. * Fixed a bug where the right side of the convenience layer in the Iris keymap was incorrectly listed twice. * Removed the tenkey from the convenience layer. Added Windows 10 virtual desktop shortcuts to the convenience layer. * Fixed a bug where the macro range was not set correctly. * Added sigil values for the keycode enum so that additions to the sync macros will not require changes to the process_record_user ranges. * Hacked send_string_P to work with ChibiOS boards. * Switched to using I2C for the Iris keyboard. * Finished a comment. * Updated comments to explain that for non-AVR MCUs, the PROGMEM macro doesn't do anything. * Updated the synchronization macros to use the more descriptive "NAME" instead of "CALL". Moved the Control-Alt-Delete chord macro to the synchronization macro. * Simplified the custom macros by consolidating the macros into a context change macro instead of using alt-tab and minimize macros. * Fixed a formatting issue where several tabs were used instead of 4 spaces. * Added more comments to explain the synchronization macros. * Simplified the PARAMS macro, since any parameters could be passed with a space by the declarer instead. * Consolidated the synchronization macros into a single list. Simplified the synchronization mechanism. * Removed the overloading macro, since it is no longer needed. * Updated the convenience layer comments to reflect the changes made. * Renamed the git_macros pointer table to custom_macros, since it no longer solely consists of git macros. * Clarified that the send_string_P function's use of pgm_read_byte is different for AVR and non-AVR compilation targets.
Diffstat (limited to 'users/csc027/csc027.c')
-rw-r--r--users/csc027/csc027.c60
1 files changed, 25 insertions, 35 deletions
diff --git a/users/csc027/csc027.c b/users/csc027/csc027.c
index 106be9b69..de1bad6f2 100644
--- a/users/csc027/csc027.c
+++ b/users/csc027/csc027.c
@@ -1,32 +1,11 @@
1#include "csc027.h" 1#include "csc027.h"
2 2
3static const char* git_macros[] = { 3// Declare the strings in PROGMEM using the convenience macro
4 // Make sure that the macro strings match the order they are declared 4CUSTOM_MACROS(CUSTOM_DEF, CUSTOM_MACRO_STRING, SEMI_DELIM);
5 // in the custom_keycodes enum. 5
6 "git add ", 6static const char* const custom_macros[] PROGMEM = {
7 "git branch ", 7 // Declare the pointer to the strings in PROGMEM
8 "git checkout ", 8 CUSTOM_MACROS(CUSTOM_VAR, DROP, COMMA_DELIM)
9 "git cherry-pick ",
10 "git commit -m \"\""SS_TAP(X_LEFT),
11 "git diff ",
12 "git fetch ",
13 "git grep ",
14 "git log --decorate --oneline --graph ",
15 "git init ",
16 "git mv ",
17 "git merge ",
18 "git push ",
19 "git pull ",
20 "git rebase ",
21 "git remote ",
22 "git reset ",
23 "git show ",
24 "git stash ",
25 "git status ",
26 "git tag ",
27 SS_LCTL(SS_LALT(SS_TAP(X_HOME)))"\t ",
28 SS_LCTL(SS_LALT(SS_TAP(X_HOME)))"\t\t\t ",
29 SS_LCTL(SS_LALT(SS_TAP(X_HOME)))SS_LALT("\t")
30}; 9};
31 10
32bool process_record_user(uint16_t keycode, keyrecord_t *record) { 11bool process_record_user(uint16_t keycode, keyrecord_t *record) {
@@ -34,26 +13,37 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
34 case LOWER: 13 case LOWER:
35 if(record->event.pressed) { 14 if(record->event.pressed) {
36 layer_on(_LW); 15 layer_on(_LW);
37 update_tri_layer(_LW, _RS, _MS);
38 } else { 16 } else {
39 layer_off(_LW); 17 layer_off(_LW);
40 update_tri_layer(_LW, _RS, _MS);
41 } 18 }
19 update_tri_layer(_LW, _RS, _MS);
42 return false; 20 return false;
43 case RAISE: 21 case RAISE:
44 if(record->event.pressed) { 22 if(record->event.pressed) {
45 layer_on(_RS); 23 layer_on(_RS);
46 update_tri_layer(_LW, _RS, _MS);
47 } else { 24 } else {
48 layer_off(_RS); 25 layer_off(_RS);
49 update_tri_layer(_LW, _RS, _MS);
50 } 26 }
27 update_tri_layer(_LW, _RS, _MS);
51 return false; 28 return false;
52 case GIT_ADD...MC_ATRD: 29 case (MC_first + 1)...(MC_last - 1):
53 if(record->event.pressed) { 30 if(record->event.pressed) {
54 // The calculation here is to make sure that the custom keycode 31 send_string_P(
55 // aligns with the git_macros array. 32#if defined(__AVR__)
56 send_string(git_macros[keycode - GIT_ADD]); 33 // The accessor here first reads from the pointer array that is located
34 // in PROGMEM. The pointer is taken and passed to the send_string_P
35 // function, which is aware of the difference between RAM and PROGMEM
36 // pointers.
37 (char*)pgm_read_word(&custom_macros[keycode - MC_first - 1])
38#else
39 // For non-AVR MCUs, the PROGMEM macro is defined as nothing. So, the strings are
40 // declared in RAM instead of flash. The send_string_P function, when compiled for
41 // non-AVR targets, uses a different definition of pgm_read_byte internally. This
42 // definition uses RAM pointers instead. This is why the raw pointer is passed for
43 // non-AVR MCUs.
44 custom_macros[keycode - MC_first - 1]
45#endif
46 );
57 return true; 47 return true;
58 } 48 }
59 return false; 49 return false;