From 50304921785da1e8d708b883259261424adc796b Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Sun, 19 Apr 2020 18:25:06 +0200 Subject: [PATCH] hog_mouse_demo/hog_keyboard_demo: handle set protocol mode = boot protocol mode --- CHANGELOG.md | 1 + example/hog_keyboard_demo.c | 13 ++++++++++++- example/hog_mouse_demo.c | 15 ++++++++++++--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 015b1c9e8..efca20342 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## Changes April 2020 ### Fixed +- hog_mouse_demo/hog_keyboard_demo: handle set protocol mode = boot protocol mode ### Added - GAP: gap_set_allow_role_switch allows to prevent role switch in outgoing classic ACL connections diff --git a/example/hog_keyboard_demo.c b/example/hog_keyboard_demo.c index 8f9000667..76eddc487 100644 --- a/example/hog_keyboard_demo.c +++ b/example/hog_keyboard_demo.c @@ -166,6 +166,7 @@ static btstack_packet_callback_registration_t hci_event_callback_registration; static btstack_packet_callback_registration_t sm_event_callback_registration; static uint8_t battery = 100; static hci_con_handle_t con_handle = HCI_CON_HANDLE_INVALID; +static uint8_t protocol_mode = 1; static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size); @@ -257,7 +258,16 @@ static int keycode_and_modifer_us_for_character(uint8_t character, uint8_t * key static void send_report(int modifier, int keycode){ uint8_t report[] = { /* 0xa1, */ modifier, 0, 0, keycode, 0, 0, 0, 0, 0}; - hids_device_send_input_report(con_handle, report, sizeof(report)); + switch (protocol_mode){ + case 0: + hids_device_send_boot_keyboard_input_report(con_handle, report, sizeof(report)); + break; + case 1: + hids_device_send_input_report(con_handle, report, sizeof(report)); + break; + default: + break; + } } // Demo Application @@ -426,6 +436,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack printf("Boot Keyboard Characteristic Subscribed %u\n", hids_subevent_boot_keyboard_input_report_enable_get_enable(packet)); break; case HIDS_SUBEVENT_PROTOCOL_MODE: + protocol_mode = hids_subevent_protocol_mode_get_protocol_mode(packet); printf("Protocol Mode: %s mode\n", hids_subevent_protocol_mode_get_protocol_mode(packet) ? "Report" : "Boot"); break; case HIDS_SUBEVENT_CAN_SEND_NOW: diff --git a/example/hog_mouse_demo.c b/example/hog_mouse_demo.c index aa99f5450..000607b1d 100644 --- a/example/hog_mouse_demo.c +++ b/example/hog_mouse_demo.c @@ -101,6 +101,7 @@ static btstack_packet_callback_registration_t hci_event_callback_registration; static btstack_packet_callback_registration_t sm_event_callback_registration; static uint8_t battery = 100; static hci_con_handle_t con_handle = HCI_CON_HANDLE_INVALID; +static uint8_t protocol_mode = 1; static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size); @@ -166,9 +167,16 @@ static void hog_mouse_setup(void){ // HID Report sending static void send_report(uint8_t buttons, int8_t dx, int8_t dy){ - // uint8_t report[] = { (uint8_t) dx, (uint8_t) dy, buttons}; - uint8_t report[] = { buttons, (uint8_t) dx, (uint8_t) dy}; - hids_device_send_input_report(con_handle, report, sizeof(report)); + uint8_t report[] = { buttons, (uint8_t) dx, (uint8_t) dy, 0}; + switch (protocol_mode){ + case 0: + hids_device_send_boot_mouse_input_report(con_handle, report, sizeof(report)); + case 1: + hids_device_send_input_report(con_handle, report, sizeof(report)); + break; + default: + break; + } printf("Mouse: %d/%d - buttons: %02x\n", dx, dy, buttons); } @@ -366,6 +374,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack printf("Boot Mouse Characteristic Subscribed %u\n", hids_subevent_boot_mouse_input_report_enable_get_enable(packet)); break; case HIDS_SUBEVENT_PROTOCOL_MODE: + protocol_mode = hids_subevent_protocol_mode_get_protocol_mode(packet); printf("Protocol Mode: %s mode\n", hids_subevent_protocol_mode_get_protocol_mode(packet) ? "Report" : "Boot"); break; case HIDS_SUBEVENT_CAN_SEND_NOW: