You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.0 KiB

  1. /* Copyright 2021 Jonathan Rascher
  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 "bcat.h"
  17. #if defined(RGBLIGHT_ENABLE)
  18. /* Adjust RGB static hue ranges for shorter gradients than default. */
  19. const uint8_t RGBLED_GRADIENT_RANGES[] PROGMEM = {255, 127, 63, 31, 15};
  20. #endif
  21. static int8_t alt_tab_layer = -1;
  22. __attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; }
  23. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  24. if (!process_record_keymap(keycode, record)) {
  25. return false;
  26. }
  27. switch (keycode) {
  28. /* Alt+Tab that holds Alt until current layer is released: */
  29. case MC_ALTT:
  30. if (record->event.pressed) {
  31. if (alt_tab_layer < 0) {
  32. alt_tab_layer = layer_switch_get_layer(record->event.key);
  33. register_code(KC_LALT);
  34. }
  35. register_code(KC_TAB);
  36. } else {
  37. unregister_code(KC_TAB);
  38. }
  39. return false;
  40. default:
  41. return true;
  42. }
  43. }
  44. __attribute__((weak)) layer_state_t layer_state_set_keymap(layer_state_t state) { return state; }
  45. layer_state_t layer_state_set_user(layer_state_t state) {
  46. state = layer_state_set_keymap(state);
  47. if (alt_tab_layer >= 0 && !layer_state_cmp(state, alt_tab_layer)) {
  48. unregister_code(KC_LALT);
  49. alt_tab_layer = -1;
  50. }
  51. return state;
  52. }