summaryrefslogtreecommitdiff
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)
[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 106be9b690..de1bad6f25 100644
--- a/users/csc027/csc027.c
+++ b/users/csc027/csc027.c
@@ -1,32 +1,11 @@
#include "csc027.h"
-static const char* git_macros[] = {
- // Make sure that the macro strings match the order they are declared
- // in the custom_keycodes enum.
- "git add ",
- "git branch ",
- "git checkout ",
- "git cherry-pick ",
- "git commit -m \"\""SS_TAP(X_LEFT),
- "git diff ",
- "git fetch ",
- "git grep ",
- "git log --decorate --oneline --graph ",
- "git init ",
- "git mv ",
- "git merge ",
- "git push ",
- "git pull ",
- "git rebase ",
- "git remote ",
- "git reset ",
- "git show ",
- "git stash ",
- "git status ",
- "git tag ",
- SS_LCTL(SS_LALT(SS_TAP(X_HOME)))"\t ",
- SS_LCTL(SS_LALT(SS_TAP(X_HOME)))"\t\t\t ",
- SS_LCTL(SS_LALT(SS_TAP(X_HOME)))SS_LALT("\t")
+// Declare the strings in PROGMEM using the convenience macro
+CUSTOM_MACROS(CUSTOM_DEF, CUSTOM_MACRO_STRING, SEMI_DELIM);
+
+static const char* const custom_macros[] PROGMEM = {
+ // Declare the pointer to the strings in PROGMEM
+ CUSTOM_MACROS(CUSTOM_VAR, DROP, COMMA_DELIM)
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
@@ -34,26 +13,37 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
case LOWER:
if(record->event.pressed) {
layer_on(_LW);
- update_tri_layer(_LW, _RS, _MS);
} else {
layer_off(_LW);
- update_tri_layer(_LW, _RS, _MS);
}
+ update_tri_layer(_LW, _RS, _MS);
return false;
case RAISE:
if(record->event.pressed) {
layer_on(_RS);
- update_tri_layer(_LW, _RS, _MS);
} else {
layer_off(_RS);
- update_tri_layer(_LW, _RS, _MS);
}
+ update_tri_layer(_LW, _RS, _MS);
return false;
- case GIT_ADD...MC_ATRD:
+ case (MC_first + 1)...(MC_last - 1):
if(record->event.pressed) {
- // The calculation here is to make sure that the custom keycode
- // aligns with the git_macros array.
- send_string(git_macros[keycode - GIT_ADD]);
+ send_string_P(
+#if defined(__AVR__)
+ // The accessor here first reads from the pointer array that is located
+ // in PROGMEM. The pointer is taken and passed to the send_string_P
+ // function, which is aware of the difference between RAM and PROGMEM
+ // pointers.
+ (char*)pgm_read_word(&custom_macros[keycode - MC_first - 1])
+#else
+ // For non-AVR MCUs, the PROGMEM macro is defined as nothing. So, the strings are
+ // declared in RAM instead of flash. The send_string_P function, when compiled for
+ // non-AVR targets, uses a different definition of pgm_read_byte internally. This
+ // definition uses RAM pointers instead. This is why the raw pointer is passed for
+ // non-AVR MCUs.
+ custom_macros[keycode - MC_first - 1]
+#endif
+ );
return true;
}
return false;