Raw HID keyboard forwarder to turn the Pi 400 into a USB keyboard

Overview

Raspberry Pi 400 as a USB HID Keyboard

Hook your Pi 400 up to your PC somehow, using a USB Type-C cable into the power port. Anker make good ones- I used a 3m white one for my tests.

Our USB-C to USB-A is great if you're using a USB-A port (but make sure it's a high power one): https://shop.pimoroni.com/products/usb-c-to-usb-a-cable-1m-black

This project started out life as a gist - https://gist.github.com/Gadgetoid/5a8ceb714de8e630059d30612503653f

Thank you to all the people who dropped by with kind words, suggestions and improvements.

Quickstart (Ish)

Add dtoverlay=dwc2 to /boot/config.txt

Reboot!

sudo modprobe libcomposite

wget https://github.com/Gadgetoid/pi400kb/blob/main/pi400kb?raw=true

chmod +x pi400kb

sudo ./pi400kb

YOUR PI 400 IS NOW A FREAKING KEYBOARD FOR YOUR PC WHAAAAT!?

Your keyboard input will be detached from your Pi while it's forwarded to your host computer.

Press Ctrl + Raspberry to exit and restore your keyboard on the Pi.

Building & Contributing

Building

sudo apt install libconfig-dev
git clone https://github.com/Gadgetoid/pi400kb
cd pi400kb
git submodule update --init
mkdir build
cd build
cmake ..
make
Comments
  • Error on run: usbg_init() no such file or directory.

    Error on run: usbg_init() no such file or directory.

    Happens on both mouse connected and disconnected.

    The full message I got:

    Found keyboard at: /dev/hidraw0
    Failed to open mouse device
    usbg_init()  No such file or directory: couldn't init gadget state
     
    Error on usbg init
    Error: USBG_ERROR_NOT_FOUND : Not found (file or directory removed)
    
    opened by ArsenicBismuth 2
  • fix compile warning

    fix compile warning

    This fixes the following compile warning:

    pi400kb/pi400.c: In function ‘modprobe_libcomposite’:                                                                                                                                         
    pi400kb/pi400.c:82:37: warning: passing argument 2 of ‘execv’ from incompatible pointer type [-Wincompatible-pointer-types]                                                                   
       82 |         execv("/usr/sbin/modprobe", argv);                                                                                                                                            
          |                                     ^~~~                                                                                                                                              
          |                                     |                                                                                                                                                 
          |                                     const char **                                                                                                                                     
    In file included from pi400kb/pi400.c:14:                                                                                                                                                     
    /usr/include/unistd.h:563:51: note: expected ‘char * const*’ but argument is of type ‘const char **’                                                                                          
      563 | extern int execv (const char *__path, char *const __argv[])                                                                                                                           
          |                                       ~~~~~~~~~~~~^~~~~~~~                                                                                                                            
    
    opened by DeeNewcum 1
  • Thanks, I can now type with pi 400 on my Ipad while ssh/vnc-ing to it

    Thanks, I can now type with pi 400 on my Ipad while ssh/vnc-ing to it

    Hi @Gadgetoid, really appreciate you made this, you pointed me to learning about libusbgx. I added ECM so that i could ssh/vnc to the PI 400 so that it's not just a "dumb" keyboard while not relying on known WIFI either. With ipad pro it's wickedly nifty and geeky ;)

    Having portable access to full linux and arm with GPIO while also act as portable keyboard for Ipad.....priceless

    Cheers

    opened by ahasani 1
  • Need to automatically run modprobe on boot

    Need to automatically run modprobe on boot

    The keyboard will not work correctly unless there is an autostart service for modprobe libcomposite on boot. If the modprobe isn't running, the main pi400kb executable will not run.

    opened by tigertank591 0
  • Toggle hook

    Toggle hook

    Use -DHOOK_PATH with cmake to define a path to a .sh script (or binary) to run on grab/ungrab.

    See hook.sh for details. "Grab" calls the script with a 1, "Ungrab" calls it with a 0.

    opened by Gadgetoid 0
  • Typo in pi400kb.service

    Typo in pi400kb.service

    Hey, this is a minor issue and would've been solved way easier and not even raised as an issue but a smarter brain than mine. However when copying and pasting and getting incredibly frustrated that I was constantly getting pi400kb.service fail no matter what I was doing I finally noticed that the script "ExecStart=/usr/sbin/pi400kb" was supposed to be "ExecStart=/usr/bin/pi400kb" which was causing the service to always fail because there is no path /usr/sbin/...

    Hopefully in the meantime this is useful to others (all 12 of us) to edit the pi400kb.service before saving until this is sorted.

    opened by Setayo 0
  • Question about why you need the vendor and the id of the keyboard.

    Question about why you need the vendor and the id of the keyboard.

    Hi, I've done this kind of thing, years ago on PDP-11s. I don't see you even passing the vendor and product id to the OTG side. I thought I was clever, back then, when I set the output port's control block for features and status to be the same as the controlling input side. Then, my friend Jeff showed me his version where he got the address of the interrupt service routine for input and did something that delivered the character to the output.

    Anyway, I'm trying to make arbitrary keyboards work for a reason. It turns out that my fancy mechanical keyboards are mostly gaming keyboards because thats the only way to get data-processing level switches and keycaps. I need to use a KVM. KVMs really don't like gaming keyboards. Hence, put a Pi in the middle,

    Is the output side getting this information in a side effect that I can't find in the code?

    I would prefer to do your "suitable device" check against the protocol field, which is 1 for keyboards. I'm going to do some experimental programming and debugging.

    My plan: if the device is a keyboard, just forward it. That's because it isn't going to do anything crazy--after all, the user has this keyboard and could plug it directly into the machine being controlled.

    I can see so many applications for pi400kb. I would always want a Pi in between my keyboard and the host.

    My best to you,

    Eirikur

    opened by Eirikur 1
  • Adds the modprobe.service on startup

    Adds the modprobe.service on startup

    The actual pi400kb service will not work on start up due to the need for modprobe libconfig to be ran. This creates a service to run on startup which should fix this.

    opened by tigertank591 0
  • The raw file returns a 404 error

    The raw file returns a 404 error

    Hi there,

    When trying to install yesterday I got a 404 error at the wget point. With or without sudo before the command. Is the link offline? Is there another link?

    2022-02-16-153452_1360x768_scrot

    opened by arm-ARMY 3
Releases(v0.0.1)
  • v0.0.1(Feb 4, 2022)

    This is the very first release, in order to move the binary out of the repository and provide 32bit/64bit versions- in theory.

    64bit TBC!

    If you find this useful I'd appreciate a dollar or two - https://patreon.com/gadgetoid

    What's Changed

    • Add basic build by @Gadgetoid in https://github.com/Gadgetoid/pi400kb/pull/3
    • Mouse support for #1 by @Gadgetoid in https://github.com/Gadgetoid/pi400kb/pull/2
    • use poll() to avoid 100% CPU load by @normen in https://github.com/Gadgetoid/pi400kb/pull/14
    • Toggle hook by @Gadgetoid in https://github.com/Gadgetoid/pi400kb/pull/9
    • fix compile warning by @DeeNewcum in https://github.com/Gadgetoid/pi400kb/pull/22
    • Prep for attached release files by @Gadgetoid in https://github.com/Gadgetoid/pi400kb/pull/23

    New Contributors

    • @Gadgetoid made their first contribution in https://github.com/Gadgetoid/pi400kb/pull/3
    • @normen made their first contribution in https://github.com/Gadgetoid/pi400kb/pull/14
    • @DeeNewcum made their first contribution in https://github.com/Gadgetoid/pi400kb/pull/22

    Full Changelog: https://github.com/Gadgetoid/pi400kb/commits/v0.0.1

    Source code(tar.gz)
    Source code(zip)
    pi400kb-v0.0.1-32bit-armv7l.zip(35.18 KB)
Owner
Philip Howard
Philip Howard
ESP8266 software USB host through general IO pins. We can connect up to 2 USB-LS HID (keyboard mouse joystick) devices simultaneously.

esp8266_usb_soft_host Test for esp8266 usb host . Works with ESP-IDF v3.4 80MHz and 160MHz. WorkInProgress Test run with mouse & combined mouse & keyb

Samsonov Dima 28 Sep 1, 2022
C/C++ Application to solve irrigation rotation whatever two-turn rotation or three-turn rotation, longitudinal section design, hydraulic calculations, and design of hydraulic structures like weirs and tail escape.

Irrigation works C/C++ Application to solve irrigation rotation whatever two-turn rotation or three-turn rotation, longitudinal section design, hydrau

Mohamed Jamal Ghayyad 1 Jun 24, 2022
esp32S2 USB HID host example.

Simple usb host HID example Since usb host support is still beta stage and include file is in private_include i copied component to this example. Code

null 16 Oct 10, 2022
IR2USB - IR to USB HID Converter based on ATtiny45/85

