diff options
author | pcoves <33952527+pcoves@users.noreply.github.com> | 2020-07-08 22:57:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-08 21:57:11 +0100 |
commit | facca2331519d5d56a926f93f0cdf925fe0857da (patch) | |
tree | 575913db2ecb5a78eeb22acabd69825f54d31b0d /users/pcoves/rainbowUnicorn.c | |
parent | 071e0c2029e7923cbaa6ff721365b2f61cdd08d8 (diff) | |
download | qmk_firmware-facca2331519d5d56a926f93f0cdf925fe0857da.tar.gz |
Add pcoves's userspace (#9354)
Co-authored-by: Ryan <fauxpark@gmail.com>
Co-authored-by: Pablo COVES <pablo.coves@anatoscope.com>
Diffstat (limited to 'users/pcoves/rainbowUnicorn.c')
-rw-r--r-- | users/pcoves/rainbowUnicorn.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/users/pcoves/rainbowUnicorn.c b/users/pcoves/rainbowUnicorn.c new file mode 100644 index 000000000..952041505 --- /dev/null +++ b/users/pcoves/rainbowUnicorn.c @@ -0,0 +1,42 @@ +#include "rainbowUnicorn.h" +#include "pcoves.h" + +static struct { + bool enabled; + uint8_t color; + char string[2]; + uint8_t mods; +} state = {false, 0}; + +bool process_record_rainbowUnicorn(uint16_t keycode, keyrecord_t* record) { + if (keycode == RAINBOW_UNICORN_TOGGLE) { + state.enabled ^= true; + return false; + } + + if (!state.enabled) return true; + + switch (keycode) { + case KC_A ... KC_Z: + case KC_1 ... KC_0: + case ALT_T(KC_A)... ALT_T(KC_Z): + case CTL_T(KC_A)... CTL_T(KC_Z): + case GUI_T(KC_A)... GUI_T(KC_Z): + case SFT_T(KC_A)... SFT_T(KC_Z): + if (record->event.pressed) { + state.mods = get_mods(); + clear_mods(); + + tap_code16(C(KC_C)); + + itoa(state.color + 3, state.string, 10); + send_string(state.string); + + set_mods(state.mods); + } else { + state.color = (state.color + 1) % 11; + } + } + + return true; +} |