diff options
Diffstat (limited to 'tmk_core/protocol/report.c')
| -rw-r--r-- | tmk_core/protocol/report.c | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/tmk_core/protocol/report.c b/tmk_core/protocol/report.c index 0166bf654f..056921d6a0 100644 --- a/tmk_core/protocol/report.c +++ b/tmk_core/protocol/report.c | |||
| @@ -22,16 +22,6 @@ | |||
| 22 | #include "util.h" | 22 | #include "util.h" |
| 23 | #include <string.h> | 23 | #include <string.h> |
| 24 | 24 | ||
| 25 | #ifdef RING_BUFFERED_6KRO_REPORT_ENABLE | ||
| 26 | # define RO_ADD(a, b) ((a + b) % KEYBOARD_REPORT_KEYS) | ||
| 27 | # define RO_SUB(a, b) ((a - b + KEYBOARD_REPORT_KEYS) % KEYBOARD_REPORT_KEYS) | ||
| 28 | # define RO_INC(a) RO_ADD(a, 1) | ||
| 29 | # define RO_DEC(a) RO_SUB(a, 1) | ||
| 30 | static int8_t cb_head = 0; | ||
| 31 | static int8_t cb_tail = 0; | ||
| 32 | static int8_t cb_count = 0; | ||
| 33 | #endif | ||
| 34 | |||
| 35 | /** \brief has_anykey | 25 | /** \brief has_anykey |
| 36 | * | 26 | * |
| 37 | * FIXME: Needs doc | 27 | * FIXME: Needs doc |
| @@ -65,18 +55,7 @@ uint8_t get_first_key(void) { | |||
| 65 | return i << 3 | biton(nkro_report->bits[i]); | 55 | return i << 3 | biton(nkro_report->bits[i]); |
| 66 | } | 56 | } |
| 67 | #endif | 57 | #endif |
| 68 | #ifdef RING_BUFFERED_6KRO_REPORT_ENABLE | ||
| 69 | uint8_t i = cb_head; | ||
| 70 | do { | ||
| 71 | if (keyboard_report->keys[i] != 0) { | ||
| 72 | break; | ||
| 73 | } | ||
| 74 | i = RO_INC(i); | ||
| 75 | } while (i != cb_tail); | ||
| 76 | return keyboard_report->keys[i]; | ||
| 77 | #else | ||
| 78 | return keyboard_report->keys[0]; | 58 | return keyboard_report->keys[0]; |
| 79 | #endif | ||
| 80 | } | 59 | } |
| 81 | 60 | ||
| 82 | /** \brief Checks if a key is pressed in the report | 61 | /** \brief Checks if a key is pressed in the report |
| @@ -110,50 +89,6 @@ bool is_key_pressed(uint8_t key) { | |||
| 110 | * FIXME: Needs doc | 89 | * FIXME: Needs doc |
| 111 | */ | 90 | */ |
| 112 | void add_key_byte(report_keyboard_t* keyboard_report, uint8_t code) { | 91 | void add_key_byte(report_keyboard_t* keyboard_report, uint8_t code) { |
| 113 | #ifdef RING_BUFFERED_6KRO_REPORT_ENABLE | ||
| 114 | int8_t i = cb_head; | ||
| 115 | int8_t empty = -1; | ||
| 116 | if (cb_count) { | ||
| 117 | do { | ||
| 118 | if (keyboard_report->keys[i] == code) { | ||
| 119 | return; | ||
| 120 | } | ||
| 121 | if (empty == -1 && keyboard_report->keys[i] == 0) { | ||
| 122 | empty = i; | ||
| 123 | } | ||
| 124 | i = RO_INC(i); | ||
| 125 | } while (i != cb_tail); | ||
| 126 | if (i == cb_tail) { | ||
| 127 | if (cb_tail == cb_head) { | ||
| 128 | // buffer is full | ||
| 129 | if (empty == -1) { | ||
| 130 | // pop head when has no empty space | ||
| 131 | cb_head = RO_INC(cb_head); | ||
| 132 | cb_count--; | ||
| 133 | } else { | ||
| 134 | // left shift when has empty space | ||
| 135 | uint8_t offset = 1; | ||
| 136 | i = RO_INC(empty); | ||
| 137 | do { | ||
| 138 | if (keyboard_report->keys[i] != 0) { | ||
| 139 | keyboard_report->keys[empty] = keyboard_report->keys[i]; | ||
| 140 | keyboard_report->keys[i] = 0; | ||
| 141 | empty = RO_INC(empty); | ||
| 142 | } else { | ||
| 143 | offset++; | ||
| 144 | } | ||
| 145 | i = RO_INC(i); | ||
| 146 | } while (i != cb_tail); | ||
| 147 | cb_tail = RO_SUB(cb_tail, offset); | ||
| 148 | } | ||
| 149 | } | ||
| 150 | } | ||
| 151 | } | ||
| 152 | // add to tail | ||
| 153 | keyboard_report->keys[cb_tail] = code; | ||
| 154 | cb_tail = RO_INC(cb_tail); | ||
| 155 | cb_count++; | ||
| 156 | #else | ||
| 157 | int8_t i = 0; | 92 | int8_t i = 0; |
| 158 | int8_t empty = -1; | 93 | int8_t empty = -1; |
| 159 | for (; i < KEYBOARD_REPORT_KEYS; i++) { | 94 | for (; i < KEYBOARD_REPORT_KEYS; i++) { |
| @@ -169,7 +104,6 @@ void add_key_byte(report_keyboard_t* keyboard_report, uint8_t code) { | |||
| 169 | keyboard_report->keys[empty] = code; | 104 | keyboard_report->keys[empty] = code; |
| 170 | } | 105 | } |
| 171 | } | 106 | } |
| 172 | #endif | ||
| 173 | } | 107 | } |
| 174 | 108 | ||
| 175 | /** \brief del key byte | 109 | /** \brief del key byte |
| @@ -177,38 +111,11 @@ void add_key_byte(report_keyboard_t* keyboard_report, uint8_t code) { | |||
| 177 | * FIXME: Needs doc | 111 | * FIXME: Needs doc |
| 178 | */ | 112 | */ |
| 179 | void del_key_byte(report_keyboard_t* keyboard_report, uint8_t code) { | 113 | void del_key_byte(report_keyboard_t* keyboard_report, uint8_t code) { |
| 180 | #ifdef RING_BUFFERED_6KRO_REPORT_ENABLE | ||
| 181 | uint8_t i = cb_head; | ||
| 182 | if (cb_count) { | ||
| 183 | do { | ||
| 184 | if (keyboard_report->keys[i] == code) { | ||
| 185 | keyboard_report->keys[i] = 0; | ||
| 186 | cb_count--; | ||
| 187 | if (cb_count == 0) { | ||
| 188 | // reset head and tail | ||
| 189 | cb_tail = cb_head = 0; | ||
| 190 | } | ||
| 191 | if (i == RO_DEC(cb_tail)) { | ||
| 192 | // left shift when next to tail | ||
| 193 | do { | ||
| 194 | cb_tail = RO_DEC(cb_tail); | ||
| 195 | if (keyboard_report->keys[RO_DEC(cb_tail)] != 0) { | ||
| 196 | break; | ||
| 197 | } | ||
| 198 | } while (cb_tail != cb_head); | ||
| 199 | } | ||
| 200 | break; | ||
| 201 | } | ||
| 202 | i = RO_INC(i); | ||
| 203 | } while (i != cb_tail); | ||
| 204 | } | ||
| 205 | #else | ||
| 206 | for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { | 114 | for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { |
| 207 | if (keyboard_report->keys[i] == code) { | 115 | if (keyboard_report->keys[i] == code) { |
| 208 | keyboard_report->keys[i] = 0; | 116 | keyboard_report->keys[i] = 0; |
| 209 | } | 117 | } |
| 210 | } | 118 | } |
| 211 | #endif | ||
| 212 | } | 119 | } |
| 213 | 120 | ||
| 214 | #ifdef NKRO_ENABLE | 121 | #ifdef NKRO_ENABLE |
