Refactoring some function names (#182)

This commit is contained in:
Hrvoje Cavrak 2024-12-05 19:02:26 +01:00 committed by 梁鸿
parent d78bcd4638
commit f841035c09
4 changed files with 12 additions and 12 deletions

View File

@ -28,7 +28,7 @@ void output_toggle_hotkey_handler(device_t *state, hid_keyboard_report_t *report
return; return;
state->active_output ^= 1; 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) { 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. */ /* 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; state->active_output = new_output;
restore_leds(state); restore_leds(state);
send_value(new_output, OUTPUT_SELECT_MSG); send_value(new_output, OUTPUT_SELECT_MSG);

View File

@ -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_toggle_gaming_msg(uart_packet_t *, device_t *);
void handle_screensaver_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) **********/ /********* Global variables (don't judge) **********/
extern device_t global_state; extern device_t global_state;

View File

@ -47,7 +47,7 @@ int main(void) {
initial_setup(device); initial_setup(device);
// Initial state, A is the default output // Initial state, A is the default output
switch_output(device, OUTPUT_A); set_active_output(device, OUTPUT_A);
while (true) { while (true) {
for (int i = 0; i < NUM_TASKS; i++) for (int i = 0; i < NUM_TASKS; i++)

View File

@ -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; 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) { 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; 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}; mouse_report_t hidden_pointer = {.y = mouse_y, .x = MAX_SCREEN_COORD};
output_mouse_report(&hidden_pointer, state); 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_x = (direction == LEFT) ? MAX_SCREEN_COORD : MIN_SCREEN_COORD;
state->pointer_y = scale_y_coordinate(output->number, 1 - output->number, state); 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 /* Fix for MACOS: Send relative mouse movement here, one or two pixels in the
direction of movement, BEFORE absolute report sets X to 0 */ direction of movement, BEFORE absolute report sets X to 0 */
uint16_t move = (direction == LEFT) ? -MACOS_SWITCH_MOVE_X : MACOS_SWITCH_MOVE_X; 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); 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) { switch (output->os) {
case MACOS: case MACOS:
switch_desktop_macos(state, direction); switch_virtual_desktop_macos(state, direction);
break; break;
case WINDOWS: case WINDOWS:
@ -206,16 +206,16 @@ void check_screen_switch(const mouse_values_t *values, device_t *state) {
if (state->mouse_buttons) if (state->mouse_buttons)
return; 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 */ /* If here, this output has multiple desktops and we are not on the main one */
else 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 */ /* 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) 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) { void extract_report_values(uint8_t *raw_report, device_t *state, mouse_values_t *values, hid_interface_t *iface) {