From 8a3fad791b61def3d3f7138a9b89a3946e8cd19f Mon Sep 17 00:00:00 2001 From: wolfv6 Date: Sat, 17 Sep 2016 12:31:14 -0600 Subject: [PATCH] rename Code_Layered* to Key_Layered* and update inheritance --- doc/keybrd_library_developer_guide.md | 15 +++++++-------- src/Code_LayeredCodeSc.cpp | 4 ++-- src/Code_LayeredCodeSc.h | 14 +++++++------- src/Code_LayeredCodeScBase.cpp | 6 +++--- src/Code_LayeredCodeScBase.h | 10 +++++----- src/Code_LayeredScSc.cpp | 4 ++-- src/Code_LayeredScSc.h | 14 +++++++------- src/Code_LayeredScScBase.cpp | 6 +++--- src/Code_LayeredScScBase.h | 10 +++++----- tutorials/tutorial_3a_multi-layer_keyboard.md | 4 ++-- 10 files changed, 43 insertions(+), 44 deletions(-) diff --git a/doc/keybrd_library_developer_guide.md b/doc/keybrd_library_developer_guide.md index 11453ff..ff76bec 100644 --- a/doc/keybrd_library_developer_guide.md +++ b/doc/keybrd_library_developer_guide.md @@ -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 diff --git a/src/Code_LayeredCodeSc.cpp b/src/Code_LayeredCodeSc.cpp index 9c0d005..7b7b2e6 100644 --- a/src/Code_LayeredCodeSc.cpp +++ b/src/Code_LayeredCodeSc.cpp @@ -1,6 +1,6 @@ -#include "Code_LayeredCodeSc.h" +#include "Key_LayeredCodeSc.h" -void Code_LayeredCodeSc::press() +void Key_LayeredCodeSc::press() { layer = refLayerState.getActiveLayer(); pressCode(); diff --git a/src/Code_LayeredCodeSc.h b/src/Code_LayeredCodeSc.h index 0566078..d56b646 100644 --- a/src/Code_LayeredCodeSc.h +++ b/src/Code_LayeredCodeSc.h @@ -1,23 +1,23 @@ -#ifndef CODE_LAYEREDCODESC_H -#define CODE_LAYEREDCODESC_H +#ifndef KEY_LAYEREDCODESC_H +#define KEY_LAYEREDCODESC_H #include #include -#include +#include #include -/* 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 diff --git a/src/Code_LayeredCodeScBase.cpp b/src/Code_LayeredCodeScBase.cpp index 2fa300a..613ea8f 100644 --- a/src/Code_LayeredCodeScBase.cpp +++ b/src/Code_LayeredCodeScBase.cpp @@ -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) { diff --git a/src/Code_LayeredCodeScBase.h b/src/Code_LayeredCodeScBase.h index 9d0171e..1f06197 100644 --- a/src/Code_LayeredCodeScBase.h +++ b/src/Code_LayeredCodeScBase.h @@ -1,16 +1,16 @@ -#ifndef CODE_LAYEREDCODESCBASE_H -#define CODE_LAYEREDCODESCBASE_H +#ifndef KEY_LAYEREDCODESCBASE_H +#define KEY_LAYEREDCODESCBASE_H #include #include #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(); diff --git a/src/Code_LayeredScSc.cpp b/src/Code_LayeredScSc.cpp index c6d20df..f02d4cc 100644 --- a/src/Code_LayeredScSc.cpp +++ b/src/Code_LayeredScSc.cpp @@ -1,6 +1,6 @@ -#include "Code_LayeredScSc.h" +#include "Key_LayeredScSc.h" -void Code_LayeredScSc::press() +void Key_LayeredScSc::press() { layer = refLayerState.getActiveLayer(); pressScancode(); diff --git a/src/Code_LayeredScSc.h b/src/Code_LayeredScSc.h index 88e765d..fb57466 100644 --- a/src/Code_LayeredScSc.h +++ b/src/Code_LayeredScSc.h @@ -1,22 +1,22 @@ -#ifndef CODE_LAYEREDSCSC_H -#define CODE_LAYEREDSCSC_H +#ifndef KEY_LAYEREDSCSC_H +#define KEY_LAYEREDSCSC_H #include #include #include -#include +#include -/* 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 diff --git a/src/Code_LayeredScScBase.cpp b/src/Code_LayeredScScBase.cpp index 2ed5e04..35e6303 100644 --- a/src/Code_LayeredScScBase.cpp +++ b/src/Code_LayeredScScBase.cpp @@ -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); } diff --git a/src/Code_LayeredScScBase.h b/src/Code_LayeredScScBase.h index 132609d..3d6f0cb 100644 --- a/src/Code_LayeredScScBase.h +++ b/src/Code_LayeredScScBase.h @@ -1,14 +1,14 @@ -#ifndef CODE_LAYERED2SCANCODES_H -#define CODE_LAYERED2SCANCODES_H +#ifndef KEY_LAYERED2SCANCODES_H +#define KEY_LAYERED2SCANCODES_H #include #include #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(); diff --git a/tutorials/tutorial_3a_multi-layer_keyboard.md b/tutorials/tutorial_3a_multi-layer_keyboard.md index 23fe2dc..c767d13 100644 --- a/tutorials/tutorial_3a_multi-layer_keyboard.md +++ b/tutorials/tutorial_3a_multi-layer_keyboard.md @@ -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.