diff --git a/docs/README.md b/docs/README.md index 034ae45..d551d39 100644 --- a/docs/README.md +++ b/docs/README.md @@ -6,6 +6,7 @@ - `RIGHT ALT + RIGHT SHIFT + L` locks both screens - `RIGHT ALT + RIGHT SHIFT + S` suspends both PCs - `RIGHT ALT + RIGHT SHIFT + D` enables debug mode\* +- `RIGHT ALT + RIGHT SHIFT + R` request to reboot active board \*the output will be shown on the `UART1 TX` pin. diff --git a/src/actions.c b/src/actions.c index 0b30c67..a8aae74 100644 --- a/src/actions.c +++ b/src/actions.c @@ -33,6 +33,14 @@ void lock_screen(void) { send_lock_screen_report(NULL, NULL); } +void request_reboot() { + if (global_state.active_output == BOARD_ROLE) { + global_state.reboot_requested = true; + } else { + send_value(1, REQUEST_REBOOT_MSG); + } +} + void suspend_pc(void) { send_value(1, SUSPEND_PC_MSG); send_suspend_pc_report(NULL, NULL); diff --git a/src/handlers.c b/src/handlers.c index e9c9462..250d896 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -89,3 +89,9 @@ void handle_uart_enable_debug_msg(uart_packet_t *packet, device_t *state) { (void)state; _enable_debug(); } + +void handle_uart_request_reboot_msg(uart_packet_t *packet, device_t *state) { + (void)packet; + (void)state; + request_reboot(); +} diff --git a/src/hotkeys.h b/src/hotkeys.h index c9199e8..510f009 100644 --- a/src/hotkeys.h +++ b/src/hotkeys.h @@ -39,4 +39,9 @@ hotkey_combo_t hotkeys[] = { .key_count = 1, .pass_to_os = false, .action_handler = &enable_debug}, + {.modifier = KEYBOARD_MODIFIER_RIGHTALT | KEYBOARD_MODIFIER_RIGHTSHIFT, + .keys = {HID_KEY_R}, + .key_count = 1, + .pass_to_os = false, + .action_handler = &request_reboot}, }; diff --git a/src/main.h b/src/main.h index 5c36145..84cb78f 100644 --- a/src/main.h +++ b/src/main.h @@ -87,6 +87,7 @@ enum packet_type_e { LOCK_SCREEN_MSG = 16, SUSPEND_PC_MSG = 17, ENABLE_DEBUG_MSG = 18, + REQUEST_REBOOT_MSG = 19, }; typedef enum { IDLE, READING_PACKET, PROCESSING_PACKET } uart_state_t; @@ -190,11 +191,12 @@ void setup_tuh(void); void _enable_debug(void); void enable_debug(void); void lock_screen(void); -void suspend_pc(void); +void request_reboot(void); void screensaver_task(device_t *state); -void send_suspend_pc_report(uart_packet_t *packet, device_t *state); void send_lock_screen_report(uart_packet_t *packet, device_t *state); +void send_suspend_pc_report(uart_packet_t *packet, device_t *state); void set_onboard_led(device_t *state); +void suspend_pc(void); void switch_output_a(device_t *state); void toggle_output(void); // handlers.c @@ -204,9 +206,10 @@ void handle_mouse(uint8_t instance, uint8_t report_id, uint8_t protocol, uint8_t const *report, uint8_t len); void handle_consumer(uint8_t instance, uint8_t report_id, uint8_t protocol, uint8_t const *report, uint8_t len); -void handle_uart_generic_msg(uart_packet_t *packet, device_t *state); void handle_uart_enable_debug_msg(uart_packet_t *packet, device_t *state); +void handle_uart_generic_msg(uart_packet_t *packet, device_t *state); void handle_uart_output_select_msg(uart_packet_t *packet, device_t *state); +void handle_uart_request_reboot_msg(uart_packet_t *packet, device_t *state); // keyboard.c uint8_t get_byte_offset(uint8_t key); uint8_t get_pos_in_byte(uint8_t key); diff --git a/src/uart.c b/src/uart.c index e1a8345..0c68c03 100644 --- a/src/uart.c +++ b/src/uart.c @@ -58,6 +58,7 @@ const uart_handler_t uart_handler[] = { {.type = LOCK_SCREEN_MSG, .handler = send_lock_screen_report}, {.type = SUSPEND_PC_MSG, .handler = send_suspend_pc_report}, {.type = ENABLE_DEBUG_MSG, .handler = handle_uart_enable_debug_msg}, + {.type = REQUEST_REBOOT_MSG, .handler = handle_uart_request_reboot_msg}, // {.type = FIRMWARE_UPGRADE_MSG, .handler = handle_fw_upgrade_msg}, // {.type = MOUSE_ZOOM_MSG, .handler = handle_mouse_zoom_msg}, // {.type = KBD_SET_REPORT_MSG, .handler = handle_set_report_msg},