←back to thread

20 points WorldDev | 3 comments | | HN request time: 0.001s | source

I want to build a little device that connects two computers together via usb, and send keystrokes from one to the other.

(I would use it to use a laptop keyboard on a headless computers).

I am looking for an easy solution, it does not have to be the cheapest.

ChatGPT points me to Arduino, but as far as I can see, there's no arduino with 2 usb ports. It also points me to Raspery pi zero, but that's a computer, not a microcontroller, so not sure if it's suitable.

If anyone with experience can give me some pointers, it would be greatly appreciated!

Show context
jauntywundrkind ◴[] No.45706847[source]
I don't think you can tackle this purely from a hardware side. If you want to send input from the laptop to another system, there's no kind of USB profile available to collect input from a system.

You're going to need software on the laptop to gather the input. That seems necessary. You're not going to invent a purely hardware based solution here.

Given that, I'd abandon your starting requirement of needing two usb device ports. That doesn't seem to help you out here, doesn't actually buy you much.

I'd look at the field of existing software out there that can ship input between systems. Use ethernet, wifi, or BT for connectivity if possible (perhaps via usb-ethernet adapters which are very cheap!), and if absolutely required you can build a little rpi-zero with a usb-gadget to act like a virtual keyboard. https://github.com/input-leap/input-leap https://github.com/feschber/lan-mouse https://github.com/lkundrak/btkbdd

replies(1): >>45706936 #
1. WorldDev ◴[] No.45706936[source]
That's absolutely fair, and I am fine with writing software for both computers. However, I need this software to not go via the network at all.
replies(1): >>45707074 #
2. jauntywundrkind ◴[] No.45707074[source]
I'd still 100% recommend using ethernet, with two usb<->ethernet adapters on each end and a cable in-between to direct link the two. It's the most standard easiest to acquire way to link two computers, and it doesn't require any other network to work. Using more bespoke hardware is only going to make this more difficult. Using usb<->serial would also be acceptable I suppose, and require a little less configuration effort, but adapting software to use this is going to be much harder when the existing software is so IP oriented. Whatever the case, having off the shelf connectivity seems like such a win, and I continue to dis-recommend building anything yourself: this is/ought be mostly a software problem.

The one carve out I'd make: if you want to minimize the configuration at the target device, it ought be possible to make a rpi0 device that outputs a usb-gadget keyboard. Continue using one of these IP based software systems to send input to the rpi0, then usb-gadget it out to the target device.

The btkbdd project also might be up your alley: if the target system has bluetooth or can have a (very cheap!) usb<->bluetooth adapter added, making the laptop just send a bluetooth HID to the other device is probably one of the lowest configuration most standard paths available for this work.

replies(1): >>45707154 #
3. WorldDev ◴[] No.45707154[source]
Thanks for your thoughts. That all sound fair.

I am fine with having quite a bit of configuration on the target device (I am fine with configuration on both sides).

> it ought be possible to make a rpi0 device that outputs a usb-gadget keyboard

I like very much the idea of being able to make the host side (macBook) appear as a usb-gadget keyboard. That way I would just need to plug a single usb cable between the 2 computers. Could you give me a few pointers to get started, to do this on macOS?