Author Topic: Keyboard controller upgrade for Kinesis (easily extended to other keyboards)  (Read 9836 times)

0 Members and 1 Guest are viewing this topic.

Offline chrisandreae

  • Thread Starter
  • Posts: 43
  • Location: Tokyo, Japan
The version of the firmware in this post has been superseded by a later version with Ergodox support added and a new GUI, described here.

I've implemented a very full-featured open source microcontroller-based programmable USB keyboard firmware.

In its current incarnation, it provides a drop-in replacement for the main microcontroller of a Kinesis. I have schematics and software versions supporting the Kinesis Advantage, Professional, and the two-PCB version of the Model 110. It has been designed to be easy to customize to any keyboard with a known matrix layout.

The firmware provides the following features:
  • Full key-rearrangement programmability, including support for a "keypad layer".
  • Built in layout profiles to save/restore up to ten separate programmed keyboard layouts.
  • Configuration and programming over USB with a GUI client.
  • Enhanced macros that fully support modifier keys within macro sequences, and can be triggered by any combination of up to four keys.
  • Built in mouse-keys in keypad layer.
  • Built in virtual machine capable of running up to six concurrent programs written in a custom bytecode (compiler included)
  • Multi-tone audio support using the internal buzzer, accessible from the VM

9037-0

The firmware is written to support both software USB with the V-USB library and hardware USB with LUFA. However, only the V-USB implementation has been recently tested, and the configuration over USB functionality is included only in the V-USB version.

My reference designs use an Atmel ATmega32 microprocessor. They're designed as mostly-single-sided PCBs for fairly easy home etching and assembly.

9035-19039-2
9041-39043-4

The firmware and schematics can be found on GitHub at https://github.com/chrisandreae/kinesis-firmware, under a GPL license.

(Moderators: please feel free to move this topic to the Making Stuff forum if it would be more appropriate there)
« Last Edit: Tue, 24 June 2014, 20:44:14 by chrisandreae »

Offline Biternk

  • Posts: 6
