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.

97 lines
2.5 KiB

  1. /* Copyright 2018 Jarred Steenvoorden
  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 "jarred.h"
  17. #include "version.h"
  18. __attribute__ ((weak))
  19. bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
  20. return true;
  21. }
  22. bool lowerPressed, raisePressed;
  23. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  24. switch (keycode) {
  25. case LOWER:
  26. case RAISE:
  27. // Both lower and raise activate the same layer
  28. if (record->event.pressed) {
  29. layer_on(_LW);
  30. } else {
  31. layer_off(_LW);
  32. }
  33. // But keep track of each to active adjust layer
  34. if (keycode == LOWER) {
  35. lowerPressed = record->event.pressed;
  36. } else {
  37. raisePressed = record->event.pressed;
  38. }
  39. // When both are pressed, activate adjust
  40. if (lowerPressed && raisePressed) {
  41. layer_on(_NP);
  42. } else {
  43. layer_off(_NP);
  44. }
  45. break;
  46. case NUMPAD:
  47. if (record->event.pressed) {
  48. layer_on(_NP);
  49. } else {
  50. layer_off(_NP);
  51. }
  52. break;
  53. case NAVI:
  54. if (record->event.pressed) {
  55. layer_on(_NV);
  56. } else {
  57. layer_off(_NV);
  58. // Release mods set by ALT_TAB and CTL_TAB
  59. unregister_code(KC_LALT);
  60. unregister_code(KC_LCTL);
  61. }
  62. break;
  63. case VRSN: // Prints firmware version
  64. if (record->event.pressed) {
  65. send_string_with_delay_P(PSTR(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION ", Built on: " QMK_BUILDDATE), MACRO_TIMER);
  66. }
  67. break;
  68. case ALT_TAB:
  69. if (record->event.pressed) {
  70. register_code(KC_LALT);
  71. tap_code(KC_TAB);
  72. }
  73. break;
  74. case CTL_TAB:
  75. if (record->event.pressed) {
  76. register_code(KC_LCTL);
  77. tap_code(KC_TAB);
  78. }
  79. break;
  80. }
  81. return process_record_keymap(keycode, record);
  82. }