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.

159 lines
5.7 KiB

  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. #define _DEFAULT 0
  32. #define _RGB 1
  33. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  34. /*
  35. ,=========================================.
  36. | Numpad 1 | Numpad 2 | Numpad 3 |
  37. |=========================================|
  38. | Numpad 4 | Numpad 5 | Numpad 6 |
  39. |=========================================|
  40. | Numpad 7 | Numpad 8 | Numpad 9 |
  41. |=========================================|
  42. | Numpad . | Numpad 0 | Numpad = |
  43. |=========================================| ,---------------------.
  44. | Numpad - | Numpad + | Numpad * | | RGB Menu | Blank |
  45. `=========================================' `--------------------'
  46. */
  47. [_DEFAULT] = LAYOUT(
  48. KC_P1, KC_P2, KC_P3,
  49. KC_P4, KC_P5, KC_P6,
  50. KC_P7, KC_P8, KC_P9,
  51. KC_PDOT, KC_P0, KC_PENT,
  52. KC_PMNS, KC_PPLS, KC_EQL,
  53. RGB_LAYER, KC_NO
  54. ),
  55. /*
  56. ,=========================================.
  57. | Plain RGB | Breathe RGB | Rainbow RGB |
  58. |=========================================|
  59. | Swirl RGB | Speed Down | Speed Up |
  60. |=========================================|
  61. | Effect Up | Sat. Down | Sat. Up |
  62. |=========================================|
  63. | Effect Down | Hue Down | Hue Up |
  64. |=========================================| ,----------------------.
  65. | Toggle RGB | Brt. Down | Brt. Up | | Norm Menu | Blank |
  66. `=========================================' `---------------------'
  67. */
  68. [_RGB] = LAYOUT(
  69. RGB_MODE_PLAIN, RGB_MODE_BREATHE, RGB_MODE_RAINBOW,
  70. RGB_MODE_SWIRL, RGB_SPD, RGB_SPI,
  71. RGB_MOD, RGB_SAD, RGB_SAI,
  72. RGB_RMOD, RGB_HUD, RGB_HUI,
  73. RGB_TOG, RGB_VAD, RGB_VAI,
  74. RGB_LAYER, KC_NO
  75. )
  76. };
  77. static void render_logo(void) {
  78. static const char PROGMEM ducky_logo[LOGO_SIZE] = {
  79. 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,
  80. 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,
  81. 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
  82. };
  83. oled_write_raw_P(ducky_logo, LOGO_SIZE);
  84. }
  85. char* make_menu_text(void){
  86. char *s = malloc((30 * 6) * sizeof(*s));
  87. int width = 3;
  88. sprintf(s, "%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s",
  89. width, MT_0_0, width, MT_0_1, width, MT_0_2,
  90. width, MT_0_3, width, MT_0_4, width, MT_0_5,
  91. width, MT_0_6, width, MT_0_7, width, MT_0_8,
  92. width, MT_0_9, width, MT_0_10, width,MT_0_11,
  93. width, MT_0_12, width, MT_0_13, width, MT_0_14
  94. );
  95. return s;
  96. };
  97. char* make_rgb_text(void){
  98. char *s = malloc((30 * 6) * sizeof(*s));
  99. int width = 3;
  100. sprintf(
  101. s, "%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s\n%-*s %-*s %-*s",
  102. width, MT_1_0, width, MT_1_1, width, MT_1_2,
  103. width, MT_1_3, width, MT_1_4, width, MT_1_5,
  104. width, MT_1_6, width, MT_1_7, width, MT_1_8,
  105. width, MT_1_9, width, MT_1_10, width,MT_1_11,
  106. width, MT_1_12, width, MT_1_13, width, MT_1_14
  107. );
  108. return s;
  109. };
  110. void oled_task_user(void) {
  111. render_logo();
  112. oled_set_cursor(0,3);
  113. if (rgbToggled) {
  114. char *s = make_rgb_text();
  115. oled_write_ln_P(s, false);
  116. free(s);
  117. } else {
  118. char *s = make_menu_text();
  119. oled_write_ln_P(s, false);
  120. free(s);
  121. }
  122. }
  123. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  124. switch (keycode) {
  125. case RGB_LAYER:
  126. if (record->event.pressed) {
  127. if (rgbToggled) {
  128. rgbToggled = false;
  129. layer_clear();
  130. } else {
  131. rgbToggled = true;
  132. layer_on(_RGB);
  133. }
  134. }
  135. return false;
  136. default:
  137. return true;
  138. }
  139. return false;
  140. }