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

Grab the latest pi400kb for your system from releases: https://github.com/Gadgetoid/pi400kb/releases

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 cmake
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

deenewcum avatar gadgetoid avatar lytex avatar normen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pi400kb's Issues

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.

passing arguments from incompatible pointer type on featue/toggle-hook branch

pi@raspberrypi400:~/test/pi400kb/build $ make
Scanning dependencies of target pi400kb
[  5%] Building C object CMakeFiles/pi400kb.dir/pi400.c.o
/home/pi/test/pi400kb/pi400.c: In function \u2018modprobe_libcomposite\u2019:
/home/pi/test/pi400kb/pi400.c:46:37: warning: passing argument 2 of \u2018execv\u2019 from incompatible pointer type [-Wincompatible-pointer-types]
         execv("/usr/sbin/modprobe", argv);
                                     ^~~~
In file included from /home/pi/test/pi400kb/pi400.c:13:
/usr/include/unistd.h:563:51: note: expected \u2018char * const*\u2019 but argument is of type \u2018const char **\u2019
 extern int execv (const char *__path, char *const __argv[])
                                       ~~~~~~~~~~~~^~~~~~~~
[ 11%] Building C object CMakeFiles/pi400kb.dir/gadget-hid.c.o
...

Custom mouse successfully recognized, but data is not transmitted.

Finally able to test this program more and honestly the simplicity of it makes it much more worthy than Bluetooth solutions.

My Pi400 is grabbed and transmitted with no problem, but my mouse is not. I have provided the correct info based on lsusb during the build time, and my mouse is actually grabbed (instead of saying undetected).

The problem is, there's another error appearing (emphasis is mine):

Found keyboard at: /dev/hidraw0
Found mouse at: /dev/hidraw2
- usbg_create_gadget()  duplicate gadget name
 
- Error creating gadget
- Error: USBG_ERROR_EXIST : Already exist
Grabbing Keyboard and/or Mouse
Grabbing: /dev/input/by-id/usb-_Raspberry_Pi_Internal_Keyboard-event-kbd
Grabbing: /dev/input/by-id/usb-Logitech_USB_Receiver-if02-event-mouse
Running...

CMake parameters:

cmake .. -DMOUSE_DEV="/dev/input/by-id/usb-Logitech_USB_Receiver-if02-event-mouse" -DMOUSE_VID=0x046D -DMOUSE_PID=0xC53F

Any help would be appreciated.

Simultaneous mouse support

As requested by @Hermann-SW on the original gist comments - https://gist.github.com/Gadgetoid/5a8ceb714de8e630059d30612503653f

  1. capture HID descriptor for a mouse (official Pi mouse to get started?)
  2. find a way to merge that descriptor (multi-endpoint?) with the keyboard descriptor
  3. get pi400kb showing mouse/keyboard devices when connected to USB
  4. expand find_hidraw_device to scan for and connect to any supplied VID/PID
  5. GRAB the mouse fd to prevent local input
  6. Add forwarding of mouse HID events to the relevant output
  7. Cross fingers!
  8. Make VID/PID for mouse/keyboard configurable
  9. systemd unit plus documentation?

Feature/Roadmap: Get HID descriptor and device path automatically from VID/PID

IE you would supply a VID/PID and it would:

  1. Get the relevant devices
  2. Dump the full HID descriptor of your keyboard/mouse
  3. Set up a new HID device pretending to be your keyboard/mouse
  4. Forward all HID reports - so it's basically 1:1 identical with plugging your mouse straight into your computer
  5. Detect keyboards and give some (optional?) way to bind toggle/escape hotkeys

I don't know how this would work with multiple devices, but it would be really nice just to supply a list of VIDs/PIDs for HID and have this forward them as transparently as possible to the host computer.

UVC gadget for raspi?

Is there any way to mock uvc camera in raspi? I want to play a local video as camera's content, when raspi connect to PC, PC only shows that a camera has been connected, which actually plays the video not real camera.

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)

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

Replicating mouse and keystrokes sent to pi via VNC/SSH

