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:
KeyAddr active_addr_ = KeyAddr::none();
};
} // namespace plugin

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

@ -72,7 +72,8 @@ class AutoShift : public Plugin {
public:
// 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() {
return Categories(LETTERS);

@ -131,13 +131,15 @@ CharShift::KeyPair CharShift::decodeCharShiftKey(Key key) {
// This should be overridden if the KeyPairs array is stored in EEPROM
__attribute__((weak))
uint8_t CharShift::numKeyPairs() {
uint8_t
CharShift::numKeyPairs() {
return numProgmemKeyPairs();
}
// This should be overridden if the KeyPairs array is stored in EEPROM
__attribute__((weak))
CharShift::KeyPair CharShift::readKeyPair(uint8_t n) {
CharShift::KeyPair
CharShift::readKeyPair(uint8_t n) {
return readKeyPairFromProgmem(n);
}

@ -59,7 +59,8 @@ class CharShift : public Plugin {
///
/// This constructor is used when defining an array of `KeyPair` objects in
/// 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
///
@ -125,10 +126,10 @@ extern kaleidoscope::plugin::CharShift CharShift;
/// defines them as an array in PROGMEM, and configures `CharShift` to use that
/// array, automatically setting the count correctly to prevent out-of-bounds
/// lookups.
#define CS_KEYS(keypairs...) { \
#define CS_KEYS(keypairs...) \
{ \
static kaleidoscope::plugin::CharShift::KeyPair const kp_table[] PROGMEM = { \
keypairs \
}; \
keypairs}; \
CharShift.setProgmemKeyPairs(kp_table); \
}

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

@ -44,21 +44,20 @@ class ColormapEffect : public Plugin,
//
class TransientLEDMode : public LEDMode {
public:
// Please note that storing the parent ptr is only required
// for those LED modes that require access to
// 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:
friend class ColormapEffect;
void onActivate(void) final;
void refreshAt(KeyAddr key_addr) final;
private:
private:
const ColormapEffect *parent_;
};

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

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

@ -72,24 +72,19 @@ struct string {
#endif
};
template <typename TSourceString, size_t remainingLength,
char... collectedChars>
template<typename TSourceString, size_t remainingLength, char... collectedChars>
struct string_maker {
using result =
typename string_maker < TSourceString, remainingLength - 1,
TSourceString::data()[remainingLength - 1],
collectedChars... >::result;
typename string_maker<TSourceString, remainingLength - 1, TSourceString::data()[remainingLength - 1], collectedChars...>::result;
};
#if ARDUINOTRACE_ENABLE_FULLPATH == 0
template <typename TSourceString, size_t remainingLength,
char... collectedChars>
template<typename TSourceString, size_t remainingLength, char... collectedChars>
struct string_maker<TSourceString, remainingLength, '/', collectedChars...> {
using result = string<collectedChars..., '\0'>;
};
template <typename TSourceString, size_t remainingLength,
char... collectedChars>
template<typename TSourceString, size_t remainingLength, char... collectedChars>
struct string_maker<TSourceString, remainingLength, '\\', collectedChars...> {
using result = string<collectedChars..., '\0'>;
};
@ -173,9 +168,7 @@ struct Printer {
// However, if you use it at global scope, you need to call ARDUINOTRACE_INIT()
// first, otherwise, the Serial port will not be ready.
#define TRACE() \
ARDUINOTRACE_PRINT(__COUNTER__, __FILE__, \
ARDUINOTRACE_TRACE_PREFIX(__LINE__), \
ARDUINOTRACE_FUNCTION_NAME)
ARDUINOTRACE_PRINT(__COUNTER__, __FILE__, ARDUINOTRACE_TRACE_PREFIX(__LINE__), ARDUINOTRACE_FUNCTION_NAME)
// 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()
// first, otherwise, the Serial port will not be ready.
#define DUMP(variable) \
ARDUINOTRACE_PRINT(__COUNTER__, __FILE__, \
ARDUINOTRACE_DUMP_PREFIX(__LINE__, variable), variable)
ARDUINOTRACE_PRINT(__COUNTER__, __FILE__, ARDUINOTRACE_DUMP_PREFIX(__LINE__, variable), variable)
#else // ie ARDUINOTRACE_ENABLE == 0

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

@ -37,8 +37,7 @@ class DynamicTapDance: public kaleidoscope::Plugin {
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,
TapDance::ActionType tap_dance_action);
static bool dance(uint8_t tap_dance_index, KeyAddr key_addr, uint8_t tap_count, TapDance::ActionType tap_dance_action);
private:
static uint16_t storage_base_;

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

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

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

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

@ -23,7 +23,8 @@
#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/driver/bootloader/samd/Bossac.h"
@ -67,6 +68,7 @@ class RaiseLEDDriver : public kaleidoscope::driver::led::Base<RaiseLEDDriverProp
static uint8_t getBrightness();
static void updateNeuronLED();
private:
static bool isLEDChangedNeuron;
static uint8_t isLEDChangedLeft[LED_BANKS];
@ -126,6 +128,7 @@ class RaiseKeyScanner : public kaleidoscope::driver::keyscanner::Base<RaiseKeySc
private:
typedef RaiseKeyScanner ThisType;
typedef RaiseKeyScannerProps Props_;
public:
static void setup();
static void scanMatrix();
@ -177,6 +180,7 @@ struct RaiseProps : kaleidoscope::device::BaseProps {
class Raise : public kaleidoscope::device::Base<RaiseProps> {
private:
static RaiseProps::SideFlasher SideFlasher;
public:
static void setup();

@ -57,7 +57,8 @@ typedef union {
class RaiseSide {
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 readSLEDVersion();

@ -32,6 +32,7 @@ template <typename _Firmware>
class SideFlash : public kaleidoscope::Plugin {
private:
_Firmware firmware;
public:
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")))

@ -29,7 +29,8 @@ namespace raise {
class TWI {
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 readFrom(uint8_t *data, size_t length);

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

@ -33,7 +33,8 @@ struct cRGB {
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/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_columns = 6;
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
};
typedef kaleidoscope::driver::bootloader::avr::HalfKay Bootloader;
static constexpr const char *short_name = "ErgoDox-EZ";

@ -90,8 +90,7 @@ out:
return status;
}
void
ErgoDoxScanner::begin() {
void ErgoDoxScanner::begin() {
expander_error_ = initExpander();
// Init columns
@ -156,8 +155,7 @@ out:
}
}
void
ErgoDoxScanner::reattachExpanderOnError() {
void ErgoDoxScanner::reattachExpanderOnError() {
static uint32_t start_time = millis();
if (!expander_error_)

@ -53,7 +53,8 @@ unsigned char i2c_start(unsigned char address) {
TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN);
// wait until transmission completed
while (!(TWCR & (1 << TWINT)));
while (!(TWCR & (1 << TWINT)))
;
// check value of TWI Status Register. Mask prescaler bits.
twst = TW_STATUS & 0xF8;
@ -64,7 +65,8 @@ unsigned char i2c_start(unsigned char address) {
TWCR = (1 << TWINT) | (1 << TWEN);
// 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.
twst = TW_STATUS & 0xF8;
@ -90,7 +92,8 @@ void i2c_start_wait(unsigned char address) {
TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN);
// wait until transmission completed
while (!(TWCR & (1 << TWINT)));
while (!(TWCR & (1 << TWINT)))
;
// check value of TWI Status Register. Mask prescaler bits.
twst = TW_STATUS & 0xF8;
@ -101,7 +104,8 @@ void i2c_start_wait(unsigned char address) {
TWCR = (1 << TWINT) | (1 << TWEN);
// wail until transmission completed
while (!(TWCR & (1 << TWINT)));
while (!(TWCR & (1 << TWINT)))
;
// check value of TWI Status Register. Mask prescaler bits.
twst = TW_STATUS & 0xF8;
@ -110,7 +114,8 @@ void i2c_start_wait(unsigned char address) {
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO);
// wait until stop condition is executed and bus released
while (TWCR & (1 << TWSTO));
while (TWCR & (1 << TWSTO))
;
continue;
}
@ -143,7 +148,8 @@ void i2c_stop(void) {
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO);
// wait until stop condition is executed and bus released
while (TWCR & (1 << TWSTO));
while (TWCR & (1 << TWSTO))
;
} /* i2c_stop */
@ -163,7 +169,8 @@ unsigned char i2c_write(unsigned char data) {
TWCR = (1 << TWINT) | (1 << TWEN);
// wait until transmission completed
while (!(TWCR & (1 << TWINT)));
while (!(TWCR & (1 << TWINT)))
;
// check value of TWI Status Register. Mask prescaler bits
twst = TW_STATUS & 0xF8;
@ -180,7 +187,8 @@ unsigned char i2c_write(unsigned char data) {
*************************************************************************/
unsigned char i2c_readAck(void) {
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWEA);
while (!(TWCR & (1 << TWINT)));
while (!(TWCR & (1 << TWINT)))
;
return TWDR;
@ -194,7 +202,8 @@ unsigned char i2c_readAck(void) {
*************************************************************************/
unsigned char i2c_readNak(void) {
TWCR = (1 << TWINT) | (1 << TWEN);
while (!(TWCR & (1 << TWINT)));
while (!(TWCR & (1 << TWINT)))
;
return TWDR;

@ -42,6 +42,7 @@ class KeyScanner: public kaleidoscope::driver::keyscanner::Base<KeyScannerProps>
private:
typedef KeyScanner ThisType;
typedef KeyScannerProps Props_;
public:
static bool do_scan;
@ -55,6 +56,7 @@ class KeyScanner: public kaleidoscope::driver::keyscanner::Base<KeyScannerProps>
static bool wasKeyswitchPressed(KeyAddr key_addr);
static uint8_t previousPressedKeyswitchCount();
private:
/*
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
// `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
// cannot be in a header-only driver, and must be placed here.

@ -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
// `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
// cannot be in a header-only driver, and must be placed here.

@ -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
// `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
// cannot be in a header-only driver, and must be placed here.
@ -190,7 +191,6 @@ void ImagoLEDDriver::setAllPwmTo(uint8_t step) {
// PWM Register 0 is 0x00 to 0xB3
for (auto i = 1; i <= 0xB4; i++) {
data[i] = step;
}
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
for (auto i = 1; i <= LED_REGISTER_PWM1_SIZE; i++) {
data[i] = step;
}
twi_writeTo(LED_DRIVER_ADDR, data, 0xAC, 1, 0);
}

@ -27,7 +27,8 @@ struct cRGB {
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/driver/bootloader/avr/Caterina.h"

@ -30,7 +30,8 @@
#include "kaleidoscope/MatrixAddr.h" // for MatrixAddr
#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 {
uint8_t b;
@ -91,6 +92,7 @@ struct Model01KeyScannerProps : public kaleidoscope::driver::keyscanner::BasePro
class Model01KeyScanner : public kaleidoscope::driver::keyscanner::Base<Model01KeyScannerProps> {
private:
typedef Model01KeyScanner ThisType;
public:
static void setup();
static void scanMatrix();

@ -82,8 +82,6 @@ uint8_t Model01Side::setKeyscanInterval(uint8_t delay) {
}
// returns -1 on error, otherwise returns the scanner version integer
int Model01Side::readVersion() {
return readRegister(TWI_CMD_VERSION);
@ -113,7 +111,6 @@ uint8_t Model01Side::setLEDSPIFrequency(uint8_t frequency) {
}
int Model01Side::readRegister(uint8_t cmd) {
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);
delayMicroseconds(15); // We may be able to drop this in the future
// but will need to verify with correctly
// sized pull-ups on both the left and right
@ -137,7 +133,6 @@ int Model01Side::readRegister(uint8_t cmd) {
} else {
return -1;
}
}
@ -195,8 +190,7 @@ void Model01Side::setAllLEDsTo(cRGB color) {
uint8_t data[] = {TWI_CMD_LED_SET_ALL_TO,
pgm_read_byte(&gamma8[color.b]),
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);
}
@ -205,10 +199,8 @@ void Model01Side::setOneLEDTo(uint8_t led, cRGB color) {
led,
pgm_read_byte(&gamma8[color.b]),
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);
}
} // namespace keyboardio

@ -34,7 +34,8 @@ struct cRGB {
uint8_t g;
uint8_t r;
};
#define CRGB(r,g,b) (cRGB){b, g, r}
#define CRGB(r, g, b) \
(cRGB) { b, g, r }
#endif
#define LED_BANKS 4

@ -48,7 +48,6 @@ void Model100Hands::setup(void) {
Model100KeyScanner::enableScannerPower();
Wire.begin();
Wire.setClock(400000);
}
/********* LED Driver *********/
@ -141,7 +140,6 @@ void Model100KeyScanner::disableScannerPower(void) {
}
void Model100KeyScanner::setup() {
enableScannerPower();
delay(250);

@ -25,7 +25,8 @@
#include <Arduino.h>
#define CRGB(r,g,b) (cRGB){b, g, r}
#define CRGB(r, g, b) \
(cRGB) { b, g, r }
struct cRGB {
uint8_t b;
@ -92,6 +93,7 @@ struct Model100KeyScannerProps : public kaleidoscope::driver::keyscanner::BasePr
class Model100KeyScanner : public kaleidoscope::driver::keyscanner::Base<Model100KeyScannerProps> {
private:
typedef Model100KeyScanner ThisType;
public:
static void setup();
static void scanMatrix();

@ -75,8 +75,6 @@ uint8_t Model100Side::setKeyscanInterval(uint8_t delay) {
}
// returns -1 on error, otherwise returns the scanner version integer
int Model100Side::readVersion() {
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.
return false;
}
}
void Model100Side::markDeviceUnavailable() {
@ -180,7 +177,6 @@ int Model100Side::readRegister(uint8_t cmd) {
markDeviceUnavailable();
return -1;
}
}
@ -245,8 +241,7 @@ void Model100Side::setAllLEDsTo(cRGB color) {
uint8_t data[] = {TWI_CMD_LED_SET_ALL_TO,
color.b,
color.g,
color.r
};
color.r};
uint8_t result = writeData(data, ELEMENTS(data));
}
@ -255,10 +250,8 @@ void Model100Side::setOneLEDTo(uint8_t led, cRGB color) {
led,
color.b,
color.g,
color.r
};
color.r};
uint8_t result = writeData(data, ELEMENTS(data));
}
} // namespace keyboardio

@ -34,7 +34,8 @@ struct cRGB {
uint8_t g;
uint8_t r;
};
#define CRGB(r,g,b) (cRGB){b, g, r}
#define CRGB(r, g, b) \
(cRGB) { b, g, r }
#endif
#define LED_BANKS 4

@ -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
// `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
// cannot be in a header-only driver, and must be placed here.

@ -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
// `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
// cannot be in a header-only driver, and must be placed here.

@ -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
// `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
// cannot be in a header-only driver, and must be placed here.

@ -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
// `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
// cannot be in a header-only driver, and must be placed here.

@ -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
// `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
// cannot be in a header-only driver, and must be placed here.

@ -75,11 +75,9 @@ void HardwareTestMode::testLeds(void) {
setLeds(blue);
setLeds(green);
setLeds(red);
}
void HardwareTestMode::testMatrix() {
// Reset bad keys from previous tests.
chatter_data state[Runtime.device().numKeys()] = {{0, 0, 0}};

@ -26,7 +26,6 @@ namespace plugin {
class HardwareTestMode : public kaleidoscope::Plugin {
public:
typedef struct {
uint8_t bad : 1,
tested : 1,
@ -38,6 +37,7 @@ class HardwareTestMode : public kaleidoscope::Plugin {
static void runTests();
static void setActionKey(uint8_t key);
private:
static void testLeds();
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)
highest_(1),
// last heatmap computation time
last_heatmap_comp_time_(Runtime.millisAtCycleStart())
{}
last_heatmap_comp_time_(Runtime.millisAtCycleStart()) {}
cRGB Heatmap::TransientLEDMode::computeColor(float v) {
// compute the color corresponding to a value between 0 and 1

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

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

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

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

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

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

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

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

@ -34,14 +34,12 @@ namespace plugin {
StalkerEffect::ColorComputer *StalkerEffect::variant;
uint16_t StalkerEffect::step_length = 50;
cRGB StalkerEffect::inactive_color = (cRGB){
0, 0, 0
};
0, 0, 0};
StalkerEffect::TransientLEDMode::TransientLEDMode(const StalkerEffect *parent)
: parent_(parent),
step_start_time_(0),
map_{}
{}
map_{} {}
EventHandlerResult StalkerEffect::onKeyEvent(KeyEvent &event) {
if (!Runtime.has_leds)

@ -53,7 +53,6 @@ class StalkerEffect : public Plugin,
//
class TransientLEDMode : public LEDMode {
public:
// Please note that storing the parent ptr is only required
// for those LED modes that require access to
// members of their parent class. Most LED modes can do without.
@ -61,11 +60,9 @@ class StalkerEffect : public Plugin,
explicit TransientLEDMode(const StalkerEffect *parent);
protected:
void update() final;
private:
const StalkerEffect *parent_;
uint16_t step_start_time_;
@ -80,9 +77,11 @@ namespace stalker {
class Haunt : public StalkerEffect::ColorComputer {
public:
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;
private:
static cRGB highlight_color_;
};

@ -55,8 +55,7 @@ PROGMEM const uint8_t WavepoolEffect::TransientLEDMode::rc2pos[Runtime.device().
WavepoolEffect::TransientLEDMode::TransientLEDMode(const WavepoolEffect *parent)
: frames_since_event_(0),
surface_{},
page_(0)
{}
page_(0) {}
EventHandlerResult WavepoolEffect::onKeyEvent(KeyEvent &event) {
if (!event.addr.isValid())
@ -137,9 +136,7 @@ void WavepoolEffect::TransientLEDMode::update(void) {
raindrop(prev_x, prev_y, oldpg);
prev_x = prev_y = -1;
}
if (frames_since_event_
>= (frames_till_next_drop
+ (idle_timeout / MS_PER_FRAME))) {
if (frames_since_event_ >= (frames_till_next_drop + (idle_timeout / MS_PER_FRAME))) {
frames_till_next_drop = 4 + (wp_rand() % FRAMES_PER_DROP);
frames_since_event_ = idle_timeout / MS_PER_FRAME;
@ -239,7 +236,6 @@ void WavepoolEffect::TransientLEDMode::update(void) {
// swap pages every frame
page_ ^= 1;
#endif
}
} // namespace plugin

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

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

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

@ -47,7 +47,6 @@ class LEDChaseEffect : public Plugin,
//
class TransientLEDMode : public LEDMode {
public:
// Please note that storing the parent ptr is only required
// for those LED modes that require access to
// 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()) {}
protected:
void update() final;
private:
const LEDChaseEffect *parent_;
uint8_t pos_ = uint8_t(0);

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

@ -28,16 +28,13 @@ namespace plugin {
class LEDSolidColor : public Plugin,
public LEDModeInterface {
public:
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
//
class TransientLEDMode : public LEDMode {
public:
// Please note that storing the parent ptr is only required
// for those LED modes that require access to
// 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;
private:
const LEDSolidColor *parent_;
};
private:
uint8_t r_, g_, b_;
};

@ -28,13 +28,13 @@ class TriColor : public Plugin,
public LEDModeInterface {
public:
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
//
class TransientLEDMode : public LEDMode {
public:
// Please note that storing the parent ptr is only required
// for those LED modes that require access to
// members of their parent class. Most LED modes can do without.
@ -43,11 +43,9 @@ class TriColor : public Plugin,
: parent_(parent) {}
protected:
void update(void) final;
private:
const TriColor *parent_;
};

@ -75,8 +75,7 @@ int8_t Leader::lookup(void) {
if (!match)
continue;
seq_key
= dictionary[seq_index].sequence[sequence_pos_ + 1].readFromProgmem();
seq_key = dictionary[seq_index].sequence[sequence_pos_ + 1].readFromProgmem();
if (seq_key == Key_NoKey) {
return seq_index;
} else {

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

@ -32,7 +32,8 @@
// =============================================================================
// Default `macroAction()` function definitions
__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;
}

@ -42,7 +42,6 @@ namespace plugin {
class Macros : public kaleidoscope::Plugin {
public:
/// Send a key press event from a Macro
///
/// Generates a new `KeyEvent` and calls `Runtime.handleKeyEvent()` with the
@ -105,7 +104,6 @@ class Macros : public kaleidoscope::Plugin {
return true;
return false;
}
};
} // namespace plugin

@ -49,8 +49,7 @@ typedef uint8_t macro_t;
{ \
static const macro_t __m[] PROGMEM = { \
__VA_ARGS__, \
MACRO_ACTION_END \
}; \
MACRO_ACTION_END}; \
&__m[0]; \
})

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

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

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

@ -94,8 +94,7 @@ bool OneShot::isSticky() const {
// could potentially use three different color values for the three
// states (sticky | active && !sticky | pressed && !active).
__attribute__((weak))
bool OneShot::isStickable(Key key) const {
__attribute__((weak)) bool OneShot::isStickable(Key key) const {
return isStickableDefault(key);
}
@ -274,7 +273,6 @@ EventHandlerResult OneShot::onKeyEvent(KeyEvent& event) {
// event. This is handled in the `beforeReportingState()` hook below.
return EventHandlerResult::ABORT;
}
}
return EventHandlerResult::OK;
@ -379,8 +377,7 @@ void OneShot::holdKey(KeyAddr key_addr) const {
Runtime.handleKeyEvent(event);
}
__attribute__((always_inline)) inline
void OneShot::releaseKey(KeyAddr key_addr) {
__attribute__((always_inline)) inline void OneShot::releaseKey(KeyAddr key_addr) {
glue_addrs_.clear(key_addr);
temp_addrs_.clear(key_addr);

@ -191,7 +191,6 @@ class OneShot : public kaleidoscope::Plugin {
EventHandlerResult afterEachCycle();
private:
// --------------------------------------------------------------------------
// Constants
static constexpr uint8_t oneshot_key_count = 16;

@ -42,7 +42,6 @@ class OneShotMetaKeys : public kaleidoscope::Plugin {
private:
static bool isMetaStickyActive();
};
} // namespace plugin

@ -32,6 +32,7 @@ class PersistentLEDMode: public kaleidoscope::Plugin {
EventHandlerResult onSetup();
EventHandlerResult onLEDModeChange();
private:
static uint16_t settings_base_;
static uint8_t cached_mode_index_;

@ -66,7 +66,8 @@ EventHandlerResult Qukeys::onKeyswitchEvent(KeyEvent &event) {
// If we can't trivially ignore the event, just add it to the queue.
event_queue_.append(event);
// In order to prevent overflowing the queue, process it now.
while (processQueue());
while (processQueue())
;
// Any event that gets added to the queue gets re-processed later, so we
// need to abort processing now.
return EventHandlerResult::ABORT;
@ -97,13 +98,13 @@ EventHandlerResult Qukeys::afterEachCycle() {
if (Runtime.hasTimeExpired(event_queue_.timestamp(0), hold_timeout_)) {
// If it's a SpaceCadet-type key, it takes on its primary value, otherwise
// it takes on its secondary value.
Key event_key = isModifierKey(queue_head_.primary_key) ?
queue_head_.primary_key : queue_head_.alternate_key;
Key event_key = isModifierKey(queue_head_.primary_key) ? queue_head_.primary_key : queue_head_.alternate_key;
flushEvent(event_key);
}
// Process as many events as we can from the queue.
while (processQueue());
while (processQueue())
;
return EventHandlerResult::OK;
}
@ -205,8 +206,7 @@ bool Qukeys::processQueue() {
// flush it now. Its state depends on whether or not it's a
// SpaceCadet-type key.
if (next_keypress_index == 0 || overlap_threshold_ == 0) {
Key event_key = qukey_is_spacecadet ?
queue_head_.alternate_key : queue_head_.primary_key;
Key event_key = qukey_is_spacecadet ? queue_head_.alternate_key : queue_head_.primary_key;
// A qukey just got released in primary state; this might turn out to be
// the beginning of a tap-repeat sequence, so we set the tap-repeat
// address and start time to the time of the initial press event before

@ -66,13 +66,11 @@ struct Qukey {
// This is the constructor that should be used when creating a Qukey object in
// the PROGMEM array that will be used by Qukeys (i.e. in the `QUKEYS()`
// macro).
constexpr
Qukey(int8_t layer, KeyAddr k, Key alternate_key)
constexpr Qukey(int8_t layer, KeyAddr k, Key alternate_key)
: layer(layer), addr(k), alternate_key(alternate_key) {}
// This constructor is here so that we can create an empty Qukey object in RAM
// into which we can copy the values from a PROGMEM Qukey object.
Qukey() = default;
};
@ -239,9 +237,9 @@ extern kaleidoscope::plugin::Qukeys Qukeys;
// guarantee that the count is set correctly. This is considerably less
// important than it used to be, with the `configureQukeys()` function taking
// care of guaranteeing the correct count setting.
#define QUKEYS(qukey_defs...) { \
#define QUKEYS(qukey_defs...) \
{ \
static kaleidoscope::plugin::Qukey const qk_table[] PROGMEM = { \
qukey_defs \
}; \
qukey_defs}; \
Qukeys.configureQukeys(qk_table); \
}

@ -80,8 +80,7 @@ SpaceCadet::SpaceCadet() {
{Key_LeftControl, Key_LeftBracket, 250},
{Key_RightControl, Key_RightBracket, 250},
*/
SPACECADET_MAP_END
};
SPACECADET_MAP_END};
map = initialmap;
}

@ -29,7 +29,8 @@
#include "kaleidoscope/plugin.h" // for Plugin
#ifndef SPACECADET_MAP_END
#define SPACECADET_MAP_END (kaleidoscope::plugin::SpaceCadet::KeyBinding) { Key_NoKey, Key_NoKey, 0 }
#define SPACECADET_MAP_END \
(kaleidoscope::plugin::SpaceCadet::KeyBinding) { Key_NoKey, Key_NoKey, 0 }
#endif
constexpr Key Key_SpaceCadetEnable = Key(kaleidoscope::ranges::SC_FIRST);

@ -170,8 +170,7 @@ EventHandlerResult TapDance::afterEachCycle() {
} // namespace plugin
} // namespace kaleidoscope
__attribute__((weak)) void tapDanceAction(uint8_t tap_dance_index, KeyAddr key_addr, uint8_t tap_count,
kaleidoscope::plugin::TapDance::ActionType tap_dance_action) {
__attribute__((weak)) void tapDanceAction(uint8_t tap_dance_index, KeyAddr key_addr, uint8_t tap_count, kaleidoscope::plugin::TapDance::ActionType tap_dance_action) {
}
kaleidoscope::plugin::TapDance TapDance;

@ -33,8 +33,7 @@
#define tapDanceActionKeys(tap_count, tap_dance_action, ...) ({ \
static const Key __k[] PROGMEM = {__VA_ARGS__}; \
TapDance.actionKeys(tap_count, tap_dance_action, \
sizeof (__k) / sizeof (Key), &__k[0]); \
TapDance.actionKeys(tap_count, tap_dance_action, sizeof(__k) / sizeof(Key), &__k[0]); \
})
namespace kaleidoscope {
@ -82,13 +81,11 @@ class TapDance : public kaleidoscope::Plugin {
static uint8_t tap_count_;
void flushQueue(KeyAddr ignored_addr = KeyAddr::none());
};
} // namespace plugin
} // namespace kaleidoscope
void tapDanceAction(uint8_t tap_dance_index, KeyAddr key_addr, uint8_t tap_count,
kaleidoscope::plugin::TapDance::ActionType tap_dance_action);
void tapDanceAction(uint8_t tap_dance_index, KeyAddr key_addr, uint8_t tap_count, kaleidoscope::plugin::TapDance::ActionType tap_dance_action);
extern kaleidoscope::plugin::TapDance TapDance;

@ -37,8 +37,7 @@ TypingBreaks::settings_t TypingBreaks::settings = {
.lock_time_out = 2700, // 45m
.lock_length = 300, // 5m
.left_hand_max_keys = 0,
.right_hand_max_keys = 0
};
.right_hand_max_keys = 0};
bool TypingBreaks::keyboard_locked_{false};
uint32_t TypingBreaks::session_start_time_;

@ -48,6 +48,7 @@ class Unicode : public kaleidoscope::Plugin {
static Key getLinuxKey() {
return linux_key_;
}
private:
static Key linux_key_;
static uint8_t input_delay_;

@ -31,6 +31,7 @@ class WinKeyToggle: public kaleidoscope::Plugin {
void toggle() {
enabled_ = !enabled_;
}
private:
static bool enabled_;
};

@ -53,18 +53,15 @@ void setup();
struct { \
static_assert(CONVERT_TO_KEY(KEY) != kaleidoscope::bad_keymap_key, \
"Bad key definition: \'" #KEY "\'"); \
} \
){}, \
CONVERT_TO_KEY(KEY) \
)
}){}, \
CONVERT_TO_KEY(KEY))
#ifdef PER_KEY_DATA_STACKED
#define KEYMAP_STACKED(...) \
{ \
MAP_LIST( \
CONVERT_AND_CHECK_KEY, \
PER_KEY_DATA_STACKED(XXX, __VA_ARGS__) \
) \
PER_KEY_DATA_STACKED(XXX, __VA_ARGS__)) \
}
#endif
@ -74,8 +71,7 @@ void setup();
{ \
MAP_LIST( \
CONVERT_AND_CHECK_KEY, \
PER_KEY_DATA(XXX, __VA_ARGS__) \
) \
PER_KEY_DATA(XXX, __VA_ARGS__)) \
}
#endif
@ -124,8 +120,7 @@ void setup();
#define xstr(a) str(a)
#define str(a) #a
static_assert(KALEIDOSCOPE_REQUIRED_API_VERSION == KALEIDOSCOPE_API_VERSION,
"Kaleidoscope API version mismatch! We have version " xstr(KALEIDOSCOPE_API_VERSION)
" available, but version " xstr(KALEIDOSCOPE_REQUIRED_API_VERSION) " is required.");
"Kaleidoscope API version mismatch! We have version " xstr(KALEIDOSCOPE_API_VERSION) " available, but version " xstr(KALEIDOSCOPE_REQUIRED_API_VERSION) " is required.");
#endif
// Use this function macro to register plugins with Kaleidoscope's

@ -40,7 +40,6 @@ constexpr _WidthType bitfieldSize(_WidthType n) {
class KeyAddrBitfield {
public:
static constexpr uint8_t size = KeyAddr::upper_limit;
static constexpr uint8_t block_size = 8 * sizeof(uint8_t);
static constexpr uint8_t total_blocks = bitfieldSize<uint8_t>(size);
@ -100,7 +99,6 @@ class KeyAddrBitfield {
}
private:
uint8_t data_[total_blocks] = {};
@ -173,7 +171,7 @@ class KeyAddrBitfield {
} __attribute__((packed)); // class KeyAddrBitfield {
} // namespace kaleidoscope {
} // namespace kaleidoscope
// ================================================================================

@ -89,6 +89,7 @@ class KeyAddrMap {
++key_addr_;
return *this;
}
private:
ThisType &map_;
KeyAddr key_addr_;

@ -30,11 +30,11 @@ struct KeyEvent {
public:
// Constructor for plugin use when regenerating an event with specific ID:
KeyEvent(KeyAddr addr, uint8_t state,
Key key = Key_Undefined, KeyEventId id = last_id_)
KeyEvent(KeyAddr addr, uint8_t state, Key key = Key_Undefined, KeyEventId id = last_id_)
: addr(addr), state(state), key(key), id_(id) {}
KeyEvent() : id_(last_id_) {}
KeyEvent()
: id_(last_id_) {}
// For use by keyscanner creating a new event from a physical keyswitch toggle
// on or off.

@ -97,7 +97,6 @@ class KeyEventTracker {
}
return false;
}
};
} // namespace kaleidoscope

@ -25,11 +25,9 @@ namespace kaleidoscope {
template<uint8_t rows__, uint8_t cols__>
class MatrixAddr {
private:
uint8_t offset_;
public:
typedef MatrixAddr<rows__, cols__> ThisType;
static constexpr uint8_t rows = rows__;
@ -43,7 +41,8 @@ class MatrixAddr {
"MatrixAddr<rows, cols> exceeds the supported total number \n"
"of 255 keys");
constexpr MatrixAddr() : offset_(invalid_state) {}
constexpr MatrixAddr()
: offset_(invalid_state) {}
constexpr MatrixAddr(uint8_t row, uint8_t col)
: offset_(row * cols + col) {}
@ -240,8 +239,7 @@ bool operator!=(const MatrixAddr1__ & a1, const MatrixAddr2__ & a2) {
template<typename MatrixAddr1__, typename MatrixAddr2__>
bool operator>(const MatrixAddr1__ &a1, const MatrixAddr2__ &a2) {
return (a1.row() > a2.row())
|| ((a1.row() == a2.row()) && (a1.col() > a2.col()));
return (a1.row() > a2.row()) || ((a1.row() == a2.row()) && (a1.col() > a2.col()));
}
template<typename MatrixAddr1__, typename MatrixAddr2__>

@ -36,8 +36,7 @@ Runtime_::Runtime_(void) {
}
// ----------------------------------------------------------------------------
void
Runtime_::setup(void) {
void Runtime_::setup(void) {
// We are explicitly initializing the Serial port as early as possible to
// (temporarily, hopefully) work around an issue on OSX. If we initialize
// Serial too late, no matter what we do, we'll end up reading garbage from
@ -60,8 +59,7 @@ Runtime_::setup(void) {
}
// ----------------------------------------------------------------------------
void
Runtime_::loop(void) {
void Runtime_::loop(void) {
millis_at_cycle_start_ = millis();
kaleidoscope::Hooks::beforeEachCycle();
@ -79,8 +77,7 @@ Runtime_::loop(void) {
}
// ----------------------------------------------------------------------------
void
Runtime_::handleKeyswitchEvent(KeyEvent event) {
void Runtime_::handleKeyswitchEvent(KeyEvent event) {
// This function strictly handles physical key events. Any event without a
// valid `KeyAddr` gets ignored.
@ -123,8 +120,7 @@ Runtime_::handleKeyswitchEvent(KeyEvent event) {
}
// ----------------------------------------------------------------------------
void
Runtime_::handleKeyEvent(KeyEvent event) {
void Runtime_::handleKeyEvent(KeyEvent event) {
// For events that didn't begin with `handleKeyswitchEvent()`, we need to look
// up the `Key` value from the keymap (maybe overridden by `live_keys`).
@ -191,8 +187,7 @@ Runtime_::handleKeyEvent(KeyEvent event) {
}
// ----------------------------------------------------------------------------
void
Runtime_::prepareKeyboardReport(const KeyEvent &event) {
void Runtime_::prepareKeyboardReport(const KeyEvent &event) {
// before building the new report, start clean
device().hid().keyboard().releaseAllKeys();
@ -220,8 +215,7 @@ Runtime_::prepareKeyboardReport(const KeyEvent &event) {
}
// ----------------------------------------------------------------------------
void
Runtime_::addToReport(Key key) {
void Runtime_::addToReport(Key key) {
// First, call any relevant plugin handlers, to give them a chance to add
// other values to the HID report directly and/or to abort the automatic
// adding of keycodes below.
@ -252,8 +246,7 @@ Runtime_::addToReport(Key key) {
}
// ----------------------------------------------------------------------------
void
Runtime_::sendKeyboardReport(const KeyEvent &event) {
void Runtime_::sendKeyboardReport(const KeyEvent &event) {
// If the keycode for this key is already in the report, we need to send an
// extra report without that keycode in order to correctly process the
// rollover. It might be better to exempt modifiers from this rule, but it's

@ -134,7 +134,9 @@
#endif
/* converting pins to ports */
enum { PIN_OFFSET, DDR_OFFSET, PORT_OFFSET};
enum { PIN_OFFSET,
DDR_OFFSET,
PORT_OFFSET };
#define PIN_ADDRESS_MASK 0xF
@ -158,4 +160,3 @@ enum { PIN_OFFSET, DDR_OFFSET, PORT_OFFSET};
#define OUTPUT_TOGGLE(pin) (PORT_REG_FOR_PIN(pin) ^= (PIN_MASK_FOR_PIN(pin)))
#define READ_PIN(pin) (!!(PIN_REG_FOR_PIN(pin) & PIN_MASK_FOR_PIN(pin)))

@ -57,8 +57,7 @@ void DefaultHIDReportConsumer::processHIDReport(
return;
}
const HID_KeyboardReport_Data_t &report_data
= *static_cast<const HID_KeyboardReport_Data_t *>(data);
const HID_KeyboardReport_Data_t &report_data = *static_cast<const HID_KeyboardReport_Data_t *>(data);
std::stringstream keypresses;
bool anything = false;

@ -24,9 +24,7 @@ namespace kaleidoscope {
class DefaultHIDReportConsumer {
public:
static void processHIDReport(uint8_t id, const void *data,
int len, int result);
static void processHIDReport(uint8_t id, const void *data, int len, int result);
};
} // namespace kaleidoscope

@ -67,9 +67,12 @@ bool HID_::setup(USBSetup &setup) {
return true;
}
HID_::HID_(void) : PluggableUSBModule(1, 1, epType),
rootNode(NULL), descriptorSize(0),
protocol(HID_REPORT_PROTOCOL), idle(1) {
HID_::HID_(void)
: PluggableUSBModule(1, 1, epType),
rootNode(NULL),
descriptorSize(0),
protocol(HID_REPORT_PROTOCOL),
idle(1) {
setReportData.reportId = 0;
setReportData.leds = 0;
epType[0] = EP_TYPE_INTERRUPT_IN;

@ -48,26 +48,22 @@ extern bool verboseOutputEnabled();
#ifdef KALEIDOSCOPE_HARDWARE_VIRTUAL_NO_LOGGING
template<typename... Args__>
inline
void log_debug(Args__&&... args) {}
inline void log_debug(Args__ &&...args) {}
template<typename... Args__>
inline
void log_info(Args__&&... args) {}
inline void log_info(Args__ &&...args) {}
#else // #ifdef KALEIDOSCOPE_HARDWARE_VIRTUAL_NO_LOGGING
template<typename... Args__>
inline
void log_debug(Args__&&... args) {
inline void log_debug(Args__ &&...args) {
if (verboseOutputEnabled()) {
fprintf(stdout, std::forward<Args__>(args)...);
}
}
template<typename... Args__>
inline
void log_info(Args__&&... args) {
inline void log_info(Args__ &&...args) {
if (verboseOutputEnabled()) {
fprintf(stdout, std::forward<Args__>(args)...);
}
@ -76,14 +72,12 @@ void log_info(Args__&&... args) {
#endif // #ifdef KALEIDOSCOPE_HARDWARE_VIRTUAL_NO_LOGGING
template<typename... Args__>
inline
void log_error(Args__&&... args) {
inline void log_error(Args__ &&...args) {
fprintf(stderr, std::forward<Args__>(args)...);
}
template<typename... Args__>
inline
void log_critical(Args__&&... args) {
inline void log_critical(Args__ &&...args) {
fprintf(stderr, std::forward<Args__>(args)...);
}

@ -203,8 +203,7 @@ void VirtualKeyScanner::readMatrix() {
} else {
key_addr = KeyAddr(
(uint8_t)std::stoi(token.substr(1, commapos - 1)),
(uint8_t)std::stoi(token.substr(commapos + 1, token.length() - commapos - 1))
);
(uint8_t)std::stoi(token.substr(commapos + 1, token.length() - commapos - 1)));
if (!key_addr.isValid()) {
log_error("Bad coordinates: %s\n", token.c_str());
@ -223,9 +222,8 @@ void VirtualKeyScanner::readMatrix() {
}
keystates_[key_addr.toInt()] =
(mode == M_DOWN) ? KeyState::Pressed :
(mode == M_UP) ? KeyState::NotPressed :
KeyState::Tap;
(mode == M_DOWN) ? KeyState::Pressed : (mode == M_UP) ? KeyState::NotPressed
: KeyState::Tap;
}
}
}
@ -285,7 +283,6 @@ uint8_t VirtualKeyScanner::pressedKeyswitchCount() const {
bool VirtualKeyScanner::isKeyswitchPressed(KeyAddr key_addr) const {
if (keystates_[key_addr.toInt()] == KeyState::NotPressed) {
return false;
}
return true;
}
@ -296,7 +293,6 @@ uint8_t VirtualKeyScanner::previousPressedKeyswitchCount() const {
bool VirtualKeyScanner::wasKeyswitchPressed(KeyAddr key_addr) const {
if (keystates_prev_[key_addr.toInt()] == KeyState::NotPressed) {
return false;
}
return true;
@ -364,5 +360,4 @@ cRGB VirtualLEDDriver::getCrgbAt(uint8_t i) const {
} // namespace kaleidoscope
#endif // ifdef KALEIDOSCOPE_VIRTUAL_BUILD

@ -42,12 +42,10 @@ namespace virt {
class VirtualKeyScanner
: public kaleidoscope::driver::keyscanner::Base<kaleidoscope::DeviceProps::KeyScannerProps> {
private:
typedef VirtualKeyScanner ThisType;
typedef kaleidoscope::driver::keyscanner::Base<kaleidoscope::DeviceProps::KeyScannerProps> ParentType;
public:
typedef typename ParentType::KeyAddr KeyAddr;
enum class KeyState {
@ -83,11 +81,9 @@ class VirtualKeyScanner
KeyState getKeystate(KeyAddr keyAddr) const;
private:
bool anythingHeld();
private:
uint8_t n_pressed_switches_,
n_previously_pressed_switches_;
@ -95,13 +91,11 @@ class VirtualKeyScanner
KeyState keystates_[matrix_rows * matrix_columns]; // NOLINT(runtime/arrays)
KeyState keystates_prev_[matrix_rows * matrix_columns]; // NOLINT(runtime/arrays)
};
class VirtualLEDDriver
: public driver::led::Base<kaleidoscope::DeviceProps::LEDDriverProps> {
public:
typedef driver::led::Base<kaleidoscope::DeviceProps::LEDDriverProps>
ParentType;
@ -113,7 +107,6 @@ class VirtualLEDDriver
cRGB getCrgbAt(uint8_t i) const;
private:
cRGB led_states_[led_count]; // NOLINT(runtime/arrays)
};
@ -149,7 +142,6 @@ struct VirtualProps : public kaleidoscope::DeviceProps {
class VirtualDevice
: public kaleidoscope::device::Base<device::virt::VirtualProps> {
public:
auto serialPort() -> decltype(Serial) & {
return Serial;
}

@ -25,23 +25,7 @@ namespace driver {
namespace color {
const uint8_t PROGMEM gamma_correction[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5,
5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10,
10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16,
17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25,
25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36,
37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50,
51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68,
69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89,
90, 92, 93, 95, 96, 98, 99, 101, 102, 104, 105, 107, 109, 110, 112, 114,
115, 117, 119, 120, 122, 124, 126, 127, 129, 131, 133, 135, 137, 138, 140, 142,
144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 167, 169, 171, 173, 175,
177, 180, 182, 184, 186, 189, 191, 193, 196, 198, 200, 203, 205, 208, 210, 213,
215, 218, 220, 223, 225, 228, 231, 233, 236, 239, 241, 244, 247, 249, 252, 255
};
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25, 25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36, 37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50, 51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68, 69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89, 90, 92, 93, 95, 96, 98, 99, 101, 102, 104, 105, 107, 109, 110, 112, 114, 115, 117, 119, 120, 122, 124, 126, 127, 129, 131, 133, 135, 137, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 167, 169, 171, 173, 175, 177, 180, 182, 184, 186, 189, 191, 193, 196, 198, 200, 203, 205, 208, 210, 213, 215, 218, 220, 223, 225, 228, 231, 233, 236, 239, 241, 244, 247, 249, 252, 255};
}
} // namespace driver

@ -45,6 +45,7 @@ template <typename _Props>
class AbsoluteMouse {
private:
typename _Props::AbsoluteMouse absolute_mouse_;
public:
AbsoluteMouse() {}

@ -135,6 +135,7 @@ class Keyboard {
typename _Props::NKROKeyboard nkro_keyboard_;
typename _Props::ConsumerControl consumer_control_;
typename _Props::SystemControl system_control_;
public:
Keyboard() {}
@ -330,7 +331,6 @@ class Keyboard {
releaseRawKey(Key_LeftGui);
}
}
};
} // namespace base

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

Loading…
Cancel
Save