Archived
1
0
This repo is archived. You can view files and clone it, but cannot push or open issues or pull requests.
keybrd/src/Code_AutoShift.h

39 lines
1.4 KiB
C
Raw Normal View History

2016-05-09 14:05:08 +00:00
#ifndef CODE_AUTOSHIFT_H
#define CODE_AUTOSHIFT_H
#include "Code.h"
#include "Code_Shift.h"
/* Code_AutoShift is an abstract base class for Codes that depend on automatic shifting.
Code_AutoShift can manage one or more shift keys.
Example initialization:
const Code_Shift s_shift(MODIFIERKEY_LEFT_SHIFT);
2016-07-18 02:26:00 +00:00
const Code_Shift*const ptrsS[] = { &s_shift };
const Code_Shift*const *const Code_AutoShift::ptrsShifts = ptrsS;
2016-07-18 02:03:03 +00:00
const uint8_t Code_AutoShift::shiftCount = sizeof(ptrsS)/sizeof(*ptrsS);
2016-05-09 14:05:08 +00:00
The two Code_Shift pointer arrays (ptrsShifts and ptrsS) must have distinct names.
Automatic shifting is usful on multi-layered keyboards.
The shift state for Code_ScS and Code_ScNS are changed and restored:
Code_ScS object is a scancode shifted e.g. '%' in symbols layer
Code_ScNS object is a scancode not shifted e.g. '5' in numbers layer
2016-07-18 02:26:00 +00:00
keyboards without Code_ScS and Code_ScNS can omit ptrsShifts[] array and
2016-05-09 14:05:08 +00:00
and place scancode MODIFIERKEY_LEFT_SHIFT directly in Code_Sc:
Code_Sc s_shift(MODIFIERKEY_LEFT_SHIFT);
*/
class Code_AutoShift : public Code
{
private:
2016-07-18 02:26:00 +00:00
static Code_Shift*const *const ptrsShifts; //array of Code_Shift pointers
2016-05-09 14:05:08 +00:00
static const uint8_t shiftCount;
protected:
bool isShifted() const;
void releaseAllShifts() const;
void restoreAllShifts() const;
public:
virtual void press()=0;
virtual void release()=0;
};
#endif