Using this, Is there a way to remote into the pi (such as vnc or less preferred ssh terminal) to then have the keystrokes & mouse movements replicated and sent to another computer, rather than using the mouse and keyboard as hardware for the other computer?

[Feature Request] Option to boot into released mode

I know I am going to forget I installed this and I am going to try and use my rpi400 and wonder why the keyboard and mouse are not working.
Booting into release mode would allow my to switch on the service if and when I need it.

Is it okay to implement keystroke record / playback?

It would be nice to have complex macros like the QMK / ZMK keyboard firmware, but I'm not ready to implement that. But I'm definitely interested in keystroke recording/playback, as a primitive macro system. Would that be welcomed as part of this project?

Q: possible to use with USB Type A?

Nice work guys!
Is it possible to use Pi400 as keyboard using USB Type A, keeping the Type C connected to power supply? It would be perfect for my needs

Do all USB devices get passed through?

Sorry if this is the wrong place but I'm wondering if you need to specifically declare which USB devices get passed through. I'm thinking of using my Pi400 as the master brain of my UPS control which means I need to connect USB devices to the Pi and I'm hoping these devices will default to only working on the Pi and won't be passed to the externally connected device.

two asprintf warnings when building according instructions

Building was fine, two warnings:

[ 17%] Building C object CMakeFiles/pi400kb.dir/libusbgx/src/usbg.c.o
/home/pi/pi400kb/libusbgx/src/usbg.c: In function \u2018usbg_allocate_config\u2019:
/home/pi/pi400kb/libusbgx/src/usbg.c:392:8: warning: implicit declaration of function \u2018asprintf\u2019; did you mean \u2018vsprintf\u2019? [-Wimplicit-function-declaration]
  ret = asprintf(&(c->name), "%s.%d", label, id);
        ^~~~~~~~
        vsprintf
[ 23%] Building C object CMakeFiles/pi400kb.dir/libusbgx/src/usbg_common.c.o
/home/pi/pi400kb/libusbgx/src/usbg_common.c: In function \u2018usbg_init_function\u2019:
/home/pi/pi400kb/libusbgx/src/usbg_common.c:306:8: warning: implicit declaration of function \u2018asprintf\u2019; did you mean \u2018vsprintf\u2019? [-Wimplicit-function-declaration]
  ret = asprintf(&(f->name), "%s.%s", type_name, instance);
        ^~~~~~~~
        vsprintf
[ 29%] Building C object CMakeFiles/pi400kb.dir/libusbgx/src/usbg_common_libconfig.c.o

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.

[Feature Request] Toggle HDMI out with pi400kb

Typical setup:
1 display with both the PC and rpi400 connected.
If the HDMI out toggled with the rpi400kb then it would have a neat result:

Release mode + HDMI on -> display auto-detects pi and switches to it.
Capture mode + HDMI off -> display detects PC activity and switches to it.

Qs: Does pi400kb work with Pi4B as well? Does pi400kb support single device keyboard+mouse?

Hi,

  1. will specifying KEYBOARD_DEV KEYBOARD_VID and KEYBOARD_PID in cmake allow to use pi400kb with Pi4B?
  2. I am using Logitech K400+ wireless keyboard with Pi4B. That has a single lsusb entry for keyboard as well as touchpad:
Bus 001 Device 004: ID 046d:c52b Logitech, Inc. Unifying Receiver

Will pi400kb work with such single device keyboard+mouse?
Just specify same values for KEYBOARD_/MOUSE_ DEV/VID/PID?

Manjaro errors?

Getting a usbg_init() No such file or directory : couldn't init gadget state

Any clues? My error maybe?

Chris Olson

readme: Autorun example

Create a simple systemd unit (for autorun)

# Copy pi400kb
sudo cp pi400kb /usr/sbin/pi400kb

# Create unit
sudo systemctl edit --force --full how_keyboard.service

And add

[Unit]
Description=simple unit for user pi400 how keyboard

[Service]
ExecStart=/usr/sbin/pi400kb
User=root   
Group=root   
Type=simple
Restart=on-failure

