make astyle

pull/389/head
Jesse Vincent 8 years ago
parent c305e085a9
commit a16411ff93
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -21,21 +21,21 @@
using namespace KaleidoscopePlugins::Ranges;
namespace KaleidoscopePlugins {
// ---- state ---------
uint32_t OneShot::startTime = 0;
uint16_t OneShot::timeOut = 2500;
uint16_t OneShot::holdTimeOut = 250;
OneShot::state_t OneShot::State;
OneShot::state_t OneShot::stickyState;
OneShot::state_t OneShot::pressedState;
uint32_t OneShot::leftMask;
uint32_t OneShot::rightMask;
Key OneShot::prevKey;
bool OneShot::shouldCancel = false;
bool OneShot::shouldCancelStickies = false;
// --- helper macros ------
// ---- state ---------
uint32_t OneShot::startTime = 0;
uint16_t OneShot::timeOut = 2500;
uint16_t OneShot::holdTimeOut = 250;
OneShot::state_t OneShot::State;
OneShot::state_t OneShot::stickyState;
OneShot::state_t OneShot::pressedState;
uint32_t OneShot::leftMask;
uint32_t OneShot::rightMask;
Key OneShot::prevKey;
bool OneShot::shouldCancel = false;
bool OneShot::shouldCancelStickies = false;
// --- helper macros ------
#define isOS(key) (key.raw >= OS_FIRST && key.raw <= OS_LAST)
#define isModifier(key) (key.raw >= Key_LeftControl.raw && key.raw <= Key_RightGui.raw)
@ -58,9 +58,9 @@ namespace KaleidoscopePlugins {
#define hasTimedOut() (millis () - startTime >= timeOut)
// ---- OneShot stuff ----
void
OneShot::injectNormalKey (uint8_t idx, uint8_t keyState) {
// ---- OneShot stuff ----
void
OneShot::injectNormalKey (uint8_t idx, uint8_t keyState) {
Key key;
if (idx < 8) {
@ -72,21 +72,21 @@ namespace KaleidoscopePlugins {
}
handle_keyswitch_event (key, UNKNOWN_KEYSWITCH_LOCATION, keyState | INJECTED);
}
}
void
OneShot::activateOneShot (uint8_t idx) {
void
OneShot::activateOneShot (uint8_t idx) {
injectNormalKey (idx, IS_PRESSED);
}
}
void
OneShot::cancelOneShot (uint8_t idx) {
void
OneShot::cancelOneShot (uint8_t idx) {
clearOneShot (idx);
injectNormalKey (idx, WAS_PRESSED);
}
}
void
OneShot::mask (byte row, byte col) {
void
OneShot::mask (byte row, byte col) {
if (row >= ROWS || col >= COLS)
return;
@ -95,10 +95,10 @@ namespace KaleidoscopePlugins {
rightMask |= SCANBIT (row, col);
} else
leftMask |= SCANBIT (row, col);
}
}
void
OneShot::unmask (byte row, byte col) {
void
OneShot::unmask (byte row, byte col) {
if (row >= ROWS || col >= COLS)
return;
@ -107,10 +107,10 @@ namespace KaleidoscopePlugins {
rightMask &= ~(SCANBIT (row, col));
} else
leftMask &= ~(SCANBIT (row, col));
}
}
bool
OneShot::isMasked (byte row, byte col) {
bool
OneShot::isMasked (byte row, byte col) {
if (row >= ROWS || col >= COLS)
return false;
@ -119,10 +119,10 @@ namespace KaleidoscopePlugins {
return rightMask & SCANBIT (row, col);
} else
return leftMask & SCANBIT (row, col);
}
}
Key
OneShot::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState) {
Key
OneShot::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState) {
uint8_t idx;
if (keyState & INJECTED)
@ -203,10 +203,10 @@ namespace KaleidoscopePlugins {
}
return mappedKey;
}
}
void
OneShot::loopHook (bool postClear) {
void
OneShot::loopHook (bool postClear) {
if (!State.all)
return;
@ -237,42 +237,42 @@ namespace KaleidoscopePlugins {
}
}
}
}
}
// --- glue code ---
// --- glue code ---
OneShot::OneShot (void) {
}
OneShot::OneShot (void) {
}
void
OneShot::begin (void) {
void
OneShot::begin (void) {
event_handler_hook_use (eventHandlerHook);
loop_hook_use (loopHook);
}
}
bool
OneShot::isActive (void) {
bool
OneShot::isActive (void) {
return (State.all && !hasTimedOut ());
}
}
bool
OneShot::isModifierActive (Key key) {
bool
OneShot::isModifierActive (Key key) {
if (key.raw < Key_LeftControl.raw || key.raw > Key_RightGui.raw)
return false;
return isOneShot (key.keyCode - Key_LeftControl.keyCode);
}
}
void
OneShot::cancel (bool withStickies) {
void
OneShot::cancel (bool withStickies) {
shouldCancel = true;
shouldCancelStickies = withStickies;
}
}
void
OneShot::inject (Key key, uint8_t keyState) {
void
OneShot::inject (Key key, uint8_t keyState) {
eventHandlerHook (key, 255, 255, keyState);
}
}
};

@ -25,7 +25,7 @@
#define OSL(n) (Key) {.raw = KaleidoscopePlugins::Ranges::OSL_FIRST + n}
namespace KaleidoscopePlugins {
class OneShot : public KaleidoscopePlugin {
class OneShot : public KaleidoscopePlugin {
public:
OneShot (void);
@ -33,7 +33,9 @@ namespace KaleidoscopePlugins {
static bool isActive (void);
static void cancel (bool withStickies);
static void cancel (void) { cancel (false); };
static void cancel (void) {
cancel (false);
};
static uint16_t timeOut;
static uint16_t holdTimeOut;
@ -69,7 +71,7 @@ namespace KaleidoscopePlugins {
static Key eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState);
static void loopHook (bool postClear);
};
};
};
extern KaleidoscopePlugins::OneShot OneShot;

Loading…
Cancel
Save