summaryrefslogtreecommitdiff
path: root/quantum/send_string.c
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2021-03-12 18:03:44 +1100
committerGitHub <noreply@github.com>2021-03-12 18:03:44 +1100
commit88dce243750d9e80948cd7262566182018d7bbdf (patch)
tree01fef7490b57303772b58c6cd0986c6d38b372f5 /quantum/send_string.c
parentea2a7c5ea4c4509ea7008a835eb9b98b0b1c05d6 (diff)
Remove hex_to_keycode and move tap_random_base64 to send_string.c (#12079)
Diffstat (limited to 'quantum/send_string.c')
-rw-r--r--quantum/send_string.c56
1 files changed, 55 insertions, 1 deletions
diff --git a/quantum/send_string.c b/quantum/send_string.c
index 0e8902ca3f..7d096b4273 100644
--- a/quantum/send_string.c
+++ b/quantum/send_string.c
@@ -249,4 +249,58 @@ void send_char(char ascii_code) {
if (is_dead) {
tap_code(KC_SPACE);
}
-} \ No newline at end of file
+}
+
+void send_dword(uint32_t number) {
+ send_word(number >> 16);
+ send_word(number & 0xFFFFUL);
+}
+
+void send_word(uint16_t number) {
+ send_byte(number >> 8);
+ send_byte(number & 0xFF);
+}
+
+void send_byte(uint8_t number) {
+ send_nibble(number >> 4);
+ send_nibble(number & 0xF);
+}
+
+void send_nibble(uint8_t number) {
+ switch (number & 0xF) {
+ case 0 ... 9:
+ send_char(number + '0');
+ break;
+ case 10 ... 15:
+ send_char(number - 10 + 'a');
+ break;
+ }
+}
+
+void tap_random_base64(void) {
+#if defined(__AVR_ATmega32U4__)
+ uint8_t key = (TCNT0 + TCNT1 + TCNT3 + TCNT4) % 64;
+#else
+ uint8_t key = rand() % 64;
+#endif
+ switch (key) {
+ case 0 ... 25:
+ send_char(key + 'A');
+ break;
+ case 26 ... 51:
+ send_char(key - 26 + 'a');
+ break;
+ case 52:
+ send_char('0');
+ break;
+ case 53 ... 61:
+ send_char(key - 53 + '1');
+ break;
+ case 62:
+ send_char('+');
+ break;
+ case 63:
+ send_char('/');
+ break;
+ }
+}