[Install]
WantedBy=multi-user.target

Try and enable service

# start
sudo systemctl start how_keyboard.service
# check status
sudo systemctl status how_keyboard.service
# enable autorun if it's ok
sudo systemctl enable how_keyboard.service

NOT work on Pi OS host

it worked on MacOS, but doesn't work on Pi OS
pi@host:~ $ hostnamectl Static hostname: host Icon name: computer Machine ID: a98fd8eb67024b6d8073f43d2cedec27 Boot ID: 37e84af532214c6e858b2bfd2da31df4 Operating System: Raspbian GNU/Linux 11 (bullseye) Kernel: Linux 6.1.21-v7+ Architecture: arm

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

Request: dump your official Pi Keyboard USB HID descriptors

Ahoy folks,

If you've got an official Pi Keyboard or a Pi 400 handy I'd appreciate you dumping the HID descriptor and posting it here.

I'm interested in colour and region variations, just in case the HID descriptors need some variation to support this better.

From a Linux computer or Raspberry Pi, use lsusb to list USB devices, eg:

pi@bullseye:~/ $ lsusb
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 04d9:0007 Holtek Semiconductor, Inc. Raspberry Pi Internal Keyboard
Bus 001 Device 004: ID 093a:2510 Pixart Imaging, Inc. Optical Mouse
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Then run sudo usbhid-dump -d 04d9:0007 (replacing the numbers with the device you want to dump), eg:

pi@bullseye:~/ $ sudo usbhid-dump -d 04d9:0007
001:003:001:DESCRIPTOR         1634138968.109157
 05 0C 09 01 A1 01 05 0C 75 01 95 01 15 00 25 01
 09 CD 81 06 09 B5 81 02 09 B6 81 02 09 B8 81 06
 09 E2 81 06 09 EA 81 02 09 E9 81 02 0A 23 02 81
 02 0A 92 01 81 02 95 07 81 01 C0

001:003:000:DESCRIPTOR         1634138968.129603
 05 01 09 06 A1 01 05 07 19 E0 29 E7 15 00 25 01
 75 01 95 08 81 02 95 01 75 08 81 01 95 03 75 01
 05 08 19 01 29 03 91 02 95 05 75 01 91 01 95 06
 75 08 15 00 26 FF 00 05 07 19 00 2A FF 00 81 00
 C0

You can parse these into a slightly more readable format using: https://eleccelerator.com/usbdescreqparser/

Just paste the table of hexadecimal numbers and hit "I do not know, make a guess for me", eg:

 05 01 09 06 A1 01 05 07 19 E0 29 E7 15 00 25 01
 75 01 95 08 81 02 95 01 75 08 81 01 95 03 75 01
 05 08 19 01 29 03 91 02 95 05 75 01 91 01 95 06
 75 08 15 00 26 FF 00 05 07 19 00 2A FF 00 81 00
 C0

becomes:

0x05, 0x01,        // Usage Page (Generic Desktop Ctrls)
0x09, 0x06,        // Usage (Keyboard)
0xA1, 0x01,        // Collection (Application)
0x05, 0x07,        //   Usage Page (Kbrd/Keypad)
0x19, 0xE0,        //   Usage Minimum (0xE0)
0x29, 0xE7,        //   Usage Maximum (0xE7)
0x15, 0x00,        //   Logical Minimum (0)
0x25, 0x01,        //   Logical Maximum (1)
0x75, 0x01,        //   Report Size (1)
0x95, 0x08,        //   Report Count (8)
0x81, 0x02,        //   Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x95, 0x01,        //   Report Count (1)
0x75, 0x08,        //   Report Size (8)
0x81, 0x01,        //   Input (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x95, 0x03,        //   Report Count (3)
0x75, 0x01,        //   Report Size (1)
0x05, 0x08,        //   Usage Page (LEDs)
0x19, 0x01,        //   Usage Minimum (Num Lock)
0x29, 0x03,        //   Usage Maximum (Scroll Lock)
0x91, 0x02,        //   Output (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x95, 0x05,        //   Report Count (5)
0x75, 0x01,        //   Report Size (1)
0x91, 0x01,        //   Output (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
0x95, 0x06,        //   Report Count (6)
0x75, 0x08,        //   Report Size (8)
0x15, 0x00,        //   Logical Minimum (0)
0x26, 0xFF, 0x00,  //   Logical Maximum (255)
0x05, 0x07,        //   Usage Page (Kbrd/Keypad)
0x19, 0x00,        //   Usage Minimum (0x00)
0x2A, 0xFF, 0x00,  //   Usage Maximum (0xFF)
0x81, 0x00,        //   Input (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position)
0xC0,              // End Collection

