[devember2022] Using laptop as keyboard through USB-C

Here’s my devember idea:

I have a laptop and a PC. Both are running Windows 10. The PC has a motherboard with a USB 3.2 Gen2 Type C port.

I want to use the new features of Windows 10 and USB Type-C (Windows support for USB Type-C connectors - Windows drivers | Microsoft Learn) to make a driver (?) so that my PC sees my laptop as a keyboard device.

The PC would be the “Host”, the Laptop the “Function”.

I have zero idea on how to approach this - I don’t even know which programming language I need. I only have experience in Matlab, and some python, js, C# and java (in diminishing order).

Any and all help is welcome - this might take me to devember2023, but right now I’m pretty determined.

2 Likes

Interesting project. I’m trying to do something similar to use a stream deck plus raspberry pi to send keyboard shortcuts to my KVM and pc.

I started with the usb otg modules in key mime pi

You can extract them from the git. It’s all python code.

Once you have the usb otg driver enabled and the “keyboard” modules loaded you can build the rest of your feature set.

I’ll post a thread on my project when I get some time to work on it later in the month

Good luck with your project.

2 Likes

Very interesting.

I’ll have to look into these so called OTG modules.

Are these serving as a virtual driver of sorts?

Very cool project!

This is totally doable and not at all impossible. The thing you want to research is “USB-C gadgets”.

Check out Rubber Ducky, PWN Pi, And loads of other Hak5 copy cats for examples on this.

This is completely a thing but I’ve never seen anyone implement it the way you’re proposing which would be a very cool and useful application of the tech!

In the past few days I was reading about USB protocols and figuring out the difference between USB 3.1 Gen 1 Type-A and USB 3.2 Gen 2.

I could only conclude that USB Implementers Forum is insane…

The problem is my laptop doesn’t have a USB-C port.

But it does have a USB 3.0 Type-A port (AKA USB 3.1 Gen 1 AKA USB 3.2 Gen 1 - see why they’re insane? (source)

To make matters more complicated, the USB OTG - or is it Dual-Role-Device (DRD) ??? - which allows devices to act as Host or Peripheral, apparently needs a Type-C connector to work. Although I’m not sure about this, but I’m not alone: see here.

So in my moment of weakness, I went on to try a different solution: using windows Ad-Hoc WiFi Network, and using Mouse without Borders. I tried a number of programs until I found out that Microsoft decided to remove this feature in favour of WiFi Direct.

Wi-Fi Direct is a Wi-Fi standard allowing Wi-Fi Direct enabled devices to easily connect to each other without having to go through an access point, or even need a router. You can think of Wi-Fi Direct as a much more robust Ad-Hoc connection that is as fast as a Wi-Fi connection; like a hybrid of Ad-Hoc and Wi-Fi.

Wi-Fi Direct is useful for everything from Internet browsing to file transfers to communicating with one or more devices simultaneously at typical Wi-Fi speeds. This is because Wi-Fi Direct allows Wi-Fi devices to connect to each other and form groups, usually one-to-one, but also one-to-many.

So what does this mean for you? As of Windows 10, Microsoft announced that Wi-Fi card manufacturers like Realtek, Intel, and Dell should no longer support the “hostednetwork” protocol that was used in previous versions of Windows to create Wi-Fi hotspots. Instead, newer Wi-Fi cards and firmware updates being rolled out to current cards should begin using the new Wi-Fi Direct APIs for creating wireless access points. Since Connectify Hotspot is the only third-party virtual router software that can leverage the new Wi-Fi Direct protocol, our hotspot software solution is your best bet for click-of-a-button Wi-Fi hotspots on Windows 10 and beyond.

From here.

Microsoft…
269686856_405009934653903_7954044252455030605_n

And I don’t wanna pay 12€ for this software.

So I went back to the USB idea and went to the basics (here and here).

And now I’m trying to figure out if I can send and receive the raw signals going through USB. There has to be a way…

Having the same issue where i need to send keyboard inputs to a connected device on my usb c port. anyone figure out a solution?

There is no really pure way of doing this over USB. USB works on a host and client relationship, where the host will poll client devices for updates. If two host devices are connected together, a conflict will occur and one or both devices will shut the USB port down.
The previous implementations that I have come across have been done over IP.
Microsoft’s PowerToys tool Mouse Without Borders is a good example.

If you want to try to write a program to do remote mouse and keyboard I recommend modifying an existing VNC implementation. VNC code bases will already have all the API calls and HID handling functions created. All that would be needed is for the functions to be lifted out and additional code to glue everything together.

1 Like