hrvach / deskhop

Fast Desktop Switching Device
GNU General Public License v3.0
5.96k stars 166 forks source link

Dual screen on macOS doesn't work #56

Open jalmeroth opened 4 months ago

jalmeroth commented 4 months ago

Hi,

I have two laptops and one external monitor. If I connect the monitor to the Linux-laptop, everything works as expected. I can move to all three screens: Linux-Laptop (DeskHop B) -> external monitor -> Mac (DeskHop A).

Unfortunately, if I connect the monitor to the macOS-laptop (using the same USB-C cable as with the other laptop), I can only control one screen on the Mac. It just doesn't allow me to use the second screen. Altough I can use the built-in trackpad to move between both screens. Either it's stuck to the primary screen, or if I use the trackpad to move the mouse to the secondary screen, it just allows this one. So it's: Mac (DeskHop B) or external monitor -> Linux (DeskHop A) but not Mac (DeskHop B) -> external monitor -> Linux (DeskHop A).

The Mac is running Sonoma 14.3.1. What information can I provide to narrow this problem?

hrvach commented 4 months ago

Hey, this issue has been reported - it seems like Mac maps the absolute report coordinates to the primary screen only, but if a relative motion is reported, it allows you to switch between screens. The workaround for this is under construction, albeit a bit slower than anticipated due to heavy workload on other fronts.

The idea is to define another, "relative" mouse and use that to switch between screens. The tricky thing is knowing where that screen is and how many are there, so I'm trying to figure out how to make it happen without config files and recompiling for every custom layout. Stay tuned.

Fallingonion commented 3 months ago

I would also be interested in a fix for this issue. My setup is a macbook with an extra monitor and a PC. Let;s call the laptop's built in monitor screen A, the extra Mac monitor screen B, and the PC monitor screen C. Reading from left to right the layout is A - B - C. Switching between the Mac and the PC works, but it depends where the mouse is on the Mac. If the cursor is on B, then I can move from B to C and back again no problem, but cannot move the mouse from B to A. However I can use the trackpad on the Mac to move the cursor to A. If I then use the external mouse and try to move from A to B, it jumps from A to C and back again. Hopefully that makes sense and I believe it matches the behaviour mentioned in the other thread. It's not fatal for me as I do most work on B and C, and it's easy enough to use the trackpad should I need to adjust anything... butr it would be great to be able to seamlessly move across all three :)

hrvach commented 3 months ago

Multiple mac screens workaround should be easier to implement than multiple windows screens, will try once I'm back from my work trip.

hrvach commented 3 months ago

Ok, the updated codebase is out. You need to rebuild and define OUTPUT_A_OS/OUTPUT_B_OS to specify where your MACOS is, and define the corresponding screen_count in defaults.c

Will be moved to config file and supported by a keyboard shortcut for easy config.

Leaving this open until confirmed working OK by several folks.

Fallingonion commented 3 months ago

That's great, thanks, I'll give it a try and report back. "You need to rebuild and define OUTPUT_A_OS/OUTPUT_B_OS to specify where your MACOS is, and define the corresponding screen_count in defaults.c" - sorry for the stupid question but can you clarify exactly what changes I would need to make for the A-B-C layout mentioned above? I'm very new to all this and would hate to make a mistake :)

hrvach commented 3 months ago

