Giter Site home page Giter Site logo

pi400kb's Introduction

Raspberry Pi 400 as a USB HID Keyboard & Mouse

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

A Raspberry Pi Mouse is also supported if plugged in, eg: https://shop.pimoroni.com/products/raspberry-pi-mouse?variant=29390982119507

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 & MOUSE 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 grab/release your keyboard and mouse, switching between local use and USB.

Press Ctrl + Shift + Raspberry (on the grabbed keyboard) to exit.

Mouse Support

Pi 400 KB supports the official Raspberry Pi Mouse VID:PID = 093a:2510 by default, but other mice should work.

Autostart

sudo cp pi400kb /usr/sbin/pi400kb
sudo systemctl edit --force --full pi400kb.service

Add the contents of the pi400kb.service file.

Start the service and check its status:

sudo systemctl start pi400kb.service
sudo systemctl status pi400kb.service

Enable start on boot if it's okay:

sudo systemctl enable pi400kb.service

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

Custom Mouse/Keyboard Devices

CMake accepts the following build arguments to customise the VID/PID and device path for the mouse/keyboard:

  • KEYBOARD_VID - Keyboard Vendor ID, default: 0x04d9
  • KEYBOARD_PID - Keyboard Product ID, default: 0x0007
  • KEYBOARD_DEV - Keyboard device path, default: /dev/input/by-id/usb-_Raspberry_Pi_Internal_Keyboard-event-kbd
  • MOUSE_VID - Mouse Vendor ID, default: 0x093a
  • MOUSE_PID - Mouse Product ID, default: 0x2510
  • MOUSE_DEV - Mouse device path, default: /dev/input/by-id/usb-PixArt_USB_Optical_Mouse-event-mouse

Supply these arguments when configuring with CMake, eg:

cmake .. -DMOUSE_DEV="/dev/input/by-id/usb-EndGameGear_XM1_Gaming_Mouse_0000000000000000-event-mouse" -DMOUSE_VID=0x3367 -DMOUSE_PID=0x1903

pi400kb's People

Contributors

gadgetoid avatar deenewcum avatar normen avatar

Stargazers

Dennis avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

that0ne-guy

pi400kb's Issues

bug when pressing and releasing keys in the right order

If you, for instance, press keys in this order:

  1. press and hold Ctrl
  2. press and hold A
  3. press and hold Raspberry
  4. release A

Then this code will interpret this as "toggle capture on/off", even though the user has just released something. Is this the right thing to do, or should we track "keys that have just been pressed" vs "keys that have just been released"?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.