Okay, now, how much would it cost me to ship a Kinesis Advantage over to you for modification? :D (I don't know the first thing about soldering...)

Offline chrisandreae

  • Thread Starter
  • Posts: 43
  • Location: Tokyo, Japan
Unfortunately it probably would be fairly expensive to ship back and forward to me - I live in New Zealand. Also I'm still etching and assembling the boards by hand, which is a fairly time consuming process, so I'm not in a position where I can produce large numbers of them for people. It'd probably be better to get in touch with someone local who could help guide you through the process, perhaps at a local makerspace?

Offline engicoder

  • Posts: 708
  • Location: North Carolina
Sound like a very complete solution. I am intrigued by your addition of an on chip virtual machine. What sort of programs do you envision this being used for? Based on the set of built-in functions in the system library, I could see it being used for multi-key mappings.

Thanks for sharing this, it must have been working on this for quite a while.
   

Offline chrisandreae

  • Thread Starter
  • Posts: 43
  • Location: Tokyo, Japan
Mostly it was just for the fun of the exercise of writing a compiler and VM. So far, the only real program I've written is a joke to watch your keystrokes and play the Tetris theme tune if you happen to type "tetris".

But more realistically, I can imagine using it for gaming, to create macros with precise delays or conditions - perhaps to navigate a character in a pattern, or use a sequence of abilities, or maybe to create a rapid-fire key/mouse button like an old 'turbo' joystick. More generally, maybe for a key that performs one action on press and another on release? I'll look forward to seeing what other people make of the functionality. :)

Offline TotalChaos

  • Posts: 733
  • Location: Houston, Texas
  • Indy Game Coder
Is there a function to add PS/2 support to Topre keyboards since Topre is to cheap to do it themselves?
Rosewill RK-9000RE #1 (Broke on day 26, fixed with Scotch Tape on day 42, barely holding together)
Rosewill RK-9000RE #2 (Lubed, still in the box.  I am afraid to use it because it will break like the first one)

Offline chrisandreae

  • Thread Starter
  • Posts: 43
  • Location: Tokyo, Japan
Is there a function to add PS/2 support to Topre keyboards since Topre is to cheap to do it themselves?

Currently the controller only provides a USB keyboard. It would be certainly be possible to rewrite it for PS/2 communication, but it's not something I was planning.

Offline hasu

  • Posts: 2502
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Wow, great job! This looks like most full-fledged and multifunctional open source firmware I have ever seen before.

Macro and programmability via VM is just what I've wanted to add to my keyboard. I should look into your code of stack machine and learn how you realized these interesting features.

Thanks for publishing your great code!
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline chrisandreae

  • Thread Starter
  • Posts: 43
  • Location: Tokyo, Japan
I've been thinking more about Biternk's question: if I were to have a larger numbers of boards made and fully assembled, how many people would be interested in purchasing them as solder-free drop-in upgrades, and what would be a reasonable price to pay for such a thing? Additionally, are there any other keyboard models that people would particularly like supported?

Offline pasph

  • Posts: 1059
  • Location: Italy
Filco, QFR
"There is more stupidity than hydrogen in the universe, and it has a longer shelf life"

Offline wcass

  • Posts: 480
  • Location: Fort Lauderdale, FL, USA
Re: Keyboard controller upgrade for Kinesis (easily extended to other keyboards)
« Reply #10 on: Wed, 05 December 2012, 22:01:13 »
how about something for the buckling spring fans?

i am not sure if you are familiar with IBM/Lexmark/Unicomp keyboards, but they have a distinctive sound and feel. but the buckling spring is just a transfer mechanism - the switch is actually a membrane in a model M. mkawa started a thread Project: SSK revival trying to build a 10keyless from new Unicomp parts.

like all membrane keyboards, the model M is 2kro. i made a suggestion to replace the bottom sheet of the membrane sandwich with very thin PCB and use a diode for each key. this will need a new controller of course. could i send you some drawings?

Offline chrisandreae

  • Thread Starter
  • Posts: 43
  • Location: Tokyo, Japan
Re: Keyboard controller upgrade for Kinesis (easily extended to other keyboards)
« Reply #11 on: Wed, 05 December 2012, 22:09:04 »
like all membrane keyboards, the model M is 2kro. i made a suggestion to replace the bottom sheet of the membrane sandwich with very thin PCB and use a diode for each key. this will need a new controller of course. could i send you some drawings?

Sure. If you're designing your own matrix, it should be very easy to take advantage of my controller. Send me a PM with details if you would like a hand adapting it.

Offline precarious

  • Posts: 280
  • LOOK MOM, I'M A DRAGONZORD! DOOOO DODOODODODOODOO
Re: Keyboard controller upgrade for Kinesis (easily extended to other keyboards)
« Reply #12 on: Wed, 19 December 2012, 17:46:35 »


I'm wondering if you think your controller may be a suitable replacement for the one on this older WYSE terminal board I'm trying to get up and running.  I tried working with Soarer's converter, but it seems the data line is dead or needs the original terminal to function properly, so I'm trying to figure out what the best thing to replace it with would be.

This thing is amazingly well built and it would be a shame to trash it or just use it for parts. :)
« Last Edit: Wed, 19 December 2012, 17:48:45 by precarious »

Offline chrisandreae

  • Thread Starter
  • Posts: 43
  • Location: Tokyo, Japan
Re: Keyboard controller upgrade for Kinesis (easily extended to other keyboards)
« Reply #13 on: Wed, 19 December 2012, 21:33:05 »
If you can access the keyboard matrix directly on the PCB, and are willing to spend some time with a multimeter to map it out, then the software should be pretty straightforward to adapt to the different matrix layout.

One factor that you might care about is that the Kinesis's matrix has built-in diodes, so I haven't bothered to include any software handling of masking/ghosting. If your keyboard doesn't include these then you'd need either add diodes, extend the firmware, or put up with masking/ghosting effects.

Offline bpiphany

  • Posts: 1001
  • Location: Stockholm, Sweden
  • bpiph is a special type of crazy. //mkawa
Re: Keyboard controller upgrade for Kinesis (easily extended to other keyboards)
« Reply #14 on: Thu, 20 December 2012, 03:36:19 »
It is very straight forward to map a matrix layout using a Teensy++ (or something similar). Just hook it up to the matrix lines by the controller. Load a program that simply scans all pair of ports to see which are connected. Hit every key and have the controller print what it sees. You may need to go a little bit slow since the scanning is done really brute force. I had a picture from me doing it to a Filco, somewhere...

