Currently I am working on a Python based keyboard simulator. I already ran simulations based on C++ and python implementations of plugins.
An important feature that I am now working on is a graphical display of the current state of the keyboard with RGB colored keys showing the current keys depending on the layer that is currently active. Imagine this as if the real keyboard had tiny LCD displays on each key, that display the current meaning of the key.
As the simulator works cycled, it is very easy to experiment with a new plugin and see how things change when keys are hit or if time elapses.
To enable this graphical display, I need to map the information stored in the Key
union taken from the layer data structure back to a string. This means to map e.g. the Key
generated via ShiftToLayer(FUNCTION)
in the sketchβs keymap definition back to a string that is as closed as possible to the actual string ShiftToLayer(FUNCTION)
.
Has anyone of the developers already attempted something similar?
Of course, the information is all there in the sketch and I could possibly replace the KEYMAP_STACKED
with something funny that generates a string array under the hood. But I would like to find a way to enable this without requiring the user to change her/his sketch and without fiddling with macros.
KEYMAP_STACKED
(___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab,
Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G,
Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
ShiftToLayer(FUNCTION),
M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD),
Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals,
Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote,
Key_RightAlt, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl,
ShiftToLayer(FUNCTION)),
Any ideas/help appreciated.
Hereβs a link to the Python wrapper API and a little teaser from my current work (see below).
self.out.write(u"ββββββ³βββββ³βββββ³βββββ³βββββ³βββββ³βββββ ββββββ³βββββ³βββββ³βββββ³βββββ³βββββ³βββββ\n".format(r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, r0c9, r0c10, r0c11, r0c12, r0c13, r0c14, r0c15))
self.out.write(u"β{ 0}β{ 1}β{ 2}β{ 3}β{ 4}β{ 5}β{ 6}β β{ 7}β{ 8}β{ 9}β{10}β{11}β{12}β{13}β\n")
self.out.write(u"β£ββββββββββββββββββββββββββββββ« β β β£ββββββββββββββββββββββββββββββ«\n")
self.out.write(u"β{ 0}β{ 1}β{ 2}β{ 3}β{ 4}β{ 5}β£βββββ« β£βββββ«{ 6}β{ 7}β{ 8}β{ 9}β{10}β{11}β\n".format(r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, r1c10, r1c11, r1c12, r1c13, r1c14, r1c15))
self.out.write(u"β£ββββββββββββββββββββββββββββββ« β β β£ββββββββββββββββββββββββββββββ«\n")
self.out.write(u"β{ 0}β{ 1}β{ 2}β{ 3}β{ 4}β{ 5}β{ 6}β β{ 7}β{ 8}β{ 9}β{10}β{11}β{12}β{13}β\n".format(r2c0, r2c1, r2c2, r2c3, r2c4, r2c5, r1c6, r1c9, r2c10, r2c11, r2c12, r2c13, r2c14, r2c15))
self.out.write(u"β£βββββββββββββββββββββββββββββββββββ« β£βββββββββββββββββββββββββββββββββββ«\n")
self.out.write(u"β{ 0}β{ 1}β{ 2}β{ 3}β{ 4}β{ 5}β{ 6}β β{ 7}β{ 8}β{ 9}β{10}β{11}β{12}β{13}β\n".format(r3c0, r3c1, r3c2, r3c3, r3c4, r3c5, r2c6, r2c9, r3c10, r3c11, r3c12, r3c13, r3c14, r3c15))
self.out.write(u"ββββββ»βββββ»βββββ»βββββ»βββββ»βββββ»βββββ ββββββ»βββββ»βββββ»βββββ»βββββ»βββββ»βββββ\n")
self.out.write(u" ββββββ ββββββ \n")
self.out.write(u" β{ 0}β£βββββ ββββββ«{ 1}β \n".format(r0c7, r0c8))
self.out.write(u" ββββββ«{ 0}β£βββββ ββββββ«{ 1}β£βββββ \n".format(r1c7, r1c8))
self.out.write(u" ββββββ«{ 0}β£βββββ ββββββ«{ 1}β£βββββ \n".format(r2c7, r2c8))
self.out.write(u" ββββββ«{ 0}β β{ 1}β£βββββ \n".format(r3c7, r3c8))
self.out.write(u" ββββββ ββββββ \n")
self.out.write(u" ββββββββ ββββββββ \n")
self.out.write(u" β { 0} β β { 1} β \n".format(r3c6, r3c9))
self.out.write(u" ββββββββ ββββββββ \n")