keymap.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /* Copyright 2020 encg
  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. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <time.h>
  20. enum my_keycodes {
  21. SPIN = SAFE_RANGE,
  22. RULES,
  23. };
  24. enum unicode_names {
  25. COW,
  26. BTTR,
  27. CHIKN,
  28. FISH,
  29. SEED,
  30. RENV,
  31. MBAG,
  32. FACE,
  33. WING,
  34. SIGN,
  35. WAVE
  36. };
  37. const uint32_t PROGMEM unicode_map[] = {
  38. [COW] = 0x1F404, // 🐄
  39. [BTTR] = 0x1F9C8, // 🧈
  40. [CHIKN] = 0x1F414, // 🐔
  41. [FISH] = 0x1F3A3, // 🎣
  42. [SEED] = 0x1F331, // 🌱
  43. [RENV] = 0x1F9E7, // 🧧
  44. [MBAG] = 0x1F4B0, // 💰
  45. [FACE] = 0x1F911, // 🤑
  46. [WING] = 0x1F4B8, // 💸
  47. [SIGN] = 0x1F4B2, // 💲
  48. [WAVE] = 0x1F44B, // 👋
  49. };
  50. /* Emojis stored in an array in order to be randomly accessed */
  51. const char* emoji[5] = {"🐄", "🧈", "🐔", "🎣", "🌱"};
  52. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  53. switch (keycode) {
  54. case SPIN:
  55. if (record->event.pressed) {
  56. /* Seed RNG used by rand() with timer_read() https://beta.docs.qmk.fm/developing-qmk/qmk-reference/ref_functions#software-timers */
  57. srand(timer_read());
  58. int rng1 = rand() % 5;
  59. send_unicode_string(emoji[rng1]);
  60. wait_ms(200);
  61. int rng2 = rand() % 5;
  62. send_unicode_string(emoji[rng2]);
  63. wait_ms(200);
  64. int rng3 = rand() % 5;
  65. send_unicode_string(emoji[rng3]);
  66. wait_ms(200);
  67. if (rng1 == rng2 && rng1 == rng3) {
  68. if (rng1 == 0) {
  69. wait_ms(200);
  70. SEND_STRING(" ");
  71. send_unicode_string("🧧🧧🧧");
  72. wait_ms(200);
  73. SEND_STRING("\n");
  74. } else if (rng1 == 1) {
  75. wait_ms(200);
  76. SEND_STRING(" ");
  77. send_unicode_string("💰💰💰");
  78. wait_ms(200);
  79. SEND_STRING("\n");
  80. } else if (rng1 == 2) {
  81. wait_ms(200);
  82. SEND_STRING(" ");
  83. send_unicode_string("🤑🤑🤑");
  84. wait_ms(200);
  85. SEND_STRING("\n");
  86. } else if (rng1 == 3) {
  87. wait_ms(200);
  88. SEND_STRING(" ");
  89. send_unicode_string("💲💲💲");
  90. wait_ms(200);
  91. SEND_STRING("\n");
  92. } else if (rng1 == 4) {
  93. wait_ms(200);
  94. SEND_STRING(" ");
  95. send_unicode_string("📈📈📈");
  96. wait_ms(200);
  97. SEND_STRING("\n");
  98. }
  99. } else {
  100. SEND_STRING(" ");
  101. send_unicode_string("👋💸");
  102. SEND_STRING("\n");
  103. }
  104. }
  105. return false;
  106. break;
  107. case RULES:
  108. if (record->event.pressed) {
  109. send_unicode_string("🐄");
  110. wait_ms(200);
  111. send_unicode_string("🐄");
  112. wait_ms(200);
  113. send_unicode_string("🐄");
  114. wait_ms(200);
  115. SEND_STRING(" ");
  116. send_unicode_string("🧧");
  117. wait_ms(200);
  118. send_unicode_string("🧧");
  119. wait_ms(200);
  120. send_unicode_string("🧧");
  121. SEND_STRING("\n");
  122. wait_ms(100);
  123. send_unicode_string("🧈");
  124. wait_ms(200);
  125. send_unicode_string("🧈");
  126. wait_ms(200);
  127. send_unicode_string("🧈");
  128. wait_ms(200);
  129. SEND_STRING(" ");
  130. send_unicode_string("💰");
  131. wait_ms(200);
  132. send_unicode_string("💰");
  133. wait_ms(200);
  134. send_unicode_string("💰");
  135. SEND_STRING("\n");
  136. wait_ms(100);
  137. send_unicode_string("🐔");
  138. wait_ms(200);
  139. send_unicode_string("🐔");
  140. wait_ms(200);
  141. send_unicode_string("🐔");
  142. wait_ms(200);
  143. SEND_STRING(" ");
  144. send_unicode_string("🤑");
  145. wait_ms(200);
  146. send_unicode_string("🤑");
  147. wait_ms(200);
  148. send_unicode_string("🤑");
  149. SEND_STRING("\n");
  150. wait_ms(100);
  151. send_unicode_string("🎣");
  152. wait_ms(200);
  153. send_unicode_string("🎣");
  154. wait_ms(200);
  155. send_unicode_string("🎣");
  156. wait_ms(200);
  157. SEND_STRING(" ");
  158. send_unicode_string("💲");
  159. wait_ms(200);
  160. send_unicode_string("💲");
  161. wait_ms(200);
  162. send_unicode_string("💲");
  163. SEND_STRING("\n");
  164. wait_ms(100);
  165. send_unicode_string("🌱");
  166. wait_ms(200);
  167. send_unicode_string("🌱");
  168. wait_ms(200);
  169. send_unicode_string("🌱");
  170. wait_ms(200);
  171. SEND_STRING(" ");
  172. send_unicode_string("📈");
  173. wait_ms(200);
  174. send_unicode_string("📈");
  175. wait_ms(200);
  176. send_unicode_string("📈");
  177. SEND_STRING("\n\n");
  178. }
  179. return false;
  180. break;
  181. }
  182. return false;
  183. };
  184. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  185. [0] = LAYOUT(
  186. SPIN, /* bottom button */
  187. RULES /* top button */
  188. )
  189. };