{
  "attachments": [
    "0b034d6acac6.jpg"
  ],
  "title": "Making of the GameChord",
  "tags": [
    "diy",
    "keyboards",
    "hardware",
    "teensy",
    "microcontrollers",
    "electronics"
  ],
  "thumbnail": "/uploads/2016/gamechord/thumbnail.jpg",
  "year": "2016",
  "month": "08",
  "day": "29",
  "isDir": true,
  "slug": "gamechord",
  "type": "entry",
  "date": "2016-08-29T19:00:00.000Z",
  "postName": "2016-08-29-gamechord",
  "html": "<p><strong>TL;DR</strong>: I made a USB keypad that's good for gaming and typing entirely with\none hand.</p>\n<!--more-->\n\n\n\n<nav role=\"navigation\" class=\"table-of-contents\"></nav>\n\n<p>So, remember back in February when I said that <a href=\"http://blog.lmorchard.com/2016/02/06/keyboard-hacking/\">keyboard hacking seems like\nfun</a>?  Well, I\nfinished this GameChord thing back in July after about 5 months of occasional\nwork. But, I've been too busy <a href=\"https://twitter.com/lmorchard/status/770771394816729088\">drinking booze\nand playing video games</a> \nto get my butt in a chair and write about it.</p>\n<p>Let's see if I can fix that now...</p>\n<h2 id=\"the-design\">The design</h2>\n<p><a href=\"http://www.keyboard-layout-editor.com/##@_name=gamechord&amp;author=lmorchard;&amp;@=1&amp;=2&amp;=3&amp;=4&amp;=5;&amp;@=1&amp;=2&amp;=3&amp;=4&amp;=5;&amp;@=1&amp;=2&amp;=3&amp;=4&amp;=5;&amp;@_r:35&amp;rx:2.5&amp;ry:3.5&amp;y:-1&amp;x:1;&amp;=a&amp;=b&amp;=c\"><img class=\"inset left\" src=\"/uploads/2016/gamechord/keyboard-layout.png\" width=\"\" height=\"\"></a></p>\n<p>I started doodling with key layouts and <a href=\"http://www.keyboard-layout-editor.com/##@_name=gamechord&amp;author=lmorchard;&amp;@=1&amp;=2&amp;=3&amp;=4&amp;=5;&amp;@=1&amp;=2&amp;=3&amp;=4&amp;=5;&amp;@=1&amp;=2&amp;=3&amp;=4&amp;=5;&amp;@_r:35&amp;rx:2.5&amp;ry:3.5&amp;y:-1&amp;x:1;&amp;=a&amp;=b&amp;=c\">came up with\nthis</a>. Only 18 switches, but enough for gaming. At the\ntime, I was putting a lot of hours into Elite\nDangerous, so this felt promising as a spaceship control pad.<br><a href=\"https://www.flickr.com/photos/deusx/24872268889/\"><img class=\"inset right\" src=\"/uploads/2016/gamechord/paper-planning.jpg\" width=\"\" height=\"\"></a></p>\n<p><a href=\"https://www.flickr.com/photos/deusx/24781232904/in/datetaken-public/\"><img class=\"inset right\" src=\"/uploads/2016/gamechord/cats-happen.jpg\" width=\"\" height=\"\"></a></p>\n<p>Over on <a href=\"http://builder.swillkb.com/\">builder.swillkb.com</a>, I plonked in the JSON from <a href=\"http://www.keyboard-layout-editor.com/##@_name=gamechord&amp;author=lmorchard;&amp;@=1&amp;=2&amp;=3&amp;=4&amp;=5;&amp;@=1&amp;=2&amp;=3&amp;=4&amp;=5;&amp;@=1&amp;=2&amp;=3&amp;=4&amp;=5;&amp;@_r:35&amp;rx:2.5&amp;ry:3.5&amp;y:-1&amp;x:1;&amp;=a&amp;=b&amp;=c\">Keyboard\nLayout Editor</a> and came up with some SVG files that printed\nup nicely.</p>\n<p>That gave me a paper mockup of a mounting plate for key switches. I had some\nclear keycaps, so I dropped them onto the paper to get a sense for how it\nwould feel under my hand.</p>\n<p>Of course, cats happen - so those keycaps didn't stay put for very long. But,\nthat's okay. Nothing wandered off too far, and I got what I needed from\nthe mess on my desk.</p>\n<h2 id=\"making-the-case\">Making the case</h2>\n<p>Back when <a href=\"http://blog.lmorchard.com/2016/02/06/keyboard-hacking/\">I first started thinking about building a\nkeyboard</a>, I\nassumed I'd send off whatever design files I came up with to a place\nlike <a href=\"https://www.ponoko.com/\">Ponoko</a> and get the mounting plate made for me.</p>\n<p>Prices at those places were just a bit higher than I liked, though. I also\nsuspected things wouldn't work with my first attempt. I wanted to be able\nto iterate without it taking days or weeks to learn from my mistakes\nand refine.</p>\n<p>That's when I remembered <a href=\"https://i3detroit.org\">i3Detroit</a> was just down the road. I'd been\nmeaning to get over there for a couple of years: Among other things, the space\nhas <a href=\"https://www.i3detroit.org/wiki/Category:Laser_Cutter\">nice laser cutters</a> that I really wish I'd used <a href=\"http://blog.lmorchard.com/2013/02/10/building-my-couch-computing-station/\">back when\nI butchered some plastic to make a terrible PC monitor case</a>. </p>\n<p>A month or so later, I'd gotten through the new member onboarding process\nand a few training sessions with the laser cutter. I had some\nacrylic sheets still on hand, so I gave my design a shot:</p>\n<p><a data-flickr-embed=\"true\" href=\"https://www.flickr.com/photos/deusx/25839524664/\" title=\"Cutting a keyboard mounting plate on a laser cutter\"><img src=\"0b034d6acac6.jpg\" width=\"\" height=\"\" alt=\"Cutting a keyboard mounting plate on a laser cutter\"></a></p>\n<p>Pretty sure I had the power too high and the speed too low for the run\nin this video. But, the result was not too bad for a first attempt.  I had a\nfew dozen Cherry MX Clear switches to play with, so I snapped them into the\nplate and put on the keycaps I'd used in the paper mockup earlier:</p>\n<img class=\"fullwidth\" src=\"/uploads/2016/gamechord/clear-keycaps.jpg\" width=\"\" height=\"\">\n\n<p>Still lots of work ahead, but I was feeling pretty accomplished after taking\nthis little glamour shot. I even took it into an <a href=\"https://i3detroit.org\">i3Detroit</a> member meeting\nfor show &amp; tell.</p>\n<h2 id=\"re-making-the-case\">Re-making the case</h2>\n<p>At this point, I'd already heard the term \"kerf\". Like a saw blade, the laser\nhas a width that destroys material while cutting. You want that on the\n<em>inside</em> edge of something like a key switch mounting hole, in order to keep\nthe dimensions correct. Unlike a blade, the laser is a cylindrical\nbeam that passes through a lens to form <a href=\"http://www.buildlog.net/blog/2013/05/why-are-my-laser-cut-edges-not-straight/\">something like an\nhourglass</a>. So, the\nkerf's shape depends on the lens focal length and the conical section that\nintersects with the material.</p>\n<p>Well, I didn't account for the kerf well enough in my first plate. All the key\nswitches were wobbly. Some would just fall out if I flipped\nthe thing over. Time for some of those iterations I\nfigured I'd have to end up doing.</p>\n<img class=\"inset wide right\" src=\"/uploads/2016/gamechord/kerf-is-real.jpg\" width=\"\" height=\"\">\n\n<p>I know the saying is \"measure twice, cut once\" - but in this case it was\neasier to measure by cutting! I tried mounting holes with a sampling of kerf\nwidths until I found one that matched the key switch tolerances. Not so snug\nthat it cracked the plate, but not so loose that it wiggled or fell out. </p>\n<p>Once I found a good laser focus and figured out the kerf, I\nattacked another sheet of acrylic with the laser to produce another\niteration of the case.</p>\n<p><a href=\"https://www.flickr.com/photos/deusx/26975072884/\"><img class=\"fullwidth\" src=\"/uploads/2016/gamechord/glamour-shot.jpg\" width=\"\" height=\"\"></a></p>\n<p>Two changes you might notice: I added slots to glue in some socket\nheaders, so I could unplug or replace the Teensy without soldering. I also found some\n<a href=\"http://dro.ps/b/x3g0KCy\">relegendable keycaps</a> on Massdrop - they have little removable covers that\ntake 14mm paper squares. I figured that would come in handy for crazy\nkey layouts I might come up with.</p>\n<h2 id=\"wiring-up-the-key-matrix\">Wiring up the key matrix</h2>\n<p>I haven't learned how to design circuit boards yet, so I figured I'd just\nhandwire this <a href=\"https://www.youtube.com/watch?v=MrokZ1afnVg\">like I saw in the video</a>. Only 18 switches, so\nhow bad could it be?\nTurns out, it's rather annoying. Interesting exercise with my terrible old\nRadio Shack soldering iron. </p>\n<img class=\"inset wide left\" src=\"/uploads/2016/gamechord/matrix-wired-up.jpg\" width=\"\" height=\"\">\n\n\n<p>I think I'd much rather get over that PCB fabrication hurdle for when I try\nscaling this up to a 60% keyboard like my HHKB.</p>\n<p>The technique here involves first building up rows of diodes across the\nright-hand pin of every key switch. The diodes serve to prevent <a href=\"https://deskthority.net/wiki/Rollover,_blocking_and_ghosting\">ghosting when\nmultiple keys are pressed</a>. </p>\n<p>Then, I stripped sections of wires to\nrun as columns down the left-hand pin of the switches. </p>\n<p>The remaining\ninsulation ensures the column wires don't short against the row diodes.</p>\n<h2 id=\"wiring-up-the-teensy\">Wiring up the Teensy</h2>\n<img class=\"inset wide left\" src=\"/uploads/2016/gamechord/teensy-wired-up.jpg\" width=\"\" height=\"\">\n\n<p>This matrix gives me 4 rows (counting the thumb switches) and 5 columns - or 9\nI/O pins to scan 18 switches.</p>\n<p>Except for <a href=\"https://geekhack.org/index.php?topic=72804.0\">magical PD6</a> - which is hardwired to an onboard LED - just\nabout every pin is fair game on the Teensy for rows or columns. </p>\n<p>So, I tried to pick a set that would be easiest to route wires. Since this\ncase is transparent, I wanted to keep things visually interesting with\ndifferent colored wires and a neat shape to the runs.</p>\n<p>Of course, I botched things a bit and marred the acrylic by splashing\nsolder and slipping with the iron a few times. But, maybe no one will really\nnotice.</p>\n<p>If I had to do this over again - and I <em>still</em> hadn't learned how to make a\nPCB - I'd probably try using something thinner like <a href=\"https://www.adafruit.com/product/1446\">30AWG repair\nwire</a>. That seems like it would thread through the spaces much\nbetter, which would be even more important for a board with many more\nswitches. </p>\n<h2 style=\"clear: both\">Programming the Teensy</h2>\n\n<p>I based <a href=\"https://github.com/lmorchard/gamechord\">the GameChord firmware</a> on the great <a href=\"https://github.com/tmk/tmk_keyboard\">tmk\nfirmware</a> that seems popular on mech keyboard forums.</p>\n<p>Building <a href=\"https://github.com/lmorchard/gamechord/blob/863295d2cbdbc7052a25e989a77c3448796e67a6/matrix.c\">the matrix</a> was easy: The firmware scans through rows (DF0, DF1,\nDF4, and DF5) by pulling each low in turn. The columns (DB4, DB5, DB6, DF7,\nand DF6) are set as \"active low\" pins - which means keys pressed in the\ncurrent scan row get connected to ground and read as signals. So,\nI wrote the functions to manipulate &amp; read the appropriate row &amp; column pins,\nrespectively. </p>\n<p>It was almost <em>too</em> easy:</p>\n<blockquote class=\"twitter-tweet\" data-lang=\"en\"><p lang=\"en\" dir=\"ltr\">Holy crap. My attempt at setting up firmware for my newly wired DIY keypad worked first time. How does this happen. <a href=\"https://t.co/xWESzku4Lp\">https://t.co/xWESzku4Lp</a></p>— Les Orchard (@lmorchard) <a href=\"https://twitter.com/lmorchard/status/746518856328372225\">June 25, 2016</a></blockquote>\n\n\n\n<p>From there, I built <a href=\"https://github.com/lmorchard/gamechord/blob/863295d2cbdbc7052a25e989a77c3448796e67a6/keymap_plain.c\">a dead simple key map</a> with just enough\nkeys to play <a href=\"https://playoverwatch.com/en-us/\">Overwatch</a>:</p>\n<pre><code class=\"language-c\">[#include](/tag/include) \"keymap_common.h\"\n\nconst uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\n    KEYMAP( ESC,   1,    2,    3,    T, \\\n            TAB,   Q,    W,    E,    R, \\\n           LSFT,   A,    S,    D,    F, \\\n             NO,  NO, LCTL,  SPC,    C),\n};\nconst uint16_t PROGMEM fn_actions[] = {};\n</code></pre>\n<p>I got it all working and had myself a nice evening of pushing carts and taking\nobjectives.</p>\n<img class=\"fullwidth\" src=\"/uploads/2016/gamechord/test-run-on-gaming-station.jpg\" width=\"\" height=\"\">\n\n<h2 id=\"going-crazy-with-chording\">Going crazy with chording</h2>\n<p>I had all these <a href=\"http://dro.ps/b/x3g0KCy\">relegendable keycaps</a> and this crazy flexible <a href=\"https://github.com/tmk/tmk_keyboard\">tmk\nfirmware</a> - so I decided to try implementing <a href=\"https://github.com/lmorchard/gamechord/blob/863295d2cbdbc7052a25e989a77c3448796e67a6/keymap_halfqwerty.c\">a complex and fully impractical\nkeymap based on chords with the thumb keys</a>.</p>\n<img class=\"fullwidth\" src=\"/uploads/2016/gamechord/finished-key-legends.jpg\" width=\"\" height=\"\">\n\n<p>Given two thumb keys in combination, I can get 4 layers out of the other 15\nkeys - for a total of 60 keys. The firmware also <a href=\"https://github.com/lmorchard/gamechord/blob/863295d2cbdbc7052a25e989a77c3448796e67a6/keymap_halfqwerty.c#L43\">lets me distinguish\nbetween keys held or just tapped</a>, which gives me a few more layers or\nmodifier keys.</p>\n<p>Long story short, I can get most of the functionality of a regular keyboard\nout of just one hand. All I have to do is just get used to putting my left\nhand through some very awkward and uncomfortable contortions until I get up to\nfull typing speed!</p>\n<p><a href=\"http://blog.lmorchard.com/2016/02/05/steam-controller/\">As I've written before</a>, I do really like odd input devices.\nBut, this got old fast. This isn't so much a practical peripheral as a thing I\ndid because I could. It gave me an excuse to explore the firmware more\nand to use Inkscape to design some legends for my nifty keycaps.</p>\n<h2 id=\"showing-it-off\">Showing it off</h2>\n<p>And just to wrap things up, this happened:</p>\n<blockquote class=\"twitter-tweet\" data-lang=\"en\"><p lang=\"en\" dir=\"ltr\">I even have a project out in the <a href=\"https://twitter.com/i3Detroit\">@i3Detroit</a> tent at <a href=\"https://twitter.com/hashtag/MakerFaireDetroit?src=hash\">#MakerFaireDetroit</a> ! <a href=\"https://t.co/v0goD3DCBk\">pic.twitter.com/v0goD3DCBk</a></p>— Les Orchard (@lmorchard) <a href=\"https://twitter.com/lmorchard/status/759400946514427904\">July 30, 2016</a></blockquote>\n\n\n\n<p>This was the first summer I went to <a href=\"http://www.makerfairedetroit.com/\">Maker Faire Detroit</a> as a Maker. I\nhelped for a bit at the <a href=\"https://i3detroit.org\">i3Detroit</a> tent, mainly just standing and smiling\nat the front table as folks walked in. But, I had my little keyboard out there\non a table, with a project card and everything.</p>\n<p>It and I were only there for a handful of hours, but it's pretty satisfying to\nhave actually gotten this thing done!</p>\n<script async=\"\" src=\"//platform.twitter.com/widgets.js\" charset=\"utf-8\"></script>\n<script async=\"\" src=\"//embedr.flickr.com/assets/client-code.js\" charset=\"utf-8\"></script>\n\n<!-- vim: set wrap wm=5 syntax=markdown textwidth=78: -->\n",
  "body": "**TL;DR**: I made a USB keypad that's good for gaming and typing entirely with\none hand.\n\n<!--more-->\n\n<nav role=\"navigation\" class=\"table-of-contents\"></nav>\n\nSo, remember back in February when I said that [keyboard hacking seems like\nfun][keyboardhacking]?  Well, I\nfinished this GameChord thing back in July after about 5 months of occasional\nwork. But, I've been too busy [drinking booze\nand playing video games](https://twitter.com/lmorchard/status/770771394816729088) \nto get my butt in a chair and write about it.\n\nLet's see if I can fix that now...\n\n[keyboardhacking]: http://blog.lmorchard.com/2016/02/06/keyboard-hacking/\n\n## The design\n\n[<img class=\"inset left\"\nsrc=\"/uploads/2016/gamechord/keyboard-layout.png\">][layoutpermalink]\n\nI started doodling with key layouts and [came up with\nthis][layoutpermalink]. Only 18 switches, but enough for gaming. At the\ntime, I was putting a lot of hours into Elite\nDangerous, so this felt promising as a spaceship control pad.  \n[<img class=\"inset right\" src=\"/uploads/2016/gamechord/paper-planning.jpg\">](https://www.flickr.com/photos/deusx/24872268889/)\n\n[<img class=\"inset right\" src=\"/uploads/2016/gamechord/cats-happen.jpg\">](https://www.flickr.com/photos/deusx/24781232904/in/datetaken-public/)\n\nOver on [builder.swillkb.com][builder], I plonked in the JSON from [Keyboard\nLayout Editor][layoutpermalink] and came up with some SVG files that printed\nup nicely.\n\nThat gave me a paper mockup of a mounting plate for key switches. I had some\nclear keycaps, so I dropped them onto the paper to get a sense for how it\nwould feel under my hand.\n\nOf course, cats happen - so those keycaps didn't stay put for very long. But,\nthat's okay. Nothing wandered off too far, and I got what I needed from\nthe mess on my desk.\n\n[builder]: http://builder.swillkb.com/\n\n## Making the case\n\nBack when [I first started thinking about building a\nkeyboard][keyboardhacking], I\nassumed I'd send off whatever design files I came up with to a place\nlike [Ponoko](https://www.ponoko.com/) and get the mounting plate made for me.\n\nPrices at those places were just a bit higher than I liked, though. I also\nsuspected things wouldn't work with my first attempt. I wanted to be able\nto iterate without it taking days or weeks to learn from my mistakes\nand refine.\n\nThat's when I remembered [i3Detroit][] was just down the road. I'd been\nmeaning to get over there for a couple of years: Among other things, the space\nhas [nice laser cutters][lasercutters] that I really wish I'd used [back when\nI butchered some plastic to make a terrible PC monitor case][monitorcase]. \n\n[lasercutters]: https://www.i3detroit.org/wiki/Category:Laser_Cutter\n[monitorcase]: http://blog.lmorchard.com/2013/02/10/building-my-couch-computing-station/\n[i3Detroit]: https://i3detroit.org\n\nA month or so later, I'd gotten through the new member onboarding process\nand a few training sessions with the laser cutter. I had some\nacrylic sheets still on hand, so I gave my design a shot:\n\n<a data-flickr-embed=\"true\"  href=\"https://www.flickr.com/photos/deusx/25839524664/\" title=\"Cutting a keyboard mounting plate on a laser cutter\"><img src=\"0b034d6acac6.jpg\" width=\"800\" height=\"450\" alt=\"Cutting a keyboard mounting plate on a laser cutter\"></a>\n\nPretty sure I had the power too high and the speed too low for the run\nin this video. But, the result was not too bad for a first attempt.  I had a\nfew dozen Cherry MX Clear switches to play with, so I snapped them into the\nplate and put on the keycaps I'd used in the paper mockup earlier:\n\n<img class=\"fullwidth\" src=\"/uploads/2016/gamechord/clear-keycaps.jpg\">\n\nStill lots of work ahead, but I was feeling pretty accomplished after taking\nthis little glamour shot. I even took it into an [i3Detroit][] member meeting\nfor show & tell.\n\n## Re-making the case\n\nAt this point, I'd already heard the term \"kerf\". Like a saw blade, the laser\nhas a width that destroys material while cutting. You want that on the\n*inside* edge of something like a key switch mounting hole, in order to keep\nthe dimensions correct. Unlike a blade, the laser is a cylindrical\nbeam that passes through a lens to form [something like an\nhourglass][beamshape]. So, the\nkerf's shape depends on the lens focal length and the conical section that\nintersects with the material.\n\n[beamshape]: http://www.buildlog.net/blog/2013/05/why-are-my-laser-cut-edges-not-straight/\n\nWell, I didn't account for the kerf well enough in my first plate. All the key\nswitches were wobbly. Some would just fall out if I flipped\nthe thing over. Time for some of those iterations I\nfigured I'd have to end up doing.\n\n<img class=\"inset wide right\" src=\"/uploads/2016/gamechord/kerf-is-real.jpg\">\n\nI know the saying is \"measure twice, cut once\" - but in this case it was\neasier to measure by cutting! I tried mounting holes with a sampling of kerf\nwidths until I found one that matched the key switch tolerances. Not so snug\nthat it cracked the plate, but not so loose that it wiggled or fell out. \n\nOnce I found a good laser focus and figured out the kerf, I\nattacked another sheet of acrylic with the laser to produce another\niteration of the case.\n\n[<img class=\"fullwidth\" src=\"/uploads/2016/gamechord/glamour-shot.jpg\">](https://www.flickr.com/photos/deusx/26975072884/)\n\nTwo changes you might notice: I added slots to glue in some socket\nheaders, so I could unplug or replace the Teensy without soldering. I also found some\n[relegendable keycaps][] on Massdrop - they have little removable covers that\ntake 14mm paper squares. I figured that would come in handy for crazy\nkey layouts I might come up with.\n\n[relegendable keycaps]: http://dro.ps/b/x3g0KCy\n\n## Wiring up the key matrix\n\nI haven't learned how to design circuit boards yet, so I figured I'd just\nhandwire this [like I saw in the video][handwirevideo]. Only 18 switches, so\nhow bad could it be?\nTurns out, it's rather annoying. Interesting exercise with my terrible old\nRadio Shack soldering iron. \n\n<img class=\"inset wide left\" src=\"/uploads/2016/gamechord/matrix-wired-up.jpg\">\n\n\nI think I'd much rather get over that PCB fabrication hurdle for when I try\nscaling this up to a 60% keyboard like my HHKB.\n\nThe technique here involves first building up rows of diodes across the\nright-hand pin of every key switch. The diodes serve to prevent [ghosting when\nmultiple keys are pressed][ghosting]. \n\nThen, I stripped sections of wires to\nrun as columns down the left-hand pin of the switches. \n\nThe remaining\ninsulation ensures the column wires don't short against the row diodes.\n\n[handwirevideo]: https://www.youtube.com/watch?v=MrokZ1afnVg\n[ghosting]: https://deskthority.net/wiki/Rollover,_blocking_and_ghosting\n\n## Wiring up the Teensy\n\n<img class=\"inset wide left\" src=\"/uploads/2016/gamechord/teensy-wired-up.jpg\">\n\nThis matrix gives me 4 rows (counting the thumb switches) and 5 columns - or 9\nI/O pins to scan 18 switches.\n\nExcept for [magical PD6][pd6] - which is hardwired to an onboard LED - just\nabout every pin is fair game on the Teensy for rows or columns. \n\nSo, I tried to pick a set that would be easiest to route wires. Since this\ncase is transparent, I wanted to keep things visually interesting with\ndifferent colored wires and a neat shape to the runs.\n\nOf course, I botched things a bit and marred the acrylic by splashing\nsolder and slipping with the iron a few times. But, maybe no one will really\nnotice.\n\nIf I had to do this over again - and I *still* hadn't learned how to make a\nPCB - I'd probably try using something thinner like [30AWG repair\nwire][30awg]. That seems like it would thread through the spaces much\nbetter, which would be even more important for a board with many more\nswitches. \n\n[30awg]: https://www.adafruit.com/product/1446\n\n[pd6]: https://geekhack.org/index.php?topic=72804.0\n\n<h2 style=\"clear: both\">Programming the Teensy</h2>\n\nI based [the GameChord firmware][gamechordfirmware] on the great [tmk\nfirmware][] that seems popular on mech keyboard forums.\n\nBuilding [the matrix][] was easy: The firmware scans through rows (DF0, DF1,\nDF4, and DF5) by pulling each low in turn. The columns (DB4, DB5, DB6, DF7,\nand DF6) are set as \"active low\" pins - which means keys pressed in the\ncurrent scan row get connected to ground and read as signals. So,\nI wrote the functions to manipulate & read the appropriate row & column pins,\nrespectively. \n\nIt was almost *too* easy:\n\n<blockquote class=\"twitter-tweet\" data-lang=\"en\"><p lang=\"en\" dir=\"ltr\">Holy crap. My attempt at setting up firmware for my newly wired DIY keypad worked first time. How does this happen. <a href=\"https://t.co/xWESzku4Lp\">https://t.co/xWESzku4Lp</a></p>&mdash; Les Orchard (@lmorchard) <a href=\"https://twitter.com/lmorchard/status/746518856328372225\">June 25, 2016</a></blockquote>\n\nFrom there, I built [a dead simple key map][plainmap] with just enough\nkeys to play [Overwatch][]:\n\n```c\n#include \"keymap_common.h\"\n\nconst uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\n    KEYMAP( ESC,   1,    2,    3,    T, \\\n            TAB,   Q,    W,    E,    R, \\\n           LSFT,   A,    S,    D,    F, \\\n             NO,  NO, LCTL,  SPC,    C),\n};\nconst uint16_t PROGMEM fn_actions[] = {};\n```\n\nI got it all working and had myself a nice evening of pushing carts and taking\nobjectives.\n\n<img class=\"fullwidth\" src=\"/uploads/2016/gamechord/test-run-on-gaming-station.jpg\">\n\n[the matrix]: https://github.com/lmorchard/gamechord/blob/863295d2cbdbc7052a25e989a77c3448796e67a6/matrix.c\n[plainmap]: https://github.com/lmorchard/gamechord/blob/863295d2cbdbc7052a25e989a77c3448796e67a6/keymap_plain.c\n[gamechordfirmware]: https://github.com/lmorchard/gamechord\n[tmk firmware]: https://github.com/tmk/tmk_keyboard\n[overwatch]: https://playoverwatch.com/en-us/\n\n## Going crazy with chording\n\nI had all these [relegendable keycaps][] and this crazy flexible [tmk\nfirmware][] - so I decided to try implementing [a complex and fully impractical\nkeymap based on chords with the thumb keys][halfqwerty].\n\n[halfqwerty]: https://github.com/lmorchard/gamechord/blob/863295d2cbdbc7052a25e989a77c3448796e67a6/keymap_halfqwerty.c\n\n<img class=\"fullwidth\" src=\"/uploads/2016/gamechord/finished-key-legends.jpg\">\n\nGiven two thumb keys in combination, I can get 4 layers out of the other 15\nkeys - for a total of 60 keys. The firmware also [lets me distinguish\nbetween keys held or just tapped][taps], which gives me a few more layers or\nmodifier keys.\n\n[taps]: https://github.com/lmorchard/gamechord/blob/863295d2cbdbc7052a25e989a77c3448796e67a6/keymap_halfqwerty.c#L43\n\nLong story short, I can get most of the functionality of a regular keyboard\nout of just one hand. All I have to do is just get used to putting my left\nhand through some very awkward and uncomfortable contortions until I get up to\nfull typing speed!\n\n[As I've written before][steamcontroller], I do really like odd input devices.\nBut, this got old fast. This isn't so much a practical peripheral as a thing I\ndid because I could. It gave me an excuse to explore the firmware more\nand to use Inkscape to design some legends for my nifty keycaps.\n\n[steamcontroller]: http://blog.lmorchard.com/2016/02/05/steam-controller/\n\n## Showing it off\n\nAnd just to wrap things up, this happened:\n\n<blockquote class=\"twitter-tweet\" data-lang=\"en\"><p lang=\"en\" dir=\"ltr\">I even have a project out in the <a href=\"https://twitter.com/i3Detroit\">@i3Detroit</a> tent at <a href=\"https://twitter.com/hashtag/MakerFaireDetroit?src=hash\">#MakerFaireDetroit</a> ! <a href=\"https://t.co/v0goD3DCBk\">pic.twitter.com/v0goD3DCBk</a></p>&mdash; Les Orchard (@lmorchard) <a href=\"https://twitter.com/lmorchard/status/759400946514427904\">July 30, 2016</a></blockquote>\n\nThis was the first summer I went to [Maker Faire Detroit][] as a Maker. I\nhelped for a bit at the [i3Detroit][] tent, mainly just standing and smiling\nat the front table as folks walked in. But, I had my little keyboard out there\non a table, with a project card and everything.\n\nIt and I were only there for a handful of hours, but it's pretty satisfying to\nhave actually gotten this thing done!\n\n[maker faire detroit]: http://www.makerfairedetroit.com/\n[laservideo]: https://www.flickr.com/photos/deusx/25839524664/\n[layoutpermalink]: http://www.keyboard-layout-editor.com/##@_name=gamechord&author=lmorchard;&@=1&=2&=3&=4&=5;&@=1&=2&=3&=4&=5;&@=1&=2&=3&=4&=5;&@_r:35&rx:2.5&ry:3.5&y:-1&x:1;&=a&=b&=c\n\n<script async src=\"//platform.twitter.com/widgets.js\" charset=\"utf-8\"></script>\n<script async src=\"//embedr.flickr.com/assets/client-code.js\" charset=\"utf-8\"></script>\n\n<!-- vim: set wrap wm=5 syntax=markdown textwidth=78: -->\n",
  "parentPath": "./content/posts/archives/2016/2016-08-29-gamechord",
  "path": "2016/08/29/gamechord",
  "summary": "TL;DR: I made a USB keypad that's good for gaming and typing entirely with\none hand.",
  "needsBuild": true,
  "prevPostPath": "2016/04/17/spreadsheets-in-space",
  "prevPostTitle": "How I learned to love spreadsheets in space",
  "nextPostPath": "2016/08/31/yak-shaving-habits",
  "nextPostTitle": "On the Yak Shaving Habits of a Writer"
}