combo.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* Copyright 2020 Christopher Ko <chriskopher@gmail.com>
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "shared_enum.h"
  17. #include "quantum.h"
  18. enum combo_event {
  19. SD_LAYER_COMBO,
  20. KL_MEH_COMBO,
  21. };
  22. const uint16_t PROGMEM sd_combo[] = {KC_S, KC_D, COMBO_END}; // Combo: S + D for SuperDuper mode
  23. const uint16_t PROGMEM kl_combo[] = {KC_K, KC_L, COMBO_END}; // Combo: K + L for Meh modifier
  24. // Register the combo action
  25. combo_t key_combos[COMBO_COUNT] = {
  26. [SD_LAYER_COMBO] = COMBO_ACTION(sd_combo),
  27. [KL_MEH_COMBO] = COMBO_ACTION(kl_combo),
  28. };
  29. // Called after a combo event is triggered
  30. void process_combo_event(uint16_t combo_index, bool pressed) {
  31. switch (combo_index) {
  32. case SD_LAYER_COMBO:
  33. if (pressed) {
  34. layer_on(_SUPERDUPER);
  35. } else {
  36. layer_off(_SUPERDUPER);
  37. }
  38. break;
  39. case KL_MEH_COMBO:
  40. if (pressed) {
  41. register_mods(MOD_MEH);
  42. } else {
  43. unregister_mods(MOD_MEH);
  44. }
  45. break;
  46. }
  47. }