Archived
1
0

rename Code_Layered* to Key_Layered* and update inheritance

This commit is contained in:
wolfv6 2016-09-17 12:31:14 -06:00
parent 2e77a18847
commit 8a3fad791b
10 changed files with 43 additions and 44 deletions

View File

@ -53,19 +53,18 @@ Keybrd library class inheritance diagram
Key __
| \
| Key_LayeredKeysArray
|
Code
|_____________________
| \ \
| Code_LayerLock Code_LayerHold
|
|___________________________
| \ \
| Code_LayeredScScBase Code_LayeredCodeScBase
| Key_LayeredScScBase Key_LayeredCodeScBase
| | |
| Code_LayeredScSc Code_LayeredCodeSc
| Key_LayeredScSc Key_LayeredCodeSc
|
|_________________________________________________________
Code
\________________________________________________________
\ \ \ \ \
Code_Sc Code_Shift Code_AutoShift Code_LEDLock Code_Null
/ \
@ -157,9 +156,9 @@ Example LayerState class names:
* LayerState_DH - main LayerState for the keybrd_DH library
* LayerState_MF - LayerState for Mouse Function sub-layers in the keybrd_DH library
*Code_Layered* class names start with "Code_Layered" and end with a descriptive name.
Example Code_Layered class names:
* Code_LayeredScSc
*Key_Layered* class names start with "Key_Layered" and end with a descriptive name.
Example Key_Layered class names:
* Key_LayeredScSc
* Key_LayeredKeysArray
Style guide

View File

