logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

keymap.c (3242B)


  1. /* Copyright 2017 WoodKeys
  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. enum layer_names {
  18. _NUMLOCK,
  19. _NAV,
  20. _ALT,
  21. _ADJUST
  22. };
  23. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  24. [_NUMLOCK] = LAYOUT_ortho_5x4( /* Base */
  25. KC_NUM, KC_PSLS, KC_PAST, KC_PMNS,
  26. KC_P7, KC_P8, KC_P9, KC_PPLS,
  27. KC_P4, KC_P5, KC_P6, KC_PEQL,
  28. KC_P1, KC_P2, KC_P3, KC_COMM,
  29. KC_LALT, KC_P0, KC_PDOT, KC_PENT
  30. ),
  31. [_NAV] = LAYOUT_ortho_5x4( /* Base */
  32. _______, _______, _______, _______,
  33. KC_HOME, KC_UP, KC_PGUP, _______,
  34. KC_LEFT, XXXXXXX, KC_RGHT, _______,
  35. KC_END, KC_DOWN, KC_PGDN, _______,
  36. _______, KC_INS, KC_DEL, _______
  37. ),
  38. [_ALT] = LAYOUT_ortho_5x4( /* Base */
  39. _______, KC_MUTE, KC_VOLD, KC_VOLU,
  40. _______, _______, _______, _______,
  41. _______, _______, _______, _______,
  42. _______, _______, _______, _______,
  43. _______, _______, _______, _______
  44. ),
  45. [_ADJUST] = LAYOUT_ortho_5x4( /* Base */
  46. _______, KC_A, _______, QK_BOOT,
  47. _______, _______, _______, _______,
  48. _______, _______, _______, _______,
  49. _______, _______, _______, _______,
  50. _______, _______, _______, _______
  51. )
  52. };
  53. static bool numlock_down = false;
  54. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  55. switch (keycode) {
  56. case KC_NUM:
  57. if (record->event.pressed) {
  58. numlock_down = true;
  59. if (IS_LAYER_ON(_ALT)) {
  60. layer_on(_ADJUST);
  61. }
  62. } else {
  63. if(!IS_LAYER_ON(_ADJUST)) {
  64. if (!IS_LAYER_ON(_NAV)) {
  65. numlock_led_off();
  66. layer_on(_NAV);
  67. } else {
  68. numlock_led_on();
  69. layer_off(_NAV);
  70. }
  71. } else {
  72. layer_off(_ADJUST);
  73. }
  74. numlock_down = false;
  75. }
  76. return false;
  77. case KC_LALT:
  78. if (record->event.pressed) {
  79. if (numlock_down) {
  80. layer_on(_ADJUST);
  81. } else {
  82. layer_on(_ALT);
  83. }
  84. } else {
  85. if(IS_LAYER_ON(_ADJUST)) {
  86. layer_off(_ADJUST);
  87. } else {
  88. layer_off(_ALT);
  89. }
  90. }
  91. // Allow normal processing of ALT
  92. return false;
  93. }
  94. return true;
  95. }