// 65 bytes

// best guess: USB HID Report Descriptor

Doesn't work!

Please test your repo, that it actually works. Also fix README, cause we need to guess where and what to put into pi400kb.service.
In the end of the day still doesn't works as USB keyboard on win10.

root@pi1035:/home/amg63/pi400kb# sudo systemctl start pi400kb.service
root@pi1035:/home/amg63/pi400kb# sudo systemctl status pi400kb.service
● pi400kb.service - pi400kb USB OTG Keyboard & Mouse forwarding
Loaded: loaded (/etc/systemd/system/pi400kb.service; enabled; vendor preset: enabl>
Active: failed (Result: exit-code) since Sat 2023-05-13 17:18:40 BST; 6s ago
Process: 3431 ExecStart=/usr/sbin/pi400kb (code=exited, status=1/FAILURE)
Main PID: 3431 (code=exited, status=1/FAILURE)
CPU: 10ms

May 13 17:18:40 pi1035 systemd[1]: pi400kb.service: Main process exited, code=exited, s>
May 13 17:18:40 pi1035 systemd[1]: pi400kb.service: Failed with result 'exit-code'.
May 13 17:18:40 pi1035 systemd[1]: pi400kb.service: Scheduled restart job, restart coun>
May 13 17:18:40 pi1035 systemd[1]: Stopped pi400kb USB OTG Keyboard & Mouse forwarding.
May 13 17:18:40 pi1035 systemd[1]: pi400kb.service: Start request repeated too quickly.
May 13 17:18:40 pi1035 systemd[1]: pi400kb.service: Failed with result 'exit-code'.
May 13 17:18:40 pi1035 systemd[1]: Failed to start pi400kb USB OTG Keyboard & Mouse for>

Can't grab/release keyboard and mouse, but can release

According to the ReadMe:

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.

However, Ctrl + Raspberry doesn't seem to grab/release the keyboard (Ctrl + Shift + Raspberry works fine, though).

I'll document my debugging journey to get the main branch working after compiling and installing (may help #39):

  • added libcomposite to /etc/modules (echo 'libcomposite' | sudo tee -a /etc/modules, as commented on #19 ), and rebooted
  • HOOK_PATH is hard-coded to /home/pi/pi400kb/hook.sh on pi400.h and on CMakeLists.txt; updated and re-compiled.
  • LED path may be outdated for Bullseye (replaced /sys/class/leds/led0/trigger and /sys/class/leds/led0/brightness to /sys/class/leds/PWR/trigger and /sys/class/leds/PWR/brightness, respectively, in hook.sh).
  • Manually inspected the Keyboard and Mouse variables passed to CMake and manually passed them when building: cmake .. -DMOUSE_DEV="/dev/input/by-id/usb-PixArt_USB_Optical_Mouse-event-mouse" -DMOUSE_VID=0x093a -DMOUSE_PID=0x2510 -DKEYBOARD_DEV="/dev/input/by-id/usb-_Raspberry_Pi_Internal_Keyboard-event-kbd" -DKEYBOARD_VID=0x04d9 -DKEYBOARD_PID=0x0007

I have tried:

  • creating a shortcut to manually restart the service (doesn't work?) in /etc/xdg/openbox/lxde-pi-rc.xml (though I'm not sure if C-W is the right combination for Ctrl + Raspberry).
  <keyboard>
    <!-- 
         [... default commands ...]
    -->
    <!-- My Custom Keyboard Shortcuts -->
    <keybind key="C-W">
      <action name="Execute">
        <command>sudo systemctl restart pi400kb.service</command>
      </action>
    </keybind>
  </keyboard>
  • Manually inspected the pi400kb.service logs (journalctl -f -u pi400kb.service), and found the following error message:
Jun 12 14:33:53 pi systemd[1]: Started pi400kb USB OTG Keyboard & Mouse forwarding.
Jun 12 14:33:53 pi pi400kb[2515]: usbg_create_gadget()  duplicate gadget name
Jun 12 14:33:53 pi pi400kb[2515]:  
Jun 12 14:33:53 pi pi400kb[2515]: Error creating gadget
Jun 12 14:33:53 pi pi400kb[2515]: Error: USBG_ERROR_EXIST : Already exist
Jun 12 14:33:54 pi pi400kb[2515]: Found keyboard at: /dev/hidraw1
Jun 12 14:33:54 pi pi400kb[2515]: Found mouse at: /dev/hidraw0
Jun 12 14:33:54 pi pi400kb[2515]: Grabbing Keyboard and/or Mouse
Jun 12 14:33:54 pi pi400kb[2515]: Grabbing: /dev/input/by-id/usb-_Raspberry_Pi_Internal_Keyboard-event-kbd
Jun 12 14:33:54 pi pi400kb[2515]: Grabbing: /dev/input/by-id/usb-PixArt_USB_Optical_Mouse-event-mouse
Jun 12 14:33:54 pi pi400kb[2515]: Running...
Jun 12 14:33:54 pi pi400kb[2515]: K:1 0 0 0 0 0 0 0
Jun 12 14:33:54 pi pi400kb[2515]: K:9 0 0 0 0 0 0 0
Jun 12 14:33:54 pi pi400kb[2515]: Releasing Keyboard and/or Mouse
Jun 12 14:33:54 pi pi400kb[2515]: K:b 0 0 0 0 0 0 0
Jun 12 14:33:54 pi pi400kb[2515]: Releasing Keyboard and/or Mouse
Jun 12 14:33:54 pi pi400kb[2515]: Cleanup USB
Jun 12 14:33:54 pi systemd[1]: pi400kb.service: Succeeded.

I'm not knowledgeable in C, so that's the limit to my ability to debug (and I'm unsure if the problem may be on pi400kb's gadget-hid.c:

usbg_ret = usbg_create_gadget(s, "g1", &g_attrs, &g_strs, &g);

... or the usbg_create_gadget function from libusbgx:

https://github.com/linux-usb-gadgets/libusbgx/blob/721e3a1cbd7e2b6361bb439d3959e7403e4f0092/src/usbg.c#L1531

I'd like to help in getting it to work... so, please let me know what I can do to continue debugging.

Feature: use libconfig to load a config file to set VID/PID of mouse/keyboard

Since libconfig is already a dependency and provides some nice config file handling, I propose the following config file format:

# Pi 400 Keyboard/Mouse Config File

version = "1.0";

application:
{
  keyboard:
  {
    vid = 0x04d9;
    pid = 0x0007;
    device_path = "/dev/input/by-id/usb-_Raspberry_Pi_Internal_Keyboard-event-kbd";
  };

  mouse:
  {
    vid = 0x093a;
    pid = 0x2510;
    device_path = "/dev/input/by-id/usb-PixArt_USB_Optical_Mouse-event-mouse";
  };
};

A path to the config file could be passed to pi400kb on the command-line.

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

Does it work in osx

First, congrats on this great tool.
I have a mac and i wonder if it would work there?

Bluetooth?

Hello,

I LOVE THIS PROJECT!!!!!!
But I'm wondering if this can be done with Bluetooth instead of usb-C because I would like to power my pi from a power bank and still use the keyboard to control my pc. The reason why I do this is because I want to put my mini pc on a power bank as well (So it's portable) and I don't want that power bank's battery charge to be reduced quicker.

So can this be done with bluetooth?

Just wondering,

Thanks.

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.