I've updated the code on github to include the state machine and some plugins I promised in the last post. I wrote it back then but, once again, didn't have time to post about it until now. There is an example plugin that simply activates a new state after a couple seconds, but the interesting stuff is in the OS and Chrome plugins.
The OS plugin handles using the joystick as a mouse and G17/G18 for left and right clicks. Because it targets the default state, if another plugin pushes a state that registers for the plugin, that plugin can essentially supersede the use of the joystick. So if you created a plugin that needed the joystick in certain cases, such as a plugin for the Terminal that doesn't need a mouse but wants to scroll through the history, that plugin can do so and give back the joystick to the OS plugin when the user is not interacting with the Terminal program anymore.
The Chrome plugin is the much more complicated one since it handles 14 button presses and 4 releases. The top 7 G1-G7 go to tabs 1-7 using Chrome's Ctrl-# shortcuts, G14 goes to the last tab (Ctrl-9). Using the bottom three keys (G20-G22), going one tab left/right and closing the current tab are done through quick movements using the top of the palm. Hitting G20 or G22 shift tabs left or right, while hitting G20-G22 together closes the current tab. If holding the Left-of-joystick key, then hitting G20-G22 actually opens the last closed tab, essentially reversing their normal action by entering a new reversing state.