From 02695b8cea4b74f2341bef5d4d6cf9e158795087 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 24 Jul 2017 22:57:36 -0700 Subject: [PATCH] Add a facde for KeyboardioHID's *.begin() --- src/key_events.cpp | 23 ++++++++++++++++++++++- src/key_events.h | 16 ++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/key_events.cpp b/src/key_events.cpp index 8e740337..30bb1193 100644 --- a/src/key_events.cpp +++ b/src/key_events.cpp @@ -59,6 +59,11 @@ void handleKeyswitchEvent(Key mappedKey, byte row, byte col, uint8_t keyState) { handleKeyswitchEventDefault(mappedKey, row, col, keyState); } + +void initializeKeyboard() { + Keyboard.begin(); +} + void pressKeyRaw(Key mappedKey) { Keyboard.press(mappedKey.keyCode); @@ -114,11 +119,14 @@ void releaseKey(Key mappedKey) { - void sendKeyboardReport() { Keyboard.sendReport(); } +void initializeConsumerControl() { + ConsumerControl.begin(); +} + void pressConsumer(Key mappedKey) { ConsumerControl.press(mappedKey.keyCode); } @@ -127,6 +135,11 @@ void releaseConsumer(Key mappedKey) { ConsumerControl.release(mappedKey.keyCode); } + +void initializeSystemControl() { + SystemControl.begin(); +} + void pressSystem(Key mappedKey) { SystemControl.press(mappedKey.keyCode); } @@ -140,6 +153,10 @@ void releaseSystem(Key mappedKey) { * See above for commentary on connectionMask. */ +void initializeMouse() { + Mouse.begin(); +} + void moveMouse(signed char x, signed char y, signed char wheel) { Mouse.move(x, y, wheel); } @@ -159,6 +176,10 @@ void releaseMouseButtons(uint8_t buttons) { /** Absolute mouse (grapahics tablet) events * See above for commentary on connectionMask. */ +void initializeAbsoluteMouse() { + AbsoluteMouse.begin(); +} + void moveAbsoluteMouse(signed char x, signed char y, signed char wheel) { AbsoluteMouse.move(x, y, wheel); } diff --git a/src/key_events.h b/src/key_events.h index 7b153495..a73a2bbb 100644 --- a/src/key_events.h +++ b/src/key_events.h @@ -43,26 +43,38 @@ extern const Key keymaps[][ROWS][COLS]; */ void handleKeyswitchEvent(Key mappedKey, byte row, byte col, uint8_t keyState); -/** Flushes any pending regular key switch events and sends them out */ -void sendKeyboardReport(); // A facade on top of our HID implementation + +void initializeKeyboard(); + void pressKey(Key mappedKey); void releaseKey(Key mappedKey); void releaseAllKeys(); void pressKeyRaw(Key mappedKey); void releaseKeyRaw(Key mappedKey); +/** Flushes any pending regular key switch events and sends them out */ +void sendKeyboardReport(); + +void initializeConsumerControl(); void pressConsumer(Key mappedKey); void releaseConsumer(Key mappedKey); +void initializeSystemControl(); + void pressSystem(Key mappedKey); void releaseSystem(Key mappedKey); +void initializeMouse(); + void moveMouse(signed char x, signed char y, signed char wheel); void clickMouseButtons(uint8_t buttons); void pressMouseButtons(uint8_t buttons); void releaseMouseButtons(uint8_t buttons); + +void initializeAbsoluteMouse(); + void moveAbsoluteMouse(signed char x, signed char y, signed char wheel); void moveAbsoluteMouseTo(uint16_t x, uint16_t y, signed char wheel); void clickAbsoluteMouseButtons(uint8_t buttons);