Refine keyboard handling lightly
This commit is contained in:
parent
8c8b4fd831
commit
741793c298
|
@ -59,6 +59,13 @@ BBQ10Keyboard keyboard;
|
|||
#define KBD_SW_RT 0x04
|
||||
#define KBD_SW_OK 0x05
|
||||
|
||||
// Upstream keyboard definitions that will be really important later
|
||||
#define _REG_CFG 2
|
||||
#define CFG_OVERFLOW_INT (1 << 1)
|
||||
#define CFG_KEY_INT (1 << 4)
|
||||
#define CFG_USE_MODS (1 << 7) // Should Alt, Sym and Shifts modify the keys reported
|
||||
#define CFG_REPORT_MODS (1 << 6) // Should Alt, Sym and Shifts be reported as well
|
||||
|
||||
// NeoPixels
|
||||
#define PIXELS_NUM_BOARD 1
|
||||
#define PIXELS_NUM_WING 1
|
||||
|
@ -133,6 +140,8 @@ void setup() {
|
|||
// Setup BBQ10Keyboard
|
||||
Wire.begin();
|
||||
keyboard.begin();
|
||||
keyboard.writeRegister(_REG_CFG, CFG_OVERFLOW_INT | CFG_KEY_INT | CFG_USE_MODS | CFG_REPORT_MODS);
|
||||
|
||||
keyboard.setBacklight(0.5f);
|
||||
|
||||
// GUI Slice (TFT is setup through GUI Slice)
|
||||
|
@ -172,8 +181,13 @@ void processRingBuffer() {
|
|||
|
||||
// Keyboard handler
|
||||
void handlerKeyboard() {
|
||||
// Check if keys were pressed
|
||||
if (keyboard.keyCount()) {
|
||||
// Don't do anything if there are no key presses to process
|
||||
if (keyboard.keyCount() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if keys were pressed and drain queue of pressed keys
|
||||
while (keyboard.keyCount() > 0) {
|
||||
// Get keyboard event
|
||||
const BBQ10Keyboard::KeyEvent key = keyboard.keyEvent();
|
||||
|
||||
|
|
Reference in a new issue