diff options
Diffstat (limited to 'users/csc027/csc027.c')
| -rw-r--r-- | users/csc027/csc027.c | 60 |
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 | ||
| 3 | static 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 | 4 | CUSTOM_MACROS(CUSTOM_DEF, CUSTOM_MACRO_STRING, SEMI_DELIM); |
| 5 | // in the custom_keycodes enum. | 5 | |
| 6 | "git add ", | 6 | static 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 | ||
| 32 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | 11 | bool 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; |
