diff options
| author | Ryan <fauxpark@gmail.com> | 2022-09-10 06:36:39 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-09 21:36:39 +0100 |
| commit | f20883fef1bc9980d86682a05f763f12679b8c45 (patch) | |
| tree | 1214de04c58195052dc826c208ce0aa15b93b432 /drivers/bluetooth | |
| parent | a18aab4c3c025fdc3d315a18a97a2215361ebafc (diff) | |
RN42 driver: small cleanups (#18310)
* RN42 driver: small cleanups
* Include header
* Fix mouse report per RN42 UG
* Spacing for consistency
Diffstat (limited to 'drivers/bluetooth')
| -rw-r--r-- | drivers/bluetooth/rn42.c | 32 | ||||
| -rw-r--r-- | drivers/bluetooth/rn42.h | 4 |
2 files changed, 21 insertions, 15 deletions
diff --git a/drivers/bluetooth/rn42.c b/drivers/bluetooth/rn42.c index 5d497cda20..0eb1733723 100644 --- a/drivers/bluetooth/rn42.c +++ b/drivers/bluetooth/rn42.c | |||
| @@ -14,6 +14,8 @@ | |||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #include "rn42.h" | ||
| 18 | |||
| 17 | #include "report.h" | 19 | #include "report.h" |
| 18 | #include "uart.h" | 20 | #include "uart.h" |
| 19 | 21 | ||
| @@ -69,33 +71,35 @@ void rn42_send_keyboard(report_keyboard_t *report) { | |||
| 69 | uart_write(0xFD); | 71 | uart_write(0xFD); |
| 70 | uart_write(0x09); | 72 | uart_write(0x09); |
| 71 | uart_write(0x01); | 73 | uart_write(0x01); |
| 74 | |||
| 72 | uart_write(report->mods); | 75 | uart_write(report->mods); |
| 73 | uart_write(0x00); | 76 | uart_write(0x00); |
| 74 | for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { | 77 | uart_write(report->keys[0]); |
| 75 | uart_write(report->keys[i]); | 78 | uart_write(report->keys[1]); |
| 76 | } | 79 | uart_write(report->keys[2]); |
| 80 | uart_write(report->keys[3]); | ||
| 81 | uart_write(report->keys[4]); | ||
| 82 | uart_write(report->keys[5]); | ||
| 77 | } | 83 | } |
| 78 | 84 | ||
| 79 | void rn42_send_mouse(report_mouse_t *report) { | 85 | void rn42_send_mouse(report_mouse_t *report) { |
| 80 | uart_write(0xFD); | 86 | uart_write(0xFD); |
| 81 | uart_write(0x00); | 87 | uart_write(0x05); |
| 82 | uart_write(0x03); | 88 | uart_write(0x02); |
| 89 | |||
| 83 | uart_write(report->buttons); | 90 | uart_write(report->buttons); |
| 84 | uart_write(report->x); | 91 | uart_write(report->x); |
| 85 | uart_write(report->y); | 92 | uart_write(report->y); |
| 86 | uart_write(report->v); // should try sending the wheel v here | 93 | uart_write(report->v); |
| 87 | uart_write(report->h); // should try sending the wheel h here | ||
| 88 | uart_write(0x00); | ||
| 89 | } | 94 | } |
| 90 | 95 | ||
| 91 | void rn42_send_consumer(uint16_t data) { | 96 | void rn42_send_consumer(uint16_t usage) { |
| 92 | static uint16_t last_data = 0; | 97 | uint16_t bitmap = rn42_consumer_usage_to_bitmap(usage); |
| 93 | if (data == last_data) return; | 98 | |
| 94 | last_data = data; | ||
| 95 | uint16_t bitmap = rn42_consumer_usage_to_bitmap(data); | ||
| 96 | uart_write(0xFD); | 99 | uart_write(0xFD); |
| 97 | uart_write(0x03); | 100 | uart_write(0x03); |
| 98 | uart_write(0x03); | 101 | uart_write(0x03); |
| 102 | |||
| 99 | uart_write(bitmap & 0xFF); | 103 | uart_write(bitmap & 0xFF); |
| 100 | uart_write((bitmap >> 8) & 0xFF); | 104 | uart_write(bitmap >> 8); |
| 101 | } | 105 | } |
diff --git a/drivers/bluetooth/rn42.h b/drivers/bluetooth/rn42.h index 4747759111..89b716bfcd 100644 --- a/drivers/bluetooth/rn42.h +++ b/drivers/bluetooth/rn42.h | |||
| @@ -14,6 +14,8 @@ | |||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #include <stdint.h> | ||
| 18 | |||
| 17 | #include "report.h" | 19 | #include "report.h" |
| 18 | 20 | ||
| 19 | void rn42_init(void); | 21 | void rn42_init(void); |
| @@ -22,4 +24,4 @@ void rn42_send_keyboard(report_keyboard_t *report); | |||
| 22 | 24 | ||
| 23 | void rn42_send_mouse(report_mouse_t *report); | 25 | void rn42_send_mouse(report_mouse_t *report); |
| 24 | 26 | ||
| 25 | void rn42_send_consumer(uint16_t data); | 27 | void rn42_send_consumer(uint16_t usage); |
