diff options
author | Olivier Poitrey <rs@rhapsodyk.net> | 2019-05-07 10:43:08 -0700 |
---|---|---|
committer | Drashna Jaelre <drashna@live.com> | 2019-05-07 10:43:08 -0700 |
commit | 2d5c16dfd4ef193c4f692722157aa2b526a4c877 (patch) | |
tree | 527c5e5f51cf75c4476616a3c6ed91e385f1e1b2 /users/rs/rs.c | |
parent | 3b132599427a648b1f14aaf30312f05f855625ea (diff) |
[Keymap] crkbd/keymaps/rs: add rs keymap to corne keyboard and adapt others (#5181)
Update all my keymaps to work with 40 keys. Refactor code using
Userspace.
Diffstat (limited to 'users/rs/rs.c')
-rw-r--r-- | users/rs/rs.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/users/rs/rs.c b/users/rs/rs.c new file mode 100644 index 0000000000..fa634bb928 --- /dev/null +++ b/users/rs/rs.c @@ -0,0 +1,74 @@ + +#include "rs.h" + +// process_record_user is like process_record_user for keymaps including this file. +__attribute__ ((weak)) +bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { + return true; +} + +// rgb_mod_changed_keymap is called any time the RGB mod has been changed. +__attribute__ ((weak)) +void rgb_mod_changed_keymap(void) { +} + +// keylog_set_keymap is called for every key press. +__attribute__ ((weak)) +void keylog_set_keymap(uint16_t keycode, keyrecord_t *record) { +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + if (record->event.pressed) { + keylog_set_keymap(keycode, record); + } + + switch (keycode) { + case NEQL: // != + if (record->event.pressed) { + SEND_STRING("!="); + } + return false; + case LPLT: // ( or < with shift + if (record->event.pressed) { + if (get_mods() & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT))) { + // < + tap_code(KC_COMM); // shift is already registered + } else { + // ( + register_mods(MOD_BIT(KC_LSFT)); + tap_code(KC_9); + unregister_mods(MOD_BIT(KC_LSFT)); + } + } + return false; + case RPGT: // ) or > with shift + if (record->event.pressed) { + if (get_mods() & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT))) { + // < + tap_code(KC_DOT); // shift is already registered + } else { + // ) + register_mods(MOD_BIT(KC_LSFT)); + tap_code(KC_0); + unregister_mods(MOD_BIT(KC_LSFT)); + } + } + return false; +#ifdef RGBLIGHT_ENABLE + case RGB_MOD: + if (record->event.pressed) { + rgblight_step(); + rgb_mod_changed_keymap(); + } + return false; + case RGBRST: + if (record->event.pressed) { + eeconfig_update_rgblight_default(); + rgblight_enable(); + rgb_mod_changed_keymap(); + } + return false; +#endif + } + return process_record_keymap(keycode, record); +}
\ No newline at end of file |