|
|
@ -26,13 +26,13 @@ uint32_t OneShot::start_time_ = 0;
|
|
|
|
uint16_t OneShot::time_out = 2500;
|
|
|
|
uint16_t OneShot::time_out = 2500;
|
|
|
|
uint16_t OneShot::hold_time_out = 250;
|
|
|
|
uint16_t OneShot::hold_time_out = 250;
|
|
|
|
int16_t OneShot::double_tap_time_out = -1;
|
|
|
|
int16_t OneShot::double_tap_time_out = -1;
|
|
|
|
OneShot::key_state_t OneShot::state_[16];
|
|
|
|
OneShot::key_state_t OneShot::state_[OneShot::ONESHOT_KEY_COUNT];
|
|
|
|
Key OneShot::prev_key_;
|
|
|
|
Key OneShot::prev_key_;
|
|
|
|
bool OneShot::should_cancel_ = false;
|
|
|
|
bool OneShot::should_cancel_ = false;
|
|
|
|
bool OneShot::should_cancel_stickies_ = false;
|
|
|
|
bool OneShot::should_cancel_stickies_ = false;
|
|
|
|
|
|
|
|
|
|
|
|
bool OneShot::isPressed() {
|
|
|
|
bool OneShot::isPressed() {
|
|
|
|
for (uint8_t i = 0; i < sizeof(state_); i++) {
|
|
|
|
for (uint8_t i = 0; i < ONESHOT_KEY_COUNT; i++) {
|
|
|
|
if (state_[i].pressed)
|
|
|
|
if (state_[i].pressed)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -40,7 +40,7 @@ bool OneShot::isPressed() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool OneShot::isSticky() {
|
|
|
|
bool OneShot::isSticky() {
|
|
|
|
for (uint8_t i = 0; i < sizeof(state_); i++) {
|
|
|
|
for (uint8_t i = 0; i < ONESHOT_KEY_COUNT; i++) {
|
|
|
|
if (state_[i].sticky)
|
|
|
|
if (state_[i].sticky)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -209,7 +209,7 @@ void OneShot::inject(Key mapped_key, uint8_t key_state) {
|
|
|
|
// --- glue code ---
|
|
|
|
// --- glue code ---
|
|
|
|
|
|
|
|
|
|
|
|
bool OneShot::isActive(void) {
|
|
|
|
bool OneShot::isActive(void) {
|
|
|
|
for (uint8_t i = 0; i < 16; i++) {
|
|
|
|
for (uint8_t i = 0; i < ONESHOT_KEY_COUNT; i++) {
|
|
|
|
if ((state_[i].active && !hasTimedOut()) ||
|
|
|
|
if ((state_[i].active && !hasTimedOut()) ||
|
|
|
|
state_[i].pressed ||
|
|
|
|
state_[i].pressed ||
|
|
|
|
state_[i].sticky)
|
|
|
|
state_[i].sticky)
|
|
|
@ -256,25 +256,25 @@ void OneShot::disableStickability(Key key) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OneShot::enableStickabilityForModifiers() {
|
|
|
|
void OneShot::enableStickabilityForModifiers() {
|
|
|
|
for (uint8_t i = 0; i < 8; i++) {
|
|
|
|
for (uint8_t i = 0; i < ONESHOT_KEY_COUNT / 2; i++) {
|
|
|
|
state_[i].stickable = true;
|
|
|
|
state_[i].stickable = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OneShot::enableStickabilityForLayers() {
|
|
|
|
void OneShot::enableStickabilityForLayers() {
|
|
|
|
for (uint8_t i = 8; i < 16; i++) {
|
|
|
|
for (uint8_t i = ONESHOT_KEY_COUNT / 2; i < ONESHOT_KEY_COUNT; i++) {
|
|
|
|
state_[i].stickable = true;
|
|
|
|
state_[i].stickable = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OneShot::disableStickabilityForModifiers() {
|
|
|
|
void OneShot::disableStickabilityForModifiers() {
|
|
|
|
for (uint8_t i = 0; i < 8; i++) {
|
|
|
|
for (uint8_t i = 0; i < ONESHOT_KEY_COUNT / 2; i++) {
|
|
|
|
state_[i].stickable = false;
|
|
|
|
state_[i].stickable = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OneShot::disableStickabilityForLayers() {
|
|
|
|
void OneShot::disableStickabilityForLayers() {
|
|
|
|
for (uint8_t i = 8; i < 16; i++) {
|
|
|
|
for (uint8_t i = ONESHOT_KEY_COUNT / 2; i < ONESHOT_KEY_COUNT; i++) {
|
|
|
|
state_[i].stickable = false;
|
|
|
|
state_[i].stickable = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|