benblazak/ergodox-firmware — pull request #41 by nacitar (2014-03-28 00:11:50+00:00)
Title: Fixed media key support, cleaning, and added a workman-p layout

Media keys work perfectly now!

I fixed a bug where media keys were being apparently spammed. I noticed that they worked once, then stopped. I opened foobar2000's hotkeys and tried to set one up, and it kept acting like I was spamming the media key. I looked at TMK's firmware and found that they store the last consumer key and avoid re-sending it. That change fixed the issue.

I finished adding support for volume up, volume down, mute, and the "stop" button. I however did not add any shorter _volUp alias or the sort for any of them; just the MEDIAKEY_* names.

Also, I implemented Workman-P (a #define can make it normal workman, too), with its shifted number-row as well as can be done in this firmware without making changes to the reporting in main.c. It works flawlessly, shifting the keys as expected... swapping so the "1_!" key for example to ! without shift and 1 with shift, handling cases where you press and hold 1 then hit a normal (non-inverted) key.

The only case where this approach fails is if you press a non-inverted key and an inverted one (the number row) at the _same time_ such that they will be sent in the same update by usb_keyboard_send(). This happens because an attempt is made to shift a key such as '1' to make a '!', so the shift modifier is applied, but in the same update the normal key is added to the 6-entry keydown list. Thus, both become shifted. The only way I can think of resolving this would be breaking up inverted and non-inverted keys into two updates or something similar, but that goes outside the realm of making the inverted keys purely a feature that lives within the layout file, and into modifying a core firmware component. I may decide to tinker with that in a branch of my own, but not in anything official.

That said, cleaning is fixed, a big media key bug is fixed, and a near-perfectly functioning workman-p that others could use as a basis for their own layouts is there. The layout is as perfect as I suspect one can make it with the current firmware design.

At minimum, the media key bug fix is worth pulling.