Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions src/mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,27 @@ void switch_to_another_pc(
}

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 */
/*
* Fix for MACOS: Before sending new absolute report setting X to 0:
* 1. Move the cursor to the edge of the screen directly in the middle to handle screens
* of different heights
* 2. Send relative mouse movement one or two pixels in the direction of movement to get
* the cursor onto the next screen
*/
mouse_report_t edge_position = {
.x = (direction == LEFT) ? MIN_SCREEN_COORD : MAX_SCREEN_COORD,
.y = MAX_SCREEN_COORD / 2,
.mode = ABSOLUTE,
.buttons = state->mouse_buttons,
};

uint16_t move = (direction == LEFT) ? -MACOS_SWITCH_MOVE_X : MACOS_SWITCH_MOVE_X;
mouse_report_t move_relative_one = {.x = move, .mode = RELATIVE};
mouse_report_t move_relative_one = {
.x = move,
.mode = RELATIVE,
};

output_mouse_report(&edge_position, state);

/* Once doesn't seem reliable enough, do it a few times */
for (int i = 0; i < MACOS_SWITCH_MOVE_COUNT; i++)
Expand Down