diff options
| author | tmk <nobody@nowhere> | 2013-07-28 17:34:41 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2013-07-28 17:34:41 +0900 |
| commit | daa4a4235fd4a88b3b6f64e4a2cf590f28f4b65b (patch) | |
| tree | 91d6c2de3f98bf11e85868c6cd4802f05a55e60e /common/host.c | |
| parent | c7d309e34bf5d05f245811389bea495d814e2111 (diff) | |
| download | qmk_firmware-daa4a4235fd4a88b3b6f64e4a2cf590f28f4b65b.tar.gz qmk_firmware-daa4a4235fd4a88b3b6f64e4a2cf590f28f4b65b.zip | |
Add NKRO support for LUFA
Diffstat (limited to 'common/host.c')
| -rw-r--r-- | common/host.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/common/host.c b/common/host.c index 2c2279aa4..569451652 100644 --- a/common/host.c +++ b/common/host.c | |||
| @@ -37,8 +37,10 @@ static uint16_t last_consumer_report = 0; | |||
| 37 | 37 | ||
| 38 | static inline void add_key_byte(uint8_t code); | 38 | static inline void add_key_byte(uint8_t code); |
| 39 | static inline void del_key_byte(uint8_t code); | 39 | static inline void del_key_byte(uint8_t code); |
| 40 | #ifdef NKRO_ENABLE | ||
| 40 | static inline void add_key_bit(uint8_t code); | 41 | static inline void add_key_bit(uint8_t code); |
| 41 | static inline void del_key_bit(uint8_t code); | 42 | static inline void del_key_bit(uint8_t code); |
| 43 | #endif | ||
| 42 | 44 | ||
| 43 | 45 | ||
| 44 | void host_set_driver(host_driver_t *d) | 46 | void host_set_driver(host_driver_t *d) |
| @@ -63,11 +65,11 @@ void host_keyboard_send(report_keyboard_t *report) | |||
| 63 | (*driver->send_keyboard)(report); | 65 | (*driver->send_keyboard)(report); |
| 64 | 66 | ||
| 65 | if (debug_keyboard) { | 67 | if (debug_keyboard) { |
| 66 | dprint("keys: "); | 68 | dprint("keyboard_report: "); |
| 67 | for (int i = 0; i < REPORT_KEYS; i++) { | 69 | for (uint8_t i = 0; i < REPORT_SIZE; i++) { |
| 68 | dprintf("%02X ", keyboard_report->keys[i]); | 70 | dprintf("%02X ", keyboard_report->raw[i]); |
| 69 | } | 71 | } |
| 70 | dprintf(" mods: %02X\n", keyboard_report->mods); | 72 | dprint("\n"); |
| 71 | } | 73 | } |
| 72 | } | 74 | } |
| 73 | 75 | ||
| @@ -122,8 +124,9 @@ void host_del_key(uint8_t key) | |||
| 122 | 124 | ||
| 123 | void host_clear_keys(void) | 125 | void host_clear_keys(void) |
| 124 | { | 126 | { |
| 125 | for (int8_t i = 0; i < REPORT_KEYS; i++) { | 127 | // not clea mods |
| 126 | keyboard_report->keys[i] = 0; | 128 | for (int8_t i = 1; i < REPORT_SIZE; i++) { |
| 129 | keyboard_report->raw[i] = 0; | ||
| 127 | } | 130 | } |
| 128 | } | 131 | } |
| 129 | 132 | ||
| @@ -155,8 +158,8 @@ void host_clear_mods(void) | |||
| 155 | uint8_t host_has_anykey(void) | 158 | uint8_t host_has_anykey(void) |
| 156 | { | 159 | { |
| 157 | uint8_t cnt = 0; | 160 | uint8_t cnt = 0; |
| 158 | for (int i = 0; i < REPORT_KEYS; i++) { | 161 | for (uint8_t i = 1; i < REPORT_SIZE; i++) { |
| 159 | if (keyboard_report->keys[i]) | 162 | if (keyboard_report->raw[i]) |
| 160 | cnt++; | 163 | cnt++; |
| 161 | } | 164 | } |
| 162 | return cnt; | 165 | return cnt; |
| @@ -172,9 +175,9 @@ uint8_t host_get_first_key(void) | |||
| 172 | #ifdef NKRO_ENABLE | 175 | #ifdef NKRO_ENABLE |
| 173 | if (keyboard_nkro) { | 176 | if (keyboard_nkro) { |
| 174 | uint8_t i = 0; | 177 | uint8_t i = 0; |
| 175 | for (; i < REPORT_KEYS && !keyboard_report->keys[i]; i++) | 178 | for (; i < REPORT_BITS && !keyboard_report->nkro.bits[i]; i++) |
| 176 | ; | 179 | ; |
| 177 | return i<<3 | biton(keyboard_report->keys[i]); | 180 | return i<<3 | biton(keyboard_report->nkro.bits[i]); |
| 178 | } | 181 | } |
| 179 | #endif | 182 | #endif |
| 180 | return keyboard_report->keys[0]; | 183 | return keyboard_report->keys[0]; |
| @@ -222,18 +225,18 @@ static inline void add_key_byte(uint8_t code) | |||
| 222 | 225 | ||
| 223 | static inline void del_key_byte(uint8_t code) | 226 | static inline void del_key_byte(uint8_t code) |
| 224 | { | 227 | { |
| 225 | int i = 0; | 228 | for (uint8_t i = 0; i < REPORT_KEYS; i++) { |
| 226 | for (; i < REPORT_KEYS; i++) { | ||
| 227 | if (keyboard_report->keys[i] == code) { | 229 | if (keyboard_report->keys[i] == code) { |
| 228 | keyboard_report->keys[i] = 0; | 230 | keyboard_report->keys[i] = 0; |
| 229 | } | 231 | } |
| 230 | } | 232 | } |
| 231 | } | 233 | } |
| 232 | 234 | ||
| 235 | #ifdef NKRO_ENABLE | ||
| 233 | static inline void add_key_bit(uint8_t code) | 236 | static inline void add_key_bit(uint8_t code) |
| 234 | { | 237 | { |
| 235 | if ((code>>3) < REPORT_KEYS) { | 238 | if ((code>>3) < REPORT_BITS) { |
| 236 | keyboard_report->keys[code>>3] |= 1<<(code&7); | 239 | keyboard_report->nkro.bits[code>>3] |= 1<<(code&7); |
| 237 | } else { | 240 | } else { |
| 238 | dprintf("add_key_bit: can't add: %02X\n", code); | 241 | dprintf("add_key_bit: can't add: %02X\n", code); |
| 239 | } | 242 | } |
| @@ -241,9 +244,10 @@ static inline void add_key_bit(uint8_t code) | |||
| 241 | 244 | ||
| 242 | static inline void del_key_bit(uint8_t code) | 245 | static inline void del_key_bit(uint8_t code) |
| 243 | { | 246 | { |
| 244 | if ((code>>3) < REPORT_KEYS) { | 247 | if ((code>>3) < REPORT_BITS) { |
| 245 | keyboard_report->keys[code>>3] &= ~(1<<(code&7)); | 248 | keyboard_report->nkro.bits[code>>3] &= ~(1<<(code&7)); |
| 246 | } else { | 249 | } else { |
| 247 | dprintf("del_key_bit: can't del: %02X\n", code); | 250 | dprintf("del_key_bit: can't del: %02X\n", code); |
| 248 | } | 251 | } |
| 249 | } | 252 | } |
| 253 | #endif | ||
