keybrd library is an open source library for creating custom-keyboard firmware.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

LayerState.h 947B

123456789101112131415161718192021222324
  1. #ifndef LAYERSTATE_H
  2. #define LAYERSTATE_H
  3. #include <inttypes.h>
  4. #include "LayerStateInterface.h"
  5. /* Basic LayerState for keyboard.
  6. When pressed, Code_Layer objects call LayerState functions lock() or hold().
  7. When pressed, Layered objects call LayerState function getActiveLayer().
  8. */
  9. class LayerState : public LayerStateInterface
  10. {
  11. protected:
  12. uint8_t activeLayer; //currently active layer
  13. uint8_t lockedLayer; //most recently pressed lock layer
  14. virtual void setActiveLayer(const uint8_t layerId);
  15. public:
  16. LayerState() : activeLayer(0), lockedLayer(0) {}
  17. virtual void hold(uint8_t layerId); //set activeLayer
  18. virtual void unhold(const uint8_t layerId); //restore activeLayer to lockedLayer
  19. virtual void lock(uint8_t layerId); //set activeLayer and lock it
  20. virtual uint8_t getActiveLayer();
  21. };
  22. #endif