Archived
1
0
This repo is archived. You can view files and clone it, but cannot push or open issues or pull requests.
keybrd/src/Key_LayeredKeys.h

26 lines
880 B
C
Raw Normal View History

#ifndef KEY_LAYEREDKEYS_H
#define KEY_LAYEREDKEYS_H
2016-05-09 14:05:08 +00:00
#include <Arduino.h>
#include <inttypes.h>
2016-05-28 21:16:32 +00:00
#include <LayerStateInterface.h>
2016-05-09 14:05:08 +00:00
#include <Key.h>
/* Class Key_LayeredKeys contains an array of Key pointers, one pointer per layer.
Codes are a kind of Key, so the Key pointers can point to Codes or Keys.
2016-05-09 14:05:08 +00:00
2016-05-28 21:16:32 +00:00
When the key is pressed, active layer is retreived from refLayerState and
2016-05-09 14:05:08 +00:00
the Key object of the active layer is called.
*/
class Key_LayeredKeys : public Key
2016-05-09 14:05:08 +00:00
{
private:
2016-07-18 02:26:00 +00:00
Key*const *const ptrsKeys; //array of Key pointers, one Key per layer
2016-05-09 14:05:08 +00:00
uint8_t layer; //active layer when key was pressed
2016-05-28 21:16:32 +00:00
static LayerStateInterface& refLayerState;
2016-05-09 14:05:08 +00:00
public:
Key_LayeredKeys(Key* const ptrsKeys[]): ptrsKeys(ptrsKeys) {}
2016-05-09 14:05:08 +00:00
virtual void press();
virtual void release();
};
#endif