IR2USB - IR to USB HID Converter based on ATtiny45/85 IR2USB receives signals from an infrared remote control and converts them into keyboard inputs,

Stefan Wagner 15 Dec 21, 2022
A USB proxy based on raw-gadget and libusb

usb-proxy This software is a USB proxy based on raw-gadget and libusb. It is recommended to run this repo on a computer that has an USB OTG port, such

Aristo Chen 39 Dec 7, 2022
Turn 2 esp32 boards into pixhawk telemetry for use with Ardupilot/Ardurover Mission Planner.

RoverLink Turn 2 esp32 boards into pixhawk telemetry for use with Ardupilot/Ardurover Mission Planner I used to use these cheap Chinese 900mhz Pixhawk

Jeffrey Berezin 3 Dec 9, 2022
Turn images into text better than caca/aalib

hiptext hiptext is command line tool for rendering images and videos inside terminals. Dependencies You need clang or gcc >=4.7. You also need to inst

Justine Tunney 688 Dec 31, 2022
Turn your ESP32 into a easy to use micro web-server allowing to interact with any GPIO by simple http(s) calls.

WebhooksTriggeredESP32WiFi Turn your ESP32 into an easy to use and manage wireless micro web-server allowing it to process reliably and asynchronouly

JayDeLux 3 Nov 24, 2022
Use Atari keyboard as USB keyboard with a Teensy 3.6

Atari Keyboard Convert an Atari 600/800/1200 XL into a USB keyboard. I bricked my Atari mainboard. My goal is to use the keyboard of the Atari on a Ra

Jos Koenis 2 Dec 3, 2021
Tiny and portable usb host and device stack for mcu with usb ip

Tiny and portable usb host and device stack for mcu with usb ip

sakumisu 545 Jan 2, 2023
USB-C_PCB_experiments - USB-C ports made from a flex PCB and an ATtiny84A

USB-C PCB Experiments This is part of an ongoing series of projects involving creative interpretations of the USB mechanical standards. You've probabl

Sam Ettinger 23 Sep 5, 2022
Anotter USB temperature logger that can record up to four channels with thermocouple or NTCs connected via CDC directly or SCPI to USB.

temperature-logger Anotter USB temperature logger that can record up to four channels with thermocouple or NTCs connected via CDC directly or SCPI to

Jana Marie Hemsing 50 Nov 24, 2022
Ramp is a HID attack program that steals all connected WiFi passwords within 13 seconds.

Ramp Ramp is a HID attack program that steals all connected WiFi passwords within 13 seconds. Tested Windows 10 Warning Ramp has been created for the

Md. Ridwanul Islam Muntakim 24 Dec 24, 2022
To turn on and off the pump, most people use a manual switch.

To turn on and off the pump, most people use a manual switch. As a result, people forget to switch off the pump from time to time, resulting in water overflow. They may forget to switch on the motor at times, resulting in a water problem later on. It also wastes a lot of electricity. To solve this problem, we need a smart device to control the pump.

Md. Asad Chowdhury Dipu 1 Aug 20, 2022
ESP32S2 Arduino USB host printer, MIDI, and keyboard demos

ESP32 S2 USB Host Jumpstart A collection of experiments and demos using Espressif ESP32 S2 in USB host mode. Most of the sketches have little or no C+

null 31 Jan 4, 2023
USB2Sun - USB keyboard/mouse to Sun Converter

USB2Sun While I've found many projects for connecting the Sun serial based keyboards to a modern machine via USB, I've never found anything to connect

Joakim L. Gilje 9 Nov 24, 2022
A fully-functional open source and open hardware mechanical USB computer keyboard with only three keys!

threeboard threeboard is a fully-functional open source and open hardware mechanical USB computer keyboard with only three keys. It supports multiple

Conor Taylor 98 Dec 9, 2022
Basic definitions and utility functions for GNSS raw measurement processing

gnss_comm Authors/Maintainers: CAO Shaozu (shaozu.cao AT gmail.com) The gnss_comm package contains basic definitions and utility functions for GNSS ra

HKUST Aerial Robotics Group 70 Dec 21, 2022
A dataset containing synchronized visual, inertial and GNSS raw measurements.

GVINS-Dataset Author/Maintainer: CAO Shaozu (shaozu.cao AT gmail.com), LU Xiuyuan (xluaj AT connect.ust.hk) This repository hosts dataset collected du

HKUST Aerial Robotics Group 134 Dec 21, 2022