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.

127 lines
3.2 KiB

  1. /* Copyright 2017 REPLACE_WITH_YOUR_NAME
  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 QMK_KEYBOARD_H
  17. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  18. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  19. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  20. // entirely and just use numbers.
  21. #define _NUMLOCK 0
  22. #define _NAV 1
  23. #define _ALT 2
  24. #define _ADJUST 3
  25. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  26. [_NUMLOCK] = KEYMAP( /* Base */
  27. KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS,\
  28. KC_P7, KC_P8, KC_P9, KC_PPLS, \
  29. KC_P4, KC_P5, KC_P6, KC_PEQL, \
  30. KC_P1, KC_P2, KC_P3, KC_COMM, \
  31. KC_LALT, KC_P0, KC_PDOT, KC_PENT \
  32. ),
  33. [_NAV] = KEYMAP( /* Base */
  34. _______, _______, _______, _______,\
  35. KC_HOME, KC_UP, KC_PGUP, _______, \
  36. KC_LEFT, XXXXXXX, KC_RIGHT, _______, \
  37. KC_END, KC_DOWN, KC_PGDN, _______, \
  38. _______, KC_INS, KC_DEL, _______ \
  39. ),
  40. [_ALT] = KEYMAP( /* Base */
  41. _______, KC_MUTE, KC_VOLD, KC_VOLU,\
  42. _______, _______, _______, _______, \
  43. _______, _______, _______, _______, \
  44. _______, _______, _______, _______, \
  45. _______, _______, _______, _______ \
  46. ),
  47. [_ADJUST] = KEYMAP( /* Base */
  48. _______, KC_A, _______, RESET,\
  49. _______, _______, _______, _______, \
  50. _______, _______, _______, _______, \
  51. _______, _______, _______, _______, \
  52. _______, _______, _______, _______ \
  53. ),
  54. };
  55. void numlock_led_on(void) {
  56. PORTF |= (1<<7);
  57. }
  58. void numlock_led_off(void) {
  59. PORTF &= ~(1<<7);
  60. }
  61. static bool numlock_down = false;
  62. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  63. switch (keycode) {
  64. case KC_NLCK:
  65. if (record->event.pressed) {
  66. numlock_down = true;
  67. if (IS_LAYER_ON(_ALT)) {
  68. layer_on(_ADJUST);
  69. }
  70. } else{
  71. if(!IS_LAYER_ON(_ADJUST)) {
  72. if (!IS_LAYER_ON(_NAV)){
  73. numlock_led_off();
  74. layer_on(_NAV);
  75. } else {
  76. numlock_led_on();
  77. layer_off(_NAV);
  78. }
  79. } else {
  80. layer_off(_ADJUST);
  81. }
  82. numlock_down = false;
  83. }
  84. return false;
  85. break;
  86. case KC_LALT:
  87. if (record->event.pressed) {
  88. if (numlock_down) {
  89. layer_on(_ADJUST);
  90. } else {
  91. layer_on(_ALT);
  92. }
  93. } else {
  94. if(IS_LAYER_ON(_ADJUST)) {
  95. layer_off(_ADJUST);
  96. } else {
  97. layer_off(_ALT);
  98. }
  99. }
  100. // Allow normal processing of ALT?
  101. return false;
  102. break;
  103. }
  104. return true;
  105. }
  106. void matrix_init_user(void) {
  107. // set Numlock LED to output and low
  108. DDRF |= (1<<7);
  109. PORTF &= ~(1<<7);
  110. }
  111. void matrix_scan_user(void) {
  112. }
  113. void led_set_user(uint8_t usb_led) {
  114. }