Author Topic: Pi (Zero) GPIO matrix keyboard using linux HID gadget  (Read 3301 times)

0 Members and 1 Guest are viewing this topic.

Offline xmagusx

  • Thread Starter
  • Posts: 130
  • Location: Texas
  • QWERTY is hateful.
    • The Ergonomic Zone
Pi (Zero) GPIO matrix keyboard using linux HID gadget
« on: Sat, 24 September 2016, 07:49:24 »
Basically a feasibility / sanity check. What I would like to build is a keyboard matrix (5x16 if possible) which connects to and is read by the Pi Zero's GPIO pins, then acts like a standard HID keyboard via Linux gadget. Ideally built in such a way that one could also still be able to switch off the gadget functionality, connect an HDMI monitor, USB hub/mouse/etc, and use the keyboard matrix to control the Pi directly -- something vaguely C64-ish, for those old enough to remember such devices.

It feels like all the pieces are there -- I've seen Linux gadget be used to act like an HID device and send information across USB, and I've seen someone connect a hand-wired switch matrix to act as a local keyboard, but I've never seen those two put together for a Pi Zero.

Has anyone already dived down this rabbit hole that any of y'all know of? I know most people who have done such projects have used a ATMEGA32U4 board of one type or another (such as a Teensy), but I think this might have the potential of being an interesting new beast.

Thoughts? Am I just off the deep end? Thanks!

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: Pi (Zero) GPIO matrix keyboard using linux HID gadget
« Reply #1 on: Sat, 24 September 2016, 10:52:31 »
I looked into this long ago with a model A pi - it does sound a good idea.  This was long ago before the zero and I found no mention of Linux gadget either, just had a read and it sounds like you'll need to reboot to switch mode but if you add a way of swapping the cmdline.txt and config.txt files using the keyboard even that sounds livable.

Will definitely be looking into this later to see if it's working on the A, it should be as the single USB is directly connected but no 5th pin so might not.  Thanks for the tip!
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline xmagusx

  • Thread Starter
  • Posts: 130
  • Location: Texas
  • QWERTY is hateful.
    • The Ergonomic Zone
Re: Pi (Zero) GPIO matrix keyboard using linux HID gadget
« Reply #2 on: Mon, 26 September 2016, 09:17:25 »
I looked into this long ago with a model A pi - it does sound a good idea.  This was long ago before the zero and I found no mention of Linux gadget either, just had a read and it sounds like you'll need to reboot to switch mode but if you add a way of swapping the cmdline.txt and config.txt files using the keyboard even that sounds livable.

Will definitely be looking into this later to see if it's working on the A, it should be as the single USB is directly connected but no 5th pin so might not.  Thanks for the tip!
My thought was just to partition out the SD card and have two installs, the first being a stripped down install which just read the matrix and was a gadget (where it would boot by default and spend most of its life), the second being a full install with GUI joy and everything.

Offline desnudopenguino

  • Posts: 3
Re: Pi (Zero) GPIO matrix keyboard using linux HID gadget
« Reply #3 on: Thu, 29 September 2016, 17:15:48 »
I have been thinking of the same thing. My idea is using a pi (or similar) and having a switch that either allows the keyboard to be used as a normal keyboard on another system, or to turn on the internal system. It would take a pi and a teensy to do this, but it should work.

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: Pi (Zero) GPIO matrix keyboard using linux HID gadget
« Reply #4 on: Thu, 29 September 2016, 17:30:38 »
What about soldering two SD to microSD adapters to the pins on the pi and having a physical switch to control which card gets power to decide which it boots into?  Not entirely sure what happens when an unpowered card is connected in parallel with one that is, but I'll find out over the weekend :))
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline drudru

  • Posts: 4
Re: Pi (Zero) GPIO matrix keyboard using linux HID gadget
« Reply #5 on: Wed, 05 October 2016, 23:26:47 »
Just joined this community, and saw this post.

Wow  :)
I had the same idea recently!

When the Raspberry Pi 0 came out, I was not interested. However, once I saw the recent USB OTG stuff that people were doing, I was turned around.

I think it would totally be possible to use a Pi 0 as a keyboard matrix scanner for a USB keyboard HID.