Move our hid facade into kaleidoscope::hid

pull/144/merge
Jesse Vincent 7 years ago
parent c9734385c5
commit 7e73341772
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -0,0 +1,142 @@
#include "Kaleidoscope.h"
namespace kaleidoscope::hid {
void initializeKeyboard() {
Keyboard.begin();
}
void pressRawKey(Key mappedKey) {
Keyboard.press(mappedKey.keyCode);
}
void pressKey(Key mappedKey) {
if (mappedKey.flags & SHIFT_HELD) {
pressRawKey(Key_LeftShift);
}
if (mappedKey.flags & CTRL_HELD) {
pressRawKey(Key_LeftControl);
}
if (mappedKey.flags & LALT_HELD) {
pressRawKey(Key_LeftAlt);
}
if (mappedKey.flags & RALT_HELD) {
pressRawKey(Key_RightAlt);
}
if (mappedKey.flags & GUI_HELD) {
pressRawKey(Key_LeftGui);
}
pressRawKey(mappedKey);
}
void releaseRawKey(Key mappedKey) {
Keyboard.release(mappedKey.keyCode);
}
void releaseAllKeys() {
Keyboard.releaseAll();
}
void releaseKey(Key mappedKey) {
if (mappedKey.flags & SHIFT_HELD) {
releaseRawKey(Key_LeftShift);
}
if (mappedKey.flags & CTRL_HELD) {
releaseRawKey(Key_LeftControl);
}
if (mappedKey.flags & LALT_HELD) {
releaseRawKey(Key_LeftAlt);
}
if (mappedKey.flags & RALT_HELD) {
releaseRawKey(Key_RightAlt);
}
if (mappedKey.flags & GUI_HELD) {
releaseRawKey(Key_LeftGui);
}
releaseRawKey(mappedKey);
}
boolean isModifierKeyActive(Key mappedKey) {
return Keyboard.isModifierActive(mappedKey.keyCode);
}
void sendKeyboardReport() {
Keyboard.sendReport();
}
void initializeConsumerControl() {
ConsumerControl.begin();
}
void pressConsumerControl(Key mappedKey) {
ConsumerControl.press(mappedKey.keyCode);
}
void releaseConsumerControl(Key mappedKey) {
ConsumerControl.release(mappedKey.keyCode);
}
void initializeSystemControl() {
SystemControl.begin();
}
void pressSystemControl(Key mappedKey) {
SystemControl.press(mappedKey.keyCode);
}
void releaseSystemControl(Key mappedKey) {
SystemControl.release();
}
// Mouse events
void initializeMouse() {
Mouse.begin();
}
void moveMouse(signed char x, signed char y, signed char wheel) {
Mouse.move(x, y, wheel);
}
void clickMouseButtons(uint8_t buttons) {
Mouse.click(buttons);
}
void pressMouseButtons(uint8_t buttons) {
Mouse.press(buttons);
}
void releaseMouseButtons(uint8_t buttons) {
Mouse.release(buttons);
}
/** Absolute mouse (grapahics tablet) events */
void initializeAbsoluteMouse() {
AbsoluteMouse.begin();
}
void moveAbsoluteMouse(signed char x, signed char y, signed char wheel) {
AbsoluteMouse.move(x, y, wheel);
}
void moveAbsoluteMouseTo(uint16_t x, uint16_t y, signed char wheel) {
AbsoluteMouse.moveTo(x, y, wheel);
}
void clickAbsoluteMouseButtons(uint8_t buttons) {
AbsoluteMouse.click(buttons);
}
void pressAbsoluteMouseButtons(uint8_t buttons) {
AbsoluteMouse.press(buttons);
}
void releaseAbsoluteMouseButtons(uint8_t buttons) {
AbsoluteMouse.release(buttons);
}
};

@ -0,0 +1,45 @@
#pragma once
#include <Arduino.h>
namespace kaleidoscope::hid {
// A facade on top of our HID implementation
void initializeKeyboard();
void pressKey(Key mappedKey);
void releaseKey(Key mappedKey);
void releaseAllKeys();
void pressRawKey(Key mappedKey);
void releaseRawKey(Key mappedKey);
/** Flushes any pending regular key switch events and sends them out */
void sendKeyboardReport();
boolean isModifierKeyActive(Key mappedKey);
void initializeConsumerControl();
void pressConsumerControl(Key mappedKey);
void releaseConsumerControl(Key mappedKey);
void initializeSystemControl();
void pressSystemControl(Key mappedKey);
void releaseSystemControl(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);
void pressAbsoluteMouseButtons(uint8_t buttons);
void releaseAbsoluteMouseButtons(uint8_t buttons);
};

