From f841035c09841668fe941619164de933386bb7a8 Mon Sep 17 00:00:00 2001 From: Hrvoje Cavrak Date: Thu, 5 Dec 2024 19:02:26 +0100 Subject: [PATCH] Refactoring some function names (#182) --- src/handlers.c | 4 ++-- src/include/main.h | 2 +- src/main.c | 2 +- src/mouse.c | 16 ++++++++-------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/handlers.c b/src/handlers.c index edfd91f..519534b 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -28,7 +28,7 @@ void output_toggle_hotkey_handler(device_t *state, hid_keyboard_report_t *report return; state->active_output ^= 1; - switch_output(state, state->active_output); + set_active_output(state, state->active_output); }; void _get_border_position(device_t *state, border_size_t *border) { @@ -368,7 +368,7 @@ void handle_heartbeat_msg(uart_packet_t *packet, device_t *state) { * ==================================================== */ /* Update output variable, set LED on/off and notify the other board so they are in sync. */ -void switch_output(device_t *state, uint8_t new_output) { +void set_active_output(device_t *state, uint8_t new_output) { state->active_output = new_output; restore_leds(state); send_value(new_output, OUTPUT_SELECT_MSG); diff --git a/src/include/main.h b/src/include/main.h index 9849709..0c8699f 100644 --- a/src/include/main.h +++ b/src/include/main.h @@ -569,7 +569,7 @@ void handle_api_read_all_msg(uart_packet_t *, device_t *); void handle_toggle_gaming_msg(uart_packet_t *, device_t *); void handle_screensaver_msg(uart_packet_t *, device_t *); -void switch_output(device_t *, uint8_t); +void set_active_output(device_t *, uint8_t); /********* Global variables (don't judge) **********/ extern device_t global_state; diff --git a/src/main.c b/src/main.c index bac5eb5..83ec45c 100644 --- a/src/main.c +++ b/src/main.c @@ -47,7 +47,7 @@ int main(void) { initial_setup(device); // Initial state, A is the default output - switch_output(device, OUTPUT_A); + set_active_output(device, OUTPUT_A); while (true) { for (int i = 0; i < NUM_TASKS; i++) diff --git a/src/mouse.c b/src/mouse.c index 6f414d7..c2474a5 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -124,7 +124,7 @@ int16_t scale_y_coordinate(int screen_from, int screen_to, device_t *state) { return ((state->pointer_y - from->border.top) * MAX_SCREEN_COORD) / size_from; } -void switch_screen( +void switch_to_another_pc( device_t *state, output_t *output, int output_to, int direction) { uint8_t *mouse_park_pos = &state->config.output[state->active_output].mouse_park_pos; @@ -135,12 +135,12 @@ void switch_screen( mouse_report_t hidden_pointer = {.y = mouse_y, .x = MAX_SCREEN_COORD}; output_mouse_report(&hidden_pointer, state); - switch_output(state, output_to); + set_active_output(state, output_to); state->pointer_x = (direction == LEFT) ? MAX_SCREEN_COORD : MIN_SCREEN_COORD; state->pointer_y = scale_y_coordinate(output->number, 1 - output->number, state); } -void switch_desktop_macos(device_t *state, int direction) { +void switch_virtual_desktop_macos(device_t *state, int direction) { /* Fix for MACOS: Send relative mouse movement here, one or two pixels in the direction of movement, BEFORE absolute report sets X to 0 */ uint16_t move = (direction == LEFT) ? -MACOS_SWITCH_MOVE_X : MACOS_SWITCH_MOVE_X; @@ -151,10 +151,10 @@ void switch_desktop_macos(device_t *state, int direction) { output_mouse_report(&move_relative_one, state); } -void switch_desktop(device_t *state, output_t *output, int new_index, int direction) { +void switch_virtual_desktop(device_t *state, output_t *output, int new_index, int direction) { switch (output->os) { case MACOS: - switch_desktop_macos(state, direction); + switch_virtual_desktop_macos(state, direction); break; case WINDOWS: @@ -206,16 +206,16 @@ void check_screen_switch(const mouse_values_t *values, device_t *state) { if (state->mouse_buttons) return; - switch_screen(state, output, 1 - state->active_output, direction); + switch_to_another_pc(state, output, 1 - state->active_output, direction); } /* If here, this output has multiple desktops and we are not on the main one */ else - switch_desktop(state, output, output->screen_index - 1, direction); + switch_virtual_desktop(state, output, output->screen_index - 1, direction); } /* We want to jump away from the other computer, only possible if there is another screen to jump to */ else if (output->screen_index < output->screen_count) - switch_desktop(state, output, output->screen_index + 1, direction); + switch_virtual_desktop(state, output, output->screen_index + 1, direction); } void extract_report_values(uint8_t *raw_report, device_t *state, mouse_values_t *values, hid_interface_t *iface) {