Feasability check : hardware keyboard remapper ?

Showroom for MicroPython related hardware projects.
Target audience: Users wanting to show off their project!
Post Reply
fpp
Posts: 64
Joined: Wed Jul 20, 2016 12:08 pm

Feasability check : hardware keyboard remapper ?

Post by fpp » Wed Jul 20, 2016 12:33 pm

Hi,

I'd like to hear some opinions about this project made with a Teensy, a "USB host shield mini" and some C code :
https://forum.colemak.com/topic/1561-ar ... -remapper/
It acts both as an USB host (to the keyboard) and device (to the PC), with the code in between acting on the data (key remapping, layouts etc.).

I would really dig making something like that, but with the code done in Python so that I could extend the functionality myself (macros, abbreviation expansion etc.).

I've tinkered with basic stuff on Raspberries and Arduinos, but I'm not what you'd call experienced in the field...
Does it sound possible to reproduce this neat setup with a pyboard(*) acting as the usb device and signal processor, and maybe a helper chip on the host side sending it the keyboard input ?

Thanks for your insights !

(*) edit: or any other micropython-compatible board, obviously...
Last edited by fpp on Thu Jul 21, 2016 8:22 am, edited 1 time in total.

torwag
Posts: 220
Joined: Fri Dec 13, 2013 9:25 am

Re: Feasability check : hardware keyboard remapper ?

Post by torwag » Wed Jul 20, 2016 4:26 pm

Hi,

I would go one step further and replace the keyboard controller by a pyboard. With this, you can have a keyboard logic as you want it. Pyboards and Micropython should be perfect for this task. In the docs you will find examples to create a HID based on a pyboard. IIRC keyboard was added as well... not sure here.
Let us know if this works out for you.

fpp
Posts: 64
Joined: Wed Jul 20, 2016 12:08 pm

Re: Feasability check : hardware keyboard remapper ?

Post by fpp » Thu Jul 21, 2016 8:34 am

Thanks torwag for the quick reply and suggestion !

In fact this is the first option I had thought of, as it seemed simpler to achieve (one board, no in/out usb).
(it also has the drawback of not being portable, but for a POC that doesn't matter)

Unfortunately I have been unable to find the right search keywords for examples, in particular on how to connect the board inside the keyboard ("controller" brings up mostly gaming gear :-). That's why I turned to the "usb adapter" solution.

If you have links to such examples of replacing an existing kb controller, I would certainly give it a try...

TIA,
fp

torwag
Posts: 220
Joined: Fri Dec 13, 2013 9:25 am

Re: Feasability check : hardware keyboard remapper ?

Post by torwag » Thu Jul 21, 2016 9:30 am

Hi,

you would want to check for those crazy DIY-keyboard community. Many of those are open source and open hardware. Thus, you get a pretty good idea what is needed. Many of those project use a teensy as controller. A pyboard would be a very nice replacement, since people could start to change the behaviour without reflashing the unit.
Search for
ErgoDox and look into the two main forums geekhack and deskthority.
There are different firmware on github for the ErgoDox and there are some other keyboards out with similar ideas.
Should give you a good starting point.

fpp
Posts: 64
Joined: Wed Jul 20, 2016 12:08 pm

Re: Feasability check : hardware keyboard remapper ?

Post by fpp » Thu Jul 21, 2016 9:50 am

Thanks again for the tips !
Man, those guys are hardcore indeed... and I could spend the rest of the year digging in those mines :-)

Also, refining my search terms accordingly, I found this topic on the Teensy forums :
https://forum.pjrc.com/threads/25209-Re ... key-layout
It has a lot of information and is written in a very accessible fashion.
As the "keyboard matrix - to - board pins - to - software" part is probably applicable to pyboards, it may be of interest to other here.

fpp
Posts: 64
Joined: Wed Jul 20, 2016 12:08 pm

Re: Feasability check : hardware keyboard remapper ?

Post by fpp » Fri Jul 22, 2016 11:51 am

Hi again, back with a (probably) stupid question...

As I haven't quite made my mind up, I'm still exploring both options, the keyboard mod and the original "usb-in-out" adapter (as per the link in the first post), trying to understand what's possible or not.

In that setup, the USB (in) Host mini shield communicates with the Teensy through SPI to send it the USB data it receives, and the Teensy in turn handles it own USB (out) to send data to the host.

In the MicroPython tutorials there is a small snippet on "Making a UART - USB pass through" :
http://docs.micropython.org/en/latest/p ... rough.html
... which looks similar to what the Teensy would do on its end.

So the question is :
Is there any chance that an Arduino-family USB Host shield could be connected via SPI to a pyboard, which would receive the data from the passthrough, process it and forward it via its own USB ?
Or am I missing something obvious ? :-)

fpp
Posts: 64
Joined: Wed Jul 20, 2016 12:08 pm

Re: Feasability check : hardware keyboard remapper ?

Post by fpp » Sun Jul 31, 2016 9:57 am

Well, not much interest in this it seems, or maybe it's just the summer break :-)

Torwag, did you actually experiment with that keyboard idea of yours ?

Meanwhile, I received my pyboard yesterday and have completed the initial setup, updates, basic tutorial. It's really great fun !

However I'm a bit confused by the documentation, especially on the topic of USB HID...

The only mention I could find is :
pyb.hid((buttons, x, y, z))
Takes a 4-tuple (or list) and sends it to the USB host (the PC) to signal a HID mouse-motion event.
Note
This function is deprecated. Use pyb.USB_HID().send(...) instead.
Nothing about keyboard HID or the new USB_HID function... have I missed something (again :-) ?

Post Reply