aboutsummaryrefslogtreecommitdiff
path: root/users/rupa/unicode.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/rupa/unicode.c')
-rw-r--r--[-rwxr-xr-x]users/rupa/unicode.c167
1 files changed, 148 insertions, 19 deletions
diff --git a/users/rupa/unicode.c b/users/rupa/unicode.c
index 89a0d4766..2302a9555 100755..100644
--- a/users/rupa/unicode.c
+++ b/users/rupa/unicode.c
@@ -17,26 +17,155 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18#include "unicode.h" 18#include "unicode.h"
19 19
20combined_mode_t combined_mode = CM_NULL;
21bool _seeded = false;
22
20#if defined(UNICODEMAP_ENABLE) 23#if defined(UNICODEMAP_ENABLE)
21const uint32_t PROGMEM unicode_map[] = { 24const uint32_t PROGMEM unicode_map[] = {
22 [CHEK] = 0x2713, // ✓ 25 [CCIR] = 0x20DD, // COMBINING CIRCLE ⃝
23 /* 26 [CENT] = 0x00A2, // ¢
24 [DI1] = 0x2680, // ⚀ 27 [CHEK] = 0x2713, // ✓
25 [DI2] = 0x2681, // ⚁ 28 [CKEY] = 0x20E3, // COMBINING KEYCAP ⃣
26 [DI3] = 0x2682, // ⚂ 29 [CUI] = 0x26A0, // ⚠
27 [DI4] = 0x2683, // ⚃ 30 [ECKS] = 0x2716, // ✖
28 [DI5] = 0x2684, // ⚄ 31 [EFF] = 0x017F, // ſ
29 [DI6] = 0x2685, // ⚅ 32 [HAS] = 0x262D, // ☭
30 */ 33 [HUN] = 0x1F4AF, // 💯
31 [HAS] = 0x262D, // ☭ 34 [IBNG] = 0x203D, // ‽
32 [IBNG] = 0x203D, // ‽ 35 [IRNY] = 0x2E2E, // ⸮
33 [IRNY] = 0x2E2E, // ⸮ 36 [LALL] = 0x2200, // ∀
34 [M4] = 0x2669, // ♩ 37 [LELM] = 0x2208, // ∈
35 [M8] = 0x266A, // ♪ 38 [LEXI] = 0x2203, // ∃
36 [M8B] = 0x266B, // ♫ 39 [LPRO] = 0x22A2, // ⊢
37 [M16] = 0x266C, // ♬ 40 [M4] = 0x2669, // ♩
38 [OM] = 0x0950, // ॐ 41 [M8] = 0x266A, // ♪
39 [STB] = 0x2605, // ★ 42 [M8B] = 0x266B, // ♫
40 [STW] = 0x2606, // ☆ 43 [M16] = 0x266C, // ♬
44 [NEG] = 0x20E0, // COMBINING NO ⃠
45 [NOPE] = 0x1F6AB, // 🚫
46 [NUM] = 0x2116, // №
47 [OM] = 0x0950, // ॐ
48 [SMB] = 0x263A, // ☻
49 [SMW] = 0x263B, // ☺
50 [STB] = 0x2605, // ★
51 [STOP] = 0x26D4, // ⛔
52 [STW] = 0x2606, // ☆
41}; 53};
42#endif 54#endif
55
56const char *d6_map[] = {
57 "⚀", "⚁", "⚂", "⚃", "⚄", "⚅"
58};
59const char *dance_map[] = {
60 "〜( ̄▽ ̄〜)",
61 "(〜 ̄▽ ̄)〜"
62};
63const char *dance_more_map[] = {
64 "ƪ(˘⌣˘)┐",
65 "┌(˘⌣˘)ʃ"
66};
67const char *flip_map[] = {
68 "(╯°□°)╯︵ ┻━━┻",
69 "(ノ-_-)ノ・・ ┻━━┻",
70 "(ノꐦ⊙曲ఠ)ノ彡┻━┻"
71};
72const char *flip_back_map[] = {
73 "┬──┬◡ノ(° -°ノ)",
74 "┬──┬ノ( ゜-゜ノ)",
75 "┬──┬ノ(ಠ_ಠノ)"
76};
77const char *joy_map[] = {
78 "ᕕ( ᐛ )ᕗ ",
79 "٩(ˊᗜˋ*)و",
80 "٩( ᐛ )و"
81};
82const char *joy_harder_map[] = {
83 "\\\ ٩( ᐛ )و //",
84 "✧*。٩(ˊᗜˋ*)و✧*。"
85};
86
87const char *choice(const char *choices[], int size) {
88 if (_seeded == false) {
89 srand(timer_read32());
90 dprintf("_seeded the roll\n");
91 _seeded = true;
92 }
93 return choices[rand() % size];
94}
95
96const char *d6(void) {
97 return choice(d6_map, 6);
98}
99const char *dance(bool more) {
100 if (more) {
101 return choice(dance_more_map, 2);
102 }
103 return choice(dance_map, 2);
104}
105const char *flip(bool flip_back) {
106 if (flip_back) {
107 return choice(flip_back_map, 3);
108 }
109 return choice(flip_map, 3);
110}
111const char *joy(bool harder) {
112 if (harder) {
113 return choice(joy_harder_map, 2);
114 }
115 return choice(joy_map, 3);
116}
117
118bool u_x(const char *text) {
119 send_unicode_string(text);
120 return false;
121};
122bool u_xp(bool is_shifted, const char *shifted, const char *plain) {
123 send_unicode_string(is_shifted ? shifted : plain);
124 return false;
125};
126
127void zalgo(void) {
128 int number = (rand() % (8 + 1 - 2)) + 2;
129 unsigned int index;
130 for (index=0; index<number; index++) {
131 uint16_t hex = (rand() % (0x036F + 1 - 0x0300)) + 0x0300;
132 register_hex(hex);
133 }
134}
135
136bool combined_text(uint16_t keycode) {
137 if (keycode < KC_A || (keycode > KC_0 && keycode < KC_MINUS) || keycode > KC_SLASH) {
138 return false;
139 }
140 tap_code(keycode);
141 unicode_input_start();
142 switch (combined_mode) {
143 case CM_CIRCLE:
144 register_hex(0x20DD);
145 break;
146 case CM_NO:
147 register_hex(0x20E0);
148 break;
149 case CM_KEYCAP:
150 register_hex(0x20E3);
151 break;
152 case CM_ZALGO:
153 zalgo();
154 break;
155 default:
156 break;
157 }
158 unicode_input_finish();
159 return true;
160}
161
162void cycle_combined_mode(void) {
163 if (combined_mode++ >= CM_MAX - 1) {
164 combined_mode = CM_NULL;
165 }
166}
167
168combined_mode_t set_combined_mode(combined_mode_t mode) {
169 combined_mode = combined_mode == mode ? CM_NULL : mode;
170 return combined_mode;
171}