Use Pi 400 as Pi Keyboard
My keyboard for my PC stopped working and im wondering would it be possible to use the Pi 400 as a USB keyboard for a replacement.
-
- Posts: 2888
- Joined: Sat Aug 18, 2012 2:33 pm
Re: Use Pi 400 as Pi Keyboard
https://hydra.angeldsis.com/build/104811 has a slightly more recent build of itcleverca22 wrote: ↑Sun Nov 29, 2020 12:47 pmhttps://hydra.angeldsis.com/build/10480 ... 1/root.zip
https://github.com/librerpi/rpi-tools/b ... oxy/main.c
and this is what happens when people dont stop me, lol
unpack root.zip to a fat32 formatted uSD card, pop it into a pi400, and then plug the usb-c port into any computer with a normal C->A cable
after ~5 seconds, it will function like a normal usb keyboard!
it has some bugs involving holding multiple keys at once, but ctrl/alt/shift are all fine to be held, so its enough to do basic tasks, but it wont handle gaming well (things like holding w and mashing a/d for ex)
https://twitter.com/Gadgetoid/status/13 ... 9497621505
and this guy beat me to it by about a week, but i suspect my setup process is simpler, i need to review his code and see if i can just bundle it into my root.zip to fix the rollover bugs
Re: Use Pi 400 as Pi Keyboard
Oh that sounds like some really impressive work there! Unfortunately, gaming would be one of my use cases so I'll hold of getting a pi 400 for now.
Maybe one day when it works. Good luck to you guys
Maybe one day when it works. Good luck to you guys

-
- Posts: 2888
- Joined: Sat Aug 18, 2012 2:33 pm
Re: Use Pi 400 as Pi Keyboard
there are also options like synergy/barrier that just share the mouse/keyboard between multiple computers
so the setup will behave like a dual-monitor setup, one on the PC, one on the pi400, and the mouse just seamlessly moves between the 2
Re: Use Pi 400 as Pi Keyboard
Hi, this idea to use the pi400 as a keyboard sounds great, but it didn't work for me. I've tried it today on three different PCs but it looks like, if there is not enough power from USB? If I connect (USB-C on Raspberry site - USB-A on PC) it, the Power LED of the RPI400 blinks a few time, then it expires and then it is blinking about every 30 seconds or so for 3 times but no reaction on key pressing.cleverca22 wrote: ↑Wed Dec 16, 2020 10:13 amhttps://hydra.angeldsis.com/build/104811 has a slightly more recent build of it
My Rasperry Pi 400 is provided with the latest eeprom update from Dec. 11 (000138a1).
-
- Posts: 2888
- Joined: Sat Aug 18, 2012 2:33 pm
Re: Use Pi 400 as Pi Keyboard
was it blinking any particular pattern? if you hook an hdmi screen up to it, does the bootloader show any error?rayjoe wrote: ↑Sat Dec 19, 2020 8:24 pmHi, this idea to use the pi400 as a keyboard sounds great, but it didn't work for me. I've tried it today on three different PCs but it looks like, if there is not enough power from USB? If I connect (USB-C on Raspberry site - USB-A on PC) it, the Power LED of the RPI400 blinks a few time, then it expires and then it is blinking about every 30 seconds or so for 3 times but no reaction on key pressing.cleverca22 wrote: ↑Wed Dec 16, 2020 10:13 amhttps://hydra.angeldsis.com/build/104811 has a slightly more recent build of it
My Rasperry Pi 400 is provided with the latest eeprom update from Dec. 11 (000138a1).
Re: Use Pi 400 as Pi Keyboard
Thank you for replying. This is the boot screen 

