2016-09-18 06:42:21 +00:00
|
|
|
#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>
|
|
|
|
|
2016-09-18 06:42:21 +00:00
|
|
|
/* Class Key_LayeredKeys contains an array of Key pointers, one pointer per layer.
|
2016-09-17 21:47:37 +00:00
|
|
|
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-09-20 01:46:03 +00:00
|
|
|
When the key is pressed, active layerId is retreived from refLayerState and
|
|
|
|
the Key object of the active layerId is called.
|
2016-05-09 14:05:08 +00:00
|
|
|
*/
|
2016-09-18 06:42:21 +00:00
|
|
|
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-09-20 01:46:03 +00:00
|
|
|
uint8_t layerId; //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:
|
2016-09-18 06:42:21 +00:00
|
|
|
Key_LayeredKeys(Key* const ptrsKeys[]): ptrsKeys(ptrsKeys) {}
|
2016-05-09 14:05:08 +00:00
|
|
|
virtual void press();
|
|
|
|
virtual void release();
|
|
|
|
};
|
|
|
|
#endif
|