We use some essential cookies to make our website work.

We use optional cookies, as detailed in our cookie policy, to remember your settings and understand how you use our website.

11 posts • Page 1 of 1
RaspStraw
Posts: 5
Joined: Sat Oct 25, 2025 7:57 pm

Forward keystrokes from one computer to another

Sat Oct 25, 2025 8:02 pm

Hi everyone! I’d like to build a simple device that can forward keyboard and trackpad input from one computer to another.

Specifically, I want to connect a MacBook to this device, and then connect the device to a Mac mini, both over USB-C.
That way, I could use a MacBook’s built-in keyboard and trackpad to control the Mac mini, instead of buying an external keyboard and mouse.

I understand that handling full trackpad gestures might be complicated, but even just basic mouse movement and clicks would be amazing.

Could you please point me in the right direction on whether this is possible and how I should get started?
I’m completely new to raspberry pies, so feel free to over-explain things 😅

Thank you! 🙏

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6874
Joined: Mon Sep 29, 2014 1:07 pm

Re: Forward keystrokes from one computer to another

Sat Oct 25, 2025 8:18 pm

If the two Macs are on the same network, you could skip the intermediate devices and just use Barrier: https://barrier.macupdate.com/
Install the server on the MacBook and the client on the Mac Mini. Configure the server so that the Mac Mini's display is to one side of your MacBook, then moving the MacBook's mouse off that side will cause it to appear on the Mac Mini's display, and keystrokes are also forwarded.

RaspStraw
Posts: 5
Joined: Sat Oct 25, 2025 7:57 pm

Re: Forward keystrokes from one computer to another

Sat Oct 25, 2025 8:27 pm

Thank you for your thoughts. I am familiar with software solutions, but for this specific case, I need very strong separation between the 2 devices, and one of the devices has no internet access.

wildfire
Posts: 1798
Joined: Sat Sep 03, 2016 10:39 am

Re: Forward keystrokes from one computer to another

Sat Oct 25, 2025 8:45 pm

In what way is this Pi related?
E8 85 A2 40 C9 40 81 94 40 81 95 40 89 84 89 96 A3
Still NF Shirls

RaspStraw
Posts: 5
Joined: Sat Oct 25, 2025 7:57 pm

Re: Forward keystrokes from one computer to another

Sat Oct 25, 2025 8:51 pm

Because the Raspberry Pi is the device that sits between the 2 computers.

wildfire
Posts: 1798
Joined: Sat Sep 03, 2016 10:39 am

Re: Forward keystrokes from one computer to another

Sat Oct 25, 2025 8:57 pm

RaspStraw wrote:
Sat Oct 25, 2025 8:51 pm
Because the Raspberry Pi is the device that sits between the 2 computers.
IMO, the additional hardware required (even assuming you have the Pi already) would probably exceed to cost of a cheap mouse/keyboard.

However, it would perhaps help others if you let us know which Pi you're planning on using.
E8 85 A2 40 C9 40 81 94 40 81 95 40 89 84 89 96 A3
Still NF Shirls

thagrol
Posts: 14786
Joined: Fri Jan 13, 2012 4:41 pm

Re: Forward keystrokes from one computer to another

Sat Oct 25, 2025 10:02 pm

Not going to be as straight forward as you might think. And I doubt a PI will add much other than cost, complexity, and unreliability.

Some problems you'll need to overcome:
  • USB is one master, many slaves
  • Two USB masters cannot communicate directly with each other. Nor can two slaves.
  • No PI can act as a USB device/slave to more than one host/master at a time.
  • No Pi has more than one port that can act as a USB device
  • Several people have reported problems with device/gadget use of the PI5 and a Mac's USB C ports.
  • Macs are USB masters/hosts. Even if they can negotiate acting as a slave/device no PI model has the support to do that.
So, what you'll need is software on the Macbook to grab keyboard and mouse events, pass them over USB to a Pi, which passes them to another Pi, which passes them to the Mac mini. And possible some functionality in the other direction to allow for stuff like keyboard LEDs.

If your Macbook has a USB keyboard and mouse* do the capture at the USB HID report level as that'll simplify processing (if you copy the HID report descriptors to the Pi on the other end that is). If it isn't USB you'll need to capture at a higher level and post process into suitable HID reports.

That's going to be a lot of work.

If it were me, and if the Macbook has thunderbolt (I know Mac minis do) I'd use that. One cable gets you an IP network between the two machines that you can use VNC, or barrier, or similar on. If you don't want one of the Macs to have internet access make sure the one with internet access is configured not to route traffic between networks.