-
- Posts: 2888
- Joined: Sat Aug 18, 2012 2:33 pm
Re: Use Pi 400 as Pi Keyboard
Yes, I've unzipped build 104811 on a empty SD-Card:
bcm2711-rpi-4-b.dtb
config.txt
kernel7l.img
bcm2711-rpi-cm4.dtb
fixup4.dat
overlays
cmdline.txt
initrd
start4.elf
bcm2711-rpi-4-b.dtb
config.txt
kernel7l.img
bcm2711-rpi-cm4.dtb
fixup4.dat
overlays
cmdline.txt
initrd
start4.elf
-
- Posts: 2888
- Joined: Sat Aug 18, 2012 2:33 pm
Re: Use Pi 400 as Pi Keyboard
does it behave any differently with the older build in https://hydra.angeldsis.com/build/10480 ... 1/root.zip ?
Re: Use Pi 400 as Pi Keyboard
Just tried it with the older build (more files; start4.elf looks like the same). Unfortunately the same behaviour as before.
-
- Posts: 2888
- Joined: Sat Aug 18, 2012 2:33 pm
Re: Use Pi 400 as Pi Keyboard
not sure what it could be then, maybe the eeprom version? or the fat32 format?
i just popped https://hydra.angeldsis.com/build/104811 onto an old 2gig card, and it worked
Code: Select all
[root@system76:~]# fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 1.85 GiB, 1990197248 bytes, 3887104 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf37b4e56
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 133119 131072 64M c W95 FAT32 (LBA)
-
- Posts: 3
- Joined: Thu Jan 28, 2021 10:48 pm
Re: Use Pi 400 as Pi Keyboard
Hey! I tried out both of the builds you have posted here (thank you for sharing!). I really like how quickly it boots and becomes a normal keyboard. I cannot get the period key to work at all, however, and that makes it tough to use. Have you run into that? I'm using the US keyboard layout model.cleverca22 wrote: ↑Wed Dec 16, 2020 10:13 amhttps://hydra.angeldsis.com/build/104811 has a slightly more recent build of itcleverca22 wrote: ↑Sun Nov 29, 2020 12:47 pmhttps://hydra.angeldsis.com/build/10480 ... 1/root.zip
https://github.com/librerpi/rpi-tools/b ... oxy/main.c
and this is what happens when people dont stop me, lol
unpack root.zip to a fat32 formatted uSD card, pop it into a pi400, and then plug the usb-c port into any computer with a normal C->A cable
after ~5 seconds, it will function like a normal usb keyboard!
it has some bugs involving holding multiple keys at once, but ctrl/alt/shift are all fine to be held, so its enough to do basic tasks, but it wont handle gaming well (things like holding w and mashing a/d for ex)
https://twitter.com/Gadgetoid/status/13 ... 9497621505
and this guy beat me to it by about a week, but i suspect my setup process is simpler, i need to review his code and see if i can just bundle it into my root.zip to fix the rollover bugs
I also tried out the method that Philip Howard posted (using it to type this reply to you now), and while I like that it works, you are correct that yours is easier to get setup. I also don't really need my Pi 400 running a full OS just to make it a USB keyboard.
Could I buy you a beverage of some sort as a thank you and a bit of a bribe to take a look at this for me?
Thank you again!
Best
DavidBowman
-
- Posts: 2888
- Joined: Sat Aug 18, 2012 2:33 pm
Re: Use Pi 400 as Pi Keyboard
https://github.com/librerpi/rpi-tools/b ... main.c#L97
*doh*, i forgot to assign a keycode to period!
https://www.usb.org/sites/default/files ... 1_12v2.pdf
page 53
0x37 i think
"modprobe usbmon" + wireshark confirms, 0x37...
https://github.com/librerpi/rpi-tools/c ... e4f766ee91
https://hydra.angeldsis.com/build/105445
and CI should be building the fix!
Code: Select all
[KEY_RIGHT] = 0x4f,
[KEY_LEFT] = 0x50,
[KEY_DOWN] = 0x51,
[KEY_UP] = 0x52,
[KEY_NUMLOCK] = 0x53,
[KEY_SYSRQ] = 0,
[KEY_DOT] = 0,
};
https://www.usb.org/sites/default/files ... 1_12v2.pdf
page 53
0x37 i think
"modprobe usbmon" + wireshark confirms, 0x37...
https://github.com/librerpi/rpi-tools/c ... e4f766ee91
https://hydra.angeldsis.com/build/105445
and CI should be building the fix!
-
- Posts: 3
- Joined: Thu Jan 28, 2021 10:48 pm
Re: Use Pi 400 as Pi Keyboard
Ah, excellent!! It is working as it should now (like literally right now as I'm typing).cleverca22 wrote: ↑Fri Jan 29, 2021 10:11 amhttps://github.com/librerpi/rpi-tools/b ... main.c#L97*doh*, i forgot to assign a keycode to period!Code: Select all
[KEY_RIGHT] = 0x4f, [KEY_LEFT] = 0x50, [KEY_DOWN] = 0x51, [KEY_UP] = 0x52, [KEY_NUMLOCK] = 0x53, [KEY_SYSRQ] = 0, [KEY_DOT] = 0, };
https://www.usb.org/sites/default/files ... 1_12v2.pdf
page 53
0x37 i think
"modprobe usbmon" + wireshark confirms, 0x37...
https://github.com/librerpi/rpi-tools/c ... e4f766ee91
https://hydra.angeldsis.com/build/105445
and CI should be building the fix!
I was serious when I'd buy you a "beverage" (i.e. send you a small donation) as a thank you. Please PM me your info if you want. I really do appreciate this!
Also, would you be okay if I were to write about your implementation of this in an article about the two methods? I don't want to send a ton of traffic and support requests in your direction if that is not your wish. If you would want someone to help you test it further first, I have done professional software QA before (as well as informal with things like this). I'd be happy to help!
Thank you again!
- mahjongg
- Forum Moderator
- Posts: 13691
- Joined: Sun Mar 11, 2012 12:19 am
- Location: South Holland, The Netherlands
Re: Use Pi 400 as Pi Keyboard
Personal messages are not supported on this form for legal reasons (to protect kids)
-
- Posts: 2888
- Joined: Sat Aug 18, 2012 2:33 pm
Re: Use Pi 400 as Pi Keyboard
sure, you can write up an articleDavidBowman wrote: ↑Fri Jan 29, 2021 10:26 pmAlso, would you be okay if I were to write about your implementation of this in an article about the two methods? I don't want to send a ton of traffic and support requests in your direction if that is not your wish. If you would want someone to help you test it further first, I have done professional software QA before (as well as informal with things like this). I'd be happy to help!
i also hang out on the #raspberrypi irc channel if you want to chat about anything else in a more real-time fashion
-
- Posts: 3
- Joined: Thu Jan 28, 2021 10:48 pm
Re: Use Pi 400 as Pi Keyboard
That makes total sense, and I completely support that. Sorry about that, wasn't trying to violate any rules!
Thank you! I will remember that if I can think of anything to ask you about. Actually, I can think of one thing right now: Does your super key work on your keyboard? That is - I think - the only key that is not working for me right now as I type booted to your solution (which has been working better for me than Philip Howard's method that has locked up on me multiple times, requiring a yank of the power cord).cleverca22 wrote:sure, you can write up an articleDavidBowman wrote: ↑Fri Jan 29, 2021 10:26 pmAlso, would you be okay if I were to write about your implementation of this in an article about the two methods? I don't want to send a ton of traffic and support requests in your direction if that is not your wish. If you would want someone to help you test it further first, I have done professional software QA before (as well as informal with things like this). I'd be happy to help!
i also hang out on the #raspberrypi irc channel if you want to chat about anything else in a more real-time fashion
I really appreciate your work on this! Thanks again!
-
- Posts: 2888
- Joined: Sat Aug 18, 2012 2:33 pm
Re: Use Pi 400 as Pi Keyboard
checking with evtest on my desktop, linux calls that key KEY_LEFTMETA, and checking my source, i also forgot that one!
and wireshark shows its just an 0x08 in the modifier field
https://github.com/librerpi/rpi-tools/c ... 04081a0494
https://hydra.angeldsis.com/build/105493
and fixed!
Re: Use Pi 400 as Pi Keyboard
Hi. Firstly, I want to say thanks for doing this. I'm actually using my Pi 400 to type this on my other computer right now! But I think I've found another key that you forgot to map: the back slash key (just above the Fn key). It's not working for me, anyway.cleverca22 wrote:checking with evtest on my desktop, linux calls that key KEY_LEFTMETA, and checking my source, i also forgot that one!
and wireshark shows its just an 0x08 in the modifier field
https://github.com/librerpi/rpi-tools/c ... 04081a0494
https://hydra.angeldsis.com/build/105493
and fixed!
Edit: I had a look at the US version of the Pi 400 and I don't think it actually has this key. So if you are using the US version as well, that will be why this key isn't mapped. Oh well, it still works pretty well for most purposes.
Also, to anyone having trouble getting the Pi to work as a keyboard, I had some difficulties too until I copied the files from the folder directly onto the SD card I was using (mine initially unzipped into a folder called "root". So in other words, don't leave them in the folder). Hope that makes sense.
-
- Posts: 2888
- Joined: Sat Aug 18, 2012 2:33 pm
Re: Use Pi 400 as Pi Keyboard
if you boot the pi400 normally, then run `sudo evtest` and select the keyboard, what KEY code comes up when your hitting the backslash key?marimo wrote: ↑Sun Feb 21, 2021 8:40 amHi. Firstly, I want to say thanks for doing this. I'm actually using my Pi 400 to type this on my other computer right now! But I think I've found another key that you forgot to map: the back slash key (just above the Fn key). It's not working for me, anyway.
Edit: I had a look at the US version of the Pi 400 and I don't think it actually has this key. So if you are using the US version as well, that will be why this key isn't mapped. Oh well, it still works pretty well for most purposes.
Re: Use Pi 400 as Pi Keyboard
I ran the test for you and I think this is the information you want:
value 70064
code 86
(KEY_102ND)
I think it's called the backslash and pipe key.
value 70064
code 86
(KEY_102ND)
I think it's called the backslash and pipe key.
-
- Posts: 2888
- Joined: Sat Aug 18, 2012 2:33 pm
Re: Use Pi 400 as Pi Keyboard
ah, thats weird, backslash is KEY_BACKSLASH on both a regular machine and my US pi400
https://hydra.angeldsis.com/build/105677
the new build maps KEY_102ND as a second backslash key
Re: Use Pi 400 as Pi Keyboard
Well, it definitely registers as a key now, but instead of the backslash and pipe it returns the #~ symbols
(like the key next to the Enter button on a UK Keyboard does). See this link for a better idea of what my UK Pi 400 Keyboard layout looks like:
https://upload.wikimedia.org/wikipedia/ ... ingdom.svg
I checked again with the test to see what code it returned and got:
value 70031
code 43
KEY_BACKSLASH
for both keys, even for the one that definitely isn't a backslash key on my computer. Weird. In any case, both keys return a different key code when booted as a Raspberry Pi 400.
(like the key next to the Enter button on a UK Keyboard does). See this link for a better idea of what my UK Pi 400 Keyboard layout looks like:
https://upload.wikimedia.org/wikipedia/ ... ingdom.svg
I checked again with the test to see what code it returned and got:
value 70031
code 43
KEY_BACKSLASH
for both keys, even for the one that definitely isn't a backslash key on my computer. Weird. In any case, both keys return a different key code when booted as a Raspberry Pi 400.
-
- Posts: 2888
- Joined: Sat Aug 18, 2012 2:33 pm
Re: Use Pi 400 as Pi Keyboard
try running wireshark and usbmon (see further up in this thread) and capture the packet when your hitting that magic backslash key
it sounds like the UK layout is doing something very funky
it sounds like the UK layout is doing something very funky