1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
/* Copyright 2021
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \defgroup send_string
*
* Send String API. These functions allow you to create macros by typing out sequences of keystrokes.
* \{
*/
#include <stdint.h>
#include "progmem.h"
#include "send_string_keycodes.h"
// Look-Up Tables (LUTs) to convert ASCII character to keycode sequence.
extern const uint8_t ascii_to_shift_lut[16];
extern const uint8_t ascii_to_altgr_lut[16];
extern const uint8_t ascii_to_dead_lut[16];
extern const uint8_t ascii_to_keycode_lut[128];
// clang-format off
#define KCLUT_ENTRY(a, b, c, d, e, f, g, h) \
( ((a) ? 1 : 0) << 0 \
| ((b) ? 1 : 0) << 1 \
| ((c) ? 1 : 0) << 2 \
| ((d) ? 1 : 0) << 3 \
| ((e) ? 1 : 0) << 4 \
| ((f) ? 1 : 0) << 5 \
| ((g) ? 1 : 0) << 6 \
| ((h) ? 1 : 0) << 7 )
// clang-format on
/**
* \brief Type out a string of ASCII characters.
*
* This function simply calls `send_string_with_delay(string, 0)`.
*
* Most keycodes from the basic keycode range are also supported by way of a special sequence - see `send_string_keycodes.h`.
*
* \param string The string to type out.
*/
void send_string(const char *string);
/**
* \brief Type out a string of ASCII characters, with a delay between each character.
*
* \param string The string to type out.
* \param interval The amount of time, in milliseconds, to wait before typing the next character.
*/
void send_string_with_delay(const char *string, uint8_t interval);
/**
* \brief Type out an ASCII character.
*
* \param ascii_code The character to type.
*/
void send_char(char ascii_code);
/**
* \brief Type out an eight digit (unsigned 32-bit) hexadecimal value.
*
* The format is `[0-9a-f]{8}`, eg. `00000000` through `ffffffff`.
*
* \param number The value to type, from 0 to 4,294,967,295.
*/
void send_dword(uint32_t number);
/**
* \brief Type out a four digit (unsigned 16-bit) hexadecimal value.
*
* The format is `[0-9a-f]{4}`, eg. `0000` through `ffff`.
*
* \param number The value to type, from 0 to 65,535.
*/
void send_word(uint16_t number);
/**
* \brief Type out a two digit (8-bit) hexadecimal value.
*
* The format is `[0-9a-f]{2}`, eg. `00` through `ff`.
*
* \param number The value to type, from 0 to 255.
*/
void send_byte(uint8_t number);
/**
* \brief Type out a single hexadecimal digit.
*
* The format is `[0-9a-f]{1}`, eg. `0` through `f`.
*
* \param number The value to type, from 0 to 15.
*/
void send_nibble(uint8_t number);
/**
* \brief Type a pseudorandom character from the set `A-Z`, `a-z`, `0-9`, `+` and `/`.
*/
void tap_random_base64(void);
#if defined(__AVR__) || defined(__DOXYGEN__)
/**
* \brief Type out a PROGMEM string of ASCII characters.
*
* On ARM devices, this function is simply an alias for send_string_with_delay(string, 0).
*
* \param string The string to type out.
*/
void send_string_P(const char *string);
/**
* \brief Type out a PROGMEM string of ASCII characters, with a delay between each character.
*
* On ARM devices, this function is simply an alias for send_string_with_delay(string, interval).
*
* \param string The string to type out.
* \param interval The amount of time, in milliseconds, to wait before typing the next character.
*/
void send_string_with_delay_P(const char *string, uint8_t interval);
#else
# define send_string_P(string) send_string_with_delay(string, 0)
# define send_string_with_delay_P(string, interval) send_string_with_delay(string, interval)
#endif
/**
* \brief Shortcut macro for send_string_with_delay_P(PSTR(string), 0).
*
* On ARM devices, this define evaluates to send_string_with_delay(string, 0).
*/
#define SEND_STRING(string) send_string_with_delay_P(PSTR(string), 0)
/**
* \brief Shortcut macro for send_string_with_delay_P(PSTR(string), interval).
*
* On ARM devices, this define evaluates to send_string_with_delay(string, interval).
*/
#define SEND_STRING_DELAY(string, interval) send_string_with_delay_P(PSTR(string), interval)
/** \} */
|