Minimum hardware to do this with Pi? Two Picos, three bits of jump wire (for a UART connection between them), two USB C to micro B cables. Or two Pi Zero and two SD cards instead of Picos.

It might be possible to use a single Pico and the PIO USB library** but that's likely more complex and going to need more than micro python running on the Pico.


*: Internally not plugged in to it.
**: I know it exists but have never used it.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

aBUGSworstnightmare
Posts: 13432
Joined: Tue Jun 30, 2015 1:35 pm

Re: Forward keystrokes from one computer to another

Sun Oct 26, 2025 6:07 am

RaspStraw wrote:
Sat Oct 25, 2025 8:27 pm
Thank you for your thoughts. I am familiar with software solutions, but for this specific case, I need very strong separation between the 2 devices, and one of the devices has no internet access.
and how will all this be connected together?
why can't you simply use the build-in screen sharing?

cleverca22
Posts: 9593
Joined: Sat Aug 18, 2012 2:33 pm

Re: Forward keystrokes from one computer to another

Sun Oct 26, 2025 6:51 am

RaspStraw wrote:
Sat Oct 25, 2025 8:27 pm
Thank you for your thoughts. I am familiar with software solutions, but for this specific case, I need very strong separation between the 2 devices, and one of the devices has no internet access.
https://github.com/cleverca22/barrier-gadget/

this runs on a pi-zero-w (original or 2), and connects to a barrier server over wifi
it then emulates a keyboard/mouse over usb and connects to the client machine

RaspStraw
Posts: 5
Joined: Sat Oct 25, 2025 7:57 pm

Re: Forward keystrokes from one computer to another

Mon Oct 27, 2025 1:20 pm

cleverca22 wrote:
Sun Oct 26, 2025 6:51 am
RaspStraw wrote:
Sat Oct 25, 2025 8:27 pm
Thank you for your thoughts. I am familiar with software solutions, but for this specific case, I need very strong separation between the 2 devices, and one of the devices has no internet access.
https://github.com/cleverca22/barrier-gadget/

this runs on a pi-zero-w (original or 2), and connects to a barrier server over wifi
it then emulates a keyboard/mouse over usb and connects to the client machine
Thanks for the pointer, I will look into it, though I was hoping for a solution without any network involved.

RaspStraw
Posts: 5
Joined: Sat Oct 25, 2025 7:57 pm

Re: Forward keystrokes from one computer to another

Mon Oct 27, 2025 1:21 pm

thagrol wrote:
Sat Oct 25, 2025 10:02 pm
Not going to be as straight forward as you might think. And I doubt a PI will add much other than cost, complexity, and unreliability.

Some problems you'll need to overcome:
  • USB is one master, many slaves
  • Two USB masters cannot communicate directly with each other. Nor can two slaves.
  • No PI can act as a USB device/slave to more than one host/master at a time.
  • No Pi has more than one port that can act as a USB device
  • Several people have reported problems with device/gadget use of the PI5 and a Mac's USB C ports.
  • Macs are USB masters/hosts. Even if they can negotiate acting as a slave/device no PI model has the support to do that.
So, what you'll need is software on the Macbook to grab keyboard and mouse events, pass them over USB to a Pi, which passes them to another Pi, which passes them to the Mac mini. And possible some functionality in the other direction to allow for stuff like keyboard LEDs.

If your Macbook has a USB keyboard and mouse* do the capture at the USB HID report level as that'll simplify processing (if you copy the HID report descriptors to the Pi on the other end that is). If it isn't USB you'll need to capture at a higher level and post process into suitable HID reports.

That's going to be a lot of work.

If it were me, and if the Macbook has thunderbolt (I know Mac minis do) I'd use that. One cable gets you an IP network between the two machines that you can use VNC, or barrier, or similar on. If you don't want one of the Macs to have internet access make sure the one with internet access is configured not to route traffic between networks.

Minimum hardware to do this with Pi? Two Picos, three bits of jump wire (for a UART connection between them), two USB C to micro B cables. Or two Pi Zero and two SD cards instead of Picos.

It might be possible to use a single Pico and the PIO USB library** but that's likely more complex and going to need more than micro python running on the Pico.


*: Internally not plugged in to it.
**: I know it exists but have never used it.
Thank you very much for all this info, that's very useful. I will think about it carefully.

11 posts • Page 1 of 1

Return to "Interfacing (DSI, CSI, I2C, etc.)"

AltStyle によって変換されたページ (->オリジナル) /