Add mouse key support to bluetooth

This commit is contained in:
lokher 2022-09-07 15:52:17 +08:00
parent 652e6f3db8
commit fa207545a9
2 changed files with 47 additions and 30 deletions

View file

@ -114,7 +114,7 @@ bluetooth_transport_t bluetooth_transport = {
ckbt51_send_nkro, ckbt51_send_nkro,
ckbt51_send_consumer, ckbt51_send_consumer,
ckbt51_send_system, ckbt51_send_system,
NULL, ckbt51_send_mouse,
ckbt51_task ckbt51_task
}; };
@ -216,6 +216,22 @@ void ckbt51_send_system(uint16_t report) {
ckbt51_send_cmd(payload, i, true); ckbt51_send_cmd(payload, i, true);
} }
void ckbt51_send_mouse(uint8_t* report) {
uint8_t i = 0;
memset(payload, 0, PACKET_MAX_LEN);
payload[i++] = CKBT51_CMD_SEND_MOUSE; // Cmd type
payload[i++] = report[1]; // Button
payload[i++] = report[2]; // X
payload[i++] = (report[2] & 0x80) ? 0xff : 0x00; // ckbt51 use 16bit report, set high byte
payload[i++] = report[3]; // Y
payload[i++] = (report[3] & 0x80) ? 0xff : 0x00; // ckbt51 use 16bit report, set high byte
payload[i++] = report[4]; // V wheel
payload[i++] = report[5]; // H wheel
ckbt51_send_cmd(payload, i, false);
}
/* Send ack to connection event, bluetooth module will retry 2 times if no ack received */ /* Send ack to connection event, bluetooth module will retry 2 times if no ack received */
void ckbt51_send_conn_evt_ack(void) { void ckbt51_send_conn_evt_ack(void) {
uint8_t i = 0; uint8_t i = 0;

View file

@ -134,6 +134,7 @@ void ckbt51_send_keyboard(uint8_t* report);
void ckbt51_send_nkro(uint8_t* report); void ckbt51_send_nkro(uint8_t* report);
void ckbt51_send_consumer(uint16_t report); void ckbt51_send_consumer(uint16_t report);
void ckbt51_send_system(uint16_t report); void ckbt51_send_system(uint16_t report);
void ckbt51_send_mouse(uint8_t* report);
void ckbt51_become_discoverable(uint8_t host_idx, void* param); void ckbt51_become_discoverable(uint8_t host_idx, void* param);
void ckbt51_connect(uint8_t hostIndex, uint16_t timeout); void ckbt51_connect(uint8_t hostIndex, uint16_t timeout);