Edit: found it =)
« Last Edit: Thu, 20 December 2012, 03:43:22 by bpiphany »

Offline alaricljs

  • I be WOT'ing all day...
  • ** Moderator Emeritus
  • Posts: 3708
  • Location: NE US
Re: Keyboard controller upgrade for Kinesis (easily extended to other keyboards)
« Reply #15 on: Thu, 20 December 2012, 08:36:50 »
The HumbleHacker firmware has a mapping tool as part of it so you can be super lazy  ;)
Filco w/ Imsto thick PBT
Ducky 1087XM PCB+Plate, w/ Matias "Quiet Click" spring-swapped w/ XM Greens

Offline TotalChaos

  • Posts: 733
  • Location: Houston, Texas
  • Indy Game Coder
Re: Keyboard controller upgrade for Kinesis (easily extended to other keyboards)
« Reply #16 on: Tue, 25 December 2012, 02:05:05 »
I've implemented a very full-featured open source microcontroller-based programmable USB keyboard firmware.

I request 2 new features:
1. PS/2 support.  So I can program the keyboard with all my special settings via USB and press save.  Then take keyboard to PS/2 computer and plug it in and it works.  This is needed for a wide variety of reasons.  For example all retrogamers can only use PS/2 keyboards on their computers, not USB.  There are thousands of great old Amiga games from 1980s and 1990s freely downloadable on the net all fully compatible to PS/2 keyboards and mice.  But trying to run USB keyboards and mice on an old 50Mhz computer ruins the game by bogging down the CPU.  PS/2 FTW!


2. Independent Repeat Speed and Repeat Delay for every single key.  Sometimes gamers need a certain key to start repeating instantly and rapidly every time they touch it.  If gamers could tell their controller that the (for example) q key has a 0 repeat delay and high repeat speed, then pressing the q key down for 0.5 seconds would send many KEYDOWN KEYUP events to the computer.  Awesome!

Rosewill RK-9000RE #1 (Broke on day 26, fixed with Scotch Tape on day 42, barely holding together)
Rosewill RK-9000RE #2 (Lubed, still in the box.  I am afraid to use it because it will break like the first one)

Offline bonega

  • Posts: 7
Sorry if my questions are noobish...its because they are.

1. Why are you inserting two boards and replacing the old usb-cable? I would have imagined one would suffice.
2. From the pictures it seems like you are just tapping into the pins of the old controller(marked 3-9-03 USB), is that correct?
3. If so, have you taken any steps to deactive the old controller?

Thanks

Offline chrisandreae

  • Thread Starter
  • Posts: 43
  • Location: Tokyo, Japan
I request 2 new features:
1. PS/2 support.  So I can program the keyboard with all my special settings via USB and press save.  Then take keyboard to PS/2 computer and plug it in and it works.  This is needed for a wide variety of reasons.  For example all retrogamers can only use PS/2 keyboards on their computers, not USB.  There are thousands of great old Amiga games from 1980s and 1990s freely downloadable on the net all fully compatible to PS/2 keyboards and mice.  But trying to run USB keyboards and mice on an old 50Mhz computer ruins the game by bogging down the CPU.  PS/2 FTW!

I see the value in that, but it's not something I'm particularly keen to work on myself. If someone were interested in forking to provide that functionality, it wouldn't be particularly difficult - the main work would be rewriting the key state management to work in terms of state change events rather than current state reports.

2. Independent Repeat Speed and Repeat Delay for every single key.  Sometimes gamers need a certain key to start repeating instantly and rapidly every time they touch it.  If gamers could tell their controller that the (for example) q key has a 0 repeat delay and high repeat speed, then pressing the q key down for 0.5 seconds would send many KEYDOWN KEYUP events to the computer.  Awesome!

The firmware already supports this using the programming language feature. For example, you could write the program:
Code: [Select]
void main(){
while(checkPhysKey(0)){ // as long as the key that triggered the program is still pressed
pressKey(0x04); // press 'a'
releaseKey(0x04); // release 'a'
delay(50); // and wait 50 milliseconds
}
}

