Switch to less insane keycodes for plover-hid

The original plover-hid tried to reuse the keycodes from the GeminiPR protocol
and had pretty weird key ordering, making the unnecessarily hard to
implement.

Switch to sequential numbering of all standard steno keys, and then add
the extra keys after those.

The ordering is the same as the ordering used by the TXBolt protocol.
This commit is contained in:
dnaq 2022-06-15 20:55:31 +02:00
parent 41c301542d
commit 7886fa3f17
2 changed files with 32 additions and 23 deletions

View file

@ -90,20 +90,16 @@ as mouse-button pressed over BLE, while it didn't do so over USB. Even though th
to change the usage to one where that doesn't happen.
## The keys
For historical reasons we reuse most of the key names from the GeminiPR protocol, but we add extra keys so that we reach 64 keys in total.
The keys are as follows, and the bit/byte position in the reports map to the following keys in order (left-to-right):
```
#1 #2 #3 #4 #5 #6 #7 #8 #9 #A #B #C
X1 S1- T- P- H- *1 *3 -F -P -L -T -D
X2 S2- K- W- R- *2 *4 -R -B -G -S -Z
X3 A- O- -E -U X4
For historical reasons we reuse the names of the standard steno keys, but we add extra keys so that we reach 64 keys in total.
The keys are ordered as follows:
X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15
X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26
```
S- T- K- P- W- H- R- A- O- * -E -U -F -R -P -B -L -G -T -S -D -Z #
```
and are then followed by key `X1-X26`
So the first bit/byte of the report (after the report type byte) maps to key
`#1` and the last bit/byte of the report maps to `X26`.
`S-` and the last bit/byte of the report maps to `X26`.
## Sample Firmware
@ -111,7 +107,7 @@ Sample firmware for the georgi is included in this repository. It defines a defa
```
X1 S1- T- P- H- *1 *3 -F -P -L -T -D
X2 S2- K- W- R- *2 *4 -R -B -G -S -Z
#1 A O E U #7
# A O E U #
```
Sample firmware for the uni (both the pro micro and the usb-c versions) are also included. The keymap is the same as above

View file

@ -28,18 +28,31 @@ SIMPLE_REPORT_LEN: int = N_LEVERS // 8
class InvalidReport(Exception):
pass
STENO_KEY_CHART = ("S-", "T-", "K-", "P-", "W-", "H-",
"R-", "A-", "O-", "*", "-E", "-U",
"-F", "-R", "-P", "-B", "-L", "-G",
"-T", "-S", "-D", "-Z", "#",
"X1", "X2", "X3", "X4", "X5", "X6",
"X7", "X8", "X9", "X10", "X11", "X12",
"X13", "X14", "X15", "X16", "X17", "X18",
"X19", "X20", "X21", "X22", "X23", "X24",
"X25", "X26", "X27", "X28", "X29", "X30",
"X31", "X32", "X33", "X34", "X35", "X36",
"X37", "X38", "X39", "X40", "X41")
print('steno key chart', len(STENO_KEY_CHART))
class HidMachine(ThreadedStenotypeBase):
KEYS_LAYOUT: str = """
#1 #2 #3 #4 #5 #6 #7 #8 #9 #A #B #C
X1 S1- T- P- H- *1 *3 -F -P -L -T -D
X2 S2- K- W- R- *2 *4 -R -B -G -S -Z
X3 A- O- -E -U X4
X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15
X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26
"""
STENO_KEY_MAP: [str] = KEYS_LAYOUT.split()
KEYS_LAYOUT: str = '''
# # # # # # # # # #
S- T- P- H- * -F -P -L -T -D
S- K- W- R- * -R -B -G -S -Z
A- O- -E -U
X1 X2 X3 X4 X5 X6 X7 X8 X9 X10
X11 X12 X13 X14 X15 X16 X17 X18 X19 X20
X21 X22 X23 X24 X25 X26 X27 X28 X29 X30
X31 X32 X33 X34 X35 X36 X37 X38 X39 X40
X41
'''
def __init__(self, params):
super().__init__()
self._params = params
@ -73,7 +86,7 @@ class HidMachine(ThreadedStenotypeBase):
keystate |= report
if not report:
steno_actions = self.keymap.keys_to_actions(
[self.STENO_KEY_MAP[i] for (i, x) in enumerate(keystate) if x]
[STENO_KEY_CHART[i] for (i, x) in enumerate(keystate) if x]
)
if steno_actions:
self._notify(steno_actions)