rename Key_LayeredKeysArray to Key_LayeredKeys
This commit is contained in:
parent
dad142eaa4
commit
59e4f38e61
@ -53,7 +53,7 @@ Keybrd library class inheritance diagram
|
||||
Key
|
||||
|____
|
||||
| \
|
||||
| Key_LayeredKeysArray
|
||||
| Key_LayeredKeys
|
||||
|
|
||||
|___________________________
|
||||
| \ \
|
||||
@ -162,7 +162,7 @@ Example LayerState class names:
|
||||
*Key_Layered* class names start with "Key_Layered" and end with a descriptive name.
|
||||
Example Key_Layered class names:
|
||||
* Key_LayeredScSc
|
||||
* Key_LayeredKeysArray
|
||||
* Key_LayeredKeys
|
||||
|
||||
Style guide
|
||||
-----------
|
||||
|
13
src/Key_LayeredKeys.cpp
Normal file
13
src/Key_LayeredKeys.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "Key_LayeredKeys.h"
|
||||
|
||||
void Key_LayeredKeys::press()
|
||||
{
|
||||
layer = refLayerState.getActiveLayer();
|
||||
|
||||
ptrsKeys[layer]->press();
|
||||
}
|
||||
|
||||
void Key_LayeredKeys::release()
|
||||
{
|
||||
ptrsKeys[layer]->release();
|
||||
}
|
@ -1,24 +1,24 @@
|
||||
#ifndef KEY_LAYEREDKEYSARRAY_H
|
||||
#define KEY_LAYEREDKEYSARRAY_H
|
||||
#ifndef KEY_LAYEREDKEYS_H
|
||||
#define KEY_LAYEREDKEYS_H
|
||||
#include <Arduino.h>
|
||||
#include <inttypes.h>
|
||||
#include <LayerStateInterface.h>
|
||||
#include <Key.h>
|
||||
|
||||
/* Class Key_LayeredKeysArray contains an array of Key pointers, one pointer per layer.
|
||||
/* 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.
|
||||
|
||||
When the key is pressed, active layer is retreived from refLayerState and
|
||||
the Key object of the active layer is called.
|
||||
*/
|
||||
class Key_LayeredKeysArray : public Key
|
||||
class Key_LayeredKeys : public Key
|
||||
{
|
||||
private:
|
||||
Key*const *const ptrsKeys; //array of Key pointers, one Key per layer
|
||||
uint8_t layer; //active layer when key was pressed
|
||||
static LayerStateInterface& refLayerState;
|
||||
public:
|
||||
Key_LayeredKeysArray(Key* const ptrsKeys[]): ptrsKeys(ptrsKeys) {}
|
||||
Key_LayeredKeys(Key* const ptrsKeys[]): ptrsKeys(ptrsKeys) {}
|
||||
virtual void press();
|
||||
virtual void release();
|
||||
};
|
@ -1,13 +0,0 @@
|
||||
#include "Key_LayeredKeysArray.h"
|
||||
|
||||
void Key_LayeredKeysArray::press()
|
||||
{
|
||||
layer = refLayerState.getActiveLayer();
|
||||
|
||||
ptrsKeys[layer]->press();
|
||||
}
|
||||
|
||||
void Key_LayeredKeysArray::release()
|
||||
{
|
||||
ptrsKeys[layer]->release();
|
||||
}
|
@ -20,7 +20,7 @@ Holding the fn key down makes it the active layer. Releasing the fn key restore
|
||||
#include <Code_Sc.h>
|
||||
#include <LayerState.h>
|
||||
#include <Code_LayerHold.h>
|
||||
#include <Key_LayeredKeysArray.h>
|
||||
#include <Key_LayeredKeys.h>
|
||||
|
||||
//Matrix
|
||||
#include <Row.h>
|
||||
@ -67,23 +67,23 @@ Code_Sc s_shift(MODIFIERKEY_LEFT_SHIFT);
|
||||
|
||||
/* =================== KEYS ====================
|
||||
Here we pack Codes into keys.
|
||||
The Key_LayeredKeysArray constructor takes one array of Code pointers - one Code object per layer.
|
||||
The Key_LayeredKeys constructor takes one array of Code pointers - one Code object per layer.
|
||||
|
||||
The Key object names in this sketch start with a "k_" followed by row-column coordinates.
|
||||
*/
|
||||
Key* const ptrsCodes_01[] = { &s_a, &s_1 };
|
||||
Key_LayeredKeysArray k_01(ptrsCodes_01);
|
||||
Key_LayeredKeys k_01(ptrsCodes_01);
|
||||
|
||||
Key* const ptrsCodes_11[] = { &s_b, &s_2 };
|
||||
Key_LayeredKeysArray k_11(ptrsCodes_11);
|
||||
Key_LayeredKeys k_11(ptrsCodes_11);
|
||||
|
||||
/* Key_LayeredKeysArray has a reference to layerState.
|
||||
Thus Key_LayeredKeysArray can call layerState to get the active layer id.
|
||||
/* Key_LayeredKeys has a reference to layerState.
|
||||
Thus Key_LayeredKeys can call layerState to get the active layer id.
|
||||
*/
|
||||
LayerStateInterface& Key_LayeredKeysArray::refLayerState = layerState;
|
||||
LayerStateInterface& Key_LayeredKeys::refLayerState = layerState;
|
||||
|
||||
/* HOW LAYERED OBJECTS WORK
|
||||
When a Key_LayeredKeysArray object is pressed, it gets the active layer id from layerState.
|
||||
When a Key_LayeredKeys object is pressed, it gets the active layer id from layerState.
|
||||
It then uses the layer id as an array index to call the Code of the active layer.
|
||||
The Code object then sends its scancode over USB.
|
||||
*/
|
||||
|
@ -22,7 +22,7 @@ Holding the fn key down makes it the active layer. Releasing the fn key restore
|
||||
#include <Code_Shift.h>
|
||||
#include <LayerState.h>
|
||||
#include <Code_LayerHold.h>
|
||||
#include <Key_LayeredKeysArray.h>
|
||||
#include <Key_LayeredKeys.h>
|
||||
|
||||
//Matrix
|
||||
#include <Row_uC.h>
|
||||
@ -92,12 +92,12 @@ When the user presses '!' or '@' on the fn layer:
|
||||
|
||||
// =================== KEYS ====================
|
||||
Key* const ptrsCodes_01[] = { &s_a, &s_exclamation };
|
||||
Key_LayeredKeysArray k_01(ptrsCodes_01);
|
||||
Key_LayeredKeys k_01(ptrsCodes_01);
|
||||
|
||||
Key* const ptrsCodes_11[] = { &s_b, &s_at };
|
||||
Key_LayeredKeysArray k_11(ptrsCodes_11);
|
||||
Key_LayeredKeys k_11(ptrsCodes_11);
|
||||
|
||||
LayerStateInterface& Key_LayeredKeysArray::refLayerState = layerState;
|
||||
LayerStateInterface& Key_LayeredKeys::refLayerState = layerState;
|
||||
|
||||
// =================== ROWS ====================
|
||||
Key* const ptrsKeys_0[] = { &s_shift, &k_01 };
|
||||
|
@ -17,7 +17,7 @@ This sketch:
|
||||
#include <Code_LEDLock.h>
|
||||
#include <LayerState_LED.h>
|
||||
#include <Code_LayerHold.h>
|
||||
#include <Key_LayeredKeysArray.h>
|
||||
#include <Key_LayeredKeys.h>
|
||||
|
||||
#include <Row_uC.h>
|
||||
#include <ScanDelay.h>
|
||||
@ -73,12 +73,12 @@ Code_Sc s_2(KEY_2);
|
||||
|
||||
// =================== KEYS ====================
|
||||
Key* const ptrsCodes_01[] = { &s_a, &s_1 };
|
||||
Key_LayeredKeysArray k_01(ptrsCodes_01);
|
||||
Key_LayeredKeys k_01(ptrsCodes_01);
|
||||
|
||||
Key* const ptrsCodes_11[] = { &s_b, &s_2 };
|
||||
Key_LayeredKeysArray k_11(ptrsCodes_11);
|
||||
Key_LayeredKeys k_11(ptrsCodes_11);
|
||||
|
||||
LayerStateInterface& Key_LayeredKeysArray::refLayerState = layerState;
|
||||
LayerStateInterface& Key_LayeredKeys::refLayerState = layerState;
|
||||
|
||||
// =================== ROWS ====================
|
||||
Key* const ptrsKeys_0[] = { &o_capsLock, &k_01 };
|
||||
|
@ -26,7 +26,7 @@ The sketch annotations explain how multi-layer keyboards work.
|
||||
The sketch uses three layer-scheme classes:
|
||||
* LayerState
|
||||
* Code_LayerHold
|
||||
* Key_LayeredKeysArray
|
||||
* Key_LayeredKeys
|
||||
|
||||
The internal workings of these three classes are revealed in the next section.
|
||||
|
||||
@ -58,11 +58,11 @@ class LayerState
|
||||
};
|
||||
```
|
||||
|
||||
**Key_LayeredKeysArray** objects contain an array of keys, one key for each layer.
|
||||
Key_LayeredKeysArray objects use layer ids as Key_LayeredKeysArray indexes.
|
||||
When a Key_LayeredKeysArray object is pressed, it gets the active layer from LayerState, and sends the corresponding key.
|
||||
**Key_LayeredKeys** objects contain an array of keys, one key for each layer.
|
||||
Key_LayeredKeys objects use layer ids as Key_LayeredKeys indexes.
|
||||
When a Key_LayeredKeys object is pressed, it gets the active layer from LayerState, and sends the corresponding key.
|
||||
```
|
||||
class Key_LayeredKeysArray
|
||||
class Key_LayeredKeys
|
||||
{
|
||||
Key** ptrsKeys; //array of Key pointers, one Key pointer per layer
|
||||
LayerState& refLayerState;
|
||||
@ -88,7 +88,7 @@ Dependency diagram
|
||||
|getActiveLayer()
|
||||
|
|
||||
+----------------------+
|
||||
| Key_LayeredKeysArray |
|
||||
| Key_LayeredKeys |
|
||||
+----------------------+
|
||||
```
|
||||
Layer-scheme classes
|
||||
@ -104,7 +104,7 @@ A basic LayerState class is:
|
||||
* LayerState
|
||||
|
||||
Key_Layered classes include:
|
||||
* Key_LayeredKeysArray
|
||||
* Key_LayeredKeys
|
||||
* Key_LayeredScSc
|
||||
* Key_LayeredCodeSc
|
||||
|
||||
|
Reference in New Issue
Block a user