@ -1,6 +1,6 @@
#include "Code_LayeredCodeSc.h"
#include "Key_LayeredCodeSc.h"
void Code_LayeredCodeSc::press()
void Key_LayeredCodeSc::press()
{
layer = refLayerState.getActiveLayer();
pressCode();

View File

@ -1,23 +1,23 @@
#ifndef CODE_LAYEREDCODESC_H
#define CODE_LAYEREDCODESC_H
#ifndef KEY_LAYEREDCODESC_H
#define KEY_LAYEREDCODESC_H
#include <Arduino.h>
#include <inttypes.h>
#include <Code_LayeredCodeScBase.h>
#include <Key_LayeredCodeScBase.h>
#include <LayerStateInterface.h>
/* Class Code_LayeredCodeSc is a 2-layer code, one object for each layer e.g.
/* Class Key_LayeredCodeSc is a 2-layer code, one object for each layer e.g.
layer0: ms_up //mouse up
layer1: KEY_UP //up arrow
When the key is pressed, the active layer is retrieved from refLayerState,
and the object for the active layer is sent to USB.
*/
class Code_LayeredCodeSc : public Code_LayeredCodeScBase
class Key_LayeredCodeSc : public Key_LayeredCodeScBase
{
private:
static LayerStateInterface& refLayerState;
public:
Code_LayeredCodeSc(Code& refCode0, const uint16_t scancode1)
: Code_LayeredCodeScBase(refCode0, scancode1, 0) { }
Key_LayeredCodeSc(Code& refCode0, const uint16_t scancode1)
: Key_LayeredCodeScBase(refCode0, scancode1, 0) { }
virtual void press();
};
#endif

View File

@ -1,6 +1,6 @@
#include "Code_LayeredCodeScBase.h"
#include "Key_LayeredCodeScBase.h"
void Code_LayeredCodeScBase::pressCode()
void Key_LayeredCodeScBase::pressCode()
{
if (layer)
{
@ -12,7 +12,7 @@ void Code_LayeredCodeScBase::pressCode()
}
}
void Code_LayeredCodeScBase::release()
void Key_LayeredCodeScBase::release()
{
if (layer)
{

View File

@ -1,16 +1,16 @@
#ifndef CODE_LAYEREDCODESCBASE_H
#define CODE_LAYEREDCODESCBASE_H
#ifndef KEY_LAYEREDCODESCBASE_H
#define KEY_LAYEREDCODESCBASE_H
#include <Arduino.h>
#include <inttypes.h>
#include "Code.h"
/* Class Code_LayeredCodeScBase is a 2-layer code, with one object for each layer e.g.
/* Class Key_LayeredCodeScBase is a 2-layer code, with one object for each layer e.g.
layer0: ms_up //mouse up
layer1: KEY_UP //up arrow
When the key is pressed, the active layer is retrieved from refLayerState,
and the object for the active layer is sent to USB.
*/
class Code_LayeredCodeScBase : public Code
class Key_LayeredCodeScBase : public Code
{
private:
Code& refCode0;
@ -18,7 +18,7 @@ class Code_LayeredCodeScBase : public Code
protected:
bool layer;
public:
Code_LayeredCodeScBase(Code& refCode0, const uint16_t scancode1, uint8_t layer):
Key_LayeredCodeScBase(Code& refCode0, const uint16_t scancode1, uint8_t layer):
refCode0(refCode0), scancode1(scancode1), layer(layer) { }
virtual void press()=0;
virtual void release();

View File

@ -1,6 +1,6 @@
#include "Code_LayeredScSc.h"
#include "Key_LayeredScSc.h"
void Code_LayeredScSc::press()
void Key_LayeredScSc::press()
{
layer = refLayerState.getActiveLayer();
pressScancode();

View File

@ -1,22 +1,22 @@
#ifndef CODE_LAYEREDSCSC_H
#define CODE_LAYEREDSCSC_H
#ifndef KEY_LAYEREDSCSC_H
#define KEY_LAYEREDSCSC_H
#include <Arduino.h>
#include <inttypes.h>
#include <LayerStateInterface.h>
#include <Code_LayeredScScBase.h>
#include <Key_LayeredScScBase.h>
/* Class Code_LayeredScSc is composed of two scancodes; "S" stands for Scancode.
/* Class Key_LayeredScSc is composed of two scancodes; "S" stands for Scancode.
layer is retreived from refLayerState.
when layer=0, press sends scancode0
when layer=1, press sends scancode1
*/
class Code_LayeredScSc : public Code_LayeredScScBase
class Key_LayeredScSc : public Key_LayeredScScBase
{
private:
static LayerStateInterface& refLayerState;
public:
Code_LayeredScSc(const uint16_t scancode0, const uint16_t scancode1)
: Code_LayeredScScBase(scancode0, scancode1) { }
Key_LayeredScSc(const uint16_t scancode0, const uint16_t scancode1)
: Key_LayeredScScBase(scancode0, scancode1) { }
virtual void press();
};
#endif

View File

@ -1,6 +1,6 @@
#include "Code_LayeredScScBase.h"
#include "Key_LayeredScScBase.h"
void Code_LayeredScScBase::pressScancode()
void Key_LayeredScScBase::pressScancode()
{
if (layer)
{
@ -14,7 +14,7 @@ void Code_LayeredScScBase::pressScancode()
Keyboard.press(scancode);
}
void Code_LayeredScScBase::release()
void Key_LayeredScScBase::release()
{
Keyboard.release(scancode);
}

View File

@ -1,14 +1,14 @@
#ifndef CODE_LAYERED2SCANCODES_H
#define CODE_LAYERED2SCANCODES_H
#ifndef KEY_LAYERED2SCANCODES_H
#define KEY_LAYERED2SCANCODES_H
#include <Arduino.h>
#include <inttypes.h>
#include "Code.h"
/* Class Code_LayeredScScBase is an abstract base class. It is composed of two scancodes:
/* Class Key_LayeredScScBase is an abstract base class. It is composed of two scancodes:
if layer=0, send scancode0
if layer=1, send scancode1
*/
class Code_LayeredScScBase : public Code
class Key_LayeredScScBase : public Code
{
private:
const uint16_t scancode0;
@ -17,7 +17,7 @@ class Code_LayeredScScBase : public Code
protected:
bool layer; //0 or 1
public:
Code_LayeredScScBase(const uint16_t scancode0, const uint16_t scancode1):
Key_LayeredScScBase(const uint16_t scancode0, const uint16_t scancode1):
scancode0(scancode0), scancode1(scancode1), layer(0) { }
virtual void press()=0;
virtual void release();

View File

@ -105,8 +105,8 @@ A basic LayerState class is:
Key_Layered classes include:
* Key_LayeredKeysArray
* Code_LayeredScSc
* Code_LayeredCodeSc
* Key_LayeredScSc
* Key_LayeredCodeSc
The basic LayerState provided by the keybrd library is sufficient for implementing ordinary layer schemes.
For experimental layer schemes, you would need to create a custom LayerState class, and possibly custom Code_Layer and Key_Layered classes as well.