bbq10kbd_i2c_sw
bbq10kbd_i2c_sw copied to clipboard
Shift key indistinguishable
I use the keyboard on the Keyboard FeatherWing with Circuit Python.
I wanted to know when the ALT key is pressed (and maybe other key like left shift, right shift and SYM) so that it can act as a keyboard and be used as a USB HID.
The problem is that to use as a real keyboard, I would need to be able to do CTRL+C and CTRL+D (and maybe a few other).
So I added the folowing missing constant:
CFG_REPORT_MODS = const(1 << 6)
CFG_USE_MODS = const(1 << 7)
And enhanced the init to set the register to the default value + CFG_REPORT_MODS (notice that reset is done first, then the config register is modified):
self.reset()
with self._i2c as i2c:
self._buffer[0] = _REG_CFG | _WRITE_MASK
self._buffer[1] = CFG_OVERFLOW_INT | CFG_KEY_INT | CFG_USE_MODS | CFG_REPORT_MODS
i2c.write(self._buffer, end=2)
The problem is that "left shift" and "right shift" are indistinguishable at the software level. I hope they are distinguishable at the hardware level and the software could be fix. One shift key could be used as a CTRL replacement or something like that.
Can this be fixed?
Yes, the code that sends the mod values can be found here: https://github.com/arturo182/bbq10kbd_i2c_sw/blob/master/app/keyboard.c#L93
As you can see the MOD_SHL
and MOD_SHR
(Shift Left and Shift Right) send the same value, this switch statement could be modified to send a different value depending on which shift it is.