logo

qmk_firmware

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

keymap.c (3914B)


  1. /* Copyright 2019 niltea
  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. #ifdef OLED_ENABLE
  18. #include <string.h>
  19. #include "lib/oled_helper.h"
  20. #endif
  21. // Defines the keycodes used by our macros in process_record_user
  22. enum custom_keycodes {
  23. KEY_01 = SAFE_RANGE,
  24. KEY_02,
  25. KEY_03,
  26. KEY_04,
  27. KEY_05,
  28. KEY_06,
  29. KEY_07,
  30. KEY_08,
  31. KEY_09,
  32. KEY_10,
  33. KEY_11,
  34. KEY_12,
  35. KEY_13,
  36. KEY_14
  37. };
  38. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  39. [0] = LAYOUT(
  40. KEY_01, KEY_02, KEY_03, KEY_04, KEY_05,
  41. KEY_06, KEY_07, KEY_08, KEY_09, KEY_10,
  42. KEY_11, KEY_12, KEY_13, KEY_14
  43. ),
  44. };
  45. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  46. switch (keycode) {
  47. case KEY_01:
  48. if (record->event.pressed) {
  49. SEND_STRING("R1C1");
  50. }
  51. break;
  52. case KEY_02:
  53. if (record->event.pressed) {
  54. SEND_STRING("R1C2");
  55. }
  56. break;
  57. case KEY_03:
  58. if (record->event.pressed) {
  59. SEND_STRING("R1C3");
  60. }
  61. break;
  62. case KEY_04:
  63. if (record->event.pressed) {
  64. SEND_STRING("R1C4");
  65. }
  66. break;
  67. case KEY_05:
  68. if (record->event.pressed) {
  69. SEND_STRING("ENCODER-UPPER:Button");
  70. }
  71. break;
  72. case KEY_06:
  73. if (record->event.pressed) {
  74. SEND_STRING("R2C1");
  75. }
  76. break;
  77. case KEY_07:
  78. if (record->event.pressed) {
  79. SEND_STRING("R2C2");
  80. }
  81. break;
  82. case KEY_08:
  83. if (record->event.pressed) {
  84. SEND_STRING("R2C3");
  85. }
  86. break;
  87. case KEY_09:
  88. if (record->event.pressed) {
  89. SEND_STRING("R2C4");
  90. }
  91. break;
  92. case KEY_10:
  93. if (record->event.pressed) {
  94. SEND_STRING("ENCODER-LOWER:Button");
  95. }
  96. break;
  97. case KEY_11:
  98. if (record->event.pressed) {
  99. SEND_STRING("R3C1");
  100. }
  101. break;
  102. case KEY_12:
  103. if (record->event.pressed) {
  104. SEND_STRING("R3C2");
  105. }
  106. break;
  107. case KEY_13:
  108. if (record->event.pressed) {
  109. SEND_STRING("R3C3");
  110. }
  111. break;
  112. case KEY_14:
  113. if (record->event.pressed) {
  114. SEND_STRING("R3C4");
  115. }
  116. break;
  117. }
  118. return true;
  119. }
  120. bool encoder_update_user(uint8_t index, bool clockwise) {
  121. if (index == 0) { /* the upper encoder */
  122. if (clockwise) {
  123. SEND_STRING("ENCODER-UPPER:CW");
  124. } else {
  125. SEND_STRING("ENCODER-UPPER:CCW");
  126. }
  127. } else if (index == 1) { /* the lower encoder */
  128. if (clockwise) {
  129. SEND_STRING("ENCODER-LOWER:CW");
  130. } else {
  131. SEND_STRING("ENCODER-LOWER:CCW");
  132. }
  133. }
  134. return true;
  135. }
  136. // OLED Display
  137. #ifdef OLED_ENABLE
  138. bool oled_task_user(void) {
  139. render_row(0, "TEST");
  140. render_row(1, "test");
  141. render_row(2, "TEST");
  142. render_row(3, "test");
  143. return false;
  144. }
  145. #endif // #ifdef OLED_ENABLE