keybrd library is an open source library for creating custom-keyboard firmware.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
Este repositório está arquivado. Você pode visualizar os arquivos e realizar clone, mas não poderá realizar push nem abrir issues e pull requests.

Key_LayeredKeysBase.h 1.2KB

12345678910111213141516171819202122232425262728293031
  1. #ifndef KEY_LAYEREDKEYSBASE_H
  2. #define KEY_LAYEREDKEYSBASE_H
  3. #include <Arduino.h>
  4. #include <inttypes.h>
  5. #include "LayerStateInterface.h"
  6. #include "Key.h"
  7. /* Class Key_LayeredKeysBase contains an array of Key pointers, one pointer per layer.
  8. Codes are a kind of Key, so the Key pointers can point to Codes or Keys.
  9. When the key is pressed, active layerId is retreived and the Key object of that layer is called.
  10. Design note:
  11. Child classes (Key_LayeredKeys and Key_LayeredKeys1) have distinct static refLayerState
  12. and different size ptrsKeys[].
  13. That way Key_LayeredKeys instantiations don't need a LayerState argument,
  14. which is significant for a sketch with 100 keys.
  15. */
  16. class Key_LayeredKeysBase : public Key
  17. {
  18. private:
  19. Key*const *const ptrsKeys; //array of Key pointers, one Key per layer
  20. uint8_t layerId; //active layer when key was pressed
  21. static LayerStateInterface& refLayerState;
  22. public:
  23. Key_LayeredKeysBase(Key* const ptrsKeys[]): ptrsKeys(ptrsKeys) {}
  24. virtual uint8_t getActiveLayer()=0;
  25. virtual void press();
  26. virtual void release();
  27. };
  28. #endif