(Actually, this use-case reveals the need for a way to obtain the keycode associated with a currently pressed key from a program, which I'll try and get around to at some point. The library available to the programmed macros is pretty rudimentary at the moment, and deserves quite a bit more work.)

Offline chrisandreae

  • Thread Starter
  • Posts: 43
  • Location: Tokyo, Japan
Sorry if my questions are noobish...its because they are.

1. Why are you inserting two boards and replacing the old usb-cable? I would have imagined one would suffice.

A couple of reasons. The largest reason for using two boards is physical space inside the keyboard: the cylindrical cut-out at the bottom of the keyboard (where the USB cable comes out) sits immediately above the microcontroller socket, and seriously constrains the possible size of any board that connects directly to that socket. In fact I have to slightly trim the internal plastic to even fit the small board pictured. (This issue could be fixed by designing a double-layer board with a smaller footprint) My first prototype was a single board like that, which required me to cut an unsightly hole in the bottom of the keyboard to fit it.

Other relevant information: the original microcontroller appear to actually be (mostly) a PS/2 keyboard: USB is provided by the PS/2-to-USB converter daughterboard (the part with the built-in USB hub). This is why I can't take advantage of the existing USB hub and the cable between that board and the mainboard: it simply doesn't provide USB.

2. From the pictures it seems like you are just tapping into the pins of the old controller(marked 3-9-03 USB), is that correct?
3. If so, have you taken any steps to deactive the old controller?

The old controller is removed from its DIP socket completely, and my board replaces it.

Offline bonega

  • Posts: 7
Thanks for your speedy answers.
Will probably take me a while to implement it.
Programmer by trade, but I know next to nothing about electronics...

Offline sordna

  • Posts: 2239
Just saw this, nice!  I wonder if this firmware works on the Ergodox keyboard (teensy 2.0) and how the two firmwares compare!
Kinesis Contoured Advantage LF with Cherry MX Red switches / Extra keys mod / O-ring dampening mod / Dvorak layout. ErgoDox with buzzer and LED mod.
Also: Kinesis Advantage Classic, Kinesis Contoured Model 110, Data911 TG3, Fingerworks Touchstream LP, KBC Poker (Cherry MX Red), IBM Space Saving keyboard (Buckling spring), Goldtouch GTU-0077 keyboard

Offline mrtomcruise

  • Posts: 1
  • Location: Pakistan
    • geekhack
So after a month or so I'm finally back up to speed with my kinesis keyboard and my wrists feel so much better. Only problem is that my extensive keybinding changes to slickedit don't really translate so well to the kinsesis layout. I was hoping that any of you out there who also use a kinsesis wouldn't mind sharing any tips or keybindings that you find useful/comfortable.........

Offline Haman03

  • Posts: 1
Based on two years of research the Kinesis contoured keyboard was designed not only to reduce the known risk factors associated with repetitive stress injuries but also to provide a more comfortable platform than other keyboards. Its unique contoured design reduces the force and stressful postures that contribute to discomfort and limit productivity. Since its introduction in 1992, the Kinesis keyboard has undergone extensive independent testing and has proven superior in both comfort and productivity against traditional and other alternative keyboards.
Haman03

Offline sordna

  • Posts: 2239
Yes, it's really good, but there's always room for improvement. In fact Kinesis themselves are soliciting input for their next generation contoured keyboard in this thread, under their own forum:

http://geekhack.org/index.php?topic=36195.0
Kinesis Contoured Advantage LF with Cherry MX Red switches / Extra keys mod / O-ring dampening mod / Dvorak layout. ErgoDox with buzzer and LED mod.
Also: Kinesis Advantage Classic, Kinesis Contoured Model 110, Data911 TG3, Fingerworks Touchstream LP, KBC Poker (Cherry MX Red), IBM Space Saving keyboard (Buckling spring), Goldtouch GTU-0077 keyboard

Offline regicide

  • Posts: 70
  • Location: Wellington, New Zealand
  • Software developer and Open source hacker
Awesome work on this Chris

I have 2 Kinesis advantages so I hope to be able to get this firmware on at least one of them.

I also happen to live in New Zealand (Wellington) so I am wondering whether the board was self made of manufactured (apologies if this is explained elsewhere)
 

In case it it of interest my potential use case is that I have quite bad RSI/OOS in my wrists as well as rather lazy typing habits,
I hope to be able to modify the firmware in some way so that I can encourage better habits (or at least track my habits)

For example I commonly will do a combos that are quite uncomfortable:
 windows-key (left thumb) and 1 (left ring finger)
 shift (either left pink or thumb depending) and a 4 (left index)

I hope to alleviate this by not recognising problematic combos where the modifier and key are pressed with the same hand.


Thanks for the great work,
From a fellow Chris who also happens to live in New Zealand
« Last Edit: Wed, 01 May 2013, 21:00:21 by regicide »
2 Kinesis advantages (MX browns)

Offline chrisandreae

  • Thread Starter
  • Posts: 43
  • Location: Tokyo, Japan
Hi Chris, thanks for the interest! The boards were self-made, but I imagine that with a little time the Eagle files could be cleaned up to get the PCBs properly manufactured. Alternatively, it would be possible to jury rig a commercial board such as a Teensy to connect to the Advantage's microcontroller socket. (This would give the additional advantage of hardware-based USB, but would require bringing the somewhat neglected LUFA-based USB core in the firmware up to date (lufa/lufa_main.c)).

Modifying the firmware to perform extra actions on specific keyboard combinations would also be fairly easy. For a really quick hack, you could just toss handlers into handle_state_normal() in keyboard.c, otherwise you might want to look into using programmed-macros for the feature.

Unfortunately, I'm not in Wellington any more, otherwise I'd offer to help you build one. In the last couple of months I've moved to Tokyo for a new job, which has somewhat reduced my available time for hacking on the keyboard project.

Offline chrisandreae

  • Thread Starter
  • Posts: 43
  • Location: Tokyo, Japan
Just saw this, nice!  I wonder if this firmware works on the Ergodox keyboard (teensy 2.0) and how the two firmwares compare!

Should work with a bit of porting - would need to:
  • Add a hardware mapping for the Ergodox' matrix layout
  • Bring the LUFA based USB core up to date - I haven't used it since switching to software USB on cheap ATmega32s, so it'll need some changes.
  • Either add some external eeprom storage for programs, or disable the uploadable program feature
  • Add a buzzer, or disable the buzzer feature
« Last Edit: Wed, 01 May 2013, 22:27:46 by chrisandreae »

Offline TotalChaos

  • Posts: 733
  • Location: Houston, Texas
  • Indy Game Coder
I also happen to live in New Zealand (Wellington) ...

For example I commonly will do a combos that are quite uncomfortable:
 windows-key (left thumb) and 1 (left ring finger)
 shift (either left pink or thumb depending) and a 4 (left index)

I have the same problems as you with same-hand multikey combos.  And I used to have a coder friend who lived in Wellington.  Small world :)
Rosewill RK-9000RE #1 (Broke on day 26, fixed with Scotch Tape on day 42, barely holding together)
Rosewill RK-9000RE #2 (Lubed, still in the box.  I am afraid to use it because it will break like the first one)

