aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/common/report.c
diff options
context:
space:
mode:
authorskullY <skullydazed@gmail.com>2019-08-30 11:19:03 -0700
committerskullydazed <skullydazed@users.noreply.github.com>2019-08-30 15:01:52 -0700
commitb624f32f944acdc59dcb130674c09090c5c404cb (patch)
treebc13adbba137d122d9a2c2fb2fafcbb08ac10e25 /tmk_core/common/report.c
parent61af76a10d00aba185b8338604171de490a13e3b (diff)
downloadqmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.tar.gz
qmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.zip
clang-format changes
Diffstat (limited to 'tmk_core/common/report.c')
-rw-r--r--tmk_core/common/report.c66
1 files changed, 27 insertions, 39 deletions
diff --git a/tmk_core/common/report.c b/tmk_core/common/report.c
index 6a06b70c6..f4758b48e 100644
--- a/tmk_core/common/report.c
+++ b/tmk_core/common/report.c
@@ -25,20 +25,18 @@
25 * 25 *
26 * FIXME: Needs doc 26 * FIXME: Needs doc
27 */ 27 */
28uint8_t has_anykey(report_keyboard_t* keyboard_report) 28uint8_t has_anykey(report_keyboard_t* keyboard_report) {
29{ 29 uint8_t cnt = 0;
30 uint8_t cnt = 0; 30 uint8_t* p = keyboard_report->keys;
31 uint8_t *p = keyboard_report->keys; 31 uint8_t lp = sizeof(keyboard_report->keys);
32 uint8_t lp = sizeof(keyboard_report->keys);
33#ifdef NKRO_ENABLE 32#ifdef NKRO_ENABLE
34 if (keyboard_protocol && keymap_config.nkro) { 33 if (keyboard_protocol && keymap_config.nkro) {
35 p = keyboard_report->nkro.bits; 34 p = keyboard_report->nkro.bits;
36 lp = sizeof(keyboard_report->nkro.bits); 35 lp = sizeof(keyboard_report->nkro.bits);
37 } 36 }
38#endif 37#endif
39 while (lp--) { 38 while (lp--) {
40 if (*p++) 39 if (*p++) cnt++;
41 cnt++;
42 } 40 }
43 return cnt; 41 return cnt;
44} 42}
@@ -47,14 +45,13 @@ uint8_t has_anykey(report_keyboard_t* keyboard_report)
47 * 45 *
48 * FIXME: Needs doc 46 * FIXME: Needs doc
49 */ 47 */
50uint8_t get_first_key(report_keyboard_t* keyboard_report) 48uint8_t get_first_key(report_keyboard_t* keyboard_report) {
51{
52#ifdef NKRO_ENABLE 49#ifdef NKRO_ENABLE
53 if (keyboard_protocol && keymap_config.nkro) { 50 if (keyboard_protocol && keymap_config.nkro) {
54 uint8_t i = 0; 51 uint8_t i = 0;
55 for (; i < KEYBOARD_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++) 52 for (; i < KEYBOARD_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++)
56 ; 53 ;
57 return i<<3 | biton(keyboard_report->nkro.bits[i]); 54 return i << 3 | biton(keyboard_report->nkro.bits[i]);
58 } 55 }
59#endif 56#endif
60#ifdef USB_6KRO_ENABLE 57#ifdef USB_6KRO_ENABLE
@@ -75,10 +72,9 @@ uint8_t get_first_key(report_keyboard_t* keyboard_report)
75 * 72 *
76 * FIXME: Needs doc 73 * FIXME: Needs doc
77 */ 74 */
78void add_key_byte(report_keyboard_t* keyboard_report, uint8_t code) 75void add_key_byte(report_keyboard_t* keyboard_report, uint8_t code) {
79{
80#ifdef USB_6KRO_ENABLE 76#ifdef USB_6KRO_ENABLE
81 int8_t i = cb_head; 77 int8_t i = cb_head;
82 int8_t empty = -1; 78 int8_t empty = -1;
83 if (cb_count) { 79 if (cb_count) {
84 do { 80 do {
@@ -97,18 +93,16 @@ void add_key_byte(report_keyboard_t* keyboard_report, uint8_t code)
97 // pop head when has no empty space 93 // pop head when has no empty space
98 cb_head = RO_INC(cb_head); 94 cb_head = RO_INC(cb_head);
99 cb_count--; 95 cb_count--;
100 } 96 } else {
101 else {
102 // left shift when has empty space 97 // left shift when has empty space
103 uint8_t offset = 1; 98 uint8_t offset = 1;
104 i = RO_INC(empty); 99 i = RO_INC(empty);
105 do { 100 do {
106 if (keyboard_report->keys[i] != 0) { 101 if (keyboard_report->keys[i] != 0) {
107 keyboard_report->keys[empty] = keyboard_report->keys[i]; 102 keyboard_report->keys[empty] = keyboard_report->keys[i];
108 keyboard_report->keys[i] = 0; 103 keyboard_report->keys[i] = 0;
109 empty = RO_INC(empty); 104 empty = RO_INC(empty);
110 } 105 } else {
111 else {
112 offset++; 106 offset++;
113 } 107 }
114 i = RO_INC(i); 108 i = RO_INC(i);
@@ -120,10 +114,10 @@ void add_key_byte(report_keyboard_t* keyboard_report, uint8_t code)
120 } 114 }
121 // add to tail 115 // add to tail
122 keyboard_report->keys[cb_tail] = code; 116 keyboard_report->keys[cb_tail] = code;
123 cb_tail = RO_INC(cb_tail); 117 cb_tail = RO_INC(cb_tail);
124 cb_count++; 118 cb_count++;
125#else 119#else
126 int8_t i = 0; 120 int8_t i = 0;
127 int8_t empty = -1; 121 int8_t empty = -1;
128 for (; i < KEYBOARD_REPORT_KEYS; i++) { 122 for (; i < KEYBOARD_REPORT_KEYS; i++) {
129 if (keyboard_report->keys[i] == code) { 123 if (keyboard_report->keys[i] == code) {
@@ -145,8 +139,7 @@ void add_key_byte(report_keyboard_t* keyboard_report, uint8_t code)
145 * 139 *
146 * FIXME: Needs doc 140 * FIXME: Needs doc
147 */ 141 */
148void del_key_byte(report_keyboard_t* keyboard_report, uint8_t code) 142void del_key_byte(report_keyboard_t* keyboard_report, uint8_t code) {
149{
150#ifdef USB_6KRO_ENABLE 143#ifdef USB_6KRO_ENABLE
151 uint8_t i = cb_head; 144 uint8_t i = cb_head;
152 if (cb_count) { 145 if (cb_count) {
@@ -186,10 +179,9 @@ void del_key_byte(report_keyboard_t* keyboard_report, uint8_t code)
186 * 179 *
187 * FIXME: Needs doc 180 * FIXME: Needs doc
188 */ 181 */
189void add_key_bit(report_keyboard_t* keyboard_report, uint8_t code) 182void add_key_bit(report_keyboard_t* keyboard_report, uint8_t code) {
190{ 183 if ((code >> 3) < KEYBOARD_REPORT_BITS) {
191 if ((code>>3) < KEYBOARD_REPORT_BITS) { 184 keyboard_report->nkro.bits[code >> 3] |= 1 << (code & 7);
192 keyboard_report->nkro.bits[code>>3] |= 1<<(code&7);
193 } else { 185 } else {
194 dprintf("add_key_bit: can't add: %02X\n", code); 186 dprintf("add_key_bit: can't add: %02X\n", code);
195 } 187 }
@@ -199,10 +191,9 @@ void add_key_bit(report_keyboard_t* keyboard_report, uint8_t code)
199 * 191 *
200 * FIXME: Needs doc 192 * FIXME: Needs doc
201 */ 193 */
202void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code) 194void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code) {
203{ 195 if ((code >> 3) < KEYBOARD_REPORT_BITS) {
204 if ((code>>3) < KEYBOARD_REPORT_BITS) { 196 keyboard_report->nkro.bits[code >> 3] &= ~(1 << (code & 7));
205 keyboard_report->nkro.bits[code>>3] &= ~(1<<(code&7));
206 } else { 197 } else {
207 dprintf("del_key_bit: can't del: %02X\n", code); 198 dprintf("del_key_bit: can't del: %02X\n", code);
208 } 199 }
@@ -213,8 +204,7 @@ void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code)
213 * 204 *
214 * FIXME: Needs doc 205 * FIXME: Needs doc
215 */ 206 */
216void add_key_to_report(report_keyboard_t* keyboard_report, uint8_t key) 207void add_key_to_report(report_keyboard_t* keyboard_report, uint8_t key) {
217{
218#ifdef NKRO_ENABLE 208#ifdef NKRO_ENABLE
219 if (keyboard_protocol && keymap_config.nkro) { 209 if (keyboard_protocol && keymap_config.nkro) {
220 add_key_bit(keyboard_report, key); 210 add_key_bit(keyboard_report, key);
@@ -228,8 +218,7 @@ void add_key_to_report(report_keyboard_t* keyboard_report, uint8_t key)
228 * 218 *
229 * FIXME: Needs doc 219 * FIXME: Needs doc
230 */ 220 */
231void del_key_from_report(report_keyboard_t* keyboard_report, uint8_t key) 221void del_key_from_report(report_keyboard_t* keyboard_report, uint8_t key) {
232{
233#ifdef NKRO_ENABLE 222#ifdef NKRO_ENABLE
234 if (keyboard_protocol && keymap_config.nkro) { 223 if (keyboard_protocol && keymap_config.nkro) {
235 del_key_bit(keyboard_report, key); 224 del_key_bit(keyboard_report, key);
@@ -243,8 +232,7 @@ void del_key_from_report(report_keyboard_t* keyboard_report, uint8_t key)
243 * 232 *
244 * FIXME: Needs doc 233 * FIXME: Needs doc
245 */ 234 */
246void clear_keys_from_report(report_keyboard_t* keyboard_report) 235void clear_keys_from_report(report_keyboard_t* keyboard_report) {
247{
248 // not clear mods 236 // not clear mods
249#ifdef NKRO_ENABLE 237#ifdef NKRO_ENABLE
250 if (keyboard_protocol && keymap_config.nkro) { 238 if (keyboard_protocol && keymap_config.nkro) {