Format codebase with `clang-format`

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/1143/head
Michael Richters 3 years ago
parent dfd9bff7bd
commit e5d67efd58
No known key found for this signature in database
GPG Key ID: 1288FD13E4EEF0C0

@ -34,7 +34,6 @@ class AppSwitcher : public kaleidoscope::Plugin {
private: private:
KeyAddr active_addr_ = KeyAddr::none(); KeyAddr active_addr_ = KeyAddr::none();
}; };
} // namespace plugin } // namespace plugin

@ -62,8 +62,7 @@ void AutoShift::disable() {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Test for whether or not to apply AutoShift to a given `Key`. This function // Test for whether or not to apply AutoShift to a given `Key`. This function
// can be overridden from the user sketch. // can be overridden from the user sketch.
__attribute__((weak)) __attribute__((weak)) bool AutoShift::isAutoShiftable(Key key) {
bool AutoShift::isAutoShiftable(Key key) {
return enabledForKey(key); return enabledForKey(key);
} }

@ -72,7 +72,8 @@ class AutoShift : public Plugin {
public: public:
// Basic un-checked constructor // Basic un-checked constructor
constexpr Categories(uint8_t raw_bits) : raw_bits_(raw_bits) {} constexpr Categories(uint8_t raw_bits)
: raw_bits_(raw_bits) {}
static constexpr Categories letterKeys() { static constexpr Categories letterKeys() {
return Categories(LETTERS); return Categories(LETTERS);

@ -38,7 +38,7 @@ namespace plugin {
// ============================================================================= // =============================================================================
// CharShift class variables // CharShift class variables
CharShift::KeyPair const * CharShift::progmem_keypairs_{nullptr}; CharShift::KeyPair const *CharShift::progmem_keypairs_{nullptr};
uint8_t CharShift::num_keypairs_{0}; uint8_t CharShift::num_keypairs_{0};
bool CharShift::reverse_shift_state_{false}; bool CharShift::reverse_shift_state_{false};
@ -131,13 +131,15 @@ CharShift::KeyPair CharShift::decodeCharShiftKey(Key key) {
// This should be overridden if the KeyPairs array is stored in EEPROM // This should be overridden if the KeyPairs array is stored in EEPROM
__attribute__((weak)) __attribute__((weak))
uint8_t CharShift::numKeyPairs() { uint8_t
CharShift::numKeyPairs() {
return numProgmemKeyPairs(); return numProgmemKeyPairs();
} }
// This should be overridden if the KeyPairs array is stored in EEPROM // This should be overridden if the KeyPairs array is stored in EEPROM
__attribute__((weak)) __attribute__((weak))
CharShift::KeyPair CharShift::readKeyPair(uint8_t n) { CharShift::KeyPair
CharShift::readKeyPair(uint8_t n) {
return readKeyPairFromProgmem(n); return readKeyPairFromProgmem(n);
} }

@ -59,7 +59,8 @@ class CharShift : public Plugin {
/// ///
/// This constructor is used when defining an array of `KeyPair` objects in /// This constructor is used when defining an array of `KeyPair` objects in
/// PROGMEM (though it can also be used elsewhere). /// PROGMEM (though it can also be used elsewhere).
constexpr KeyPair(Key lower, Key upper) : lower(lower), upper(upper) {} constexpr KeyPair(Key lower, Key upper)
: lower(lower), upper(upper) {}
/// Constructor for reading from PROGMEM /// Constructor for reading from PROGMEM
/// ///
@ -75,15 +76,15 @@ class CharShift : public Plugin {
/// `keypairs` array given, which must be a fixed-sized array, not a pointer. /// `keypairs` array given, which must be a fixed-sized array, not a pointer.
/// Generally, it will be called via the `KEYPAIRS()` preprocessor macro, not /// Generally, it will be called via the `KEYPAIRS()` preprocessor macro, not
/// directly by user code. /// directly by user code.
template <uint8_t _num_keypairs> template<uint8_t _num_keypairs>
static void setProgmemKeyPairs(KeyPair const(&keypairs)[_num_keypairs]) { static void setProgmemKeyPairs(KeyPair const (&keypairs)[_num_keypairs]) {
progmem_keypairs_ = keypairs; progmem_keypairs_ = keypairs;
num_keypairs_ = _num_keypairs; num_keypairs_ = _num_keypairs;
} }
private: private:
// A pointer to an array of `KeyPair` objects in PROGMEM // A pointer to an array of `KeyPair` objects in PROGMEM
static KeyPair const * progmem_keypairs_; static KeyPair const *progmem_keypairs_;
// The size of the PROGMEM array of `KeyPair` objects // The size of the PROGMEM array of `KeyPair` objects
static uint8_t num_keypairs_; static uint8_t num_keypairs_;
@ -125,12 +126,12 @@ extern kaleidoscope::plugin::CharShift CharShift;
/// defines them as an array in PROGMEM, and configures `CharShift` to use that /// defines them as an array in PROGMEM, and configures `CharShift` to use that
/// array, automatically setting the count correctly to prevent out-of-bounds /// array, automatically setting the count correctly to prevent out-of-bounds
/// lookups. /// lookups.
#define CS_KEYS(keypairs...) { \ #define CS_KEYS(keypairs...) \
{ \
static kaleidoscope::plugin::CharShift::KeyPair const kp_table[] PROGMEM = { \ static kaleidoscope::plugin::CharShift::KeyPair const kp_table[] PROGMEM = { \
keypairs \ keypairs}; \
}; \
CharShift.setProgmemKeyPairs(kp_table); \ CharShift.setProgmemKeyPairs(kp_table); \
} }
/// Define an `KeyPair` entry in a keymap /// Define an `KeyPair` entry in a keymap
/// ///

@ -68,8 +68,7 @@ EventHandlerResult ColormapEffect::onLayerChange() {
} }
EventHandlerResult ColormapEffect::onFocusEvent(const char *command) { EventHandlerResult ColormapEffect::onFocusEvent(const char *command) {
return ::LEDPaletteTheme.themeFocusEvent(command, PSTR("colormap.map"), return ::LEDPaletteTheme.themeFocusEvent(command, PSTR("colormap.map"), map_base_, max_layers_);
map_base_, max_layers_);
} }
} // namespace plugin } // namespace plugin

@ -44,21 +44,20 @@ class ColormapEffect : public Plugin,
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
// //
explicit TransientLEDMode(const ColormapEffect *parent) : parent_(parent) {} explicit TransientLEDMode(const ColormapEffect *parent)
: parent_(parent) {}
protected: protected:
friend class ColormapEffect; friend class ColormapEffect;
void onActivate(void) final; void onActivate(void) final;
void refreshAt(KeyAddr key_addr) final; void refreshAt(KeyAddr key_addr) final;
private:
private:
const ColormapEffect *parent_; const ColormapEffect *parent_;
}; };

@ -113,8 +113,7 @@ uint8_t Cycle::toModFlag(uint8_t keyCode) {
} // namespace plugin } // namespace plugin
} // namespace kaleidoscope } // namespace kaleidoscope
__attribute__((weak)) __attribute__((weak)) void cycleAction(Key previous_key, uint8_t cycle_count) {
void cycleAction(Key previous_key, uint8_t cycle_count) {
} }
kaleidoscope::plugin::Cycle Cycle; kaleidoscope::plugin::Cycle Cycle;

@ -30,9 +30,9 @@
constexpr Key Key_Cycle = Key(kaleidoscope::ranges::CYCLE); constexpr Key Key_Cycle = Key(kaleidoscope::ranges::CYCLE);
#define cycleThrough(...) ({ \ #define cycleThrough(...) ({ \
static const Key __k[] PROGMEM = { __VA_ARGS__ }; \ static const Key __k[] PROGMEM = {__VA_ARGS__}; \
Cycle.replace(sizeof(__k) / sizeof(Key), &__k[0]); \ Cycle.replace(sizeof(__k) / sizeof(Key), &__k[0]); \
}) })
namespace kaleidoscope { namespace kaleidoscope {
namespace plugin { namespace plugin {

@ -62,8 +62,7 @@ EventHandlerResult CycleTimeReport::afterEachCycle() {
} // namespace kaleidoscope } // namespace kaleidoscope
__attribute__((weak)) void cycleTimeReport(void) { __attribute__((weak)) void cycleTimeReport(void) {
Focus.send(Focus.COMMENT, F("average loop time:"), CycleTimeReport.average_loop_time, Focus.send(Focus.COMMENT, F("average loop time:"), CycleTimeReport.average_loop_time, Focus.NEWLINE);
Focus.NEWLINE);
} }
kaleidoscope::plugin::CycleTimeReport CycleTimeReport; kaleidoscope::plugin::CycleTimeReport CycleTimeReport;

@ -57,7 +57,7 @@ constexpr size_t strlen(const char *str) {
return str[0] ? strlen(str + 1) + 1 : 0; return str[0] ? strlen(str + 1) + 1 : 0;
} }
template <char... chars> template<char... chars>
struct string { struct string {
#if ARDUINOTRACE_ENABLE_PROGMEM #if ARDUINOTRACE_ENABLE_PROGMEM
const __FlashStringHelper *data() { const __FlashStringHelper *data() {
@ -72,52 +72,47 @@ struct string {
#endif #endif
}; };
template <typename TSourceString, size_t remainingLength, template<typename TSourceString, size_t remainingLength, char... collectedChars>
char... collectedChars>
struct string_maker { struct string_maker {
using result = using result =
typename string_maker < TSourceString, remainingLength - 1, typename string_maker<TSourceString, remainingLength - 1, TSourceString::data()[remainingLength - 1], collectedChars...>::result;
TSourceString::data()[remainingLength - 1],
collectedChars... >::result;
}; };
#if ARDUINOTRACE_ENABLE_FULLPATH == 0 #if ARDUINOTRACE_ENABLE_FULLPATH == 0
template <typename TSourceString, size_t remainingLength, template<typename TSourceString, size_t remainingLength, char... collectedChars>
char... collectedChars>
struct string_maker<TSourceString, remainingLength, '/', collectedChars...> { struct string_maker<TSourceString, remainingLength, '/', collectedChars...> {
using result = string<collectedChars..., '\0'>; using result = string<collectedChars..., '\0'>;
}; };
template <typename TSourceString, size_t remainingLength, template<typename TSourceString, size_t remainingLength, char... collectedChars>
char... collectedChars>
struct string_maker<TSourceString, remainingLength, '\\', collectedChars...> { struct string_maker<TSourceString, remainingLength, '\\', collectedChars...> {
using result = string<collectedChars..., '\0'>; using result = string<collectedChars..., '\0'>;
}; };
#endif #endif
template <typename TSourceString, char... collectedChars> template<typename TSourceString, char... collectedChars>
struct string_maker<TSourceString, 0, collectedChars...> { struct string_maker<TSourceString, 0, collectedChars...> {
using result = string<collectedChars..., '\0'>; using result = string<collectedChars..., '\0'>;
}; };
template <typename TStringSource> template<typename TStringSource>
using make_string = using make_string =
typename string_maker<TStringSource, strlen(TStringSource::data())>::result; typename string_maker<TStringSource, strlen(TStringSource::data())>::result;
struct Initializer { struct Initializer {
template <typename TSerial> template<typename TSerial>
Initializer(TSerial &serial, int bauds) { Initializer(TSerial &serial, int bauds) {
serial.begin(bauds); serial.begin(bauds);
while (!serial) continue; while (!serial) continue;
} }
}; };
template <typename TFilename, typename TPrefix> template<typename TFilename, typename TPrefix>
struct Printer { struct Printer {
template <typename TSerial, typename TValue> template<typename TSerial, typename TValue>
Printer(TSerial &serial, const TValue &content) { Printer(TSerial &serial, const TValue &content) {
serial.print(make_string<TFilename> {}.data()); serial.print(make_string<TFilename>{}.data());
serial.print(make_string<TPrefix> {}.data()); serial.print(make_string<TPrefix>{}.data());
serial.println(content); serial.println(content);
serial.flush(); serial.flush();
} }
@ -173,9 +168,7 @@ struct Printer {
// However, if you use it at global scope, you need to call ARDUINOTRACE_INIT() // However, if you use it at global scope, you need to call ARDUINOTRACE_INIT()
// first, otherwise, the Serial port will not be ready. // first, otherwise, the Serial port will not be ready.
#define TRACE() \ #define TRACE() \
ARDUINOTRACE_PRINT(__COUNTER__, __FILE__, \ ARDUINOTRACE_PRINT(__COUNTER__, __FILE__, ARDUINOTRACE_TRACE_PREFIX(__LINE__), ARDUINOTRACE_FUNCTION_NAME)
ARDUINOTRACE_TRACE_PREFIX(__LINE__), \
ARDUINOTRACE_FUNCTION_NAME)
// Prints the value of a variable. // Prints the value of a variable.
// //
@ -183,8 +176,7 @@ struct Printer {
// Serial. If you use it at global scope, you need to call ARDUINOTRACE_INIT() // Serial. If you use it at global scope, you need to call ARDUINOTRACE_INIT()
// first, otherwise, the Serial port will not be ready. // first, otherwise, the Serial port will not be ready.
#define DUMP(variable) \ #define DUMP(variable) \
ARDUINOTRACE_PRINT(__COUNTER__, __FILE__, \ ARDUINOTRACE_PRINT(__COUNTER__, __FILE__, ARDUINOTRACE_DUMP_PREFIX(__LINE__, variable), variable)
ARDUINOTRACE_DUMP_PREFIX(__LINE__, variable), variable)
#else // ie ARDUINOTRACE_ENABLE == 0 #else // ie ARDUINOTRACE_ENABLE == 0

@ -68,8 +68,7 @@ void DynamicTapDance::updateDynamicTapDanceCache() {
} }
} }
bool DynamicTapDance::dance(uint8_t tap_dance_index, KeyAddr key_addr, bool DynamicTapDance::dance(uint8_t tap_dance_index, KeyAddr key_addr, uint8_t tap_count, TapDance::ActionType tap_dance_action) {
uint8_t tap_count, TapDance::ActionType tap_dance_action) {
uint16_t pos = map_[tap_dance_index - offset_] + ((tap_count - 1) * 2); uint16_t pos = map_[tap_dance_index - offset_] + ((tap_count - 1) * 2);
uint16_t next_pos = map_[tap_dance_index - offset_ + 1]; uint16_t next_pos = map_[tap_dance_index - offset_ + 1];
if (next_pos <= pos || (tap_dance_index > offset_ + dance_count_)) if (next_pos <= pos || (tap_dance_index > offset_ + dance_count_))

@ -28,7 +28,7 @@
namespace kaleidoscope { namespace kaleidoscope {
namespace plugin { namespace plugin {
class DynamicTapDance: public kaleidoscope::Plugin { class DynamicTapDance : public kaleidoscope::Plugin {
public: public:
DynamicTapDance() {} DynamicTapDance() {}
@ -37,8 +37,7 @@ class DynamicTapDance: public kaleidoscope::Plugin {
static void setup(uint8_t dynamic_offset, uint16_t size); static void setup(uint8_t dynamic_offset, uint16_t size);
static bool dance(uint8_t tap_dance_index, KeyAddr key_addr, uint8_t tap_count, static bool dance(uint8_t tap_dance_index, KeyAddr key_addr, uint8_t tap_count, TapDance::ActionType tap_dance_action);
TapDance::ActionType tap_dance_action);
private: private:
static uint16_t storage_base_; static uint16_t storage_base_;

@ -91,7 +91,7 @@ void EEPROMKeymap::updateKey(uint16_t base_pos, Key key) {
Runtime.storage().update(keymap_base_ + base_pos * 2 + 1, key.getKeyCode()); Runtime.storage().update(keymap_base_ + base_pos * 2 + 1, key.getKeyCode());
} }
void EEPROMKeymap::dumpKeymap(uint8_t layers, Key(*getkey)(uint8_t, KeyAddr)) { void EEPROMKeymap::dumpKeymap(uint8_t layers, Key (*getkey)(uint8_t, KeyAddr)) {
for (uint8_t layer = 0; layer < layers; layer++) { for (uint8_t layer = 0; layer < layers; layer++) {
for (auto key_addr : KeyAddr::all()) { for (auto key_addr : KeyAddr::all()) {
Key k = (*getkey)(layer, key_addr); Key k = (*getkey)(layer, key_addr);
@ -134,7 +134,7 @@ EventHandlerResult EEPROMKeymap::onFocusEvent(const char *command) {
// we actully want. // we actully want.
// //
dumpKeymap(progmem_layers_, dumpKeymap(progmem_layers_,
static_cast<Key(*)(uint8_t, KeyAddr)>(Layer_::getKeyFromPROGMEM)); static_cast<Key (*)(uint8_t, KeyAddr)>(Layer_::getKeyFromPROGMEM));
return EventHandlerResult::EVENT_CONSUMED; return EventHandlerResult::EVENT_CONSUMED;
} }
@ -146,7 +146,7 @@ EventHandlerResult EEPROMKeymap::onFocusEvent(const char *command) {
// tell the compiler which overload of getKey // tell the compiler which overload of getKey
// we actually want. // we actually want.
// //
dumpKeymap(max_layers_, static_cast<Key(*)(uint8_t, KeyAddr)>(getKey)); dumpKeymap(max_layers_, static_cast<Key (*)(uint8_t, KeyAddr)>(getKey));
} else { } else {
uint16_t i = 0; uint16_t i = 0;

@ -57,7 +57,7 @@ class EEPROMKeymap : public kaleidoscope::Plugin {
static Key parseKey(void); static Key parseKey(void);
static void printKey(Key key); static void printKey(Key key);
static void dumpKeymap(uint8_t layers, Key(*getkey)(uint8_t, KeyAddr)); static void dumpKeymap(uint8_t layers, Key (*getkey)(uint8_t, KeyAddr));
}; };
} // namespace plugin } // namespace plugin

@ -74,8 +74,8 @@ class EEPROMSettings : public kaleidoscope::Plugin {
static bool sealed_; static bool sealed_;
static struct settings { static struct settings {
uint8_t default_layer: 7; uint8_t default_layer : 7;
bool ignore_hardcoded_layers: 1; bool ignore_hardcoded_layers : 1;
uint8_t version; uint8_t version;
uint16_t crc; uint16_t crc;
} settings_; } settings_;

@ -28,8 +28,7 @@
#include "crc.h" #include "crc.h"
void void CRC_::reflect(uint8_t len) {
CRC_::reflect(uint8_t len) {
uint8_t i; uint8_t i;
uint16_t newCRC; uint16_t newCRC;
@ -42,8 +41,7 @@ CRC_::reflect(uint8_t len) {
crc = newCRC; crc = newCRC;
} }
void void CRC_::update(const void *data, uint8_t len) {
CRC_::update(const void *data, uint8_t len) {
const uint8_t *d = (const uint8_t *)data; const uint8_t *d = (const uint8_t *)data;
uint8_t i; uint8_t i;
bool bit; bool bit;

@ -34,7 +34,7 @@ class CRC_ {
public: public:
uint16_t crc = 0; uint16_t crc = 0;
CRC_(void) {}; CRC_(void){};
void update(const void *data, uint8_t len); void update(const void *data, uint8_t len);
void finalize(void) { void finalize(void) {

@ -28,8 +28,7 @@ namespace kaleidoscope {
namespace plugin { namespace plugin {
EscapeOneShot::Settings EscapeOneShot::settings_ = { EscapeOneShot::Settings EscapeOneShot::settings_ = {
.cancel_oneshot_key = Key_Escape .cancel_oneshot_key = Key_Escape};
};
EventHandlerResult EscapeOneShot::onKeyEvent(KeyEvent &event) { EventHandlerResult EscapeOneShot::onKeyEvent(KeyEvent &event) {
// We only act on an escape key (or `cancel_oneshot_key_`, if that has been // We only act on an escape key (or `cancel_oneshot_key_`, if that has been

@ -27,8 +27,8 @@
// DEPRECATED: `OneShotCancelKey` doesn't match our normal naming, and should // DEPRECATED: `OneShotCancelKey` doesn't match our normal naming, and should
// eventually be removed. // eventually be removed.
constexpr Key OneShotCancelKey {kaleidoscope::ranges::OS_CANCEL}; constexpr Key OneShotCancelKey{kaleidoscope::ranges::OS_CANCEL};
constexpr Key Key_OneShotCancel {kaleidoscope::ranges::OS_CANCEL}; constexpr Key Key_OneShotCancel{kaleidoscope::ranges::OS_CANCEL};
namespace kaleidoscope { namespace kaleidoscope {
namespace plugin { namespace plugin {

@ -37,6 +37,7 @@ class FirmwareDump : public kaleidoscope::Plugin {
EventHandlerResult onSetup(); EventHandlerResult onSetup();
EventHandlerResult onFocusEvent(const char *command); EventHandlerResult onFocusEvent(const char *command);
private: private:
uint16_t bootloader_size_; uint16_t bootloader_size_;
}; };

@ -44,10 +44,7 @@ EventHandlerResult FocusSerial::afterEachCycle() {
do { do {
command_[buf_cursor_++] = Runtime.serialPort().read(); command_[buf_cursor_++] = Runtime.serialPort().read();
} while (command_[buf_cursor_ - 1] != SEPARATOR } while (command_[buf_cursor_ - 1] != SEPARATOR && buf_cursor_ < sizeof(command_) && Runtime.serialPort().available() && (Runtime.serialPort().peek() != NEWLINE));
&& buf_cursor_ < sizeof(command_)
&& Runtime.serialPort().available()
&& (Runtime.serialPort().peek() != NEWLINE));
// If there was no command, there's nothing to do // If there was no command, there's nothing to do
@ -57,9 +54,7 @@ EventHandlerResult FocusSerial::afterEachCycle() {
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }
if ((command_[buf_cursor_ - 1] != SEPARATOR) && (Runtime.serialPort().peek() != NEWLINE) if ((command_[buf_cursor_ - 1] != SEPARATOR) && (Runtime.serialPort().peek() != NEWLINE) && buf_cursor_ < sizeof(command_)) {
&& buf_cursor_ < sizeof(command_)
) {
// We don't have enough command to work with yet. // We don't have enough command to work with yet.
// Let's leave the buffer around for another cycle // Let's leave the buffer around for another cycle
return EventHandlerResult::OK; return EventHandlerResult::OK;
@ -86,7 +81,6 @@ EventHandlerResult FocusSerial::afterEachCycle() {
buf_cursor_ = 0; buf_cursor_ = 0;
memset(command_, 0, sizeof(command_)); memset(command_, 0, sizeof(command_));
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }
bool FocusSerial::handleHelp(const char *command, bool FocusSerial::handleHelp(const char *command,

@ -57,19 +57,19 @@ class FocusSerial : public kaleidoscope::Plugin {
printBool(b); printBool(b);
Runtime.serialPort().print(SEPARATOR); Runtime.serialPort().print(SEPARATOR);
} }
template <typename V> template<typename V>
void send(V v) { void send(V v) {
Runtime.serialPort().print(v); Runtime.serialPort().print(v);
Runtime.serialPort().print(SEPARATOR); Runtime.serialPort().print(SEPARATOR);
} }
template <typename Var, typename... Vars> template<typename Var, typename... Vars>
void send(Var v, Vars... vars) { void send(Var v, Vars... vars) {
send(v); send(v);
send(vars...); send(vars...);
} }
void sendRaw() {} void sendRaw() {}
template <typename Var, typename... Vars> template<typename Var, typename... Vars>
void sendRaw(Var v, Vars... vars) { void sendRaw(Var v, Vars... vars) {
Runtime.serialPort().print(v); Runtime.serialPort().print(v);
sendRaw(vars...); sendRaw(vars...);

@ -159,7 +159,7 @@ uint8_t RaiseLEDDriver::getBrightness() {
void RaiseLEDDriver::syncLeds() { void RaiseLEDDriver::syncLeds() {
// left and right sides // left and right sides
for (uint8_t i = 0; i < LED_BANKS; i ++) { for (uint8_t i = 0; i < LED_BANKS; i++) {
// only send the banks that have changed - try to improve jitter performance // only send the banks that have changed - try to improve jitter performance
if (isLEDChangedLeft[i]) { if (isLEDChangedLeft[i]) {
RaiseHands::leftHand.sendLEDBank(i); RaiseHands::leftHand.sendLEDBank(i);
@ -180,7 +180,7 @@ void RaiseLEDDriver::syncLeds() {
void RaiseLEDDriver::updateNeuronLED() { void RaiseLEDDriver::updateNeuronLED() {
static constexpr struct { static constexpr struct {
uint8_t r, g, b; uint8_t r, g, b;
} pins = { 3, 5, 4 }; } pins = {3, 5, 4};
auto constexpr gamma8 = kaleidoscope::driver::color::gamma_correction; auto constexpr gamma8 = kaleidoscope::driver::color::gamma_correction;
// invert as these are common anode, and make sure we reach 65535 to be able // invert as these are common anode, and make sure we reach 65535 to be able

@ -23,7 +23,8 @@
#include "kaleidoscope/device/dygma/raise/RaiseSide.h" #include "kaleidoscope/device/dygma/raise/RaiseSide.h"
#define CRGB(r,g,b) (cRGB){b, g, r} #define CRGB(r, g, b) \
(cRGB) { b, g, r }
#include "kaleidoscope/device/Base.h" #include "kaleidoscope/device/Base.h"
#include "kaleidoscope/driver/bootloader/samd/Bossac.h" #include "kaleidoscope/driver/bootloader/samd/Bossac.h"
@ -67,6 +68,7 @@ class RaiseLEDDriver : public kaleidoscope::driver::led::Base<RaiseLEDDriverProp
static uint8_t getBrightness(); static uint8_t getBrightness();
static void updateNeuronLED(); static void updateNeuronLED();
private: private:
static bool isLEDChangedNeuron; static bool isLEDChangedNeuron;
static uint8_t isLEDChangedLeft[LED_BANKS]; static uint8_t isLEDChangedLeft[LED_BANKS];
@ -126,6 +128,7 @@ class RaiseKeyScanner : public kaleidoscope::driver::keyscanner::Base<RaiseKeySc
private: private:
typedef RaiseKeyScanner ThisType; typedef RaiseKeyScanner ThisType;
typedef RaiseKeyScannerProps Props_; typedef RaiseKeyScannerProps Props_;
public: public:
static void setup(); static void setup();
static void scanMatrix(); static void scanMatrix();
@ -174,9 +177,10 @@ struct RaiseProps : kaleidoscope::device::BaseProps {
static constexpr const char *short_name = "raise"; static constexpr const char *short_name = "raise";
}; };
class Raise: public kaleidoscope::device::Base<RaiseProps> { class Raise : public kaleidoscope::device::Base<RaiseProps> {
private: private:
static RaiseProps::SideFlasher SideFlasher; static RaiseProps::SideFlasher SideFlasher;
public: public:
static void setup(); static void setup();

@ -223,7 +223,7 @@ auto constexpr gamma8 = kaleidoscope::driver::color::gamma_correction;
void RaiseSide::sendLEDBank(uint8_t bank) { void RaiseSide::sendLEDBank(uint8_t bank) {
uint8_t data[LED_BYTES_PER_BANK + 1]; // + 1 for the update LED command itself uint8_t data[LED_BYTES_PER_BANK + 1]; // + 1 for the update LED command itself
data[0] = TWI_CMD_LED_BASE + bank; data[0] = TWI_CMD_LED_BASE + bank;
for (uint8_t i = 0 ; i < LED_BYTES_PER_BANK; i++) { for (uint8_t i = 0; i < LED_BYTES_PER_BANK; i++) {
uint8_t c = led_data.bytes[bank][i]; uint8_t c = led_data.bytes[bank][i];
if (c > brightness_adjustment_) if (c > brightness_adjustment_)
c -= brightness_adjustment_; c -= brightness_adjustment_;

@ -57,7 +57,8 @@ typedef union {
class RaiseSide { class RaiseSide {
public: public:
explicit RaiseSide(uint8_t ad01) : ad01_(ad01), twi_(i2c_addr_base_ | ad01) {} explicit RaiseSide(uint8_t ad01)
: ad01_(ad01), twi_(i2c_addr_base_ | ad01) {}
int readVersion(); int readVersion();
int readSLEDVersion(); int readSLEDVersion();

@ -28,10 +28,11 @@ namespace device {
namespace dygma { namespace dygma {
namespace raise { namespace raise {
template <typename _Firmware> template<typename _Firmware>
class SideFlash : public kaleidoscope::Plugin { class SideFlash : public kaleidoscope::Plugin {
private: private:
_Firmware firmware; _Firmware firmware;
public: public:
EventHandlerResult onFocusEvent(const char *command) { EventHandlerResult onFocusEvent(const char *command) {
if (::Focus.handleHelp(command, PSTR("hardware.flash_left_side\nhardware.flash_right_side\nhardware.verify_left_side\nhardware.verify_right_side"))) if (::Focus.handleHelp(command, PSTR("hardware.flash_left_side\nhardware.flash_right_side\nhardware.verify_left_side\nhardware.verify_right_side")))

@ -50,7 +50,7 @@ uint8_t TWI::writeTo(uint8_t *data, size_t length) {
return 0; return 0;
} }
uint8_t TWI::readFrom(uint8_t* data, size_t length) { uint8_t TWI::readFrom(uint8_t *data, size_t length) {
uint8_t counter = 0; uint8_t counter = 0;
uint32_t timeout; uint32_t timeout;
uint8_t *buffer = data; uint8_t *buffer = data;

@ -29,10 +29,11 @@ namespace raise {
class TWI { class TWI {
public: public:
explicit TWI(int addr) : addr_(addr), crc_errors_(0) {} explicit TWI(int addr)
: addr_(addr), crc_errors_(0) {}
uint8_t writeTo(uint8_t *data, size_t length); uint8_t writeTo(uint8_t *data, size_t length);
uint8_t readFrom(uint8_t* data, size_t length); uint8_t readFrom(uint8_t *data, size_t length);
void disable(); void disable();
void init(uint16_t clock_khz); void init(uint16_t clock_khz);
uint8_t crc_errors() { uint8_t crc_errors() {

@ -148,9 +148,8 @@ void ErgoDox::setStatusLED(uint8_t led, bool state) {
} }
void ErgoDox::setStatusLEDBrightness(uint8_t led, uint8_t brightness) { void ErgoDox::setStatusLEDBrightness(uint8_t led, uint8_t brightness) {
(led == 1) ? (OCR1A = brightness) : (led == 1) ? (OCR1A = brightness) : (led == 2) ? (OCR1B = brightness)
(led == 2) ? (OCR1B = brightness) : : (OCR1C = brightness);
(OCR1C = brightness);
} }
uint8_t ErgoDox::debounceMaskForRow(uint8_t row) { uint8_t ErgoDox::debounceMaskForRow(uint8_t row) {

@ -33,7 +33,8 @@ struct cRGB {
uint8_t r, g, b; uint8_t r, g, b;
}; };
#define CRGB(r,g,b) (cRGB){b, g, r} #define CRGB(r, g, b) \
(cRGB) { b, g, r }
#include "kaleidoscope/device/ATmega32U4Keyboard.h" #include "kaleidoscope/device/ATmega32U4Keyboard.h"
#include "kaleidoscope/driver/bootloader/avr/HalfKay.h" #include "kaleidoscope/driver/bootloader/avr/HalfKay.h"
@ -51,7 +52,6 @@ struct ErgoDoxProps : public kaleidoscope::device::ATmega32U4KeyboardProps {
static constexpr uint8_t matrix_rows = 14; static constexpr uint8_t matrix_rows = 14;
static constexpr uint8_t matrix_columns = 6; static constexpr uint8_t matrix_columns = 6;
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr; typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
}; };
typedef kaleidoscope::driver::bootloader::avr::HalfKay Bootloader; typedef kaleidoscope::driver::bootloader::avr::HalfKay Bootloader;
static constexpr const char *short_name = "ErgoDox-EZ"; static constexpr const char *short_name = "ErgoDox-EZ";

@ -35,8 +35,8 @@
#include "kaleidoscope/device/ez/ErgoDox/i2cmaster.h" #include "kaleidoscope/device/ez/ErgoDox/i2cmaster.h"
#define I2C_ADDR 0b0100000 #define I2C_ADDR 0b0100000
#define I2C_ADDR_WRITE ( (I2C_ADDR<<1) | I2C_WRITE ) #define I2C_ADDR_WRITE ((I2C_ADDR << 1) | I2C_WRITE)
#define I2C_ADDR_READ ( (I2C_ADDR<<1) | I2C_READ ) #define I2C_ADDR_READ ((I2C_ADDR << 1) | I2C_READ)
#define IODIRA 0x00 #define IODIRA 0x00
#define IODIRB 0x01 #define IODIRB 0x01
#define GPPUA 0x0C #define GPPUA 0x0C
@ -90,8 +90,7 @@ out:
return status; return status;
} }
void void ErgoDoxScanner::begin() {
ErgoDoxScanner::begin() {
expander_error_ = initExpander(); expander_error_ = initExpander();
// Init columns // Init columns
@ -118,13 +117,13 @@ void __attribute__((optimize(3))) ErgoDoxScanner::selectExtenderRow(int row) {
expander_error_ = i2c_write(0xFF & ~(1 << row)); expander_error_ = i2c_write(0xFF & ~(1 << row));
if (expander_error_) if (expander_error_)
goto out; goto out;
out: out:
i2c_stop(); i2c_stop();
} }
} }
void __attribute__((optimize(3))) ErgoDoxScanner::toggleATMegaRow(int row) { void __attribute__((optimize(3))) ErgoDoxScanner::toggleATMegaRow(int row) {
static uint8_t row_pins[] = { PIN_B0, PIN_B1, PIN_B2, PIN_B3, PIN_D2, PIN_D3, PIN_C6 }; static uint8_t row_pins[] = {PIN_B0, PIN_B1, PIN_B2, PIN_B3, PIN_D2, PIN_D3, PIN_C6};
OUTPUT_TOGGLE(row_pins[row]); OUTPUT_TOGGLE(row_pins[row]);
} }
@ -148,7 +147,7 @@ ErgoDoxScanner::readCols(int row) {
data = i2c_readNak(); data = i2c_readNak();
data = ~data; data = ~data;
out: out:
i2c_stop(); i2c_stop();
return data; return data;
} else { } else {
@ -156,8 +155,7 @@ out:
} }
} }
void void ErgoDoxScanner::reattachExpanderOnError() {
ErgoDoxScanner::reattachExpanderOnError() {
static uint32_t start_time = millis(); static uint32_t start_time = millis();
if (!expander_error_) if (!expander_error_)

@ -39,7 +39,7 @@ void i2c_init(void) {
TWSR = 0; /* no prescaler */ TWSR = 0; /* no prescaler */
TWBR = 10; /* must be >= 10 for stable operation */ TWBR = 10; /* must be >= 10 for stable operation */
}/* i2c_init */ } /* i2c_init */
/************************************************************************* /*************************************************************************
@ -53,7 +53,8 @@ unsigned char i2c_start(unsigned char address) {
TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN); TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN);
// wait until transmission completed // wait until transmission completed
while (!(TWCR & (1 << TWINT))); while (!(TWCR & (1 << TWINT)))
;
// check value of TWI Status Register. Mask prescaler bits. // check value of TWI Status Register. Mask prescaler bits.
twst = TW_STATUS & 0xF8; twst = TW_STATUS & 0xF8;
@ -64,7 +65,8 @@ unsigned char i2c_start(unsigned char address) {
TWCR = (1 << TWINT) | (1 << TWEN); TWCR = (1 << TWINT) | (1 << TWEN);
// wail until transmission completed and ACK/NACK has been received // wail until transmission completed and ACK/NACK has been received
while (!(TWCR & (1 << TWINT))); while (!(TWCR & (1 << TWINT)))
;
// check value of TWI Status Register. Mask prescaler bits. // check value of TWI Status Register. Mask prescaler bits.
twst = TW_STATUS & 0xF8; twst = TW_STATUS & 0xF8;
@ -72,7 +74,7 @@ unsigned char i2c_start(unsigned char address) {
return 0; return 0;
}/* i2c_start */ } /* i2c_start */
/************************************************************************* /*************************************************************************
@ -90,7 +92,8 @@ void i2c_start_wait(unsigned char address) {
TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN); TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN);
// wait until transmission completed // wait until transmission completed
while (!(TWCR & (1 << TWINT))); while (!(TWCR & (1 << TWINT)))
;
// check value of TWI Status Register. Mask prescaler bits. // check value of TWI Status Register. Mask prescaler bits.
twst = TW_STATUS & 0xF8; twst = TW_STATUS & 0xF8;
@ -101,7 +104,8 @@ void i2c_start_wait(unsigned char address) {
TWCR = (1 << TWINT) | (1 << TWEN); TWCR = (1 << TWINT) | (1 << TWEN);
// wail until transmission completed // wail until transmission completed
while (!(TWCR & (1 << TWINT))); while (!(TWCR & (1 << TWINT)))
;
// check value of TWI Status Register. Mask prescaler bits. // check value of TWI Status Register. Mask prescaler bits.
twst = TW_STATUS & 0xF8; twst = TW_STATUS & 0xF8;
@ -110,7 +114,8 @@ void i2c_start_wait(unsigned char address) {
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO); TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO);
// wait until stop condition is executed and bus released // wait until stop condition is executed and bus released
while (TWCR & (1 << TWSTO)); while (TWCR & (1 << TWSTO))
;
continue; continue;
} }
@ -118,7 +123,7 @@ void i2c_start_wait(unsigned char address) {
break; break;
} }
}/* i2c_start_wait */ } /* i2c_start_wait */
/************************************************************************* /*************************************************************************
@ -132,7 +137,7 @@ void i2c_start_wait(unsigned char address) {
unsigned char i2c_rep_start(unsigned char address) { unsigned char i2c_rep_start(unsigned char address) {
return i2c_start(address); return i2c_start(address);
}/* i2c_rep_start */ } /* i2c_rep_start */
/************************************************************************* /*************************************************************************
@ -143,9 +148,10 @@ void i2c_stop(void) {
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO); TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO);
// wait until stop condition is executed and bus released // wait until stop condition is executed and bus released
while (TWCR & (1 << TWSTO)); while (TWCR & (1 << TWSTO))
;
}/* i2c_stop */ } /* i2c_stop */
/************************************************************************* /*************************************************************************
@ -163,14 +169,15 @@ unsigned char i2c_write(unsigned char data) {
TWCR = (1 << TWINT) | (1 << TWEN); TWCR = (1 << TWINT) | (1 << TWEN);
// wait until transmission completed // wait until transmission completed
while (!(TWCR & (1 << TWINT))); while (!(TWCR & (1 << TWINT)))
;
// check value of TWI Status Register. Mask prescaler bits // check value of TWI Status Register. Mask prescaler bits
twst = TW_STATUS & 0xF8; twst = TW_STATUS & 0xF8;
if (twst != TW_MT_DATA_ACK) return 1; if (twst != TW_MT_DATA_ACK) return 1;
return 0; return 0;
}/* i2c_write */ } /* i2c_write */
/************************************************************************* /*************************************************************************
@ -180,11 +187,12 @@ unsigned char i2c_write(unsigned char data) {
*************************************************************************/ *************************************************************************/
unsigned char i2c_readAck(void) { unsigned char i2c_readAck(void) {
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWEA); TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWEA);
while (!(TWCR & (1 << TWINT))); while (!(TWCR & (1 << TWINT)))
;
return TWDR; return TWDR;
}/* i2c_readAck */ } /* i2c_readAck */
/************************************************************************* /*************************************************************************
@ -194,11 +202,12 @@ unsigned char i2c_readAck(void) {
*************************************************************************/ *************************************************************************/
unsigned char i2c_readNak(void) { unsigned char i2c_readNak(void) {
TWCR = (1 << TWINT) | (1 << TWEN); TWCR = (1 << TWINT) | (1 << TWEN);
while (!(TWCR & (1 << TWINT))); while (!(TWCR & (1 << TWINT)))
;
return TWDR; return TWDR;
}/* i2c_readNak */ } /* i2c_readNak */
#endif #endif
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD

@ -30,9 +30,9 @@ namespace kaleidoscope {
namespace device { namespace device {
namespace gd32 { namespace gd32 {
struct EvalStorageProps: kaleidoscope::driver::storage::GD32FlashProps {}; struct EvalStorageProps : kaleidoscope::driver::storage::GD32FlashProps {};
struct EvalProps: kaleidoscope::device::BaseProps { struct EvalProps : kaleidoscope::device::BaseProps {
typedef kaleidoscope::driver::bootloader::gd32::Base BootLoader; typedef kaleidoscope::driver::bootloader::gd32::Base BootLoader;
typedef eval::KeyScannerProps KeyScannerProps; typedef eval::KeyScannerProps KeyScannerProps;
typedef eval::KeyScanner KeyScanner; typedef eval::KeyScanner KeyScanner;
@ -41,7 +41,7 @@ struct EvalProps: kaleidoscope::device::BaseProps {
static constexpr const char *short_name = "GD32Eval"; static constexpr const char *short_name = "GD32Eval";
}; };
class Eval: public kaleidoscope::device::Base<EvalProps> {}; class Eval : public kaleidoscope::device::Base<EvalProps> {};
// clang-format off // clang-format off
#define PER_KEY_DATA(dflt, \ #define PER_KEY_DATA(dflt, \

@ -32,16 +32,17 @@ struct KeyScannerProps : public kaleidoscope::driver::keyscanner::BaseProps {
static constexpr uint8_t matrix_rows = 1; static constexpr uint8_t matrix_rows = 1;
static constexpr uint8_t matrix_columns = 2; static constexpr uint8_t matrix_columns = 2;
static constexpr uint8_t matrix_row_pins[] = { PA3 }; static constexpr uint8_t matrix_row_pins[] = {PA3};
static constexpr uint8_t matrix_col_pins[] = { PE4, PD12 }; static constexpr uint8_t matrix_col_pins[] = {PE4, PD12};
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr; typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
}; };
class KeyScanner: public kaleidoscope::driver::keyscanner::Base<KeyScannerProps> { class KeyScanner : public kaleidoscope::driver::keyscanner::Base<KeyScannerProps> {
private: private:
typedef KeyScanner ThisType; typedef KeyScanner ThisType;
typedef KeyScannerProps Props_; typedef KeyScannerProps Props_;
public: public:
static bool do_scan; static bool do_scan;
@ -55,6 +56,7 @@ class KeyScanner: public kaleidoscope::driver::keyscanner::Base<KeyScannerProps>
static bool wasKeyswitchPressed(KeyAddr key_addr); static bool wasKeyswitchPressed(KeyAddr key_addr);
static uint8_t previousPressedKeyswitchCount(); static uint8_t previousPressedKeyswitchCount();
private: private:
/* /*
each of these variables are storing the state for a row of keys each of these variables are storing the state for a row of keys

@ -44,7 +44,8 @@ constexpr uint8_t KeyScannerProps::matrix_col_pins[matrix_columns];
// `KeyScanner` here refers to the alias set up above, just like in the // `KeyScanner` here refers to the alias set up above, just like in the
// `KeyScannerProps` case above. // `KeyScannerProps` case above.
template<> KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {}; template<>
KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {};
// We set up the TIMER1 interrupt vector here. Due to dependency reasons, this // We set up the TIMER1 interrupt vector here. Due to dependency reasons, this
// cannot be in a header-only driver, and must be placed here. // cannot be in a header-only driver, and must be placed here.

@ -32,7 +32,7 @@ namespace device {
namespace kbdfans { namespace kbdfans {
struct KBD4xProps : kaleidoscope::device::ATmega32U4KeyboardProps { struct KBD4xProps : kaleidoscope::device::ATmega32U4KeyboardProps {
struct MCUProps: public kaleidoscope::driver::mcu::ATmega32U4Props { struct MCUProps : public kaleidoscope::driver::mcu::ATmega32U4Props {
static constexpr bool disable_jtag = true; static constexpr bool disable_jtag = true;
static constexpr bool disable_clock_division = true; static constexpr bool disable_clock_division = true;
}; };
@ -43,7 +43,7 @@ struct KBD4xProps : kaleidoscope::device::ATmega32U4KeyboardProps {
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr; typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifndef KALEIDOSCOPE_VIRTUAL_BUILD
static constexpr uint8_t matrix_row_pins[matrix_rows] = {PIN_D0, PIN_D1, PIN_D2, PIN_D3}; static constexpr uint8_t matrix_row_pins[matrix_rows] = {PIN_D0, PIN_D1, PIN_D2, PIN_D3};
static constexpr uint8_t matrix_col_pins[matrix_columns] = { PIN_F0, PIN_F1, PIN_F4, PIN_F5, PIN_F6, PIN_F7, PIN_B3, PIN_B1, PIN_B0, PIN_D5, PIN_B7, PIN_C7 }; static constexpr uint8_t matrix_col_pins[matrix_columns] = {PIN_F0, PIN_F1, PIN_F4, PIN_F5, PIN_F6, PIN_F7, PIN_B3, PIN_B1, PIN_B0, PIN_D5, PIN_B7, PIN_C7};
#endif // KALEIDOSCOPE_VIRTUAL_BUILD #endif // KALEIDOSCOPE_VIRTUAL_BUILD
}; };
typedef kaleidoscope::driver::keyscanner::ATmega<KeyScannerProps> KeyScanner; typedef kaleidoscope::driver::keyscanner::ATmega<KeyScannerProps> KeyScanner;
@ -52,7 +52,7 @@ struct KBD4xProps : kaleidoscope::device::ATmega32U4KeyboardProps {
}; };
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifndef KALEIDOSCOPE_VIRTUAL_BUILD
class KBD4x: public kaleidoscope::device::ATmega32U4Keyboard<KBD4xProps> {}; class KBD4x : public kaleidoscope::device::ATmega32U4Keyboard<KBD4xProps> {};
#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
/* Device definition omitted for virtual device builds. /* Device definition omitted for virtual device builds.
* We need to forward declare the device name, though, as there are * We need to forward declare the device name, though, as there are

@ -45,7 +45,8 @@ constexpr uint8_t KeyScannerProps::matrix_col_pins[matrix_columns];
// `KeyScanner` here refers to the alias set up above, just like in the // `KeyScanner` here refers to the alias set up above, just like in the
// `KeyScannerProps` case above. // `KeyScannerProps` case above.
template<> KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {}; template<>
KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {};
// We set up the TIMER1 interrupt vector here. Due to dependency reasons, this // We set up the TIMER1 interrupt vector here. Due to dependency reasons, this
// cannot be in a header-only driver, and must be placed here. // cannot be in a header-only driver, and must be placed here.

@ -50,7 +50,7 @@ struct AtreusProps : kaleidoscope::device::ATmega32U4KeyboardProps {
}; };
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifndef KALEIDOSCOPE_VIRTUAL_BUILD
class Atreus: public kaleidoscope::device::ATmega32U4Keyboard<AtreusProps> {}; class Atreus : public kaleidoscope::device::ATmega32U4Keyboard<AtreusProps> {};
#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
/* Device definition omitted for virtual device builds. /* Device definition omitted for virtual device builds.
* We need to forward declare the device name, though, as there are * We need to forward declare the device name, though, as there are

@ -71,7 +71,8 @@ constexpr uint8_t KeyScannerProps::matrix_col_pins[matrix_columns];
// `KeyScanner` here refers to the alias set up above, just like in the // `KeyScanner` here refers to the alias set up above, just like in the
// `KeyScannerProps` case above. // `KeyScannerProps` case above.
template<> KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {}; template<>
KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {};
// We set up the TIMER1 interrupt vector here. Due to dependency reasons, this // We set up the TIMER1 interrupt vector here. Due to dependency reasons, this
// cannot be in a header-only driver, and must be placed here. // cannot be in a header-only driver, and must be placed here.
@ -97,7 +98,7 @@ void ImagoLEDDriver::setup() {
} }
void ImagoLEDDriver::twiSend(uint8_t addr, uint8_t Reg_Add, uint8_t Reg_Dat) { void ImagoLEDDriver::twiSend(uint8_t addr, uint8_t Reg_Add, uint8_t Reg_Dat) {
uint8_t data[] = {Reg_Add, Reg_Dat }; uint8_t data[] = {Reg_Add, Reg_Dat};
uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0); uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0);
} }
@ -139,11 +140,11 @@ uint8_t ImagoLEDDriver::adjustBrightness(uint8_t value) {
} }
void ImagoLEDDriver::syncLeds() { void ImagoLEDDriver::syncLeds() {
// if (!isLEDChanged) // if (!isLEDChanged)
// return; // return;
uint8_t data[LED_REGISTER_DATA_LARGEST + 1]; uint8_t data[LED_REGISTER_DATA_LARGEST + 1];
data[0] = 0;// the address of the first byte to copy in data[0] = 0; // the address of the first byte to copy in
uint8_t last_led = 0; uint8_t last_led = 0;
// Write the first LED bank // Write the first LED bank
@ -190,7 +191,6 @@ void ImagoLEDDriver::setAllPwmTo(uint8_t step) {
// PWM Register 0 is 0x00 to 0xB3 // PWM Register 0 is 0x00 to 0xB3
for (auto i = 1; i <= 0xB4; i++) { for (auto i = 1; i <= 0xB4; i++) {
data[i] = step; data[i] = step;
} }
twi_writeTo(LED_DRIVER_ADDR, data, 0xB5, 1, 0); twi_writeTo(LED_DRIVER_ADDR, data, 0xB5, 1, 0);
@ -198,7 +198,6 @@ void ImagoLEDDriver::setAllPwmTo(uint8_t step) {
// PWM Register 1 is 0x00 to 0xAA // PWM Register 1 is 0x00 to 0xAA
for (auto i = 1; i <= LED_REGISTER_PWM1_SIZE; i++) { for (auto i = 1; i <= LED_REGISTER_PWM1_SIZE; i++) {
data[i] = step; data[i] = step;
} }
twi_writeTo(LED_DRIVER_ADDR, data, 0xAC, 1, 0); twi_writeTo(LED_DRIVER_ADDR, data, 0xAC, 1, 0);
} }

@ -27,7 +27,8 @@ struct cRGB {
uint8_t r; uint8_t r;
}; };
#define CRGB(r,g,b) (cRGB){b, g, r} #define CRGB(r, g, b) \
(cRGB) { b, g, r }
#include "kaleidoscope/device/ATmega32U4Keyboard.h" #include "kaleidoscope/device/ATmega32U4Keyboard.h"
#include "kaleidoscope/driver/bootloader/avr/Caterina.h" #include "kaleidoscope/driver/bootloader/avr/Caterina.h"
@ -40,7 +41,7 @@ namespace keyboardio {
using kaleidoscope::driver::led::no_led; using kaleidoscope::driver::led::no_led;
struct ImagoLEDDriverProps: public kaleidoscope::driver::led::BaseProps { struct ImagoLEDDriverProps : public kaleidoscope::driver::led::BaseProps {
static constexpr uint8_t led_count = 78; static constexpr uint8_t led_count = 78;
static constexpr uint8_t key_led_map[/* 5*16 */] PROGMEM = { static constexpr uint8_t key_led_map[/* 5*16 */] PROGMEM = {
// clang-format off // clang-format off
@ -103,7 +104,7 @@ struct ImagoProps : kaleidoscope::device::ATmega32U4KeyboardProps {
}; };
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifndef KALEIDOSCOPE_VIRTUAL_BUILD
class Imago: public kaleidoscope::device::ATmega32U4Keyboard<ImagoProps> { class Imago : public kaleidoscope::device::ATmega32U4Keyboard<ImagoProps> {
public: public:
void setup(); void setup();
}; };

@ -44,10 +44,10 @@ void twi_init(void);
void twi_disable(void); void twi_disable(void);
void twi_setAddress(uint8_t); void twi_setAddress(uint8_t);
void twi_setFrequency(uint32_t); void twi_setFrequency(uint32_t);
uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t, uint8_t); uint8_t twi_readFrom(uint8_t, uint8_t *, uint8_t, uint8_t);
uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t); uint8_t twi_writeTo(uint8_t, uint8_t *, uint8_t, uint8_t, uint8_t);
uint8_t twi_transmit(const uint8_t*, uint8_t); uint8_t twi_transmit(const uint8_t *, uint8_t);
void twi_attachSlaveRxEvent(void (*)(uint8_t*, int)); void twi_attachSlaveRxEvent(void (*)(uint8_t *, int));
void twi_attachSlaveTxEvent(void (*)(void)); void twi_attachSlaveTxEvent(void (*)(void));
void twi_reply(uint8_t); void twi_reply(uint8_t);
void twi_stop(void); void twi_stop(void);

@ -30,7 +30,8 @@
#include "kaleidoscope/MatrixAddr.h" // for MatrixAddr #include "kaleidoscope/MatrixAddr.h" // for MatrixAddr
#include "kaleidoscope/macro_helpers.h" // for RESTRICT_AR... #include "kaleidoscope/macro_helpers.h" // for RESTRICT_AR...
#define CRGB(r,g,b) (cRGB){b, g, r} #define CRGB(r, g, b) \
(cRGB) { b, g, r }
struct cRGB { struct cRGB {
uint8_t b; uint8_t b;
@ -91,6 +92,7 @@ struct Model01KeyScannerProps : public kaleidoscope::driver::keyscanner::BasePro
class Model01KeyScanner : public kaleidoscope::driver::keyscanner::Base<Model01KeyScannerProps> { class Model01KeyScanner : public kaleidoscope::driver::keyscanner::Base<Model01KeyScannerProps> {
private: private:
typedef Model01KeyScanner ThisType; typedef Model01KeyScanner ThisType;
public: public:
static void setup(); static void setup();
static void scanMatrix(); static void scanMatrix();

@ -44,10 +44,10 @@ void twi_init(void);
void twi_disable(void); void twi_disable(void);
void twi_setAddress(uint8_t); void twi_setAddress(uint8_t);
void twi_setFrequency(uint32_t); void twi_setFrequency(uint32_t);
uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t, uint8_t); uint8_t twi_readFrom(uint8_t, uint8_t *, uint8_t, uint8_t);
uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t); uint8_t twi_writeTo(uint8_t, uint8_t *, uint8_t, uint8_t, uint8_t);
uint8_t twi_transmit(const uint8_t*, uint8_t); uint8_t twi_transmit(const uint8_t *, uint8_t);
void twi_attachSlaveRxEvent(void (*)(uint8_t*, int)); void twi_attachSlaveRxEvent(void (*)(uint8_t *, int));
void twi_attachSlaveTxEvent(void (*)(void)); void twi_attachSlaveTxEvent(void (*)(void));
void twi_reply(uint8_t); void twi_reply(uint8_t);
void twi_stop(void); void twi_stop(void);

@ -82,8 +82,6 @@ uint8_t Model01Side::setKeyscanInterval(uint8_t delay) {
} }
// returns -1 on error, otherwise returns the scanner version integer // returns -1 on error, otherwise returns the scanner version integer
int Model01Side::readVersion() { int Model01Side::readVersion() {
return readRegister(TWI_CMD_VERSION); return readRegister(TWI_CMD_VERSION);
@ -113,7 +111,6 @@ uint8_t Model01Side::setLEDSPIFrequency(uint8_t frequency) {
} }
int Model01Side::readRegister(uint8_t cmd) { int Model01Side::readRegister(uint8_t cmd) {
uint8_t return_value = 0; uint8_t return_value = 0;
@ -122,7 +119,6 @@ int Model01Side::readRegister(uint8_t cmd) {
uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0); uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0);
delayMicroseconds(15); // We may be able to drop this in the future delayMicroseconds(15); // We may be able to drop this in the future
// but will need to verify with correctly // but will need to verify with correctly
// sized pull-ups on both the left and right // sized pull-ups on both the left and right
@ -137,7 +133,6 @@ int Model01Side::readRegister(uint8_t cmd) {
} else { } else {
return -1; return -1;
} }
} }
@ -175,7 +170,7 @@ auto constexpr gamma8 = kaleidoscope::driver::color::gamma_correction;
void Model01Side::sendLEDBank(uint8_t bank) { void Model01Side::sendLEDBank(uint8_t bank) {
uint8_t data[LED_BYTES_PER_BANK + 1]; uint8_t data[LED_BYTES_PER_BANK + 1];
data[0] = TWI_CMD_LED_BASE + bank; data[0] = TWI_CMD_LED_BASE + bank;
for (uint8_t i = 0 ; i < LED_BYTES_PER_BANK; i++) { for (uint8_t i = 0; i < LED_BYTES_PER_BANK; i++) {
/* While the ATTiny controller does have a global brightness command, it is /* While the ATTiny controller does have a global brightness command, it is
* limited to 32 levels, and those aren't nicely spread out either. For this * limited to 32 levels, and those aren't nicely spread out either. For this
* reason, we're doing our own brightness adjustment on this side, because * reason, we're doing our own brightness adjustment on this side, because
@ -195,8 +190,7 @@ void Model01Side::setAllLEDsTo(cRGB color) {
uint8_t data[] = {TWI_CMD_LED_SET_ALL_TO, uint8_t data[] = {TWI_CMD_LED_SET_ALL_TO,
pgm_read_byte(&gamma8[color.b]), pgm_read_byte(&gamma8[color.b]),
pgm_read_byte(&gamma8[color.g]), pgm_read_byte(&gamma8[color.g]),
pgm_read_byte(&gamma8[color.r]) pgm_read_byte(&gamma8[color.r])};
};
uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0); uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0);
} }
@ -205,10 +199,8 @@ void Model01Side::setOneLEDTo(uint8_t led, cRGB color) {
led, led,
pgm_read_byte(&gamma8[color.b]), pgm_read_byte(&gamma8[color.b]),
pgm_read_byte(&gamma8[color.g]), pgm_read_byte(&gamma8[color.g]),
pgm_read_byte(&gamma8[color.r]) pgm_read_byte(&gamma8[color.r])};
};
uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0); uint8_t result = twi_writeTo(addr, data, ELEMENTS(data), 1, 0);
} }
} // namespace keyboardio } // namespace keyboardio

@ -34,13 +34,14 @@ struct cRGB {
uint8_t g; uint8_t g;
uint8_t r; uint8_t r;
}; };
#define CRGB(r,g,b) (cRGB){b, g, r} #define CRGB(r, g, b) \
(cRGB) { b, g, r }
#endif #endif
#define LED_BANKS 4 #define LED_BANKS 4
#define LEDS_PER_HAND 32 #define LEDS_PER_HAND 32
#define LED_BYTES_PER_BANK sizeof(cRGB) * LEDS_PER_HAND/LED_BANKS #define LED_BYTES_PER_BANK sizeof(cRGB) * LEDS_PER_HAND / LED_BANKS
namespace kaleidoscope { namespace kaleidoscope {
namespace driver { namespace driver {

@ -48,7 +48,6 @@ void Model100Hands::setup(void) {
Model100KeyScanner::enableScannerPower(); Model100KeyScanner::enableScannerPower();
Wire.begin(); Wire.begin();
Wire.setClock(400000); Wire.setClock(400000);
} }
/********* LED Driver *********/ /********* LED Driver *********/
@ -125,9 +124,9 @@ driver::keyboardio::keydata_t Model100KeyScanner::previousLeftHandState;
driver::keyboardio::keydata_t Model100KeyScanner::previousRightHandState; driver::keyboardio::keydata_t Model100KeyScanner::previousRightHandState;
void Model100KeyScanner::enableScannerPower(void) { void Model100KeyScanner::enableScannerPower(void) {
// Turn on the switched 5V network. // Turn on the switched 5V network.
// make sure this happens at least 100ms after USB connect // make sure this happens at least 100ms after USB connect
// to satisfy inrush limits // to satisfy inrush limits
// //
pinMode(PB9, OUTPUT_OPEN_DRAIN); pinMode(PB9, OUTPUT_OPEN_DRAIN);
digitalWrite(PB9, LOW); digitalWrite(PB9, LOW);
@ -141,7 +140,6 @@ void Model100KeyScanner::disableScannerPower(void) {
} }
void Model100KeyScanner::setup() { void Model100KeyScanner::setup() {
enableScannerPower(); enableScannerPower();
delay(250); delay(250);

@ -25,7 +25,8 @@
#include <Arduino.h> #include <Arduino.h>
#define CRGB(r,g,b) (cRGB){b, g, r} #define CRGB(r, g, b) \
(cRGB) { b, g, r }
struct cRGB { struct cRGB {
uint8_t b; uint8_t b;
@ -47,7 +48,7 @@ namespace kaleidoscope {
namespace device { namespace device {
namespace keyboardio { namespace keyboardio {
struct Model100StorageProps: public kaleidoscope::driver::storage::GD32FlashProps { struct Model100StorageProps : public kaleidoscope::driver::storage::GD32FlashProps {
static constexpr uint16_t length = EEPROM_EMULATION_SIZE; static constexpr uint16_t length = EEPROM_EMULATION_SIZE;
}; };
@ -92,6 +93,7 @@ struct Model100KeyScannerProps : public kaleidoscope::driver::keyscanner::BasePr
class Model100KeyScanner : public kaleidoscope::driver::keyscanner::Base<Model100KeyScannerProps> { class Model100KeyScanner : public kaleidoscope::driver::keyscanner::Base<Model100KeyScannerProps> {
private: private:
typedef Model100KeyScanner ThisType; typedef Model100KeyScanner ThisType;
public: public:
static void setup(); static void setup();
static void scanMatrix(); static void scanMatrix();
@ -122,7 +124,7 @@ class Model100KeyScanner;
// If we need to override HID props: // If we need to override HID props:
struct Model100HIDProps: public kaleidoscope::driver::hid::KeyboardioProps { struct Model100HIDProps : public kaleidoscope::driver::hid::KeyboardioProps {
//typedef kaleidoscope::driver::hid::base::AbsoluteMouseProps AbsoluteMouseProps; //typedef kaleidoscope::driver::hid::base::AbsoluteMouseProps AbsoluteMouseProps;
//typedef kaleidoscope::driver::hid::base::AbsoluteMouse<AbsoluteMouseProps> AbsoluteMouse; //typedef kaleidoscope::driver::hid::base::AbsoluteMouse<AbsoluteMouseProps> AbsoluteMouse;
}; };

@ -75,8 +75,6 @@ uint8_t Model100Side::setKeyscanInterval(uint8_t delay) {
} }
// returns -1 on error, otherwise returns the scanner version integer // returns -1 on error, otherwise returns the scanner version integer
int Model100Side::readVersion() { int Model100Side::readVersion() {
return readRegister(TWI_CMD_VERSION); return readRegister(TWI_CMD_VERSION);
@ -134,7 +132,6 @@ bool Model100Side::isDeviceAvailable() {
// we've decremented the counter, but it's not time to probe for the device yet. // we've decremented the counter, but it's not time to probe for the device yet.
return false; return false;
} }
} }
void Model100Side::markDeviceUnavailable() { void Model100Side::markDeviceUnavailable() {
@ -180,7 +177,6 @@ int Model100Side::readRegister(uint8_t cmd) {
markDeviceUnavailable(); markDeviceUnavailable();
return -1; return -1;
} }
} }
@ -225,7 +221,7 @@ void Model100Side::sendLEDData() {
void Model100Side::sendLEDBank(uint8_t bank) { void Model100Side::sendLEDBank(uint8_t bank) {
uint8_t data[LED_BYTES_PER_BANK + 1]; uint8_t data[LED_BYTES_PER_BANK + 1];
data[0] = TWI_CMD_LED_BASE + bank; data[0] = TWI_CMD_LED_BASE + bank;
for (uint8_t i = 0 ; i < LED_BYTES_PER_BANK; i++) { for (uint8_t i = 0; i < LED_BYTES_PER_BANK; i++) {
/* While the ATTiny controller does have a global brightness command, it is /* While the ATTiny controller does have a global brightness command, it is
* limited to 32 levels, and those aren't nicely spread out either. For this * limited to 32 levels, and those aren't nicely spread out either. For this
* reason, we're doing our own brightness adjustment on this side, because * reason, we're doing our own brightness adjustment on this side, because
@ -245,8 +241,7 @@ void Model100Side::setAllLEDsTo(cRGB color) {
uint8_t data[] = {TWI_CMD_LED_SET_ALL_TO, uint8_t data[] = {TWI_CMD_LED_SET_ALL_TO,
color.b, color.b,
color.g, color.g,
color.r color.r};
};
uint8_t result = writeData(data, ELEMENTS(data)); uint8_t result = writeData(data, ELEMENTS(data));
} }
@ -255,10 +250,8 @@ void Model100Side::setOneLEDTo(uint8_t led, cRGB color) {
led, led,
color.b, color.b,
color.g, color.g,
color.r color.r};
};
uint8_t result = writeData(data, ELEMENTS(data)); uint8_t result = writeData(data, ELEMENTS(data));
} }
} // namespace keyboardio } // namespace keyboardio

@ -34,13 +34,14 @@ struct cRGB {
uint8_t g; uint8_t g;
uint8_t r; uint8_t r;
}; };
#define CRGB(r,g,b) (cRGB){b, g, r} #define CRGB(r, g, b) \
(cRGB) { b, g, r }
#endif #endif
#define LED_BANKS 4 #define LED_BANKS 4
#define LEDS_PER_HAND 32 #define LEDS_PER_HAND 32
#define LED_BYTES_PER_BANK sizeof(cRGB) * LEDS_PER_HAND/LED_BANKS #define LED_BYTES_PER_BANK sizeof(cRGB) * LEDS_PER_HAND / LED_BANKS
namespace kaleidoscope { namespace kaleidoscope {
namespace driver { namespace driver {
@ -103,7 +104,7 @@ class Model100Side {
byte nextLEDBank = 0; byte nextLEDBank = 0;
void sendLEDBank(byte bank); void sendLEDBank(byte bank);
int readRegister(uint8_t cmd); int readRegister(uint8_t cmd);
uint8_t writeData(uint8_t* data, uint8_t length); uint8_t writeData(uint8_t *data, uint8_t length);
}; };
#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD

@ -45,7 +45,8 @@ constexpr uint8_t KeyScannerProps::matrix_col_pins[matrix_columns];
// `KeyScanner` here refers to the alias set up above, just like in the // `KeyScanner` here refers to the alias set up above, just like in the
// `KeyScannerProps` case above. // `KeyScannerProps` case above.
template<> KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {}; template<>
KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {};
// We set up the TIMER1 interrupt vector here. Due to dependency reasons, this // We set up the TIMER1 interrupt vector here. Due to dependency reasons, this
// cannot be in a header-only driver, and must be placed here. // cannot be in a header-only driver, and must be placed here.

@ -45,7 +45,7 @@ struct PlanckProps : kaleidoscope::device::ATmega32U4KeyboardProps {
}; };
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifndef KALEIDOSCOPE_VIRTUAL_BUILD
class Planck: public kaleidoscope::device::ATmega32U4Keyboard<PlanckProps> {}; class Planck : public kaleidoscope::device::ATmega32U4Keyboard<PlanckProps> {};
#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
/* Device definition omitted for virtual device builds. /* Device definition omitted for virtual device builds.
* We need to forward declare the device name, though, as there are * We need to forward declare the device name, though, as there are

@ -52,7 +52,8 @@ constexpr uint8_t KeyScannerProps::matrix_col_pins[matrix_columns];
// `KeyScanner` here refers to the alias set up above, just like in the // `KeyScanner` here refers to the alias set up above, just like in the
// `KeyScannerProps` case above. // `KeyScannerProps` case above.
template<> KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {}; template<>
KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {};
// We set up the TIMER1 interrupt vector here. Due to dependency reasons, this // We set up the TIMER1 interrupt vector here. Due to dependency reasons, this
// cannot be in a header-only driver, and must be placed here. // cannot be in a header-only driver, and must be placed here.

@ -39,7 +39,7 @@ namespace device {
namespace softhruf { namespace softhruf {
struct SplitographyProps : kaleidoscope::device::ATmega32U4KeyboardProps { struct SplitographyProps : kaleidoscope::device::ATmega32U4KeyboardProps {
struct MCUProps: kaleidoscope::driver::mcu::ATmega32U4Props { struct MCUProps : kaleidoscope::driver::mcu::ATmega32U4Props {
static constexpr bool disable_jtag = true; static constexpr bool disable_jtag = true;
}; };
typedef kaleidoscope::driver::mcu::ATmega32U4<MCUProps> MCU; typedef kaleidoscope::driver::mcu::ATmega32U4<MCUProps> MCU;
@ -49,7 +49,7 @@ struct SplitographyProps : kaleidoscope::device::ATmega32U4KeyboardProps {
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr; typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifndef KALEIDOSCOPE_VIRTUAL_BUILD
static constexpr uint8_t matrix_row_pins[matrix_rows] = {PIN_D0, PIN_D1, PIN_D2, PIN_D3}; static constexpr uint8_t matrix_row_pins[matrix_rows] = {PIN_D0, PIN_D1, PIN_D2, PIN_D3};
static constexpr uint8_t matrix_col_pins[matrix_columns] = { PIN_F0, PIN_F1, PIN_F4, PIN_F5, PIN_F6, PIN_F7, PIN_C7, PIN_C6, PIN_B6, PIN_B5, PIN_B4, PIN_D7 }; static constexpr uint8_t matrix_col_pins[matrix_columns] = {PIN_F0, PIN_F1, PIN_F4, PIN_F5, PIN_F6, PIN_F7, PIN_C7, PIN_C6, PIN_B6, PIN_B5, PIN_B4, PIN_D7};
#endif // KALEIDOSCOPE_VIRTUAL_BUILD #endif // KALEIDOSCOPE_VIRTUAL_BUILD
}; };
typedef kaleidoscope::driver::keyscanner::ATmega<KeyScannerProps> KeyScanner; typedef kaleidoscope::driver::keyscanner::ATmega<KeyScannerProps> KeyScanner;
@ -58,7 +58,7 @@ struct SplitographyProps : kaleidoscope::device::ATmega32U4KeyboardProps {
}; };
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifndef KALEIDOSCOPE_VIRTUAL_BUILD
class Splitography: public kaleidoscope::device::ATmega32U4Keyboard<SplitographyProps> {}; class Splitography : public kaleidoscope::device::ATmega32U4Keyboard<SplitographyProps> {};
#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
/* Device definition omitted for virtual device builds. /* Device definition omitted for virtual device builds.
* We need to forward declare the device name, though, as there are * We need to forward declare the device name, though, as there are

@ -55,7 +55,8 @@ constexpr uint8_t KeyScannerProps::matrix_col_pins[matrix_columns];
// `KeyScanner` here refers to the alias set up above, just like in the // `KeyScanner` here refers to the alias set up above, just like in the
// `KeyScannerProps` case above. // `KeyScannerProps` case above.
template<> KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {}; template<>
KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {};
// We set up the TIMER1 interrupt vector here. Due to dependency reasons, this // We set up the TIMER1 interrupt vector here. Due to dependency reasons, this
// cannot be in a header-only driver, and must be placed here. // cannot be in a header-only driver, and must be placed here.

@ -75,7 +75,7 @@ struct AtreusProps : kaleidoscope::device::ATmega32U4KeyboardProps {
}; };
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifndef KALEIDOSCOPE_VIRTUAL_BUILD
class Atreus: public kaleidoscope::device::ATmega32U4Keyboard<AtreusProps> {}; class Atreus : public kaleidoscope::device::ATmega32U4Keyboard<AtreusProps> {};
#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
/* Device definition omitted for virtual device builds. /* Device definition omitted for virtual device builds.
* We need to forward declare the device name, though, as there are * We need to forward declare the device name, though, as there are

@ -45,7 +45,8 @@ constexpr uint8_t KeyScannerProps::matrix_col_pins[matrix_columns];
// `KeyScanner` here refers to the alias set up above, just like in the // `KeyScanner` here refers to the alias set up above, just like in the
// `KeyScannerProps` case above. // `KeyScannerProps` case above.
template<> KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {}; template<>
KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {};
// We set up the TIMER1 interrupt vector here. Due to dependency reasons, this // We set up the TIMER1 interrupt vector here. Due to dependency reasons, this
// cannot be in a header-only driver, and must be placed here. // cannot be in a header-only driver, and must be placed here.

@ -37,8 +37,8 @@ struct ButterStickProps : kaleidoscope::device::ATmega32U4KeyboardProps {
static constexpr uint8_t matrix_columns = 10; static constexpr uint8_t matrix_columns = 10;
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr; typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifndef KALEIDOSCOPE_VIRTUAL_BUILD
static constexpr uint8_t matrix_row_pins[matrix_rows] = { PIN_F4, PIN_F5 }; static constexpr uint8_t matrix_row_pins[matrix_rows] = {PIN_F4, PIN_F5};
static constexpr uint8_t matrix_col_pins[matrix_columns] = { PIN_B0, PIN_B1, PIN_B2, PIN_B3, PIN_B4, PIN_B5, PIN_B6, PIN_B7, PIN_C6, PIN_C7 }; static constexpr uint8_t matrix_col_pins[matrix_columns] = {PIN_B0, PIN_B1, PIN_B2, PIN_B3, PIN_B4, PIN_B5, PIN_B6, PIN_B7, PIN_C6, PIN_C7};
#endif // KALEIDOSCOPE_VIRTUAL_BUILD #endif // KALEIDOSCOPE_VIRTUAL_BUILD
}; };
typedef kaleidoscope::driver::keyscanner::ATmega<KeyScannerProps> KeyScanner; typedef kaleidoscope::driver::keyscanner::ATmega<KeyScannerProps> KeyScanner;
@ -47,7 +47,7 @@ struct ButterStickProps : kaleidoscope::device::ATmega32U4KeyboardProps {
}; };
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifndef KALEIDOSCOPE_VIRTUAL_BUILD
class ButterStick: public kaleidoscope::device::ATmega32U4Keyboard<ButterStickProps> {}; class ButterStick : public kaleidoscope::device::ATmega32U4Keyboard<ButterStickProps> {};
#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
/* Device definition omitted for virtual device builds. /* Device definition omitted for virtual device builds.
* We need to forward declare the device name, though, as there are * We need to forward declare the device name, though, as there are

@ -45,7 +45,8 @@ constexpr uint8_t KeyScannerProps::matrix_col_pins[matrix_columns];
// `KeyScanner` here refers to the alias set up above, just like in the // `KeyScanner` here refers to the alias set up above, just like in the
// `KeyScannerProps` case above. // `KeyScannerProps` case above.
template<> KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {}; template<>
KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {};
// We set up the TIMER1 interrupt vector here. Due to dependency reasons, this // We set up the TIMER1 interrupt vector here. Due to dependency reasons, this
// cannot be in a header-only driver, and must be placed here. // cannot be in a header-only driver, and must be placed here.

@ -37,8 +37,8 @@ struct FaunchPadProps : kaleidoscope::device::ATmega32U4KeyboardProps {
static constexpr uint8_t matrix_columns = 4; static constexpr uint8_t matrix_columns = 4;
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr; typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifndef KALEIDOSCOPE_VIRTUAL_BUILD
static constexpr uint8_t matrix_row_pins[matrix_rows] = { PIN_F4, PIN_F5 }; static constexpr uint8_t matrix_row_pins[matrix_rows] = {PIN_F4, PIN_F5};
static constexpr uint8_t matrix_col_pins[matrix_columns] = { PIN_B3, PIN_B2, PIN_B1, PIN_B0 }; static constexpr uint8_t matrix_col_pins[matrix_columns] = {PIN_B3, PIN_B2, PIN_B1, PIN_B0};
#endif // KALEIDOSCOPE_VIRTUAL_BUILD #endif // KALEIDOSCOPE_VIRTUAL_BUILD
}; };
typedef kaleidoscope::driver::keyscanner::ATmega<KeyScannerProps> KeyScanner; typedef kaleidoscope::driver::keyscanner::ATmega<KeyScannerProps> KeyScanner;
@ -47,7 +47,7 @@ struct FaunchPadProps : kaleidoscope::device::ATmega32U4KeyboardProps {
}; };
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifndef KALEIDOSCOPE_VIRTUAL_BUILD
class FaunchPad: public kaleidoscope::device::ATmega32U4Keyboard<FaunchPadProps> {}; class FaunchPad : public kaleidoscope::device::ATmega32U4Keyboard<FaunchPadProps> {};
#else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD #else // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
/* Device definition omitted for virtual device builds. /* Device definition omitted for virtual device builds.
* We need to forward declare the device name, though, as there are * We need to forward declare the device name, though, as there are

@ -41,7 +41,7 @@ void HardwareTestMode::waitForKeypress() {
while (1) { while (1) {
Runtime.device().readMatrix(); Runtime.device().readMatrix();
if (Runtime.device().isKeyswitchPressed(actionKey) && if (Runtime.device().isKeyswitchPressed(actionKey) &&
! Runtime.device().wasKeyswitchPressed(actionKey)) { !Runtime.device().wasKeyswitchPressed(actionKey)) {
break; break;
} }
} }
@ -75,11 +75,9 @@ void HardwareTestMode::testLeds(void) {
setLeds(blue); setLeds(blue);
setLeds(green); setLeds(green);
setLeds(red); setLeds(red);
} }
void HardwareTestMode::testMatrix() { void HardwareTestMode::testMatrix() {
// Reset bad keys from previous tests. // Reset bad keys from previous tests.
chatter_data state[Runtime.device().numKeys()] = {{0, 0, 0}}; chatter_data state[Runtime.device().numKeys()] = {{0, 0, 0}};
@ -95,7 +93,7 @@ void HardwareTestMode::testMatrix() {
uint8_t keynum = key_addr.toInt(); uint8_t keynum = key_addr.toInt();
// If the key is toggled on // If the key is toggled on
if (Runtime.device().isKeyswitchPressed(key_addr) && ! Runtime.device().wasKeyswitchPressed(key_addr)) { if (Runtime.device().isKeyswitchPressed(key_addr) && !Runtime.device().wasKeyswitchPressed(key_addr)) {
// And it's too soon (in terms of cycles between changes) // And it's too soon (in terms of cycles between changes)
state[keynum].tested = 1; state[keynum].tested = 1;
if (state[keynum].cyclesSinceStateChange < CHATTER_CYCLE_LIMIT) { if (state[keynum].cyclesSinceStateChange < CHATTER_CYCLE_LIMIT) {
@ -113,7 +111,7 @@ void HardwareTestMode::testMatrix() {
Runtime.device().setCrgbAt(key_addr, red); Runtime.device().setCrgbAt(key_addr, red);
} else if (state[keynum].tested == 0) { } else if (state[keynum].tested == 0) {
Runtime.device().setCrgbAt(key_addr, yellow); Runtime.device().setCrgbAt(key_addr, yellow);
} else if (! Runtime.device().isKeyswitchPressed(key_addr)) { } else if (!Runtime.device().isKeyswitchPressed(key_addr)) {
// If the key is not currently pressed and was not just released and is not marked bad // If the key is not currently pressed and was not just released and is not marked bad
Runtime.device().setCrgbAt(key_addr, blue); Runtime.device().setCrgbAt(key_addr, blue);
} }

@ -26,11 +26,10 @@ namespace plugin {
class HardwareTestMode : public kaleidoscope::Plugin { class HardwareTestMode : public kaleidoscope::Plugin {
public: public:
typedef struct { typedef struct {
uint8_t bad : 1, uint8_t bad : 1,
tested : 1, tested : 1,
cyclesSinceStateChange: 6; cyclesSinceStateChange : 6;
} chatter_data; } chatter_data;
static uint8_t actionKey; static uint8_t actionKey;
@ -38,6 +37,7 @@ class HardwareTestMode : public kaleidoscope::Plugin {
static void runTests(); static void runTests();
static void setActionKey(uint8_t key); static void setActionKey(uint8_t key);
private: private:
static void testLeds(); static void testLeds();
static void testMatrix(); static void testMatrix();

@ -47,8 +47,7 @@ Heatmap::TransientLEDMode::TransientLEDMode(const Heatmap *parent)
// max of heatmap_ (we divide by it so we start at 1) // max of heatmap_ (we divide by it so we start at 1)
highest_(1), highest_(1),
// last heatmap computation time // last heatmap computation time
last_heatmap_comp_time_(Runtime.millisAtCycleStart()) last_heatmap_comp_time_(Runtime.millisAtCycleStart()) {}
{}
cRGB Heatmap::TransientLEDMode::computeColor(float v) { cRGB Heatmap::TransientLEDMode::computeColor(float v) {
// compute the color corresponding to a value between 0 and 1 // compute the color corresponding to a value between 0 and 1

@ -48,7 +48,6 @@ class Heatmap : public Plugin,
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
@ -60,11 +59,9 @@ class Heatmap : public Plugin,
EventHandlerResult beforeEachCycle(); EventHandlerResult beforeEachCycle();
protected: protected:
void update() final; void update() final;
private: private:
uint16_t heatmap_[Runtime.device().numKeys()]; uint16_t heatmap_[Runtime.device().numKeys()];
uint16_t highest_; uint16_t highest_;
uint16_t last_heatmap_comp_time_; uint16_t last_heatmap_comp_time_;

@ -40,7 +40,7 @@ EventHandlerResult FocusHostOSCommand::onFocusEvent(const char *command) {
} else { } else {
uint8_t new_os; uint8_t new_os;
::Focus.read(new_os); ::Focus.read(new_os);
::HostOS.os((hostos::Type) new_os); ::HostOS.os((hostos::Type)new_os);
} }
return EventHandlerResult::EVENT_CONSUMED; return EventHandlerResult::EVENT_CONSUMED;

@ -27,7 +27,7 @@
namespace kaleidoscope { namespace kaleidoscope {
namespace plugin { namespace plugin {
class IdleLEDs: public kaleidoscope::Plugin { class IdleLEDs : public kaleidoscope::Plugin {
public: public:
IdleLEDs(void) {} IdleLEDs(void) {}
@ -51,6 +51,7 @@ class PersistentIdleLEDs : public IdleLEDs {
EventHandlerResult onFocusEvent(const char *command); EventHandlerResult onFocusEvent(const char *command);
static void setIdleTimeoutSeconds(uint32_t new_limit); static void setIdleTimeoutSeconds(uint32_t new_limit);
private: private:
static uint16_t settings_base_; static uint16_t settings_base_;
}; };

@ -34,8 +34,7 @@ const cRGB *LEDActiveLayerColorEffect::colormap_;
LEDActiveLayerColorEffect::TransientLEDMode::TransientLEDMode( LEDActiveLayerColorEffect::TransientLEDMode::TransientLEDMode(
const LEDActiveLayerColorEffect *parent) const LEDActiveLayerColorEffect *parent)
: parent_(parent), : parent_(parent),
active_color_{0, 0, 0} active_color_{0, 0, 0} {}
{}
void LEDActiveLayerColorEffect::setColormap(const cRGB colormap[]) { void LEDActiveLayerColorEffect::setColormap(const cRGB colormap[]) {
colormap_ = colormap; colormap_ = colormap;

@ -40,7 +40,6 @@ class LEDActiveLayerColorEffect : public Plugin,
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
@ -48,12 +47,10 @@ class LEDActiveLayerColorEffect : public Plugin,
explicit TransientLEDMode(const LEDActiveLayerColorEffect *parent); explicit TransientLEDMode(const LEDActiveLayerColorEffect *parent);
protected: protected:
void onActivate(void) final; void onActivate(void) final;
void refreshAt(KeyAddr key_addr) final; void refreshAt(KeyAddr key_addr) final;
private: private:
const LEDActiveLayerColorEffect *parent_; const LEDActiveLayerColorEffect *parent_;
cRGB active_color_; cRGB active_color_;
@ -64,7 +61,6 @@ class LEDActiveLayerColorEffect : public Plugin,
}; };
private: private:
static const cRGB *colormap_; static const cRGB *colormap_;
}; };

@ -44,7 +44,7 @@ cRGB ActiveModColorEffect::sticky_color_ = CRGB(160, 0, 0);
EventHandlerResult ActiveModColorEffect::onKeyEvent(KeyEvent &event) { EventHandlerResult ActiveModColorEffect::onKeyEvent(KeyEvent &event) {
// If `event.addr` is not a physical key address, ignore it: // If `event.addr` is not a physical key address, ignore it:
if (! event.addr.isValid()) { if (!event.addr.isValid()) {
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }

@ -67,8 +67,7 @@ static const uint16_t alphabet[] PROGMEM = {
ALPHASQUARE_SYMBOL_7, ALPHASQUARE_SYMBOL_7,
ALPHASQUARE_SYMBOL_8, ALPHASQUARE_SYMBOL_8,
ALPHASQUARE_SYMBOL_9, ALPHASQUARE_SYMBOL_9,
ALPHASQUARE_SYMBOL_0 ALPHASQUARE_SYMBOL_0};
};
cRGB AlphaSquare::color = {0x80, 0x80, 0x80}; cRGB AlphaSquare::color = {0x80, 0x80, 0x80};

@ -42,7 +42,6 @@ namespace kaleidoscope {
namespace plugin { namespace plugin {
class AlphaSquare : public kaleidoscope::Plugin { class AlphaSquare : public kaleidoscope::Plugin {
public: public:
AlphaSquare(void) {} AlphaSquare(void) {}
static void display(Key key, KeyAddr key_addr, cRGB key_color); static void display(Key key, KeyAddr key_addr, cRGB key_color);

@ -35,10 +35,9 @@ namespace plugin {
uint16_t AlphaSquareEffect::length = 1000; uint16_t AlphaSquareEffect::length = 1000;
AlphaSquareEffect::TransientLEDMode::TransientLEDMode(AlphaSquareEffect */*parent*/) // NOLINT(readability/casting) AlphaSquareEffect::TransientLEDMode::TransientLEDMode(AlphaSquareEffect * /*parent*/) // NOLINT(readability/casting)
: last_key_left_(Key_NoKey), : last_key_left_(Key_NoKey),
last_key_right_(Key_NoKey) last_key_right_(Key_NoKey) {}
{}
void AlphaSquareEffect::TransientLEDMode::update(void) { void AlphaSquareEffect::TransientLEDMode::update(void) {
if (!Runtime.has_leds) if (!Runtime.has_leds)

@ -44,7 +44,8 @@ class LEDPaletteTheme : public kaleidoscope::Plugin {
EventHandlerResult onFocusEvent(const char *command); EventHandlerResult onFocusEvent(const char *command);
EventHandlerResult themeFocusEvent(const char *command, EventHandlerResult themeFocusEvent(const char *command,
const char *expected_command, const char *expected_command,
uint16_t theme_base, uint8_t max_themes); uint16_t theme_base,
uint8_t max_themes);
private: private:
static uint16_t palette_base_; static uint16_t palette_base_;

@ -33,15 +33,13 @@ namespace plugin {
StalkerEffect::ColorComputer *StalkerEffect::variant; StalkerEffect::ColorComputer *StalkerEffect::variant;
uint16_t StalkerEffect::step_length = 50; uint16_t StalkerEffect::step_length = 50;
cRGB StalkerEffect::inactive_color = (cRGB) { cRGB StalkerEffect::inactive_color = (cRGB){
0, 0, 0 0, 0, 0};
};
StalkerEffect::TransientLEDMode::TransientLEDMode(const StalkerEffect *parent) StalkerEffect::TransientLEDMode::TransientLEDMode(const StalkerEffect *parent)
: parent_(parent), : parent_(parent),
step_start_time_(0), step_start_time_(0),
map_{} map_{} {}
{}
EventHandlerResult StalkerEffect::onKeyEvent(KeyEvent &event) { EventHandlerResult StalkerEffect::onKeyEvent(KeyEvent &event) {
if (!Runtime.has_leds) if (!Runtime.has_leds)
@ -130,7 +128,7 @@ cRGB BlazingTrail::compute(uint8_t *step) {
// Fade value from full following a 1-x^4 curve // Fade value from full following a 1-x^4 curve
uint8_t val = uint8_t val =
0xff // Maximum brightness 0xff // Maximum brightness
- ((uint32_t) pos255 * pos255 * pos255 * pos255 // Animation position to 4th power - ((uint32_t)pos255 * pos255 * pos255 * pos255 // Animation position to 4th power
>> 24) // ...pulled down to 8-bit range (but this has a maximum of 0xfc rather than 0xff) >> 24) // ...pulled down to 8-bit range (but this has a maximum of 0xfc rather than 0xff)
- pos255 / (0x100 / 4); // Correction to bring the end result into a full 0 to 0xff range - pos255 / (0x100 / 4); // Correction to bring the end result into a full 0 to 0xff range

@ -28,7 +28,7 @@
#include "kaleidoscope/plugin/LEDMode.h" // for LEDMode #include "kaleidoscope/plugin/LEDMode.h" // for LEDMode
#include "kaleidoscope/plugin/LEDModeInterface.h" // for LEDModeInter... #include "kaleidoscope/plugin/LEDModeInterface.h" // for LEDModeInter...
#define STALKER(v, ...) ({static kaleidoscope::plugin::stalker::v _effect __VA_ARGS__; &_effect;}) #define STALKER(v, ...) ({static kaleidoscope::plugin::stalker::v _effect __VA_ARGS__; &_effect; })
namespace kaleidoscope { namespace kaleidoscope {
namespace plugin { namespace plugin {
@ -53,7 +53,6 @@ class StalkerEffect : public Plugin,
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
@ -61,11 +60,9 @@ class StalkerEffect : public Plugin,
explicit TransientLEDMode(const StalkerEffect *parent); explicit TransientLEDMode(const StalkerEffect *parent);
protected: protected:
void update() final; void update() final;
private: private:
const StalkerEffect *parent_; const StalkerEffect *parent_;
uint16_t step_start_time_; uint16_t step_start_time_;
@ -80,9 +77,11 @@ namespace stalker {
class Haunt : public StalkerEffect::ColorComputer { class Haunt : public StalkerEffect::ColorComputer {
public: public:
explicit Haunt(const cRGB highlight_color); explicit Haunt(const cRGB highlight_color);
Haunt(void) : Haunt(CRGB(0x40, 0x80, 0x80)) {} Haunt(void)
: Haunt(CRGB(0x40, 0x80, 0x80)) {}
cRGB compute(uint8_t *step) final; cRGB compute(uint8_t *step) final;
private: private:
static cRGB highlight_color_; static cRGB highlight_color_;
}; };

@ -55,8 +55,7 @@ PROGMEM const uint8_t WavepoolEffect::TransientLEDMode::rc2pos[Runtime.device().
WavepoolEffect::TransientLEDMode::TransientLEDMode(const WavepoolEffect *parent) WavepoolEffect::TransientLEDMode::TransientLEDMode(const WavepoolEffect *parent)
: frames_since_event_(0), : frames_since_event_(0),
surface_{}, surface_{},
page_(0) page_(0) {}
{}
EventHandlerResult WavepoolEffect::onKeyEvent(KeyEvent &event) { EventHandlerResult WavepoolEffect::onKeyEvent(KeyEvent &event) {
if (!event.addr.isValid()) if (!event.addr.isValid())
@ -112,9 +111,9 @@ void WavepoolEffect::TransientLEDMode::update(void) {
// (side note: it's weird that this is a 16-bit int instead of 8-bit, // (side note: it's weird that this is a 16-bit int instead of 8-bit,
// but that's what the library function wants) // but that's what the library function wants)
static uint8_t current_hue = 0; static uint8_t current_hue = 0;
current_hue ++; current_hue++;
frames_since_event_ ++; frames_since_event_++;
// needs two pages of height map to do the calculations // needs two pages of height map to do the calculations
int8_t *newpg = &surface_[page_ ^ 1][0]; int8_t *newpg = &surface_[page_ ^ 1][0];
@ -137,9 +136,7 @@ void WavepoolEffect::TransientLEDMode::update(void) {
raindrop(prev_x, prev_y, oldpg); raindrop(prev_x, prev_y, oldpg);
prev_x = prev_y = -1; prev_x = prev_y = -1;
} }
if (frames_since_event_ if (frames_since_event_ >= (frames_till_next_drop + (idle_timeout / MS_PER_FRAME))) {
>= (frames_till_next_drop
+ (idle_timeout / MS_PER_FRAME))) {
frames_till_next_drop = 4 + (wp_rand() % FRAMES_PER_DROP); frames_till_next_drop = 4 + (wp_rand() % FRAMES_PER_DROP);
frames_since_event_ = idle_timeout / MS_PER_FRAME; frames_since_event_ = idle_timeout / MS_PER_FRAME;
@ -239,7 +236,6 @@ void WavepoolEffect::TransientLEDMode::update(void) {
// swap pages every frame // swap pages every frame
page_ ^= 1; page_ ^= 1;
#endif #endif
} }
} // namespace plugin } // namespace plugin

@ -55,7 +55,6 @@ class WavepoolEffect : public Plugin,
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
@ -65,11 +64,9 @@ class WavepoolEffect : public Plugin,
EventHandlerResult onKeyEvent(KeyEvent &event); EventHandlerResult onKeyEvent(KeyEvent &event);
protected: protected:
void update() final; void update() final;
private: private:
uint8_t frames_since_event_; uint8_t frames_since_event_;
int8_t surface_[2][WP_WID * WP_HGT]; int8_t surface_[2][WP_WID * WP_HGT];
uint8_t page_; uint8_t page_;

@ -47,8 +47,7 @@ const uint8_t BootAnimationEffect::greeting_[11] PROGMEM = {
Key_D.getKeyCode(), Key_D.getKeyCode(),
Key_Period.getKeyCode(), Key_Period.getKeyCode(),
Key_I.getKeyCode(), Key_I.getKeyCode(),
Key_O.getKeyCode() Key_O.getKeyCode()};
};
EventHandlerResult BootAnimationEffect::onSetup() { EventHandlerResult BootAnimationEffect::onSetup() {
return EventHandlerResult::OK; return EventHandlerResult::OK;

@ -36,7 +36,6 @@ class LEDBreatheEffect : public Plugin,
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
@ -48,7 +47,6 @@ class LEDBreatheEffect : public Plugin,
void update(void) final; void update(void) final;
private: private:
const LEDBreatheEffect *parent_; const LEDBreatheEffect *parent_;
static constexpr uint8_t update_interval_ = 50; static constexpr uint8_t update_interval_ = 50;

@ -47,7 +47,6 @@ class LEDChaseEffect : public Plugin,
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
@ -56,11 +55,9 @@ class LEDChaseEffect : public Plugin,
: parent_(parent), last_update_(Runtime.millisAtCycleStart()) {} : parent_(parent), last_update_(Runtime.millisAtCycleStart()) {}
protected: protected:
void update() final; void update() final;
private: private:
const LEDChaseEffect *parent_; const LEDChaseEffect *parent_;
uint8_t pos_ = uint8_t(0); uint8_t pos_ = uint8_t(0);

@ -42,7 +42,6 @@ class LEDRainbowEffect : public Plugin,
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
@ -53,7 +52,6 @@ class LEDRainbowEffect : public Plugin,
void update() final; void update() final;
private: private:
const LEDRainbowEffect *parent_; const LEDRainbowEffect *parent_;
uint16_t rainbow_hue = 0; // stores 0 to 614 uint16_t rainbow_hue = 0; // stores 0 to 614
@ -87,7 +85,6 @@ class LEDRainbowWaveEffect : public Plugin, public LEDModeInterface {
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
@ -98,7 +95,6 @@ class LEDRainbowWaveEffect : public Plugin, public LEDModeInterface {
void update() final; void update() final;
private: private:
const LEDRainbowWaveEffect *parent_; const LEDRainbowWaveEffect *parent_;
uint16_t rainbow_hue = 0; // stores 0 to 614 uint16_t rainbow_hue = 0; // stores 0 to 614

@ -28,16 +28,13 @@ namespace plugin {
class LEDSolidColor : public Plugin, class LEDSolidColor : public Plugin,
public LEDModeInterface { public LEDModeInterface {
public: public:
LEDSolidColor(uint8_t r, uint8_t g, uint8_t b) LEDSolidColor(uint8_t r, uint8_t g, uint8_t b)
: r_(r), g_(g), b_(b) : r_(r), g_(g), b_(b) {}
{}
// This class' instance has dynamic lifetime // This class' instance has dynamic lifetime
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
@ -50,12 +47,10 @@ class LEDSolidColor : public Plugin,
void refreshAt(KeyAddr key_addr) final; void refreshAt(KeyAddr key_addr) final;
private: private:
const LEDSolidColor *parent_; const LEDSolidColor *parent_;
}; };
private: private:
uint8_t r_, g_, b_; uint8_t r_, g_, b_;
}; };

@ -45,12 +45,12 @@ void TriColor::TransientLEDMode::update(void) {
cRGB color = parent_->mod_color_; cRGB color = parent_->mod_color_;
switch (k.getKeyCode()) { switch (k.getKeyCode()) {
case Key_A.getKeyCode() ... Key_0.getKeyCode(): case Key_A.getKeyCode()... Key_0.getKeyCode():
case Key_Spacebar.getKeyCode(): case Key_Spacebar.getKeyCode():
case Key_KeypadDivide.getKeyCode() ... Key_KeypadSubtract.getKeyCode(): case Key_KeypadDivide.getKeyCode()... Key_KeypadSubtract.getKeyCode():
case Key_Keypad1.getKeyCode() ... Key_KeypadDot.getKeyCode(): case Key_Keypad1.getKeyCode()... Key_KeypadDot.getKeyCode():
case Key_F1.getKeyCode() ... Key_F4.getKeyCode(): case Key_F1.getKeyCode()... Key_F4.getKeyCode():
case Key_F9.getKeyCode() ... Key_F12.getKeyCode(): case Key_F9.getKeyCode()... Key_F12.getKeyCode():
color = parent_->base_color_; color = parent_->base_color_;
break; break;
case Key_Escape.getKeyCode(): case Key_Escape.getKeyCode():

@ -28,13 +28,13 @@ class TriColor : public Plugin,
public LEDModeInterface { public LEDModeInterface {
public: public:
TriColor(cRGB base_color, cRGB mod_color, cRGB esc_color); TriColor(cRGB base_color, cRGB mod_color, cRGB esc_color);
TriColor(cRGB base_color, cRGB mod_color) : TriColor(base_color, mod_color, mod_color) {} TriColor(cRGB base_color, cRGB mod_color)
: TriColor(base_color, mod_color, mod_color) {}
// This class' instance has dynamic lifetime // This class' instance has dynamic lifetime
// //
class TransientLEDMode : public LEDMode { class TransientLEDMode : public LEDMode {
public: public:
// Please note that storing the parent ptr is only required // Please note that storing the parent ptr is only required
// for those LED modes that require access to // for those LED modes that require access to
// members of their parent class. Most LED modes can do without. // members of their parent class. Most LED modes can do without.
@ -43,11 +43,9 @@ class TriColor : public Plugin,
: parent_(parent) {} : parent_(parent) {}
protected: protected:
void update(void) final; void update(void) final;
private: private:
const TriColor *parent_; const TriColor *parent_;
}; };

@ -24,7 +24,7 @@
namespace kaleidoscope { namespace kaleidoscope {
namespace plugin { namespace plugin {
class LayerFocus: public kaleidoscope::Plugin { class LayerFocus : public kaleidoscope::Plugin {
public: public:
LayerFocus() {} LayerFocus() {}

@ -56,7 +56,7 @@ const Leader::dictionary_t *Leader::dictionary;
int8_t Leader::lookup(void) { int8_t Leader::lookup(void) {
bool match; bool match;
for (uint8_t seq_index = 0; ; seq_index++) { for (uint8_t seq_index = 0;; seq_index++) {
match = true; match = true;
if (dictionary[seq_index].sequence[0].readFromProgmem() == Key_NoKey) if (dictionary[seq_index].sequence[0].readFromProgmem() == Key_NoKey)
@ -75,8 +75,7 @@ int8_t Leader::lookup(void) {
if (!match) if (!match)
continue; continue;
seq_key seq_key = dictionary[seq_index].sequence[sequence_pos_ + 1].readFromProgmem();
= dictionary[seq_index].sequence[sequence_pos_ + 1].readFromProgmem();
if (seq_key == Key_NoKey) { if (seq_key == Key_NoKey) {
return seq_index; return seq_index;
} else { } else {
@ -143,7 +142,7 @@ EventHandlerResult Leader::onKeyswitchEvent(KeyEvent &event) {
return EventHandlerResult::ABORT; return EventHandlerResult::ABORT;
} }
action_t leaderAction = (action_t) pgm_read_ptr((void const **) & (dictionary[action_index].action)); action_t leaderAction = (action_t)pgm_read_ptr((void const **)&(dictionary[action_index].action));
(*leaderAction)(action_index); (*leaderAction)(action_index);
reset(); reset();

@ -46,8 +46,12 @@
#define LEAD(n) kaleidoscope::plugin::LeaderKey(n) #define LEAD(n) kaleidoscope::plugin::LeaderKey(n)
#define LEADER_SEQ(...) { __VA_ARGS__, Key_NoKey } #define LEADER_SEQ(...) \
#define LEADER_DICT(...) { __VA_ARGS__, {{Key_NoKey}, NULL} } { __VA_ARGS__, Key_NoKey }
#define LEADER_DICT(...) \
{ \
__VA_ARGS__, { {Key_NoKey}, NULL } \
}
namespace kaleidoscope { namespace kaleidoscope {
namespace plugin { namespace plugin {

@ -32,7 +32,8 @@
// ============================================================================= // =============================================================================
// Default `macroAction()` function definitions // Default `macroAction()` function definitions
__attribute__((weak)) __attribute__((weak))
const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) { const macro_t *
macroAction(uint8_t macro_id, KeyEvent &event) {
return MACRO_NONE; return MACRO_NONE;
} }
@ -300,7 +301,7 @@ EventHandlerResult Macros::onKeyEvent(KeyEvent &event) {
uint8_t macro_id = event.key.getRaw() - ranges::MACRO_FIRST; uint8_t macro_id = event.key.getRaw() - ranges::MACRO_FIRST;
// Call the new `macroAction(event)` function. // Call the new `macroAction(event)` function.
const macro_t* macro_ptr = macroAction(macro_id, event); const macro_t *macro_ptr = macroAction(macro_id, event);
// Play back the macro pointed to by `macroAction()` // Play back the macro pointed to by `macroAction()`
play(macro_ptr); play(macro_ptr);

@ -27,7 +27,7 @@
// ============================================================================= // =============================================================================
// Define this function in a Kaleidoscope sketch in order to trigger Macros. // Define this function in a Kaleidoscope sketch in order to trigger Macros.
const macro_t* macroAction(uint8_t macro_id, KeyEvent &event); const macro_t *macroAction(uint8_t macro_id, KeyEvent &event);
// The number of simultaneously-active `Key` values that a macro can have // The number of simultaneously-active `Key` values that a macro can have
// running during a call to `Macros.play()`. I don't know if it's actually // running during a call to `Macros.play()`. I don't know if it's actually
@ -42,7 +42,6 @@ namespace plugin {
class Macros : public kaleidoscope::Plugin { class Macros : public kaleidoscope::Plugin {
public: public:
/// Send a key press event from a Macro /// Send a key press event from a Macro
/// ///
/// Generates a new `KeyEvent` and calls `Runtime.handleKeyEvent()` with the /// Generates a new `KeyEvent` and calls `Runtime.handleKeyEvent()` with the
@ -71,17 +70,17 @@ class Macros : public kaleidoscope::Plugin {
void tap(Key key) const; void tap(Key key) const;
/// Play a macro sequence of key events /// Play a macro sequence of key events
void play(const macro_t* macro_ptr); void play(const macro_t *macro_ptr);
// Templates provide a `type()` function that takes a variable number of // Templates provide a `type()` function that takes a variable number of
// `char*` (string) arguments, in the form of a list of strings stored in // `char*` (string) arguments, in the form of a list of strings stored in
// PROGMEM, of the form `Macros.type(PSTR("Hello "), PSTR("world!"))`. // PROGMEM, of the form `Macros.type(PSTR("Hello "), PSTR("world!"))`.
inline const macro_t* type() const { inline const macro_t *type() const {
return MACRO_NONE; return MACRO_NONE;
} }
const macro_t* type(const char* string) const; const macro_t *type(const char *string) const;
template <typename... Strings> template<typename... Strings>
const macro_t* type(const char* first, Strings&&... strings) const { const macro_t *type(const char *first, Strings &&...strings) const {
type(first); type(first);
return type(strings...); return type(strings...);
} }
@ -105,7 +104,6 @@ class Macros : public kaleidoscope::Plugin {
return true; return true;
return false; return false;
} }
}; };
} // namespace plugin } // namespace plugin

@ -49,8 +49,7 @@ typedef uint8_t macro_t;
{ \ { \
static const macro_t __m[] PROGMEM = { \ static const macro_t __m[] PROGMEM = { \
__VA_ARGS__, \ __VA_ARGS__, \
MACRO_ACTION_END \ MACRO_ACTION_END}; \
}; \
&__m[0]; \ &__m[0]; \
}) })
@ -58,15 +57,15 @@ typedef uint8_t macro_t;
#define W(n) MACRO_ACTION_STEP_WAIT, n #define W(n) MACRO_ACTION_STEP_WAIT, n
#define Kr(k) (k).getFlags(), (k).getKeyCode() #define Kr(k) (k).getFlags(), (k).getKeyCode()
#define Kc(k) (Key_ ## k).getKeyCode() #define Kc(k) (Key_##k).getKeyCode()
#define K(k) Kr(Key_ ## k) #define K(k) Kr(Key_##k)
#define Dr(k) MACRO_ACTION_STEP_KEYDOWN, Kr(k) #define Dr(k) MACRO_ACTION_STEP_KEYDOWN, Kr(k)
#define D(k) Dr(Key_ ## k) #define D(k) Dr(Key_##k)
#define Ur(k) MACRO_ACTION_STEP_KEYUP, Kr(k) #define Ur(k) MACRO_ACTION_STEP_KEYUP, Kr(k)
#define U(k) Ur(Key_ ## k) #define U(k) Ur(Key_##k)
#define Tr(k) MACRO_ACTION_STEP_TAP, Kr(k) #define Tr(k) MACRO_ACTION_STEP_TAP, Kr(k)
#define T(k) Tr(Key_ ## k) #define T(k) Tr(Key_##k)
#define Dc(k) MACRO_ACTION_STEP_KEYCODEDOWN, Kc(k) #define Dc(k) MACRO_ACTION_STEP_KEYCODEDOWN, Kc(k)
#define Uc(k) MACRO_ACTION_STEP_KEYCODEUP, Kc(k) #define Uc(k) MACRO_ACTION_STEP_KEYCODEUP, Kc(k)

@ -55,7 +55,7 @@ EventHandlerResult MagicCombo::afterEachCycle() {
match = false; match = false;
if (match && Runtime.hasTimeExpired(start_time_, min_interval)) { if (match && Runtime.hasTimeExpired(start_time_, min_interval)) {
ComboAction action = (ComboAction) pgm_read_ptr((void const **) & (magiccombo::combos[i].action)); ComboAction action = (ComboAction)pgm_read_ptr((void const **)&(magiccombo::combos[i].action));
(*action)(i); (*action)(i);
start_time_ = Runtime.millisAtCycleStart(); start_time_ = Runtime.millisAtCycleStart();

@ -57,26 +57,26 @@ void MouseKeys::setSpeedLimit(uint8_t speed_limit) {
// ============================================================================= // =============================================================================
// Key variant tests // Key variant tests
bool MouseKeys::isMouseKey(const Key& key) const { bool MouseKeys::isMouseKey(const Key &key) const {
return (key.getFlags() == (SYNTHETIC | IS_MOUSE_KEY)); return (key.getFlags() == (SYNTHETIC | IS_MOUSE_KEY));
} }
bool MouseKeys::isMouseButtonKey(const Key& key) const { bool MouseKeys::isMouseButtonKey(const Key &key) const {
uint8_t variant = key.getKeyCode() & (KEY_MOUSE_BUTTON | KEY_MOUSE_WARP); uint8_t variant = key.getKeyCode() & (KEY_MOUSE_BUTTON | KEY_MOUSE_WARP);
return variant == KEY_MOUSE_BUTTON; return variant == KEY_MOUSE_BUTTON;
} }
bool MouseKeys::isMouseMoveKey(const Key& key) const { bool MouseKeys::isMouseMoveKey(const Key &key) const {
uint8_t mask = (KEY_MOUSE_BUTTON | KEY_MOUSE_WARP | KEY_MOUSE_WHEEL); uint8_t mask = (KEY_MOUSE_BUTTON | KEY_MOUSE_WARP | KEY_MOUSE_WHEEL);
uint8_t variant = key.getKeyCode() & mask; uint8_t variant = key.getKeyCode() & mask;
return variant == 0; return variant == 0;
} }
bool MouseKeys::isMouseWarpKey(const Key& key) const { bool MouseKeys::isMouseWarpKey(const Key &key) const {
return (key.getKeyCode() & KEY_MOUSE_WARP) != 0; return (key.getKeyCode() & KEY_MOUSE_WARP) != 0;
} }
bool MouseKeys::isMouseWheelKey(const Key& key) const { bool MouseKeys::isMouseWheelKey(const Key &key) const {
uint8_t mask = (KEY_MOUSE_BUTTON | KEY_MOUSE_WARP | KEY_MOUSE_WHEEL); uint8_t mask = (KEY_MOUSE_BUTTON | KEY_MOUSE_WARP | KEY_MOUSE_WHEEL);
uint8_t variant = key.getKeyCode() & mask; uint8_t variant = key.getKeyCode() & mask;
return variant == KEY_MOUSE_WHEEL; return variant == KEY_MOUSE_WHEEL;

@ -69,7 +69,6 @@ class MouseKeys : public kaleidoscope::Plugin {
void sendMouseWarpReport(const KeyEvent &event) const; void sendMouseWarpReport(const KeyEvent &event) const;
void sendMouseMoveReport(); void sendMouseMoveReport();
void sendMouseWheelReport(); void sendMouseWheelReport();
}; };
} // namespace plugin } // namespace plugin

@ -31,30 +31,30 @@
#define KEY_MOUSE_BUTTON 0b1000000 #define KEY_MOUSE_BUTTON 0b1000000
#define Key_mouseWarpNW Key(KEY_MOUSE_WARP| KEY_MOUSE_UP | KEY_MOUSE_LEFT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseWarpNW Key(KEY_MOUSE_WARP | KEY_MOUSE_UP | KEY_MOUSE_LEFT, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseWarpN Key(KEY_MOUSE_WARP| KEY_MOUSE_UP, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseWarpN Key(KEY_MOUSE_WARP | KEY_MOUSE_UP, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseWarpNE Key(KEY_MOUSE_WARP| KEY_MOUSE_UP | KEY_MOUSE_RIGHT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseWarpNE Key(KEY_MOUSE_WARP | KEY_MOUSE_UP | KEY_MOUSE_RIGHT, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseWarpW Key(KEY_MOUSE_WARP| KEY_MOUSE_LEFT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseWarpW Key(KEY_MOUSE_WARP | KEY_MOUSE_LEFT, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseWarpIn Key(KEY_MOUSE_WARP| KEY_MOUSE_UP | KEY_MOUSE_DOWN, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseWarpIn Key(KEY_MOUSE_WARP | KEY_MOUSE_UP | KEY_MOUSE_DOWN, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseWarpE Key(KEY_MOUSE_WARP| KEY_MOUSE_RIGHT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseWarpE Key(KEY_MOUSE_WARP | KEY_MOUSE_RIGHT, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseWarpSW Key(KEY_MOUSE_WARP| KEY_MOUSE_DOWN | KEY_MOUSE_LEFT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseWarpSW Key(KEY_MOUSE_WARP | KEY_MOUSE_DOWN | KEY_MOUSE_LEFT, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseWarpS Key(KEY_MOUSE_WARP| KEY_MOUSE_DOWN, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseWarpS Key(KEY_MOUSE_WARP | KEY_MOUSE_DOWN, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseWarpSE Key(KEY_MOUSE_WARP| KEY_MOUSE_DOWN | KEY_MOUSE_RIGHT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseWarpSE Key(KEY_MOUSE_WARP | KEY_MOUSE_DOWN | KEY_MOUSE_RIGHT, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseWarpEnd Key(KEY_MOUSE_WARP| KEY_MOUSE_WARP_END, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseWarpEnd Key(KEY_MOUSE_WARP | KEY_MOUSE_WARP_END, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseUpL Key(KEY_MOUSE_UP | KEY_MOUSE_LEFT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseUpL Key(KEY_MOUSE_UP | KEY_MOUSE_LEFT, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseUp Key(KEY_MOUSE_UP, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseUp Key(KEY_MOUSE_UP, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseUpR Key(KEY_MOUSE_UP | KEY_MOUSE_RIGHT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseUpR Key(KEY_MOUSE_UP | KEY_MOUSE_RIGHT, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseL Key(KEY_MOUSE_LEFT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseL Key(KEY_MOUSE_LEFT, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseR Key(KEY_MOUSE_RIGHT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseR Key(KEY_MOUSE_RIGHT, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseDnL Key(KEY_MOUSE_DOWN | KEY_MOUSE_LEFT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseDnL Key(KEY_MOUSE_DOWN | KEY_MOUSE_LEFT, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseDn Key(KEY_MOUSE_DOWN, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseDn Key(KEY_MOUSE_DOWN, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseDnR Key(KEY_MOUSE_DOWN | KEY_MOUSE_RIGHT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseDnR Key(KEY_MOUSE_DOWN | KEY_MOUSE_RIGHT, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseScrollUp Key(KEY_MOUSE_WHEEL | KEY_MOUSE_UP, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseScrollUp Key(KEY_MOUSE_WHEEL | KEY_MOUSE_UP, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseScrollDn Key(KEY_MOUSE_WHEEL | KEY_MOUSE_DOWN, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseScrollDn Key(KEY_MOUSE_WHEEL | KEY_MOUSE_DOWN, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseScrollL Key(KEY_MOUSE_WHEEL | KEY_MOUSE_LEFT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseScrollL Key(KEY_MOUSE_WHEEL | KEY_MOUSE_LEFT, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
#define Key_mouseScrollR Key(KEY_MOUSE_WHEEL | KEY_MOUSE_RIGHT, KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY) #define Key_mouseScrollR Key(KEY_MOUSE_WHEEL | KEY_MOUSE_RIGHT, KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY)
// The MOUSE_xxx button definitions come from our HID driver // The MOUSE_xxx button definitions come from our HID driver

@ -122,14 +122,18 @@ void MouseWrapper::move(int8_t x, int8_t y) {
if (x != 0) { if (x != 0) {
moveX = remainderX + (x * acceleration(accel_step)); moveX = remainderX + (x * acceleration(accel_step));
if (moveX > effectiveSpeedLimit) moveX = effectiveSpeedLimit; if (moveX > effectiveSpeedLimit)
else if (moveX < -effectiveSpeedLimit) moveX = -effectiveSpeedLimit; moveX = effectiveSpeedLimit;
else if (moveX < -effectiveSpeedLimit)
moveX = -effectiveSpeedLimit;
} }
if (y != 0) { if (y != 0) {
moveY = remainderY + (y * acceleration(accel_step)); moveY = remainderY + (y * acceleration(accel_step));
if (moveY > effectiveSpeedLimit) moveY = effectiveSpeedLimit; if (moveY > effectiveSpeedLimit)
else if (moveY < -effectiveSpeedLimit) moveY = -effectiveSpeedLimit; moveY = effectiveSpeedLimit;
else if (moveY < -effectiveSpeedLimit)
moveY = -effectiveSpeedLimit;
} }
endWarping(); endWarping();

@ -39,7 +39,6 @@ class NumPad : public kaleidoscope::Plugin {
EventHandlerResult afterEachCycle(); EventHandlerResult afterEachCycle();
private: private:
void setKeyboardLEDColors(void); void setKeyboardLEDColors(void);
static KeyAddr numpadLayerToggleKeyAddr; static KeyAddr numpadLayerToggleKeyAddr;

@ -80,7 +80,7 @@ bool OneShot::isActive() const {
bool OneShot::isSticky() const { bool OneShot::isSticky() const {
for (KeyAddr key_addr : glue_addrs_) { for (KeyAddr key_addr : glue_addrs_) {
if (! temp_addrs_.read(key_addr)) { if (!temp_addrs_.read(key_addr)) {
return true; return true;
} }
} }
@ -94,8 +94,7 @@ bool OneShot::isSticky() const {
// could potentially use three different color values for the three // could potentially use three different color values for the three
// states (sticky | active && !sticky | pressed && !active). // states (sticky | active && !sticky | pressed && !active).
__attribute__((weak)) __attribute__((weak)) bool OneShot::isStickable(Key key) const {
bool OneShot::isStickable(Key key) const {
return isStickableDefault(key); return isStickableDefault(key);
} }
@ -189,7 +188,7 @@ EventHandlerResult OneShot::onNameQuery() {
return ::Focus.sendName(F("OneShot")); return ::Focus.sendName(F("OneShot"));
} }
EventHandlerResult OneShot::onKeyEvent(KeyEvent& event) { EventHandlerResult OneShot::onKeyEvent(KeyEvent &event) {
// Ignore injected key events. This prevents re-processing events that the // Ignore injected key events. This prevents re-processing events that the
// hook functions generate (by calling `injectNormalKey()` via one of the // hook functions generate (by calling `injectNormalKey()` via one of the
@ -274,14 +273,13 @@ EventHandlerResult OneShot::onKeyEvent(KeyEvent& event) {
// event. This is handled in the `beforeReportingState()` hook below. // event. This is handled in the `beforeReportingState()` hook below.
return EventHandlerResult::ABORT; return EventHandlerResult::ABORT;
} }
} }
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
EventHandlerResult OneShot::afterReportingState(const KeyEvent& event) { EventHandlerResult OneShot::afterReportingState(const KeyEvent &event) {
return afterEachCycle(); return afterEachCycle();
} }
@ -379,8 +377,7 @@ void OneShot::holdKey(KeyAddr key_addr) const {
Runtime.handleKeyEvent(event); Runtime.handleKeyEvent(event);
} }
__attribute__((always_inline)) inline __attribute__((always_inline)) inline void OneShot::releaseKey(KeyAddr key_addr) {
void OneShot::releaseKey(KeyAddr key_addr) {
glue_addrs_.clear(key_addr); glue_addrs_.clear(key_addr);
temp_addrs_.clear(key_addr); temp_addrs_.clear(key_addr);

@ -31,7 +31,7 @@
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Keymap macros // Keymap macros
#define OSM(k) ::kaleidoscope::plugin::OneShotModifierKey(Key_ ## k) #define OSM(k) ::kaleidoscope::plugin::OneShotModifierKey(Key_##k)
#define OSL(n) ::kaleidoscope::plugin::OneShotLayerKey(n) #define OSL(n) ::kaleidoscope::plugin::OneShotLayerKey(n)
namespace kaleidoscope { namespace kaleidoscope {
@ -56,8 +56,8 @@ class OneShot : public kaleidoscope::Plugin {
void enableStickablity() {} void enableStickablity() {}
void enableStickability(Key key); void enableStickability(Key key);
template <typename... Keys> template<typename... Keys>
void enableStickability(Key key, Keys&&... keys) { void enableStickability(Key key, Keys &&...keys) {
enableStickability(key); enableStickability(key);
enableStickability(keys...); enableStickability(keys...);
} }
@ -66,8 +66,8 @@ class OneShot : public kaleidoscope::Plugin {
void disableStickability() {} void disableStickability() {}
void disableStickability(Key key); void disableStickability(Key key);
template <typename... Keys> template<typename... Keys>
void disableStickability(Key key, Keys&&... keys) { void disableStickability(Key key, Keys &&...keys) {
disableStickability(key); disableStickability(key);
disableStickability(keys...); disableStickability(keys...);
} }
@ -97,10 +97,10 @@ class OneShot : public kaleidoscope::Plugin {
} }
void toggleAutoModifiers() { void toggleAutoModifiers() {
auto_modifiers_ = ! auto_modifiers_; auto_modifiers_ = !auto_modifiers_;
} }
void toggleAutoLayers() { void toggleAutoLayers() {
auto_layers_ = ! auto_layers_; auto_layers_ = !auto_layers_;
} }
void toggleAutoOneShot() { void toggleAutoOneShot() {
if (auto_modifiers_ || auto_layers_) { if (auto_modifiers_ || auto_layers_) {
@ -191,7 +191,6 @@ class OneShot : public kaleidoscope::Plugin {
EventHandlerResult afterEachCycle(); EventHandlerResult afterEachCycle();
private: private:
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Constants // Constants
static constexpr uint8_t oneshot_key_count = 16; static constexpr uint8_t oneshot_key_count = 16;

@ -26,8 +26,8 @@
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Key constants // Key constants
constexpr Key OneShot_MetaStickyKey {kaleidoscope::ranges::OS_META_STICKY}; constexpr Key OneShot_MetaStickyKey{kaleidoscope::ranges::OS_META_STICKY};
constexpr Key OneShot_ActiveStickyKey {kaleidoscope::ranges::OS_ACTIVE_STICKY}; constexpr Key OneShot_ActiveStickyKey{kaleidoscope::ranges::OS_ACTIVE_STICKY};
namespace kaleidoscope { namespace kaleidoscope {
namespace plugin { namespace plugin {
@ -42,7 +42,6 @@ class OneShotMetaKeys : public kaleidoscope::Plugin {
private: private:
static bool isMetaStickyActive(); static bool isMetaStickyActive();
}; };
} // namespace plugin } // namespace plugin

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save