Offline seva1385

  • Posts: 5
Hi Chris!

I can see that your design involves a PCB plugged into Kinesis panel...
Would it be possible to replace just the firmware in the AT89S8253 chip?
They are both Atmel... am I missing anything?

Thanks!
Kinesis Advantage (2 original + 1 with QMK f/w)
Maltron RH

Offline chrisandreae

  • Thread Starter
  • Posts: 43
  • Location: Tokyo, Japan
I can see that your design involves a PCB plugged into Kinesis panel...
Would it be possible to replace just the firmware in the AT89S8253 chip?
They are both Atmel... am I missing anything?

Potentially, but it would require a rather different approach. First of all, the AT89S8253 is 8051 architecture rather than AVR, so significant porting would be required. Second, the Advantage seems to be internally implemented as a (mostly) PS/2 keyboard behind an internal USB-PS/2 adaptor on a daughterboard. So in order to make no hardware changes, you'd need to implement a PS/2 firmware plus any additional proprietary internal features required by the USB daughterboard (notice for example there's an extra connection labelled 'USB' between them, which presumably serves some purpose).

Offline seva1385

  • Posts: 5
Potentially, but it would require a rather different approach. First of all, the AT89S8253 is 8051 architecture rather than AVR, so significant porting would be required. Second, the Advantage seems to be internally implemented as a (mostly) PS/2 keyboard behind an internal USB-PS/2 adaptor on a daughterboard. So in order to make no hardware changes, you'd need to implement a PS/2 firmware plus any additional proprietary internal features required by the USB daughterboard (notice for example there's an extra connection labelled 'USB' between them, which presumably serves some purpose).

Ah! Immediately after posting I realized that AT89S is not the same as ATMega, and now turns out these are different families altogether.
I totally missed the part about USB to PS/2 bridge.

Still, I am feeling adventurous enough to port your code to the native CPU, or at least some USB-enabled 8051. I am a decent C programmer, and even was, years ago, taught to code for Z80, but I have next to no experience with embedded systems. Would you be so kind to point me to some resource explaining the basic setup for programming a microcontroller? I imagine I would need a flash programmer, compiler tool chain, debugger, perhaps an emulator... what else?

Thanks!
Kinesis Advantage (2 original + 1 with QMK f/w)
Maltron RH

Offline Input Nirvana

  • Master of the Calculated Risk
  • Posts: 2310
  • Location: Somewhere in the San Francisco Bay area/Best Coast
  • If I tell ya, I'll hafta kill ya
Can this GUI and firmware be implemented and programmed on a Mac computer?

And yes, the Advantage is a PS/2 keyboard mainboard with a PS/2 to USB active converter provided by Pi Engineering. The next incarnation of the Kinesis is supposed to be USB native.
Kinesis Advantage cut into 2 halves | RollerMouse Free 2 | Apple Magic Trackpad | Alphagrip | Colemak | on Mac+Hackintosh
Evil Screaming Flying Door Monkeys From Hell                     Proudly GeekWhacking since 2009
Staying in touch via Tapatalk VIP                                        Thanks much, Smallfry  
I AM THE REAPER . . . BECAUSE I KILL IT
~retired from forum activities 2015~

Offline chrisandreae

  • Thread Starter
  • Posts: 43
  • Location: Tokyo, Japan
Still, I am feeling adventurous enough to port your code to the native CPU, or at least some USB-enabled 8051. I am a decent C programmer, and even was, years ago, taught to code for Z80, but I have next to no experience with embedded systems. Would you be so kind to point me to some resource explaining the basic setup for programming a microcontroller? I imagine I would need a flash programmer, compiler tool chain, debugger, perhaps an emulator... what else?

Pretty much as you described, except for the level of frustration potentially involved in getting your hands on them and their documentation. AVRs are well-beloved by the hobbyist community, so there's no end of resources available - guides, libraries, free compilers, large variety of cheap parts (flashers, debuggers, microcontrollers) available on eBay and so on. From a quick Google it looks like the support you want is there, but a little more awkward. Have a look into SDCC for a compiler toolchain. You could consider getting started with a development board kit like this one http://bit.ly/ZpzmU8.

Offline chrisandreae

  • Thread Starter
  • Posts: 43
  • Location: Tokyo, Japan
Can this GUI and firmware be implemented and programmed on a Mac computer?

Yup, I work on a Mac most of the time. The current GUI requires Ruby and GTK from Homebrew, but there's a nicer QT GUI in the works that will build directly to a native Mac application.

Offline vvp

  • Posts: 663
Still, I am feeling adventurous enough to port your code to the native CPU, or at least some USB-enabled 8051.
Did you try to port it yet?

Offline vvp

  • Posts: 663
So in order to make no hardware changes, you'd need to implement a PS/2 firmware plus any additional proprietary internal features required by the USB daughterboard (notice for example there's an extra connection labelled 'USB' between them, which presumably serves some purpose).
If they use some proprietary extension of PS2 there there may be a problem. I believe the extra connection marked MPCUSB is just an access to Scroll Lock key when the main board is powered down. Just a speculation - looks like a way to wake up the main board when it is powered down and user presses Scroll Lock. On keyboards without the white relay MPCUSB is not even connected.
It would be interesting to test whether it would work when the main board is disconnected from the PS2-USB converter and we would connect some standard PS2 keyboard to the daughterboard converter.