diff --git a/src/kaleidoscope/plugin/AccessTransientLEDMode.h b/src/kaleidoscope/plugin/AccessTransientLEDMode.h new file mode 100644 index 00000000..5cb353df --- /dev/null +++ b/src/kaleidoscope/plugin/AccessTransientLEDMode.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2017-2018 Keyboard.io, Inc. + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#pragma once + +namespace kaleidoscope { +namespace plugin { + +class AccessTransientLEDMode { + public: + + // This method is called when a plugin's LED mode is activated. + // Derived plugins may reimplement it to store the id of their + // exported LED mode. A plugin can thus check + // whether their LED mode is currently active. + // + void registerLEDModeActivated(uint8_t led_mode_id) { + led_mode_id_ = led_mode_id; + } + + protected: + + uint8_t led_mode_id_ = 255; /* 255 means uninitialized */ +}; + +} // end namespace plugin +} // end namespace kaleidoscope diff --git a/src/kaleidoscope/plugin/LEDMode.h b/src/kaleidoscope/plugin/LEDMode.h index 2459ba95..e734046b 100644 --- a/src/kaleidoscope/plugin/LEDMode.h +++ b/src/kaleidoscope/plugin/LEDMode.h @@ -1,4 +1,4 @@ -/* Kaleidoscope-LEDControl - LED control plugin for Kaleidoscope +/* Kaleidoscope-LEDMode - LED modes for Kaleidoscope * Copyright (C) 2017-2018 Keyboard.io, Inc. * * This program is free software: you can redistribute it and/or modify it under @@ -17,6 +17,8 @@ #pragma once #include "kaleidoscope/plugin.h" +#include "kaleidoscope/plugin/AccessTransientLEDMode.h" +#include "kaleidoscope/plugin/LEDModeInterface.h" namespace kaleidoscope { @@ -27,42 +29,6 @@ class LEDModeManager; namespace plugin { -class LEDModeInterface { - public: - - void activate(); - - // This auxiliary class helps to generate a verbose error message - // in case that there is no TransientLEDMode typedef or nested - // class present in a derived class of LEDModeInterface. - // - struct _____LEDModeInterface_derived_class_is_missing_a_TransientLEDMode_typedef_or_nested_class_____ {}; - typedef _____LEDModeInterface_derived_class_is_missing_a_TransientLEDMode_typedef_or_nested_class_____ NoLEDMode; - - // By redefining TransientLEDMode, derived plugins export - // a LED mode that becomes part of the set of LED modes whose - // lifetime is handled dynamically. - // - typedef NoLEDMode DynamicLEDMode; -}; - -class AccessTransientLEDMode { - public: - - // This method is called when a plugin's LED mode is activated. - // Derived plugins may reimplement it to store the id of their - // exported LED mode. A plugin can thus check - // whether their LED mode is currently active. - // - void registerLEDModeActivated(uint8_t led_mode_id) { - led_mode_id_ = led_mode_id; - } - - protected: - - uint8_t led_mode_id_ = 255; /* 255 means uninitialized */ -}; - /** Base class for LED modes. * * LED modes are a special kind of plugin, they are in charge of updating LED diff --git a/src/kaleidoscope/plugin/LEDMode.cpp b/src/kaleidoscope/plugin/LEDModeInterface.cpp similarity index 84% rename from src/kaleidoscope/plugin/LEDMode.cpp rename to src/kaleidoscope/plugin/LEDModeInterface.cpp index ed422ab0..6205f0eb 100644 --- a/src/kaleidoscope/plugin/LEDMode.cpp +++ b/src/kaleidoscope/plugin/LEDModeInterface.cpp @@ -1,4 +1,4 @@ -/* Kaleidoscope-LEDControl - LED control plugin for Kaleidoscope +/* * Copyright (C) 2017-2018 Keyboard.io, Inc. * * This program is free software: you can redistribute it and/or modify it under @@ -15,9 +15,8 @@ */ -#include +#include #include -#include namespace kaleidoscope { namespace plugin { diff --git a/src/kaleidoscope/plugin/LEDModeInterface.h b/src/kaleidoscope/plugin/LEDModeInterface.h new file mode 100644 index 00000000..aca5f7ac --- /dev/null +++ b/src/kaleidoscope/plugin/LEDModeInterface.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2017-2018 Keyboard.io, Inc. + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#pragma once + +namespace kaleidoscope { +namespace plugin { + +class LEDModeInterface { + public: + + void activate(); + + // This auxiliary class helps to generate a verbose error message + // in case that there is no TransientLEDMode typedef or nested + // class present in a derived class of LEDModeInterface. + // + struct _____LEDModeInterface_derived_class_is_missing_a_TransientLEDMode_typedef_or_nested_class_____ {}; + typedef _____LEDModeInterface_derived_class_is_missing_a_TransientLEDMode_typedef_or_nested_class_____ NoLEDMode; + + // By redefining TransientLEDMode, derived plugins export + // a LED mode that becomes part of the set of LED modes whose + // lifetime is handled dynamically. + // + typedef NoLEDMode DynamicLEDMode; +}; + +} // end namespace plugin +} // end namespace kaleidoscope