@ -58,142 +58,3 @@ void handleKeyswitchEvent(Key mappedKey, byte row, byte col, uint8_t keyState) {
return;
handleKeyswitchEventDefault(mappedKey, row, col, keyState);
}
void initializeKeyboard() {
Keyboard.begin();
}
void pressRawKey(Key mappedKey) {
Keyboard.press(mappedKey.keyCode);
}
void pressKey(Key mappedKey) {
if (mappedKey.flags & SHIFT_HELD) {
pressRawKey(Key_LeftShift);
}
if (mappedKey.flags & CTRL_HELD) {
pressRawKey(Key_LeftControl);
}
if (mappedKey.flags & LALT_HELD) {
pressRawKey(Key_LeftAlt);
}
if (mappedKey.flags & RALT_HELD) {
pressRawKey(Key_RightAlt);
}
if (mappedKey.flags & GUI_HELD) {
pressRawKey(Key_LeftGui);
}
pressRawKey(mappedKey);
}
void releaseRawKey(Key mappedKey) {
Keyboard.release(mappedKey.keyCode);
}
void releaseAllKeys() {
Keyboard.releaseAll();
}
void releaseKey(Key mappedKey) {
if (mappedKey.flags & SHIFT_HELD) {
releaseRawKey(Key_LeftShift);
}
if (mappedKey.flags & CTRL_HELD) {
releaseRawKey(Key_LeftControl);
}
if (mappedKey.flags & LALT_HELD) {
releaseRawKey(Key_LeftAlt);
}
if (mappedKey.flags & RALT_HELD) {
releaseRawKey(Key_RightAlt);
}
if (mappedKey.flags & GUI_HELD) {
releaseRawKey(Key_LeftGui);
}
releaseRawKey(mappedKey);
}
boolean isModifierKeyActive(Key mappedKey) {
return Keyboard.isModifierActive(mappedKey.keyCode);
}
void sendKeyboardReport() {
Keyboard.sendReport();
}
void initializeConsumerControl() {
ConsumerControl.begin();
}
void pressConsumerControl(Key mappedKey) {
ConsumerControl.press(mappedKey.keyCode);
}
void releaseConsumerControl(Key mappedKey) {
ConsumerControl.release(mappedKey.keyCode);
}
void initializeSystemControl() {
SystemControl.begin();
}
void pressSystemControl(Key mappedKey) {
SystemControl.press(mappedKey.keyCode);
}
void releaseSystemControl(Key mappedKey) {
SystemControl.release();
}
// Mouse events
void initializeMouse() {
Mouse.begin();
}
void moveMouse(signed char x, signed char y, signed char wheel) {
Mouse.move(x, y, wheel);
}
void clickMouseButtons(uint8_t buttons) {
Mouse.click(buttons);
}
void pressMouseButtons(uint8_t buttons) {
Mouse.press(buttons);
}
void releaseMouseButtons(uint8_t buttons) {
Mouse.release(buttons);
}
/** Absolute mouse (grapahics tablet) events */
void initializeAbsoluteMouse() {
AbsoluteMouse.begin();
}
void moveAbsoluteMouse(signed char x, signed char y, signed char wheel) {
AbsoluteMouse.move(x, y, wheel);
}
void moveAbsoluteMouseTo(uint16_t x, uint16_t y, signed char wheel) {
AbsoluteMouse.moveTo(x, y, wheel);
}
void clickAbsoluteMouseButtons(uint8_t buttons) {
AbsoluteMouse.click(buttons);
}
void pressAbsoluteMouseButtons(uint8_t buttons) {
AbsoluteMouse.press(buttons);
}
void releaseAbsoluteMouseButtons(uint8_t buttons) {
AbsoluteMouse.release(buttons);
}

@ -43,44 +43,3 @@ extern const Key keymaps[][ROWS][COLS];
*/
void handleKeyswitchEvent(Key mappedKey, byte row, byte col, uint8_t keyState);
// A facade on top of our HID implementation
void initializeKeyboard();
void pressKey(Key mappedKey);
void releaseKey(Key mappedKey);
void releaseAllKeys();
void pressRawKey(Key mappedKey);
void releaseRawKey(Key mappedKey);
/** Flushes any pending regular key switch events and sends them out */
void sendKeyboardReport();
boolean isModifierKeyActive(Key mappedKey);
void initializeConsumerControl();
void pressConsumerControl(Key mappedKey);
void releaseConsumerControl(Key mappedKey);
void initializeSystemControl();
void pressSystemControl(Key mappedKey);
void releaseSystemControl(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);
void pressAbsoluteMouseButtons(uint8_t buttons);
void releaseAbsoluteMouseButtons(uint8_t buttons);

Loading…
Cancel
Save