B needs to be your main mac screen, A needs to be the extended one (that's defined under MacOS I believe).

Then in defaults.c for output A you would define screen_count = 2 instead of 1 and in user_defaults.h OUTPUT_A_OS as MACOS.

It's still not super user-friendly, as it's a work in progress, but should get there. I'll also try writing better instructions.

jalmeroth commented 3 months ago

Ok, the updated codebase is out. You need to rebuild and define OUTPUT_A_OS/OUTPUT_B_OS to specify where your MACOS is, and define the corresponding screen_count in defaults.c

Will be moved to config file and supported by a keyboard shortcut for easy config.

Leaving this open until confirmed working OK by several folks.

My test setup: A1 (left): Linux B2 (center): external Monitor B1 (right): macOS Laptop

First notice: my keyboard, as reported in https://github.com/hrvach/deskhop/issues/47 does not work with this build.

Other then that, it kinda work… :tada: Sometimes, when you freshly connect deskhop and I try move from A1, I actually end up on B1 first (should be B2). Moving the mouse to the right edge of B1 seems to discover that the external monitor is on the left, not the right. After that, I can move the mouse from A1 to B2 to B1 as expected. :+1:

Is there anything I can provide? Maybe logs from WireShark or something?

Fallingonion commented 3 months ago

Hm, I'm getting the following error when trying to build it:

C:\deskhop\deskhop\src\mouse.c: In function 'switch_desktop': C:\deskhop\deskhop\src\mouse.c:139:13: error: a label can only be part of a statement and a declaration is not a statement 139 | mouse_report_t move_relative_one | ^~~~~~ mingw32-make.exe[2]: [CMakeFiles\board_A.dir\build.make:173: CMakeFiles/board_A.dir/src/mouse.c.obj] Error 1 mingw32-make.exe[1]: [CMakeFiles\Makefile2:1587: CMakeFiles/board_A.dir/all] Error 2 mingw32-make.exe: *** [Makefile:90: all] Error 2

I thought it might be because I'm building on Windows but I tried on an Ubuntu machine and got the same error. Am I doing something wrong?

hrvach commented 3 months ago

Hm, I'm getting the following error when trying to build it:

C:\deskhop\deskhop\src\mouse.c: In function 'switch_desktop': C:\deskhop\deskhop\src\mouse.c:139:13: error: a label can only be part of a statement and a declaration is not a statement 139 | mouse_report_t move_relative_one | ^~~~~~ mingw32-make.exe[2]: [CMakeFiles\board_A.dir\build.make:173: CMakeFiles/board_A.dir/src/mouse.c.obj] Error 1 mingw32-make.exe[1]: [CMakeFiles\Makefile2:1587: CMakeFiles/board_A.dir/all] Error 2 mingw32-make.exe: *** [Makefile:90: all] Error 2

I thought it might be because I'm building on Windows but I tried on an Ubuntu machine and got the same error. Am I doing something wrong?

@Fallingonion can you please pull the latest version and try again? Initializing a struct within a switch/case doesn't seem to make some compiler versions happy. :-)

hrvach commented 3 months ago

Ok, the updated codebase is out. You need to rebuild and define OUTPUT_A_OS/OUTPUT_B_OS to specify where your MACOS is, and define the corresponding screen_count in defaults.c Will be moved to config file and supported by a keyboard shortcut for easy config. Leaving this open until confirmed working OK by several folks.

My test setup: A1 (left): Linux B2 (center): external Monitor B1 (right): macOS Laptop

First notice: my keyboard, as reported in #47 does not work with this build.

Other then that, it kinda work… 🎉 Sometimes, when you freshly connect deskhop and I try move from A1, I actually end up on B1 first (should be B2). Moving the mouse to the right edge of B1 seems to discover that the external monitor is on the left, not the right. After that, I can move the mouse from A1 to B2 to B1 as expected. 👍

Is there anything I can provide? Maybe logs from WireShark or something?

@jalmeroth do these do anything for your keyboard?

test-fw-enforce-ports.zip

jalmeroth commented 3 months ago

Ok, the updated codebase is out. You need to rebuild and define OUTPUT_A_OS/OUTPUT_B_OS to specify where your MACOS is, and define the corresponding screen_count in defaults.c Will be moved to config file and supported by a keyboard shortcut for easy config. Leaving this open until confirmed working OK by several folks.

My test setup: A1 (left): Linux B2 (center): external Monitor B1 (right): macOS Laptop First notice: my keyboard, as reported in #47 does not work with this build. Other then that, it kinda work… 🎉 Sometimes, when you freshly connect deskhop and I try move from A1, I actually end up on B1 first (should be B2). Moving the mouse to the right edge of B1 seems to discover that the external monitor is on the left, not the right. After that, I can move the mouse from A1 to B2 to B1 as expected. 👍 Is there anything I can provide? Maybe logs from WireShark or something?

@jalmeroth do these do anything for your keyboard?

test-fw-enforce-ports.zip

@hrvach Yes, keyboard works with this.

But I can't move the mouse from A1 to B2 (from left [A] to right [B2]). I have to go to the left to land on B2 but can't reach B1 at all. :shrug:

hrvach commented 3 months ago

Ok, the updated codebase is out. You need to rebuild and define OUTPUT_A_OS/OUTPUT_B_OS to specify where your MACOS is, and define the corresponding screen_count in defaults.c

Will be moved to config file and supported by a keyboard shortcut for easy config.

Leaving this open until confirmed working OK by several folks.

My test setup: A1 (left): Linux B2 (center): external Monitor B1 (right): macOS Laptop

First notice: my keyboard, as reported in #47 does not work with this build.

Other then that, it kinda work… 🎉 Sometimes, when you freshly connect deskhop and I try move from A1, I actually end up on B1 first (should be B2). Moving the mouse to the right edge of B1 seems to discover that the external monitor is on the left, not the right. After that, I can move the mouse from A1 to B2 to B1 as expected. 👍

Is there anything I can provide? Maybe logs from WireShark or something?

@jalmeroth do these do anything for your keyboard?

test-fw-enforce-ports.zip

@hrvach Yes, keyboard works with this.

But I can't move the mouse from A1 to B2 (from left [A] to right [B2]). I have to go to the left to land on B2 but can't reach B1 at all. :shrug:

@jalmeroth Try parking cursor on mac output and pressing right shift + backspace + 2 and then right shift + backspace + 9. Any difference?

jalmeroth commented 3 months ago

@hrvach yes, now I can move to B1 as well. But still the jump is on the wrong edge

jalmeroth commented 3 months ago

@hrvach oh, and is moving windows on macOS (B1 <-> B2) supposed to work already?

Fallingonion commented 3 months ago

@Fallingonion can you please pull the latest version and try again? Initializing a struct within a switch/case doesn't seem to make some compiler versions happy. :-)

OK, so that now builds correctly and works perfectly for my setup! Amazing, thanks :)

