Forward keystrokes from one computer to another
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! 🙏
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
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.
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.
Re: Forward keystrokes from one computer to another
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.
Re: Forward keystrokes from one computer to another
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
Still NF Shirls
Re: Forward keystrokes from one computer to another
Because the Raspberry Pi is the device that sits between the 2 computers.
Re: Forward keystrokes from one computer to another
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
Still NF Shirls
Re: Forward keystrokes from one computer to another
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:
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.
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.
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
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
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
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
Re: Forward keystrokes from one computer to another
Thanks for the pointer, I will look into it, though I was hoping for a solution without any network involved.cleverca22 wrote: ↑Sun Oct 26, 2025 6:51 amhttps://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
Re: Forward keystrokes from one computer to another
Thank you very much for all this info, that's very useful. I will think about it carefully.thagrol wrote: ↑Sat Oct 25, 2025 10:02 pmNot 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: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.
- 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.
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.
Return to "Interfacing (DSI, CSI, I2C, etc.)"
Jump to
- Community
- General discussion
- Announcements
- Other languages
- Deutsch
- Español
- Français
- Italiano
- Nederlands
- 日本語
- Polski
- Português
- Русский
- Türkçe
- User groups and events
- Raspberry Pi Official Magazine
- Using the Raspberry Pi
- Beginners
- Troubleshooting
- Advanced users
- Assistive technology and accessibility
- Education
- Picademy
- Teaching and learning resources
- Staffroom, classroom and projects
- Astro Pi
- Mathematica
- High Altitude Balloon
- Weather station
- Programming
- C/C++
- Java
- Python
- Scratch
- Other programming languages
- Windows 10 for IoT
- Wolfram Language
- Bare metal, Assembly language
- Graphics programming
- OpenGLES
- OpenVG
- OpenMAX
- General programming discussion
- Projects
- Networking and servers
- Automation, sensing and robotics
- Graphics, sound and multimedia
- Other projects
- Media centres
- Gaming
- AIY Projects
- Hardware and peripherals
- Camera board
- Compute Module
- Official Display
- HATs and other add-ons
- Device Tree
- Interfacing (DSI, CSI, I2C, etc.)
- Keyboard computers (400, 500, 500+)
- Raspberry Pi Pico
- General
- SDK
- MicroPython
- Other RP2040 boards
- Zephyr
- Rust
- AI Accelerator
- AI Camera - IMX500
- Hailo
- Software
- Raspberry Pi OS
- Raspberry Pi Connect
- Raspberry Pi Desktop for PC and Mac
- Beta testing
- Other
- Android
- Debian
- FreeBSD
- Gentoo
- Linux Kernel
- NetBSD
- openSUSE
- Plan 9
- Puppy
- Arch
- Pidora / Fedora
- RISCOS
- Ubuntu
- Ye Olde Pi Shoppe
- For sale
- Wanted
- Off topic
- Off topic discussion