Compare commits
44 Commits
main
...
wip/rcm-st
Author | SHA1 | Date |
---|---|---|
Gergely Nagy | 9b6d659542 | 3 years ago |
Gergely Nagy | e77ff67486 | 3 years ago |
Jesse Vincent | f6a0489094 | 3 years ago |
Gergely Nagy | 7e6ed71583 | 3 years ago |
Gergely Nagy | 8292a2d92f | 3 years ago |
Jesse Vincent | e1514a0bc5 | 3 years ago |
Jesse Vincent | 746726d105 | 3 years ago |
Jesse Vincent | 7346b6a6b4 | 3 years ago |
Gergely Nagy | ba53073cf1 | 3 years ago |
Gergely Nagy | 45545c2358 | 3 years ago |
Gergely Nagy | 1bb8d4b49d | 3 years ago |
Gergely Nagy | d60784e6cf | 3 years ago |
Gergely Nagy | 1fafd8b5bb | 3 years ago |
Gergely Nagy | fe91906163 | 3 years ago |
Gergely Nagy | c01d5a45d8 | 3 years ago |
Gergely Nagy | 785cb841fe | 3 years ago |
Gergely Nagy | c28eea03f3 | 3 years ago |
Jesse Vincent | 9d9b16dc93 | 3 years ago |
Jesse Vincent | b44edf476b | 3 years ago |
Jesse Vincent | 40e40cd868 | 3 years ago |
Jesse Vincent | fedcd25d61 | 3 years ago |
Jesse Vincent | 41fad82e41 | 3 years ago |
Jesse Vincent | b2899f970b | 3 years ago |
Jesse Vincent | 9af4e121b2 | 3 years ago |
Jesse Vincent | d84918280b | 3 years ago |
Jesse Vincent | c6eb7529ca | 3 years ago |
Jesse Vincent | ff1cacad51 | 3 years ago |
Jesse Vincent | 968c71abc3 | 3 years ago |
Jesse Vincent | 80996ee9cc | 3 years ago |
Jesse Vincent | 059d4c9e39 | 3 years ago |
Jesse Vincent | f3a604dfe1 | 3 years ago |
Jesse Vincent | 0e3425297a | 3 years ago |
Jesse Vincent | 414f9d3297 | 3 years ago |
Jesse Vincent | b73f6a7eeb | 3 years ago |
Jesse Vincent | 608889818c | 3 years ago |
Jesse Vincent | ebc230cb96 | 3 years ago |
Jesse Vincent | f827c5506e | 3 years ago |
Jesse Vincent | 7a2de238c4 | 3 years ago |
Jesse Vincent | a021528b04 | 3 years ago |
Jesse Vincent | 303d4b7e3f | 3 years ago |
Jesse Vincent | 71e461966f | 3 years ago |
Jesse Vincent | c329a6dfe0 | 3 years ago |
Jesse Vincent | 0d23db0741 | 3 years ago |
Jesse Vincent | 2514b216fa | 3 years ago |
@ -0,0 +1,48 @@
|
|||||||
|
# This makefile for a Kaleidoscope sketch pulls in all the targets
|
||||||
|
# required to build the example
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ifneq ($(KALEIDOSCOPE_DIR),)
|
||||||
|
search_path += $(KALEIDOSCOPE_DIR)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(ARDUINO_DIRECTORIES_USER),)
|
||||||
|
search_path += $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(shell uname -s),Darwin)
|
||||||
|
search_path += $(HOME)/Documents/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope
|
||||||
|
else
|
||||||
|
search_path += $(HOME)/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope
|
||||||
|
endif
|
||||||
|
|
||||||
|
sketch_makefile := etc/makefiles/sketch.mk
|
||||||
|
|
||||||
|
$(foreach candidate, $(search_path), $(if $(wildcard $(candidate)/$(sketch_makefile)), $(eval ks_dir ?= $(candidate))))
|
||||||
|
|
||||||
|
ifneq ($(ks_dir),)
|
||||||
|
|
||||||
|
$(info Using Kaleidoscope from $(ks_dir))
|
||||||
|
|
||||||
|
export KALEIDOSCOPE_DIR := $(ks_dir)
|
||||||
|
include $(ks_dir)/$(sketch_makefile)
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
$(info I can't find your Kaleidoscope installation.)
|
||||||
|
$(info )
|
||||||
|
$(info I tried looking in:)
|
||||||
|
$(info )
|
||||||
|
$(foreach candidate, $(search_path), $(info $(candidate)))
|
||||||
|
$(info )
|
||||||
|
$(info The easiest way to fix this is to set the 'KALEIDOSCOPE_DIR' environment)
|
||||||
|
$(info variable to the location of your Kaleidoscope directory.)
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
null-target:
|
||||||
|
$(info You should never see this message)
|
||||||
|
@:
|
@ -0,0 +1,571 @@
|
|||||||
|
// -*- mode: c++ -*-
|
||||||
|
// Copyright 2016 Keyboardio, inc. <jesse@keyboard.io>
|
||||||
|
// See "LICENSE" for license details
|
||||||
|
|
||||||
|
#ifndef BUILD_INFORMATION
|
||||||
|
#define BUILD_INFORMATION "locally built on " __DATE__ " at " __TIME__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These #include directives pull in the Kaleidoscope firmware core,
|
||||||
|
* as well as the Kaleidoscope plugins we use in the Model 01's firmware
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// The Kaleidoscope core
|
||||||
|
#include "Kaleidoscope.h"
|
||||||
|
|
||||||
|
// Support for storing the keymap in EEPROM
|
||||||
|
//#include "Kaleidoscope-EEPROM-Settings.h"
|
||||||
|
//#include "Kaleidoscope-EEPROM-Keymap.h"
|
||||||
|
|
||||||
|
// Support for communicating with the host via a simple Serial protocol
|
||||||
|
//#include "Kaleidoscope-FocusSerial.h"
|
||||||
|
|
||||||
|
// Support for keys that move the mouse
|
||||||
|
#include "Kaleidoscope-MouseKeys.h"
|
||||||
|
|
||||||
|
// Support for macros
|
||||||
|
#include "Kaleidoscope-Macros.h"
|
||||||
|
|
||||||
|
// Support for controlling the keyboard's LEDs
|
||||||
|
#include "Kaleidoscope-LEDControl.h"
|
||||||
|
|
||||||
|
// Support for "Numpad" mode, which is mostly just the Numpad specific LED mode
|
||||||
|
#include "Kaleidoscope-NumPad.h"
|
||||||
|
|
||||||
|
// Support for the "Boot greeting" effect, which pulses the 'LED' button for 10s
|
||||||
|
// when the keyboard is connected to a computer (or that computer is powered on)
|
||||||
|
#include "Kaleidoscope-LEDEffect-BootGreeting.h"
|
||||||
|
|
||||||
|
// Support for LED modes that set all LEDs to a single color
|
||||||
|
#include "Kaleidoscope-LEDEffect-SolidColor.h"
|
||||||
|
|
||||||
|
// Support for an LED mode that makes all the LEDs 'breathe'
|
||||||
|
#include "Kaleidoscope-LEDEffect-Breathe.h"
|
||||||
|
|
||||||
|
// Support for an LED mode that makes a red pixel chase a blue pixel across the keyboard
|
||||||
|
#include "Kaleidoscope-LEDEffect-Chase.h"
|
||||||
|
|
||||||
|
// Support for LED modes that pulse the keyboard's LED in a rainbow pattern
|
||||||
|
#include "Kaleidoscope-LEDEffect-Rainbow.h"
|
||||||
|
|
||||||
|
// Support for an LED mode that lights up the keys as you press them
|
||||||
|
#include "Kaleidoscope-LED-Stalker.h"
|
||||||
|
|
||||||
|
// Support for an LED mode that prints the keys you press in letters 4px high
|
||||||
|
#include "Kaleidoscope-LED-AlphaSquare.h"
|
||||||
|
|
||||||
|
// Support for shared palettes for other plugins, like Colormap below
|
||||||
|
#include "Kaleidoscope-LED-Palette-Theme.h"
|
||||||
|
|
||||||
|
// Support for an LED mode that lets one configure per-layer color maps
|
||||||
|
#include "Kaleidoscope-Colormap.h"
|
||||||
|
|
||||||
|
// Support for Keyboardio's internal keyboard testing mode
|
||||||
|
#include "Kaleidoscope-HardwareTestMode.h"
|
||||||
|
|
||||||
|
// Support for host power management (suspend & wakeup)
|
||||||
|
#include "Kaleidoscope-HostPowerManagement.h"
|
||||||
|
|
||||||
|
// Support for magic combos (key chords that trigger an action)
|
||||||
|
#include "Kaleidoscope-MagicCombo.h"
|
||||||
|
|
||||||
|
// Support for USB quirks, like changing the key state report protocol
|
||||||
|
#include "Kaleidoscope-USB-Quirks.h"
|
||||||
|
|
||||||
|
/** This 'enum' is a list of all the macros used by the Model 01's firmware
|
||||||
|
* The names aren't particularly important. What is important is that each
|
||||||
|
* is unique.
|
||||||
|
*
|
||||||
|
* These are the names of your macros. They'll be used in two places.
|
||||||
|
* The first is in your keymap definitions. There, you'll use the syntax
|
||||||
|
* `M(MACRO_NAME)` to mark a specific keymap position as triggering `MACRO_NAME`
|
||||||
|
*
|
||||||
|
* The second usage is in the 'switch' statement in the `macroAction` function.
|
||||||
|
* That switch statement actually runs the code associated with a macro when
|
||||||
|
* a macro key is pressed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum { MACRO_VERSION_INFO,
|
||||||
|
MACRO_ANY
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** The Model 01's key layouts are defined as 'keymaps'. By default, there are three
|
||||||
|
* keymaps: The standard QWERTY keymap, the "Function layer" keymap and the "Numpad"
|
||||||
|
* keymap.
|
||||||
|
*
|
||||||
|
* Each keymap is defined as a list using the 'KEYMAP_STACKED' macro, built
|
||||||
|
* of first the left hand's layout, followed by the right hand's layout.
|
||||||
|
*
|
||||||
|
* Keymaps typically consist mostly of `Key_` definitions. There are many, many keys
|
||||||
|
* defined as part of the USB HID Keyboard specification. You can find the names
|
||||||
|
* (if not yet the explanations) for all the standard `Key_` defintions offered by
|
||||||
|
* Kaleidoscope in these files:
|
||||||
|
* https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs_keyboard.h
|
||||||
|
* https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs_consumerctl.h
|
||||||
|
* https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs_sysctl.h
|
||||||
|
* https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs_keymaps.h
|
||||||
|
*
|
||||||
|
* Additional things that should be documented here include
|
||||||
|
* using ___ to let keypresses fall through to the previously active layer
|
||||||
|
* using XXX to mark a keyswitch as 'blocked' on this layer
|
||||||
|
* using ShiftToLayer() and LockLayer() keys to change the active keymap.
|
||||||
|
* keeping NUM and FN consistent and accessible on all layers
|
||||||
|
*
|
||||||
|
* The PROG key is special, since it is how you indicate to the board that you
|
||||||
|
* want to flash the firmware. However, it can be remapped to a regular key.
|
||||||
|
* When the keyboard boots, it first looks to see whether the PROG key is held
|
||||||
|
* down; if it is, it simply awaits further flashing instructions. If it is
|
||||||
|
* not, it continues loading the rest of the firmware and the keyboard
|
||||||
|
* functions normally, with whatever binding you have set to PROG. More detail
|
||||||
|
* here: https://community.keyboard.io/t/how-the-prog-key-gets-you-into-the-bootloader/506/8
|
||||||
|
*
|
||||||
|
* The "keymaps" data structure is a list of the keymaps compiled into the firmware.
|
||||||
|
* The order of keymaps in the list is important, as the ShiftToLayer(#) and LockLayer(#)
|
||||||
|
* macros switch to key layers based on this list.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
|
||||||
|
* A key defined as 'ShiftToLayer(FUNCTION)' will switch to FUNCTION while held.
|
||||||
|
* Similarly, a key defined as 'LockLayer(NUMPAD)' will switch to NUMPAD when tapped.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Layers are "0-indexed" -- That is the first one is layer 0. The second one is layer 1.
|
||||||
|
* The third one is layer 2.
|
||||||
|
* This 'enum' lets us use names like QWERTY, FUNCTION, and NUMPAD in place of
|
||||||
|
* the numbers 0, 1 and 2.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum { PRIMARY, NUMPAD, FUNCTION }; // layers
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To change your keyboard's layout from QWERTY to DVORAK or COLEMAK, comment out the line
|
||||||
|
*
|
||||||
|
* #define PRIMARY_KEYMAP_QWERTY
|
||||||
|
*
|
||||||
|
* by changing it to
|
||||||
|
*
|
||||||
|
* // #define PRIMARY_KEYMAP_QWERTY
|
||||||
|
*
|
||||||
|
* Then uncomment the line corresponding to the layout you want to use.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define PRIMARY_KEYMAP_QWERTY
|
||||||
|
// #define PRIMARY_KEYMAP_DVORAK
|
||||||
|
// #define PRIMARY_KEYMAP_COLEMAK
|
||||||
|
// #define PRIMARY_KEYMAP_CUSTOM
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* This comment temporarily turns off astyle's indent enforcement
|
||||||
|
* so we can make the keymaps actually resemble the physical key layout better
|
||||||
|
*/
|
||||||
|
// *INDENT-OFF*
|
||||||
|
|
||||||
|
KEYMAPS(
|
||||||
|
|
||||||
|
#if defined (PRIMARY_KEYMAP_QWERTY)
|
||||||
|
[PRIMARY] = KEYMAP_STACKED
|
||||||
|
(___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
|
||||||
|
Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab,
|
||||||
|
Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G,
|
||||||
|
Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
|
||||||
|
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
|
||||||
|
ShiftToLayer(FUNCTION),
|
||||||
|
|
||||||
|
M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD),
|
||||||
|
Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals,
|
||||||
|
Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote,
|
||||||
|
Key_RightAlt, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
|
||||||
|
Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl,
|
||||||
|
ShiftToLayer(FUNCTION)),
|
||||||
|
|
||||||
|
#elif defined (PRIMARY_KEYMAP_DVORAK)
|
||||||
|
|
||||||
|
[PRIMARY] = KEYMAP_STACKED
|
||||||
|
(___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
|
||||||
|
Key_Backtick, Key_Quote, Key_Comma, Key_Period, Key_P, Key_Y, Key_Tab,
|
||||||
|
Key_PageUp, Key_A, Key_O, Key_E, Key_U, Key_I,
|
||||||
|
Key_PageDown, Key_Semicolon, Key_Q, Key_J, Key_K, Key_X, Key_Escape,
|
||||||
|
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
|
||||||
|
ShiftToLayer(FUNCTION),
|
||||||
|
|
||||||
|
M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD),
|
||||||
|
Key_Enter, Key_F, Key_G, Key_C, Key_R, Key_L, Key_Slash,
|
||||||
|
Key_D, Key_H, Key_T, Key_N, Key_S, Key_Minus,
|
||||||
|
Key_RightAlt, Key_B, Key_M, Key_W, Key_V, Key_Z, Key_Equals,
|
||||||
|
Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl,
|
||||||
|
ShiftToLayer(FUNCTION)),
|
||||||
|
|
||||||
|
#elif defined (PRIMARY_KEYMAP_COLEMAK)
|
||||||
|
|
||||||
|
[PRIMARY] = KEYMAP_STACKED
|
||||||
|
(___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
|
||||||
|
Key_Backtick, Key_Q, Key_W, Key_F, Key_P, Key_G, Key_Tab,
|
||||||
|
Key_PageUp, Key_A, Key_R, Key_S, Key_T, Key_D,
|
||||||
|
Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
|
||||||
|
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
|
||||||
|
ShiftToLayer(FUNCTION),
|
||||||
|
|
||||||
|
M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD),
|
||||||
|
Key_Enter, Key_J, Key_L, Key_U, Key_Y, Key_Semicolon, Key_Equals,
|
||||||
|
Key_H, Key_N, Key_E, Key_I, Key_O, Key_Quote,
|
||||||
|
Key_RightAlt, Key_K, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
|
||||||
|
Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl,
|
||||||
|
ShiftToLayer(FUNCTION)),
|
||||||
|
|
||||||
|
#elif defined (PRIMARY_KEYMAP_CUSTOM)
|
||||||
|
// Edit this keymap to make a custom layout
|
||||||
|
[PRIMARY] = KEYMAP_STACKED
|
||||||
|
(___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
|
||||||
|
Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab,
|
||||||
|
Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G,
|
||||||
|
Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
|
||||||
|
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
|
||||||
|
ShiftToLayer(FUNCTION),
|
||||||
|
|
||||||
|
M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD),
|
||||||
|
Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals,
|
||||||
|
Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote,
|
||||||
|
Key_RightAlt, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
|
||||||
|
Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl,
|
||||||
|
ShiftToLayer(FUNCTION)),
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#error "No default keymap defined. You should make sure that you have a line like '#define PRIMARY_KEYMAP_QWERTY' in your sketch"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[NUMPAD] = KEYMAP_STACKED
|
||||||
|
(___, ___, ___, ___, ___, ___, ___,
|
||||||
|
___, ___, ___, ___, ___, ___, ___,
|
||||||
|
___, ___, ___, ___, ___, ___,
|
||||||
|
___, ___, ___, ___, ___, ___, ___,
|
||||||
|
___, ___, ___, ___,
|
||||||
|
___,
|
||||||
|
|
||||||
|
M(MACRO_VERSION_INFO), ___, Key_7, Key_8, Key_9, Key_KeypadSubtract, ___,
|
||||||
|
___, ___, Key_4, Key_5, Key_6, Key_KeypadAdd, ___,
|
||||||
|
___, Key_1, Key_2, Key_3, Key_Equals, ___,
|
||||||
|
___, ___, Key_0, Key_Period, Key_KeypadMultiply, Key_KeypadDivide, Key_Enter,
|
||||||
|
___, ___, ___, ___,
|
||||||
|
___),
|
||||||
|
|
||||||
|
[FUNCTION] = KEYMAP_STACKED
|
||||||
|
(___, Key_F1, Key_F2, Key_F3, Key_F4, Key_F5, Key_CapsLock,
|
||||||
|
Key_Tab, ___, Key_mouseUp, ___, Key_mouseBtnR, Key_mouseWarpEnd, Key_mouseWarpNE,
|
||||||
|
Key_Home, Key_mouseL, Key_mouseDn, Key_mouseR, Key_mouseBtnL, Key_mouseWarpNW,
|
||||||
|
Key_End, Key_PrintScreen, Key_Insert, ___, Key_mouseBtnM, Key_mouseWarpSW, Key_mouseWarpSE,
|
||||||
|
___, Key_Delete, ___, ___,
|
||||||
|
___,
|
||||||
|
|
||||||
|
Consumer_ScanPreviousTrack, Key_F6, Key_F7, Key_F8, Key_F9, Key_F10, Key_F11,
|
||||||
|
Consumer_PlaySlashPause, Consumer_ScanNextTrack, Key_LeftCurlyBracket, Key_RightCurlyBracket, Key_LeftBracket, Key_RightBracket, Key_F12,
|
||||||
|
Key_LeftArrow, Key_DownArrow, Key_UpArrow, Key_RightArrow, ___, ___,
|
||||||
|
Key_PcApplication, Consumer_Mute, Consumer_VolumeDecrement, Consumer_VolumeIncrement, ___, Key_Backslash, Key_Pipe,
|
||||||
|
___, ___, Key_Enter, ___,
|
||||||
|
___)
|
||||||
|
) // KEYMAPS(
|
||||||
|
|
||||||
|
/* Re-enable astyle's indent enforcement */
|
||||||
|
// *INDENT-ON*
|
||||||
|
|
||||||
|
/** versionInfoMacro handles the 'firmware version info' macro
|
||||||
|
* When a key bound to the macro is pressed, this macro
|
||||||
|
* prints out the firmware build information as virtual keystrokes
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void versionInfoMacro(uint8_t key_state) {
|
||||||
|
if (keyToggledOn(key_state)) {
|
||||||
|
Macros.type(PSTR("Keyboardio Model 01 - Kaleidoscope "));
|
||||||
|
Macros.type(PSTR(BUILD_INFORMATION));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** anyKeyMacro is used to provide the functionality of the 'Any' key.
|
||||||
|
*
|
||||||
|
* When the 'any key' macro is toggled on, a random alphanumeric key is
|
||||||
|
* selected. While the key is held, the function generates a synthetic
|
||||||
|
* keypress event repeating that randomly selected key.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void anyKeyMacro(KeyEvent &event) {
|
||||||
|
if (keyToggledOn(event.state)) {
|
||||||
|
event.key.setKeyCode(Key_A.getKeyCode() + (uint8_t)(millis() % 36));
|
||||||
|
event.key.setFlags(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** macroAction dispatches keymap events that are tied to a macro
|
||||||
|
to that macro. It takes two uint8_t parameters.
|
||||||
|
|
||||||
|
The first is the macro being called (the entry in the 'enum' earlier in this file).
|
||||||
|
The second is the state of the keyswitch. You can use the keyswitch state to figure out
|
||||||
|
if the key has just been toggled on, is currently pressed or if it's just been released.
|
||||||
|
|
||||||
|
The 'switch' statement should have a 'case' for each entry of the macro enum.
|
||||||
|
Each 'case' statement should call out to a function to handle the macro in question.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
|
||||||
|
switch (macro_id) {
|
||||||
|
|
||||||
|
case MACRO_VERSION_INFO:
|
||||||
|
versionInfoMacro(event.state);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MACRO_ANY:
|
||||||
|
anyKeyMacro(event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return MACRO_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// These 'solid' color effect definitions define a rainbow of
|
||||||
|
// LED color modes calibrated to draw 500mA or less on the
|
||||||
|
// Keyboardio Model 01.
|
||||||
|
|
||||||
|
|
||||||
|
static kaleidoscope::plugin::LEDSolidColor solidRed(160, 0, 0);
|
||||||
|
static kaleidoscope::plugin::LEDSolidColor solidOrange(140, 70, 0);
|
||||||
|
static kaleidoscope::plugin::LEDSolidColor solidYellow(130, 100, 0);
|
||||||
|
static kaleidoscope::plugin::LEDSolidColor solidGreen(0, 160, 0);
|
||||||
|
static kaleidoscope::plugin::LEDSolidColor solidBlue(0, 70, 130);
|
||||||
|
static kaleidoscope::plugin::LEDSolidColor solidIndigo(0, 0, 170);
|
||||||
|
static kaleidoscope::plugin::LEDSolidColor solidViolet(130, 0, 120);
|
||||||
|
|
||||||
|
/** toggleLedsOnSuspendResume toggles the LEDs off when the host goes to sleep,
|
||||||
|
* and turns them back on when it wakes up.
|
||||||
|
*/
|
||||||
|
void toggleLedsOnSuspendResume(kaleidoscope::plugin::HostPowerManagement::Event event) {
|
||||||
|
switch (event) {
|
||||||
|
case kaleidoscope::plugin::HostPowerManagement::Suspend:
|
||||||
|
LEDControl.disable();
|
||||||
|
break;
|
||||||
|
case kaleidoscope::plugin::HostPowerManagement::Resume:
|
||||||
|
LEDControl.enable();
|
||||||
|
break;
|
||||||
|
case kaleidoscope::plugin::HostPowerManagement::Sleep:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** hostPowerManagementEventHandler dispatches power management events (suspend,
|
||||||
|
* resume, and sleep) to other functions that perform action based on these
|
||||||
|
* events.
|
||||||
|
*/
|
||||||
|
void hostPowerManagementEventHandler(kaleidoscope::plugin::HostPowerManagement::Event event) {
|
||||||
|
toggleLedsOnSuspendResume(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This 'enum' is a list of all the magic combos used by the Model 01's
|
||||||
|
* firmware The names aren't particularly important. What is important is that
|
||||||
|
* each is unique.
|
||||||
|
*
|
||||||
|
* These are the names of your magic combos. They will be used by the
|
||||||
|
* `USE_MAGIC_COMBOS` call below.
|
||||||
|
*/
|
||||||
|
enum {
|
||||||
|
// Toggle between Boot (6-key rollover; for BIOSes and early boot) and NKRO
|
||||||
|
// mode.
|
||||||
|
COMBO_TOGGLE_NKRO_MODE,
|
||||||
|
// Enter test mode
|
||||||
|
COMBO_ENTER_TEST_MODE
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Wrappers, to be used by MagicCombo. **/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This simply toggles the keyboard protocol via USBQuirks, and wraps it within
|
||||||
|
* a function with an unused argument, to match what MagicCombo expects.
|
||||||
|
*/
|
||||||
|
static void toggleKeyboardProtocol(uint8_t combo_index) {
|
||||||
|
USBQuirks.toggleKeyboardProtocol();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This enters the hardware test mode
|
||||||
|
*/
|
||||||
|
static void enterHardwareTestMode(uint8_t combo_index) {
|
||||||
|
HardwareTestMode.runTests();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Magic combo list, a list of key combo and action pairs the firmware should
|
||||||
|
* recognise.
|
||||||
|
*/
|
||||||
|
USE_MAGIC_COMBOS({.action = toggleKeyboardProtocol,
|
||||||
|
// Left Fn + Esc + Shift
|
||||||
|
.keys = { R3C6, R2C6, R3C7 }
|
||||||
|
}, {
|
||||||
|
.action = enterHardwareTestMode,
|
||||||
|
// Left Fn + Prog + LED
|
||||||
|
.keys = { R3C6, R0C0, R0C6 }
|
||||||
|
});
|
||||||
|
|
||||||
|
// First, tell Kaleidoscope which plugins you want to use.
|
||||||
|
// The order can be important. For example, LED effects are
|
||||||
|
// added in the order they're listed here.
|
||||||
|
KALEIDOSCOPE_INIT_PLUGINS(
|
||||||
|
// The EEPROMSettings & EEPROMKeymap plugins make it possible to have an
|
||||||
|
// editable keymap in EEPROM.
|
||||||
|
// EEPROMSettings,
|
||||||
|
// EEPROMKeymap,
|
||||||
|
|
||||||
|
// Focus allows bi-directional communication with the host, and is the
|
||||||
|
// interface through which the keymap in EEPROM can be edited.
|
||||||
|
//Focus,
|
||||||
|
|
||||||
|
// FocusSettingsCommand adds a few Focus commands, intended to aid in
|
||||||
|
// changing some settings of the keyboard, such as the default layer (via the
|
||||||
|
// `settings.defaultLayer` command)
|
||||||
|
//FocusSettingsCommand,
|
||||||
|
|
||||||
|
// FocusEEPROMCommand adds a set of Focus commands, which are very helpful in
|
||||||
|
// both debugging, and in backing up one's EEPROM contents.
|
||||||
|
// FocusEEPROMCommand,
|
||||||
|
|
||||||
|
// The boot greeting effect pulses the LED button for 10 seconds after the
|
||||||
|
// keyboard is first connected
|
||||||
|
BootGreetingEffect,
|
||||||
|
|
||||||
|
// The hardware test mode, which can be invoked by tapping Prog, LED and the
|
||||||
|
// left Fn button at the same time.
|
||||||
|
HardwareTestMode,
|
||||||
|
|
||||||
|
// LEDControl provides support for other LED modes
|
||||||
|
LEDControl,
|
||||||
|
|
||||||
|
// We start with the LED effect that turns off all the LEDs.
|
||||||
|
LEDOff,
|
||||||
|
|
||||||
|
// The rainbow effect changes the color of all of the keyboard's keys at the same time
|
||||||
|
// running through all the colors of the rainbow.
|
||||||
|
LEDRainbowEffect,
|
||||||
|
|
||||||
|
// The rainbow wave effect lights up your keyboard with all the colors of a rainbow
|
||||||
|
// and slowly moves the rainbow across your keyboard
|
||||||
|
LEDRainbowWaveEffect,
|
||||||
|
|
||||||
|
// The chase effect follows the adventure of a blue pixel which chases a red pixel across
|
||||||
|
// your keyboard. Spoiler: the blue pixel never catches the red pixel
|
||||||
|
LEDChaseEffect,
|
||||||
|
|
||||||
|
// These static effects turn your keyboard's LEDs a variety of colors
|
||||||
|
solidRed, solidOrange, solidYellow, solidGreen, solidBlue, solidIndigo, solidViolet,
|
||||||
|
|
||||||
|
// The breathe effect slowly pulses all of the LEDs on your keyboard
|
||||||
|
LEDBreatheEffect,
|
||||||
|
|
||||||
|
// The AlphaSquare effect prints each character you type, using your
|
||||||
|
// keyboard's LEDs as a display
|
||||||
|
AlphaSquareEffect,
|
||||||
|
|
||||||
|
// The stalker effect lights up the keys you've pressed recently
|
||||||
|
StalkerEffect,
|
||||||
|
|
||||||
|
// The LED Palette Theme plugin provides a shared palette for other plugins,
|
||||||
|
// like Colormap below
|
||||||
|
LEDPaletteTheme,
|
||||||
|
|
||||||
|
// The Colormap effect makes it possible to set up per-layer colormaps
|
||||||
|
// ColormapEffect,
|
||||||
|
|
||||||
|
// The numpad plugin is responsible for lighting up the 'numpad' mode
|
||||||
|
// with a custom LED effect
|
||||||
|
NumPad,
|
||||||
|
|
||||||
|
// The macros plugin adds support for macros
|
||||||
|
Macros,
|
||||||
|
|
||||||
|
// The MouseKeys plugin lets you add keys to your keymap which move the mouse.
|
||||||
|
MouseKeys,
|
||||||
|
|
||||||
|
// The HostPowerManagement plugin allows us to turn LEDs off when then host
|
||||||
|
// goes to sleep, and resume them when it wakes up.
|
||||||
|
HostPowerManagement,
|
||||||
|
|
||||||
|
// The MagicCombo plugin lets you use key combinations to trigger custom
|
||||||
|
// actions - a bit like Macros, but triggered by pressing multiple keys at the
|
||||||
|
// same time.
|
||||||
|
MagicCombo,
|
||||||
|
|
||||||
|
// The USBQuirks plugin lets you do some things with USB that we aren't
|
||||||
|
// comfortable - or able - to do automatically, but can be useful
|
||||||
|
// nevertheless. Such as toggling the key report protocol between Boot (used
|
||||||
|
// by BIOSes) and Report (NKRO).
|
||||||
|
USBQuirks
|
||||||
|
);
|
||||||
|
|
||||||
|
/** The 'setup' function is one of the two standard Arduino sketch functions.
|
||||||
|
* It's called when your keyboard first powers up. This is where you set up
|
||||||
|
* Kaleidoscope and any plugins.
|
||||||
|
*/
|
||||||
|
void setup() {
|
||||||
|
// First, call Kaleidoscope's internal setup function
|
||||||
|
Kaleidoscope.setup();
|
||||||
|
|
||||||
|
// While we hope to improve this in the future, the NumPad plugin
|
||||||
|
// needs to be explicitly told which keymap layer is your numpad layer
|
||||||
|
NumPad.numPadLayer = NUMPAD;
|
||||||
|
|
||||||
|
// We configure the AlphaSquare effect to use RED letters
|
||||||
|
AlphaSquare.color = CRGB(255, 0, 0);
|
||||||
|
|
||||||
|
// We set the brightness of the rainbow effects to 150 (on a scale of 0-255)
|
||||||
|
// This draws more than 500mA, but looks much nicer than a dimmer effect
|
||||||
|
LEDRainbowEffect.brightness(150);
|
||||||
|
LEDRainbowWaveEffect.brightness(150);
|
||||||
|
|
||||||
|
// Set the action key the test mode should listen for to Left Fn
|
||||||
|
HardwareTestMode.setActionKey(R3C6);
|
||||||
|
|
||||||
|
// The LED Stalker mode has a few effects. The one we like is called
|
||||||
|
// 'BlazingTrail'. For details on other options, see
|
||||||
|
// https://github.com/keyboardio/Kaleidoscope/blob/master/docs/plugins/LED-Stalker.md
|
||||||
|
StalkerEffect.variant = STALKER(BlazingTrail);
|
||||||
|
|
||||||
|
// We want to make sure that the firmware starts with LED effects off
|
||||||
|
// This avoids over-taxing devices that don't have a lot of power to share
|
||||||
|
// with USB devices
|
||||||
|
LEDOff.activate();
|
||||||
|
|
||||||
|
// To make the keymap editable without flashing new firmware, we store
|
||||||
|
// additional layers in EEPROM. For now, we reserve space for five layers. If
|
||||||
|
// one wants to use these layers, just set the default layer to one in EEPROM,
|
||||||
|
// by using the `settings.defaultLayer` Focus command, or by using the
|
||||||
|
// `keymap.onlyCustom` command to use EEPROM layers only.
|
||||||
|
//EEPROMKeymap.setup(5);
|
||||||
|
|
||||||
|
// We need to tell the Colormap plugin how many layers we want to have custom
|
||||||
|
// maps for. To make things simple, we set it to five layers, which is how
|
||||||
|
// many editable layers we have (see above).
|
||||||
|
//ColormapEffect.max_layers(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** loop is the second of the standard Arduino sketch functions.
|
||||||
|
* As you might expect, it runs in a loop, never exiting.
|
||||||
|
*
|
||||||
|
* For Kaleidoscope-based keyboard firmware, you usually just want to
|
||||||
|
* call Kaleidoscope.loop(); and not do anything custom here.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
Kaleidoscope.loop();
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cpu": {
|
||||||
|
"fqbn": "keyboardio:STM32F1:keyboardio_model_100",
|
||||||
|
"port": ""
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
# This makefile for a Kaleidoscope sketch pulls in all the targets
|
||||||
|
# required to build the example
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ifneq ($(KALEIDOSCOPE_DIR),)
|
||||||
|
search_path += $(KALEIDOSCOPE_DIR)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(ARDUINO_DIRECTORIES_USER),)
|
||||||
|
search_path += $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(shell uname -s),Darwin)
|
||||||
|
search_path += $(HOME)/Documents/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope
|
||||||
|
else
|
||||||
|
search_path += $(HOME)/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope
|
||||||
|
endif
|
||||||
|
|
||||||
|
sketch_makefile := etc/makefiles/sketch.mk
|
||||||
|
|
||||||
|
$(foreach candidate, $(search_path), $(if $(wildcard $(candidate)/$(sketch_makefile)), $(eval ks_dir ?= $(candidate))))
|
||||||
|
|
||||||
|
ifneq ($(ks_dir),)
|
||||||
|
|
||||||
|
$(info Using Kaleidoscope from $(ks_dir))
|
||||||
|
|
||||||
|
export KALEIDOSCOPE_DIR := $(ks_dir)
|
||||||
|
include $(ks_dir)/$(sketch_makefile)
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
$(info I can't find your Kaleidoscope installation.)
|
||||||
|
$(info )
|
||||||
|
$(info I tried looking in:)
|
||||||
|
$(info )
|
||||||
|
$(foreach candidate, $(search_path), $(info $(candidate)))
|
||||||
|
$(info )
|
||||||
|
$(info The easiest way to fix this is to set the 'KALEIDOSCOPE_DIR' environment)
|
||||||
|
$(info variable to the location of your Kaleidoscope directory.)
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
null-target:
|
||||||
|
$(info You should never see this message)
|
||||||
|
@:
|
@ -0,0 +1,20 @@
|
|||||||
|
// -*- mode: c++ -*-
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <Kaleidoscope.h>
|
||||||
|
#include <Kaleidoscope-Macros.h>
|
||||||
|
|
||||||
|
KALEIDOSCOPE_INIT_PLUGINS(Macros);
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Kaleidoscope.setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
Kaleidoscope.device().hid().keyboard().pressKey(Key_H);
|
||||||
|
Kaleidoscope.device().hid().keyboard().sendReport();
|
||||||
|
Kaleidoscope.device().hid().keyboard().releaseKey(Key_H);
|
||||||
|
Kaleidoscope.device().hid().keyboard().sendReport();
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cpu": {
|
||||||
|
"fqbn": "keyboardio:STM32F1:keyboardio_model_100",
|
||||||
|
"port": ""
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
# This makefile for a Kaleidoscope sketch pulls in all the targets
|
||||||
|
# required to build the example
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ifneq ($(KALEIDOSCOPE_DIR),)
|
||||||
|
search_path += $(KALEIDOSCOPE_DIR)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(ARDUINO_DIRECTORIES_USER),)
|
||||||
|
search_path += $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(shell uname -s),Darwin)
|
||||||
|
search_path += $(HOME)/Documents/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope
|
||||||
|
else
|
||||||
|
search_path += $(HOME)/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope
|
||||||
|
endif
|
||||||
|
|
||||||
|
sketch_makefile := etc/makefiles/sketch.mk
|
||||||
|
|
||||||
|
$(foreach candidate, $(search_path), $(if $(wildcard $(candidate)/$(sketch_makefile)), $(eval ks_dir ?= $(candidate))))
|
||||||
|
|
||||||
|
ifneq ($(ks_dir),)
|
||||||
|
|
||||||
|
$(info Using Kaleidoscope from $(ks_dir))
|
||||||
|
|
||||||
|
export KALEIDOSCOPE_DIR := $(ks_dir)
|
||||||
|
include $(ks_dir)/$(sketch_makefile)
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
$(info I can't find your Kaleidoscope installation.)
|
||||||
|
$(info )
|
||||||
|
$(info I tried looking in:)
|
||||||
|
$(info )
|
||||||
|
$(foreach candidate, $(search_path), $(info $(candidate)))
|
||||||
|
$(info )
|
||||||
|
$(info The easiest way to fix this is to set the 'KALEIDOSCOPE_DIR' environment)
|
||||||
|
$(info variable to the location of your Kaleidoscope directory.)
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
null-target:
|
||||||
|
$(info You should never see this message)
|
||||||
|
@:
|
@ -0,0 +1,27 @@
|
|||||||
|
// -*- mode: c++ -*-
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <Kaleidoscope.h>
|
||||||
|
#include <Kaleidoscope-Macros.h>
|
||||||
|
|
||||||
|
KALEIDOSCOPE_INIT_PLUGINS(Macros);
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Kaleidoscope.setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
auto s = Kaleidoscope.device().serialPort();
|
||||||
|
|
||||||
|
if (s.available()) {
|
||||||
|
uint8_t r = s.read();
|
||||||
|
|
||||||
|
if (r == '1') {
|
||||||
|
s.println("Hello");
|
||||||
|
Kaleidoscope.device().hid().keyboard().pressKey(Key_H);
|
||||||
|
Kaleidoscope.device().hid().keyboard().sendReport();
|
||||||
|
Kaleidoscope.device().hid().keyboard().releaseKey(Key_H);
|
||||||
|
Kaleidoscope.device().hid().keyboard().sendReport();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cpu": {
|
||||||
|
"fqbn": "keyboardio:STM32F1:keyboardio_model_100",
|
||||||
|
"port": ""
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
# This makefile for a Kaleidoscope sketch pulls in all the targets
|
||||||
|
# required to build the example
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ifneq ($(KALEIDOSCOPE_DIR),)
|
||||||
|
search_path += $(KALEIDOSCOPE_DIR)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(ARDUINO_DIRECTORIES_USER),)
|
||||||
|
search_path += $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(shell uname -s),Darwin)
|
||||||
|
search_path += $(HOME)/Documents/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope
|
||||||
|
else
|
||||||
|
search_path += $(HOME)/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope
|
||||||
|
endif
|
||||||
|
|
||||||
|
sketch_makefile := etc/makefiles/sketch.mk
|
||||||
|
|
||||||
|
$(foreach candidate, $(search_path), $(if $(wildcard $(candidate)/$(sketch_makefile)), $(eval ks_dir ?= $(candidate))))
|
||||||
|
|
||||||
|
ifneq ($(ks_dir),)
|
||||||
|
|
||||||
|
$(info Using Kaleidoscope from $(ks_dir))
|
||||||
|
|
||||||
|
export KALEIDOSCOPE_DIR := $(ks_dir)
|
||||||
|
include $(ks_dir)/$(sketch_makefile)
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
$(info I can't find your Kaleidoscope installation.)
|
||||||
|
$(info )
|
||||||
|
$(info I tried looking in:)
|
||||||
|
$(info )
|
||||||
|
$(foreach candidate, $(search_path), $(info $(candidate)))
|
||||||
|
$(info )
|
||||||
|
$(info The easiest way to fix this is to set the 'KALEIDOSCOPE_DIR' environment)
|
||||||
|
$(info variable to the location of your Kaleidoscope directory.)
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
null-target:
|
||||||
|
$(info You should never see this message)
|
||||||
|
@:
|
@ -0,0 +1,213 @@
|
|||||||
|
// --------------------------------------
|
||||||
|
// i2c_scanner
|
||||||
|
//
|
||||||
|
// Version 1
|
||||||
|
// This program (or code that looks like it)
|
||||||
|
// can be found in many places.
|
||||||
|
// For example on the Arduino.cc forum.
|
||||||
|
// The original author is not know.
|
||||||
|
// Version 2, Juni 2012, Using Arduino 1.0.1
|
||||||
|
// Adapted to be as simple as possible by Arduino.cc user Krodal
|
||||||
|
// Version 3, Feb 26 2013
|
||||||
|
// V3 by louarnold
|
||||||
|
// Version 4, March 3, 2013, Using Arduino 1.0.3
|
||||||
|
// by Arduino.cc user Krodal.
|
||||||
|
// Changes by louarnold removed.
|
||||||
|
// Scanning addresses changed from 0...127 to 1...119,
|
||||||
|
// according to the i2c scanner by Nick Gammon
|
||||||
|
// http://www.gammon.com.au/forum/?id=10896
|
||||||
|
// Version 5, March 28, 2013
|
||||||
|
// As version 4, but address scans now to 127.
|
||||||
|
// A sensor seems to use address 120.
|
||||||
|
//
|
||||||
|
// This sketch tests the standard 7-bit addresses
|
||||||
|
// Devices with higher bit address might not be seen properly.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Example pinmap for Bluepill I2Cs (by Testato)
|
||||||
|
|
||||||
|
I2C-1 standard pins: PB7(sda) PB6(scl)
|
||||||
|
Use it by "Wire" without pin declaration
|
||||||
|
Wire.begin();
|
||||||
|
|
||||||
|
I2C-1 alternative pins: PB9(sda) PB8(scl)
|
||||||
|
Remap the first I2C before call begin()
|
||||||
|
Wire.setSDA(PB9);
|
||||||
|
Wire.setSCL(PB8);
|
||||||
|
Wire.begin();
|
||||||
|
|
||||||
|
I2C-2: PB11(sda) PB10(scl)
|
||||||
|
Remap the second I2C before call begin()
|
||||||
|
Wire.setSDA(PB11);
|
||||||
|
Wire.setSCL(PB10);
|
||||||
|
Wire.begin();
|
||||||
|
|
||||||
|
If you want to use the two I2Cs simultaneously, create a new instance for the second I2C
|
||||||
|
TwoWire Wire2(PB11,PB10);
|
||||||
|
Wire2.begin();
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <SoftWire.h>
|
||||||
|
struct cRGB {
|
||||||
|
uint8_t b;
|
||||||
|
uint8_t g;
|
||||||
|
uint8_t r;
|
||||||
|
};
|
||||||
|
#define CRGB(r,g,b) (cRGB){b, g, r}
|
||||||
|
|
||||||
|
uint16_t rainbow_hue = 0; // stores 0 to 614
|
||||||
|
cRGB rainbow;
|
||||||
|
|
||||||
|
|
||||||
|
#define ELEMENTS(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||||
|
|
||||||
|
|
||||||
|
SoftWire SWire(PB6, PB7, SOFT_FAST);
|
||||||
|
|
||||||
|
// From http://web.mit.edu/storborg/Public/hsvtorgb.c - talk to Scott about licensing
|
||||||
|
void hsvToRgb(cRGB *cRGB, uint16_t h, uint16_t s, uint16_t v) {
|
||||||
|
// HSV to RGB conversion function with only integer math
|
||||||
|
uint16_t region, fpart, p, q, t;
|
||||||
|
|
||||||
|
if (s == 0) {
|
||||||
|
// color is grayscale
|
||||||
|
cRGB->r = cRGB->g = cRGB->b = v;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// make hue 0-5
|
||||||
|
region = h / 43;
|
||||||
|
// find remainder part, make it from 0-255
|
||||||
|
fpart = (h - (region * 43)) * 6;
|
||||||
|
|
||||||
|
// calculate temp vars, doing integer multiplication
|
||||||
|
p = (v * (255 - s)) >> 8;
|
||||||
|
q = (v * (255 - ((s * fpart) >> 8))) >> 8;
|
||||||
|
t = (v * (255 - ((s * (255 - fpart)) >> 8))) >> 8;
|
||||||
|
|
||||||
|
// assign temp vars based on color cone region
|
||||||
|
switch (region) {
|
||||||
|
case 0:
|
||||||
|
cRGB->r = v;
|
||||||
|
cRGB->g = t;
|
||||||
|
cRGB->b = p;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
cRGB->r = q;
|
||||||
|
cRGB->g = v;
|
||||||
|
cRGB->b = p;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
cRGB->r = p;
|
||||||
|
cRGB->g = v;
|
||||||
|
cRGB->b = t;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
cRGB->r = p;
|
||||||
|
cRGB->g = q;
|
||||||
|
cRGB->b = v;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
cRGB->r = t;
|
||||||
|
cRGB->g = p;
|
||||||
|
cRGB->b = v;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
cRGB->r = v;
|
||||||
|
cRGB->g = p;
|
||||||
|
cRGB->b = q;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t error, error2;
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
|
||||||
|
pinMode(PB9, OUTPUT_OPEN_DRAIN);
|
||||||
|
digitalWrite(PB9, LOW);
|
||||||
|
//Serial.begin(9600);
|
||||||
|
//Serial.println("\nI2C Scanner");
|
||||||
|
// Wire.begin();
|
||||||
|
SWire.begin();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void effect_rainbow_update() {
|
||||||
|
rainbow_hue += 1;
|
||||||
|
if (rainbow_hue >= 255) {
|
||||||
|
rainbow_hue %= 255;
|
||||||
|
}
|
||||||
|
hsvToRgb(&rainbow, rainbow_hue, 255, 100);
|
||||||
|
uint8_t data[] = {0x03,
|
||||||
|
rainbow.b,
|
||||||
|
rainbow.g,
|
||||||
|
rainbow.r
|
||||||
|
};
|
||||||
|
/*
|
||||||
|
if (!error) {
|
||||||
|
SWire.beginTransmission(0x5B);
|
||||||
|
|
||||||
|
uint8_t result = SWire.write( data, ELEMENTS(data));
|
||||||
|
error = SWire.endTransmission();
|
||||||
|
} else {
|
||||||
|
|
||||||
|
SWire.beginTransmission(0x5B);
|
||||||
|
error = SWire.endTransmission();
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if (!error2) {
|
||||||
|
|
||||||
|
SWire.beginTransmission(0x58);
|
||||||
|
|
||||||
|
uint8_t result2 = SWire.write( data, ELEMENTS(data));
|
||||||
|
error2 = SWire.endTransmission();
|
||||||
|
} else {
|
||||||
|
SWire.beginTransmission(0x58);
|
||||||
|
error2 = SWire.endTransmission();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
byte error, address,r,g,b;
|
||||||
|
int nDevices;
|
||||||
|
|
||||||
|
//Serial.println("Scanning...");
|
||||||
|
|
||||||
|
nDevices = 0;
|
||||||
|
|
||||||
|
effect_rainbow_update();
|
||||||
|
/*
|
||||||
|
for (r=0;r<255;r+=10) {
|
||||||
|
for (g=0;g<255;g+=10) {
|
||||||
|
for (b=0;b<255;b+=10) {
|
||||||
|
|
||||||
|
|
||||||
|
SWire.beginTransmission(0x58);
|
||||||
|
uint8_t data[] = {0x03,
|
||||||
|
r,g,b
|
||||||
|
|
||||||
|
};
|
||||||
|
uint8_t result = Wire.write( data, ELEMENTS(data));
|
||||||
|
Wire.endTransmission();
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
delay(10); // wait 2m seconds for next scan
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cpu": {
|
||||||
|
"fqbn": "keyboardio:STM32F1:keyboardio_model_100",
|
||||||
|
"port": ""
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
name=Kaleidoscope-Hardware-STM32-Test
|
||||||
|
version=0.0.0
|
||||||
|
sentence=...
|
||||||
|
maintainer=Kaleidoscope's Developers <jesse@keyboard.io>
|
||||||
|
url=https://github.com/keyboardio/Kaleidoscope
|
||||||
|
author=Keyboardio
|
||||||
|
paragraph=
|
@ -0,0 +1,20 @@
|
|||||||
|
/* -*- mode: c++ -*-
|
||||||
|
* Kaleidoscope - Firmware for computer input devices
|
||||||
|
* Copyright (C) 2021 Keyboard.io, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "kaleidoscope/device/stm32/Test.h"
|
@ -0,0 +1,31 @@
|
|||||||
|
/* -*- mode: c++ -*-
|
||||||
|
* Kaleidoscope - Firmware for computer input devices
|
||||||
|
* Copyright (C) 2021 Keyboard.io, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef KBIO_TEST
|
||||||
|
|
||||||
|
#include "kaleidoscope/Runtime.h"
|
||||||
|
#include "kaleidoscope/driver/keyscanner/Base_Impl.h"
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
namespace device {
|
||||||
|
namespace stm32 {
|
||||||
|
|
||||||
|
} // namespace stm32
|
||||||
|
} // namespace device
|
||||||
|
} // namespace kaleidoscope
|
||||||
|
|
||||||
|
#endif // ifdef KBIO_TEST
|
@ -0,0 +1,57 @@
|
|||||||
|
/* -*- mode: c++ -*-
|
||||||
|
* Kaleidoscope - Firmware for computer input devices
|
||||||
|
* Copyright (C) 2021 Keyboard.io, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef KBIO_TEST
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#include "kaleidoscope/device/Base.h"
|
||||||
|
#include "kaleidoscope/driver/hid/RCMComposite.h"
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
namespace device {
|
||||||
|
namespace stm32 {
|
||||||
|
|
||||||
|
struct TestProps: public kaleidoscope::device::BaseProps {
|
||||||
|
typedef kaleidoscope::driver::hid::RCMCompositeProps HIDProps;
|
||||||
|
typedef kaleidoscope::driver::hid::RCMComposite<HIDProps> HID;
|
||||||
|
|
||||||
|
static constexpr const char *short_name = "KBIOTest";
|
||||||
|
};
|
||||||
|
|
||||||
|
class Test: public kaleidoscope::device::Base<TestProps> {
|
||||||
|
public:
|
||||||
|
auto serialPort() -> decltype(kaleidoscope::driver::hid::rcmcomposite::CompositeSerial) & {
|
||||||
|
return kaleidoscope::driver::hid::rcmcomposite::CompositeSerial;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#define PER_KEY_DATA(dflt, \
|
||||||
|
R0C0, R0C1 \
|
||||||
|
) \
|
||||||
|
R0C0, R0C1
|
||||||
|
|
||||||
|
} // namespace stm32
|
||||||
|
} // namespace device
|
||||||
|
|
||||||
|
EXPORT_DEVICE(kaleidoscope::device::stm32::Test)
|
||||||
|
|
||||||
|
} // namespace kaleidoscope
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,34 @@
|
|||||||
|
// -*- mode: c++ -*-
|
||||||
|
/* Kaleidoscope - Firmware for computer input devices
|
||||||
|
* Copyright (C) 2021 Keyboard.io, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "kaleidoscope/driver/hid/RCMComposite.h"
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
namespace driver {
|
||||||
|
namespace hid {
|
||||||
|
namespace rcmcomposite {
|
||||||
|
|
||||||
|
USBHID RCMHID;
|
||||||
|
HIDKeyboard RCMKeyboard(RCMHID);
|
||||||
|
HIDConsumer RCMConsumer(RCMHID);
|
||||||
|
HIDMouse RCMMouse(RCMHID);
|
||||||
|
USBCompositeSerial CompositeSerial;
|
||||||
|
|
||||||
|
} // namespace rcmcomposite
|
||||||
|
} // namespace hid
|
||||||
|
} // namespace driver
|
||||||
|
} // namespace kaleidoscope
|
@ -0,0 +1,67 @@
|
|||||||
|
// -*- mode: c++ -*-
|
||||||
|
/* Kaleidoscope - Firmware for computer input devices
|
||||||
|
* Copyright (C) 2021 Keyboard.io, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <USBComposite.h>
|
||||||
|
|
||||||
|
#include "kaleidoscope/driver/hid/Base.h"
|
||||||
|
|
||||||
|
#include "rcmcomposite/Keyboard.h"
|
||||||
|
#include "rcmcomposite/Mouse.h"
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
namespace driver {
|
||||||
|
namespace hid {
|
||||||
|
|
||||||
|
namespace rcmcomposite {
|
||||||
|
|
||||||
|
extern USBHID RCMHID;
|
||||||
|
extern USBCompositeSerial CompositeSerial;
|
||||||
|
|
||||||
|
const uint8_t report_description_[] = {
|
||||||
|
HID_KEYBOARD_REPORT_DESCRIPTOR(),
|
||||||
|
HID_CONSUMER_REPORT_DESCRIPTOR(),
|
||||||
|
HID_MOUSE_REPORT_DESCRIPTOR()
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
struct RCMCompositeProps: public BaseProps {
|
||||||
|
typedef rcmcomposite::KeyboardProps KeyboardProps;
|
||||||
|
typedef rcmcomposite::Keyboard<KeyboardProps> Keyboard;
|
||||||
|
typedef rcmcomposite::MouseProps MouseProps;
|
||||||
|
typedef rcmcomposite::Mouse<MouseProps> Mouse;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename _Props>
|
||||||
|
class RCMComposite: public Base<_Props> {
|
||||||
|
public:
|
||||||
|
void setup() {
|
||||||
|
rcmcomposite::RCMHID.begin(rcmcomposite::CompositeSerial,
|
||||||
|
rcmcomposite::report_description_,
|
||||||
|
sizeof(rcmcomposite::report_description_));
|
||||||
|
while(!USBComposite);
|
||||||
|
|
||||||
|
rcmcomposite::RCMKeyboard.begin();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace hid
|
||||||
|
} // namespace driver
|
||||||
|
} // namespace kaleidoscope
|
@ -0,0 +1,116 @@
|
|||||||
|
// -*- mode: c++ -*-
|
||||||
|
/* Kaleidoscope - Firmware for computer input devices
|
||||||
|
* Copyright (C) 2021 Keyboard.io, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <USBComposite.h>
|
||||||
|
|
||||||
|
#include "kaleidoscope/driver/hid/base/Keyboard.h"
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
namespace driver {
|
||||||
|
namespace hid {
|
||||||
|
namespace rcmcomposite {
|
||||||
|
|
||||||
|
extern HIDKeyboard RCMKeyboard;
|
||||||
|
extern HIDConsumer RCMConsumer;
|
||||||
|
|
||||||
|
class KeyboardWrapper {
|
||||||
|
public:
|
||||||
|
KeyboardWrapper() {}
|
||||||
|
|
||||||
|
void begin() {}
|
||||||
|
|
||||||
|
uint8_t getProtocol() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
void setProtocol(uint8_t protocol) {}
|
||||||
|
void setDefaultProtocol(uint8_t protocol) {}
|
||||||
|
|
||||||
|
void sendReport() {
|
||||||
|
RCMKeyboard.sendReport();
|
||||||
|
}
|
||||||
|
|
||||||
|
void press(uint8_t code) {
|
||||||
|
RCMKeyboard.press(code);
|
||||||
|
}
|
||||||
|
void release(uint8_t code) {
|
||||||
|
RCMKeyboard.release(code);
|
||||||
|
}
|
||||||
|
void releaseAll() {
|
||||||
|
RCMKeyboard.releaseAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isKeyPressed(uint8_t code) {
|
||||||
|
return RCMKeyboard.isKeyPressed(code);
|
||||||
|
}
|
||||||
|
bool wasKeyPressed(uint8_t code) {
|
||||||
|
return RCMKeyboard.wasKeyPressed(code);
|
||||||
|
}
|
||||||
|
bool isModifierActive(uint8_t code) {
|
||||||
|
return RCMKeyboard.isModifierActive(code);
|
||||||
|
}
|
||||||
|
bool wasModifierActive(uint8_t code) {
|
||||||
|
return RCMKeyboard.wasModifierActive(code);
|
||||||
|
}
|
||||||
|
bool isAnyModifierActive() {
|
||||||
|
return RCMKeyboard.isAnyModifierActive();
|
||||||
|
}
|
||||||
|
bool wasAnyModifierActive() {
|
||||||
|
return RCMKeyboard.wasAnyModifierActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t getLeds() {
|
||||||
|
return RCMKeyboard.getLEDs();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class ConsumerControlWrapper {
|
||||||
|
public:
|
||||||
|
ConsumerControlWrapper() {}
|
||||||
|
|
||||||
|
void begin() {
|
||||||
|
RCMConsumer.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void sendReport() {
|
||||||
|
}
|
||||||
|
void releaseAll() {
|
||||||
|
RCMConsumer.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
void press(uint16_t code) {
|
||||||
|
RCMConsumer.press(code);
|
||||||
|
}
|
||||||
|
void release(uint16_t code) {
|
||||||
|
RCMConsumer.release();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct KeyboardProps: public base::KeyboardProps {
|
||||||
|
typedef KeyboardWrapper NKROKeyboard;
|
||||||
|
typedef ConsumerControlWrapper ConsumerControl;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename _Props>
|
||||||
|
class Keyboard: public base::Keyboard<_Props> {};
|
||||||
|
|
||||||
|
} // namespace rcmcomposite
|
||||||
|
} // namespace hid
|
||||||
|
} // namespace driver
|
||||||
|
} // namespace keyboardio
|
@ -0,0 +1,81 @@
|
|||||||
|
// -*- mode: c++ -*-
|
||||||
|
/* Kaleidoscope - Firmware for computer input devices
|
||||||
|
* Copyright (C) 2021 Keyboard.io, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <USBComposite.h>
|
||||||
|
|
||||||
|
#include "kaleidoscope/driver/hid/base/Mouse.h"
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
namespace driver {
|
||||||
|
namespace hid {
|
||||||
|
namespace rcmcomposite {
|
||||||
|
|
||||||
|
extern HIDMouse RCMMouse;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We are wrapping `Mouse` here, instead of directly using the class in
|
||||||
|
* `MouseProps` below. We do this, because this lets the linker optimize this
|
||||||
|
* whole thing out if it is unused. It can do that because instantiating `Mouse`
|
||||||
|
* is in a separate compilation unit.
|
||||||
|
*
|
||||||
|
* While it would have been cleaner and shorter to instantiate them here, and
|
||||||
|
* drop the global objects, that prevents optimizing them out, and that's a cost
|
||||||
|
* we do not want to pay.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class MouseWrapper {
|
||||||
|
public:
|
||||||
|
MouseWrapper() {}
|
||||||
|
|
||||||
|
void begin() {}
|
||||||
|
void sendReport() {
|
||||||
|
RCMMouse.sendReport();
|
||||||
|
}
|
||||||
|
void move(int8_t x, int8_t y, int8_t vWheel, int8_t hWheel) {
|
||||||
|
RCMMouse.move(x, y, vWheel);
|
||||||
|
}
|
||||||
|
void stop(bool x, bool y, bool vWheel = false, bool hWheel = false) {
|
||||||
|
RCMMouse.stop(x, y, vWheel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void releaseAll() {
|
||||||
|
RCMMouse.releaseAll();
|
||||||
|
}
|
||||||
|
void press(uint8_t buttons) {
|
||||||
|
RCMMouse.press(buttons);
|
||||||
|
}
|
||||||
|
void release(uint8_t buttons) {
|
||||||
|
RCMMouse.release(buttons);
|
||||||
|
}
|
||||||
|
void click(uint8_t buttons) {
|
||||||
|
RCMMouse.click(buttons);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MouseProps: public base::MouseProps {
|
||||||
|
typedef MouseWrapper Mouse;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename _Props>
|
||||||
|
class Mouse: public base::Mouse<_Props> {};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue