logo

qmk_firmware

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

keymap.c (5785B)


  1. /*
  2. Default Keymap for dekuNukem/duckyPad QMK firmware
  3. Copyright (C) 2020 Max Bridgland
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  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. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #include QMK_KEYBOARD_H
  16. #include <stdio.h>
  17. #include <unistd.h>
  18. #include <string.h>
  19. #define LOGO_SIZE 384
  20. bool rgbToggled = false;
  21. enum layer_codes {
  22. RGB_LAYER = SAFE_RANGE
  23. };
  24. enum my_keycodes {
  25. Z0 = SAFE_RANGE, Z1, Z2,
  26. Z3, Z4, Z5,
  27. Z6, Z7, Z8,
  28. Z9, Z10, Z11,
  29. Z12, Z13, Z14
  30. };
  31. enum layers {
  32. _DEFAULT,
  33. _RGB
  34. };
  35. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  36. /*
  37. ,=========================================.
  38. | Numpad 1 | Numpad 2 | Numpad 3 |
  39. |=========================================|
  40. | Numpad 4 | Numpad 5 | Numpad 6 |
  41. |=========================================|
  42. | Numpad 7 | Numpad 8 | Numpad 9 |
  43. |=========================================|
  44. | Numpad . | Numpad 0 | Numpad = |
  45. |=========================================| ,---------------------.
  46. | Numpad - | Numpad + | Numpad * | | RGB Menu | Blank |
  47. `=========================================' `--------------------'
  48. */
  49. [_DEFAULT] = LAYOUT(
  50. KC_P1, KC_P2, KC_P3,
  51. KC_P4, KC_P5, KC_P6,
  52. KC_P7, KC_P8, KC_P9,
  53. KC_PDOT, KC_P0, KC_PENT,
  54. KC_PMNS, KC_PPLS, KC_EQL,
  55. RGB_LAYER, KC_NO
  56. ),
  57. /*
  58. ,=========================================.
  59. | Plain RGB | Breathe RGB | Rainbow RGB |
  60. |=========================================|
  61. | Swirl RGB | Speed Down | Speed Up |
  62. |=========================================|
  63. | Effect Up | Sat. Down | Sat. Up |
  64. |=========================================|
  65. | Effect Down | Hue Down | Hue Up |
  66. |=========================================| ,----------------------.
  67. | Toggle RGB | Brt. Down | Brt. Up | | Norm Menu | Blank |
  68. `=========================================' `---------------------'
  69. */
  70. [_RGB] = LAYOUT(
  71. RGB_M_P, RGB_M_B, RGB_M_R,
  72. RGB_M_SW, RM_SPDD, RM_SPDU,
  73. RM_NEXT, RM_SATD, RM_SATU,
  74. RM_PREV, RM_HUED, RM_HUEU,
  75. RM_TOGG, RM_VALD, RM_VALU,
  76. RGB_LAYER, KC_NO
  77. )
  78. };
  79. static void render_logo(void) {
  80. static const char PROGMEM ducky_logo[LOGO_SIZE] = {
  81. 0, 0, 0, 0,128,128,128,128,128, 0, 0,252,252,252, 0, 0, 0,128,128,128, 0, 0, 0, 0, 0,128,128,128, 0, 0, 0, 0, 0,128,128,128,128,128, 0, 0, 0, 0, 0,252,252,252, 0, 0, 0, 0, 0,128,128,128,128,128,128, 0, 0, 0, 0, 0, 0,128,128,128,128, 0,248,248,248, 56, 56, 56, 56, 56, 56,120,240,224,192, 0, 0,128,128,128,128,128,128, 0, 0, 0, 0, 0, 0, 0, 0,128,128,128,128,128, 0, 0,252,252,252, 0, 0, 0, 0, 0,232, 24, 24,232, 0, 24, 48, 48, 24, 0,232, 24, 24,232, 0, 0,
  82. 0,248,254,255,143, 7, 3, 3, 3, 7,142,255,255,255, 0, 0, 0,255,255,255, 0, 0, 0, 0, 0,255,255,255, 0,248,254,255,143, 7, 3, 3, 3, 3,143, 7, 2, 0, 0,255,255,255,240,120,252,254,231,131, 1, 0, 1, 7, 63,254,240,192, 0,224,252,127, 31, 3, 0, 0,255,255,255,112,112,112,112,112,112, 56, 63, 31, 15,193,231,243,115, 51, 51, 51, 55,255,255,252, 0, 0,248,254,255,143, 7, 3, 3, 3, 7,142,255,255,255, 0, 0, 0, 0, 0, 21,127,127,252,252,252,253,253,252,252,252,255,255,255, 0, 0,
  83. 0, 0, 3, 7, 15, 15, 14, 14, 14, 7, 3, 15, 15, 15, 0, 0, 0, 3, 7, 15, 15, 14, 14, 6, 3, 15, 15, 15, 0, 0, 3, 7, 7, 15, 14, 14, 14, 14, 7, 7, 2, 0, 0, 15, 15, 15, 0, 0, 0, 1, 3, 15, 15, 12,136,224,224,224,247,127,127, 31, 3, 0, 0, 0, 0, 0, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 7, 15, 14, 14, 14, 6, 3, 15, 15, 15, 0, 0, 0, 3, 7, 15, 15, 14, 14, 14, 7, 3, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 7, 11, 3, 11, 7, 11, 7, 7, 31, 0, 0
  84. };
  85. oled_write_raw_P(ducky_logo, LOGO_SIZE);
  86. }
  87. char* make_menu_text(void){
  88. char *s = malloc((30 * 6) * sizeof(*s));
  89. int width = 3;
  90. sprintf(s, "%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s",
  91. width, MT_0_0, width, MT_0_1, width, MT_0_2,
  92. width, MT_0_3, width, MT_0_4, width, MT_0_5,
  93. width, MT_0_6, width, MT_0_7, width, MT_0_8,
  94. width, MT_0_9, width, MT_0_10, width,MT_0_11,
  95. width, MT_0_12, width, MT_0_13, width, MT_0_14
  96. );
  97. return s;
  98. };
  99. char* make_rgb_text(void){
  100. char *s = malloc((30 * 6) * sizeof(*s));
  101. int width = 3;
  102. sprintf(
  103. s, "%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s",
  104. width, MT_1_0, width, MT_1_1, width, MT_1_2,
  105. width, MT_1_3, width, MT_1_4, width, MT_1_5,
  106. width, MT_1_6, width, MT_1_7, width, MT_1_8,
  107. width, MT_1_9, width, MT_1_10, width,MT_1_11,
  108. width, MT_1_12, width, MT_1_13, width, MT_1_14
  109. );
  110. return s;
  111. };
  112. bool oled_task_user(void) {
  113. render_logo();
  114. oled_set_cursor(0,3);
  115. if (rgbToggled) {
  116. char *s = make_rgb_text();
  117. oled_write_ln_P(s, false);
  118. free(s);
  119. } else {
  120. char *s = make_menu_text();
  121. oled_write_ln_P(s, false);
  122. free(s);
  123. }
  124. return false;
  125. }
  126. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  127. switch (keycode) {
  128. case RGB_LAYER:
  129. if (record->event.pressed) {
  130. if (rgbToggled) {
  131. rgbToggled = false;
  132. layer_clear();
  133. } else {
  134. rgbToggled = true;
  135. layer_on(_RGB);
  136. }
  137. }
  138. return false;
  139. default:
  140. return true;
  141. }
  142. return false;
  143. }