Fallingonion commented 3 months ago

One side comment - on the Mac, I can't click+drag a window from one screen to the other using the mouse that goes through deskhop. The built-in trackpad works as you would expect. No idea if there's anything that can be done about that :)

hrvach commented 3 months ago

Hmmm, maybe ... I didn't think of the mouse buttons, the relative "helper" mouse should mimic the button presses from the absolute one, then it just might work

hrvach commented 3 months ago

@Fallingonion can you try this and let me know? test_drag_macos.zip

Fallingonion commented 3 months ago

Hi - didn't work unfortunately: I was unable to move the mouse to screen A (the laptop's built-in screen.) Movement between B and C (Mac extra screen and Windows) works as expected...

hrvach commented 3 months ago

Did you configure that output as two screens (Right Shift + Backspace + 2), MacOS (Right Shift + Backspace + 9) ?

Fallingonion commented 3 months ago

Did you configure that output as two screens (Right Shift + Backspace + 2), MacOS (Right Shift + Backspace + 9) ?

Oops, no, I hadn't. I have now done that and can move the mouse to all three screens, but I still can't click+drag between the two Mac screens. Thanks for all your help with this :)

hrvach commented 3 months ago

I think I know what else might be needed, will try looking into it...

crablab commented 2 months ago

but I still can't click+drag between the two Mac screens.

++ Same.

I also notice that sometimes when moving from the second MacOS screen to the primary, the cursor gets stuck on the second screen 🤔 It's almost like it got stuck in a second layer, as moving it to the far left edge doesn't move the cursor to the other machine, but back into the secondary MacOS screen.

hrvach commented 2 months ago

It probably needs some tweaking to reliably move the "helper" mouse for the MacOS workaround. For the click-and-drag, I have an idea how it might be done, but still not 100% it will work... will try though! :)

Ardakilic commented 2 months ago

Hello, I didn't want to create a new issue since I believe my issue is related, so I wanted to add a comment here. I have a single external monitor, and my mac's main display and external monitor are placed vertically (On top, my external monitor (through a converter since there's no usb-c direct connection), and on the bottom my mac's main integrated display). I am using Deskhop like a KVM switch, and at this stage the second pc is shut down, and on the single machine the mouse does not pass from the bottom main display to external on the same OS.

image

My mouse is Steelseries Rival 3, and I'm utilizing 2.4 ghz usb dongle. It works, just does not go to the top external display.

hrvach commented 2 months ago

Hello, I didn't want to create a new issue since I believe my issue is related, so I wanted to add a comment here. I have a single external monitor, and my mac's main display and external monitor are placed vertically (On top, my external monitor (through a converter since there's no usb-c direct connection), and on the bottom my mac's main integrated display). I am using Deskhop like a KVM switch, and at this stage the second pc is shut down, and on the single machine the mouse does not pass from the bottom main display to external on the same OS. My mouse is Steelseries Rival 3, and I'm utilizing 2.4 ghz usb dongle. It works, just does not go to the top external display.

You need to configure the output is a mac and there are two monitors there. Top/bottom still isn't implemented, so you need to configure displays as left-right.

akorobko commented 2 weeks ago

Thanks for the cool project. Just built it and it is great so far. I confirm as well that dragging files between Mac screens does not work :(

hrvach commented 2 weeks ago

That is a known issue, I have a few ideas how to potentially address it - probably will rely on relative mouse while dragging.

akorobko commented 2 weeks ago

Thanks. I tried to fix it myself yesterday. And while now I can drag something to another screen (I moved check for buttons being pressed lower; and passing buttons mask to the relative move report). But as soon as I move something to another screen, the button does not depress anymore and remains sticky. Will keep trying other things and maybe do PR if I figure this out.

hrvach commented 2 weeks ago

I thought I had it initially, but it turned out trickier than originally thought. Normally, you use absolute movement and relative only to switch screens, but shifting the pressed buttons between the two reports caused the dragged thing to be dropped. I wonder if I could define a relative helper mouse report without any buttons, that might be worth trying.