First working version of the layer based led theme plugin
This commit is contained in:
parent
3caa17f211
commit
eda0a38fd3
31
LayerBasedTheme.cpp
Normal file
31
LayerBasedTheme.cpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#include "LayerBasedTheme.h"
|
||||||
|
|
||||||
|
#include "kaleidoscope/layers.h"
|
||||||
|
#include "kaleidoscope/plugin/LEDControl.h"
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
namespace plugin {
|
||||||
|
EventHandlerResult LayerBasedTheme::onLayerChange() {
|
||||||
|
uint8_t current_layer = Layer.mostRecent();
|
||||||
|
uint8_t current_mode =::LEDControl.get_mode_index();
|
||||||
|
uint8_t new_mode;
|
||||||
|
|
||||||
|
if (current_layer <= 3) {
|
||||||
|
new_mode = 2;
|
||||||
|
} else {
|
||||||
|
new_mode = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (new_mode != current_mode) {
|
||||||
|
::LEDControl.set_mode(new_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EventHandlerResult::OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
LayerBasedTheme::TransientLEDMode::TransientLEDMode(const LayerBasedTheme *parent)
|
||||||
|
: parent_(parent) {};
|
||||||
|
} // namespace plugin
|
||||||
|
} // namespace kaleidoscope
|
||||||
|
|
||||||
|
kaleidoscope::plugin::LayerBasedTheme LayerBasedTheme;
|
29
LayerBasedTheme.h
Normal file
29
LayerBasedTheme.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "kaleidoscope/event_handler_result.h"
|
||||||
|
#include "kaleidoscope/plugin.h"
|
||||||
|
#include "kaleidoscope/plugin/AccessTransientLEDMode.h"
|
||||||
|
#include "kaleidoscope/plugin/LEDModeInterface.h"
|
||||||
|
#include "kaleidoscope/plugin/LEDMode.h"
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
namespace plugin {
|
||||||
|
class LayerBasedTheme : public Plugin,
|
||||||
|
public LEDModeInterface,
|
||||||
|
public AccessTransientLEDMode {
|
||||||
|
public:
|
||||||
|
LayerBasedTheme(void) {}
|
||||||
|
|
||||||
|
EventHandlerResult onLayerChange();
|
||||||
|
|
||||||
|
class TransientLEDMode : public LEDMode {
|
||||||
|
public:
|
||||||
|
explicit TransientLEDMode(const LayerBasedTheme *parent);
|
||||||
|
private:
|
||||||
|
const LayerBasedTheme *parent_;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} // namespace plugin
|
||||||
|
} // namespace kaleidoscope
|
||||||
|
|
||||||
|
extern kaleidoscope::plugin::LayerBasedTheme LayerBasedTheme;
|
@ -24,6 +24,8 @@
|
|||||||
#include "Kaleidoscope-MagicCombo.h"
|
#include "Kaleidoscope-MagicCombo.h"
|
||||||
#include "Kaleidoscope-USB-Quirks.h"
|
#include "Kaleidoscope-USB-Quirks.h"
|
||||||
|
|
||||||
|
#include "LayerBasedTheme.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MACRO_VERSION_INFO,
|
MACRO_VERSION_INFO,
|
||||||
MACRO_ANY,
|
MACRO_ANY,
|
||||||
@ -296,7 +298,9 @@ KALEIDOSCOPE_INIT_PLUGINS(
|
|||||||
MouseKeys,
|
MouseKeys,
|
||||||
HostPowerManagement,
|
HostPowerManagement,
|
||||||
MagicCombo,
|
MagicCombo,
|
||||||
USBQuirks);
|
USBQuirks,
|
||||||
|
LayerBasedTheme
|
||||||
|
);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Kaleidoscope.setup();
|
Kaleidoscope.setup();
|
||||||
|
Loading…
Reference in New Issue
Block a user