|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
#include "HIDTables.h"
|
|
|
|
|
|
|
|
#include "key_defs_keyboard.h"
|
|
|
|
#include "key_defs_sysctl.h"
|
|
|
|
#include "key_defs_consumerctl.h"
|
|
|
|
#include "key_defs_keymaps.h"
|
|
|
|
|
|
|
|
#include "key_defs_aliases.h"
|
|
|
|
|
|
|
|
#ifdef ARDUINO_VIRTUAL
|
|
|
|
#include "VirtualHID/VirtualHID.h"
|
|
|
|
#else
|
|
|
|
#include "KeyboardioHID.h"
|
|
|
|
#endif
|
|
|
|
|
Major redesign of the plugin and hooking interface
With this redesign, we introduce a new way to create plugins, which is easier to
extend with new hook points, provides a better interface, uses less memory, less
program space, and is a tiny bit faster too.
It all begins with `kaleidoscope::Plugin` being the base class, which provides
the hook methods plugins can implement. Plugins should be declared with
`KALEIDOSCOPE_INIT_PLUGINS` instead of `Kaleidoscope.use()`. Behind this macro
is a bit of magic (see the in-code documentation) that allows us to unroll the
hook method calls, avoid vtables, and so on. It creates an override for
`kaleidoscope::Hooks::*` methods, each of which will call the respective methods
of each initialized plugin.
With the new API come new names: all of the methods plugins can implement
received new, more descriptive names that all follow a similar pattern.
The old (dubbed V1) API still remains in place, although deprecated. One can
turn it off by setting the `KALEIDOSCOPE_ENABLE_V1_PLUGIN_API` define to zero,
while compiling the firmware.
This work is based on #276, written by @noseglasses. @obra and @algernon did
some cleaning up and applied a little naming treatment.
Signed-off-by: noseglasses <shinynoseglasses@gmail.com>
Signed-off-by: Jesse Vincent <jesse@keyboard.io>
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
7 years ago
|
|
|
namespace kaleidoscope {
|
|
|
|
|
Major redesign of the plugin and hooking interface
With this redesign, we introduce a new way to create plugins, which is easier to
extend with new hook points, provides a better interface, uses less memory, less
program space, and is a tiny bit faster too.
It all begins with `kaleidoscope::Plugin` being the base class, which provides
the hook methods plugins can implement. Plugins should be declared with
`KALEIDOSCOPE_INIT_PLUGINS` instead of `Kaleidoscope.use()`. Behind this macro
is a bit of magic (see the in-code documentation) that allows us to unroll the
hook method calls, avoid vtables, and so on. It creates an override for
`kaleidoscope::Hooks::*` methods, each of which will call the respective methods
of each initialized plugin.
With the new API come new names: all of the methods plugins can implement
received new, more descriptive names that all follow a similar pattern.
The old (dubbed V1) API still remains in place, although deprecated. One can
turn it off by setting the `KALEIDOSCOPE_ENABLE_V1_PLUGIN_API` define to zero,
while compiling the firmware.
This work is based on #276, written by @noseglasses. @obra and @algernon did
some cleaning up and applied a little naming treatment.
Signed-off-by: noseglasses <shinynoseglasses@gmail.com>
Signed-off-by: Jesse Vincent <jesse@keyboard.io>
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
7 years ago
|
|
|
union Key {
|
|
|
|
|
|
|
|
struct {
|
|
|
|
uint8_t keyCode;
|
|
|
|
uint8_t flags;
|
|
|
|
};
|
|
|
|
uint16_t raw;
|
|
|
|
|
|
|
|
constexpr inline bool operator==(const uint16_t rhs) const {
|
|
|
|
return this->raw == rhs;
|
|
|
|
}
|
|
|
|
constexpr inline bool operator==(const Key& rhs) const {
|
|
|
|
return this->raw == rhs.raw;
|
|
|
|
}
|
|
|
|
inline Key& operator=(const uint16_t raw) {
|
|
|
|
this->raw = raw;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
constexpr inline bool operator!=(const Key& rhs) const {
|
|
|
|
return !(*this == rhs);
|
|
|
|
}
|
|
|
|
constexpr inline bool operator>=(const uint16_t raw) const {
|
|
|
|
return this->raw >= raw;
|
|
|
|
}
|
|
|
|
constexpr inline bool operator<=(const uint16_t raw) const {
|
|
|
|
return this->raw <= raw;
|
|
|
|
}
|
|
|
|
constexpr inline bool operator>(const uint16_t raw) const {
|
|
|
|
return this->raw > raw;
|
|
|
|
}
|
|
|
|
constexpr inline bool operator<(const uint16_t raw) const {
|
|
|
|
return this->raw < raw;
|
|
|
|
}
|
|
|
|
constexpr inline bool operator>=(const Key& other) const {
|
|
|
|
return this->raw >= other.raw;
|
|
|
|
}
|
|
|
|
constexpr inline bool operator<=(const Key& other) const {
|
|
|
|
return this->raw <= other.raw;
|
|
|
|
}
|
|
|
|
constexpr inline bool operator>(const Key& other) const {
|
|
|
|
return this->raw > other.raw;
|
|
|
|
}
|
|
|
|
constexpr inline bool operator<(const Key& other) const {
|
|
|
|
return this->raw < other.raw;
|
|
|
|
}
|
Major redesign of the plugin and hooking interface
With this redesign, we introduce a new way to create plugins, which is easier to
extend with new hook points, provides a better interface, uses less memory, less
program space, and is a tiny bit faster too.
It all begins with `kaleidoscope::Plugin` being the base class, which provides
the hook methods plugins can implement. Plugins should be declared with
`KALEIDOSCOPE_INIT_PLUGINS` instead of `Kaleidoscope.use()`. Behind this macro
is a bit of magic (see the in-code documentation) that allows us to unroll the
hook method calls, avoid vtables, and so on. It creates an override for
`kaleidoscope::Hooks::*` methods, each of which will call the respective methods
of each initialized plugin.
With the new API come new names: all of the methods plugins can implement
received new, more descriptive names that all follow a similar pattern.
The old (dubbed V1) API still remains in place, although deprecated. One can
turn it off by setting the `KALEIDOSCOPE_ENABLE_V1_PLUGIN_API` define to zero,
while compiling the firmware.
This work is based on #276, written by @noseglasses. @obra and @algernon did
some cleaning up and applied a little naming treatment.
Signed-off-by: noseglasses <shinynoseglasses@gmail.com>
Signed-off-by: Jesse Vincent <jesse@keyboard.io>
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
7 years ago
|
|
|
};
|
|
|
|
|
Major redesign of the plugin and hooking interface
With this redesign, we introduce a new way to create plugins, which is easier to
extend with new hook points, provides a better interface, uses less memory, less
program space, and is a tiny bit faster too.
It all begins with `kaleidoscope::Plugin` being the base class, which provides
the hook methods plugins can implement. Plugins should be declared with
`KALEIDOSCOPE_INIT_PLUGINS` instead of `Kaleidoscope.use()`. Behind this macro
is a bit of magic (see the in-code documentation) that allows us to unroll the
hook method calls, avoid vtables, and so on. It creates an override for
`kaleidoscope::Hooks::*` methods, each of which will call the respective methods
of each initialized plugin.
With the new API come new names: all of the methods plugins can implement
received new, more descriptive names that all follow a similar pattern.
The old (dubbed V1) API still remains in place, although deprecated. One can
turn it off by setting the `KALEIDOSCOPE_ENABLE_V1_PLUGIN_API` define to zero,
while compiling the firmware.
This work is based on #276, written by @noseglasses. @obra and @algernon did
some cleaning up and applied a little naming treatment.
Signed-off-by: noseglasses <shinynoseglasses@gmail.com>
Signed-off-by: Jesse Vincent <jesse@keyboard.io>
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
7 years ago
|
|
|
} // namespace kaleidoscope
|
|
|
|
|
Major redesign of the plugin and hooking interface
With this redesign, we introduce a new way to create plugins, which is easier to
extend with new hook points, provides a better interface, uses less memory, less
program space, and is a tiny bit faster too.
It all begins with `kaleidoscope::Plugin` being the base class, which provides
the hook methods plugins can implement. Plugins should be declared with
`KALEIDOSCOPE_INIT_PLUGINS` instead of `Kaleidoscope.use()`. Behind this macro
is a bit of magic (see the in-code documentation) that allows us to unroll the
hook method calls, avoid vtables, and so on. It creates an override for
`kaleidoscope::Hooks::*` methods, each of which will call the respective methods
of each initialized plugin.
With the new API come new names: all of the methods plugins can implement
received new, more descriptive names that all follow a similar pattern.
The old (dubbed V1) API still remains in place, although deprecated. One can
turn it off by setting the `KALEIDOSCOPE_ENABLE_V1_PLUGIN_API` define to zero,
while compiling the firmware.
This work is based on #276, written by @noseglasses. @obra and @algernon did
some cleaning up and applied a little naming treatment.
Signed-off-by: noseglasses <shinynoseglasses@gmail.com>
Signed-off-by: Jesse Vincent <jesse@keyboard.io>
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
7 years ago
|
|
|
// For compatibility reasons make the Key class also available
|
|
|
|
// in global namespace.
|
|
|
|
//
|
|
|
|
typedef kaleidoscope::Key Key;
|
|
|
|
typedef kaleidoscope::Key Key_;
|
|
|
|
|
|
|
|
#define KEY_FLAGS B00000000
|
|
|
|
#define CTRL_HELD B00000001
|
|
|
|
#define LALT_HELD B00000010
|
|
|
|
#define RALT_HELD B00000100
|
|
|
|
#define SHIFT_HELD B00001000
|
|
|
|
#define GUI_HELD B00010000
|
|
|
|
#define SYNTHETIC B01000000
|
|
|
|
#define RESERVED B10000000
|
|
|
|
|
|
|
|
#define LCTRL(k) ((Key) { k.keyCode, k.flags | CTRL_HELD })
|
|
|
|
#define LALT(k) ((Key) { k.keyCode, k.flags | LALT_HELD })
|
|
|
|
#define RALT(k) ((Key) { k.keyCode, k.flags | RALT_HELD })
|
|
|
|
#define LSHIFT(k) ((Key) { k.keyCode, k.flags | SHIFT_HELD })
|
|
|
|
#define LGUI(k) ((Key) { k.keyCode, k.flags | GUI_HELD })
|
|
|
|
|
|
|
|
// we assert that synthetic keys can never have keys held, so we reuse the _HELD bits
|
|
|
|
#define IS_SYSCTL B00000001
|
|
|
|
#define IS_INTERNAL B00000010
|
|
|
|
#define SWITCH_TO_KEYMAP B00000100
|
|
|
|
#define IS_CONSUMER B00001000
|
|
|
|
|
|
|
|
/* HID types we need to encode in the key flags for system and consumer control hid controls
|
|
|
|
Each key can only have one, so we don't need to use a bit vector.
|
|
|
|
We need to keep the top two bits clear for defining the keys as synthetic
|
|
|
|
We need to keep the bottom two bits clear for defining the keys as sysctl / consumerctl
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define HID_TYPE_CL B00000000
|
|
|
|
#define HID_TYPE_LC B00000100
|
|
|
|
#define HID_TYPE_NARY B00001000
|
|
|
|
#define HID_TYPE_OOC B00001100
|
|
|
|
#define HID_TYPE_OSC B00010000
|
|
|
|
#define HID_TYPE_RTC B00010100
|
|
|
|
#define HID_TYPE_SEL B00011000
|
|
|
|
|
|
|
|
|
|
|
|
#define Key_NoKey (Key) { 0, KEY_FLAGS }
|
|
|
|
#define Key_skip (Key) { 0, KEY_FLAGS }
|
|
|
|
#define Key_Transparent (Key){ .raw = 0xffff }
|
|
|
|
#define ___ Key_Transparent
|
|
|
|
#define XXX Key_NoKey
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define KEY_BACKLIGHT_DOWN 0xF1
|
|
|
|
#define KEY_BACKLIGHT_UP 0xF2
|
|
|
|
#define Key_BacklightDown (Key) { KEY_BACKLIGHT_DOWN, KEY_FLAGS }
|
|
|
|
#define Key_BacklightUp (Key) { KEY_BACKLIGHT_UP, KEY_FLAGS }
|
|
|
|
#define KEY_RIGHT_FN2 0xfe
|
|
|
|
#define Key_RFN2 (Key) { KEY_RIGHT_FN2, KEY_FLAGS }
|
|
|
|
#define KEY_LEFT_FN2 0xff
|
|
|
|
#define Key_LFN2 (Key) { KEY_LEFT_FN2, KEY_FLAGS }
|
|
|
|
|
|
|
|
|
|
|
|
/* Most Consumer keys are more then 8bit, the highest Consumer hid code
|
|
|
|
uses 10bit. By using the 11bit as flag to indicate a consumer keys was activate we can
|
|
|
|
use the 10 lsb as the HID Consumer code. If you need to get the keycode of a Consumer key
|
|
|
|
use the CONSUMER(key) macro this will return the 10bit keycode.
|
|
|
|
*/
|
|
|
|
#define CONSUMER(key) (key.raw & 0x03FF)
|
|
|
|
#define CONSUMER_KEY(code, flags) (Key) { .raw = (code) | ((flags | SYNTHETIC|IS_CONSUMER) << 8) }
|