|
|
@ -134,6 +134,14 @@ EventHandlerResult Qukeys::beforeReportingState() {
|
|
|
|
queue_head_.primary_key : queue_head_.alternate_key;
|
|
|
|
queue_head_.primary_key : queue_head_.alternate_key;
|
|
|
|
flushEvent(event_key);
|
|
|
|
flushEvent(event_key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Last, if there hasn't been a keypress in a while, update the prior keypress
|
|
|
|
|
|
|
|
// timestamp to avoid integer overflow issues:
|
|
|
|
|
|
|
|
if (Runtime.hasTimeExpired(prior_keypress_timestamp_,
|
|
|
|
|
|
|
|
minimum_prior_interval_)) {
|
|
|
|
|
|
|
|
prior_keypress_timestamp_ =
|
|
|
|
|
|
|
|
Runtime.millisAtCycleStart() - (minimum_prior_interval_ + 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
return EventHandlerResult::OK;
|
|
|
|
return EventHandlerResult::OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -185,6 +193,14 @@ bool Qukeys::processQueue() {
|
|
|
|
// key, so we don't need to do it repeatedly later.
|
|
|
|
// key, so we don't need to do it repeatedly later.
|
|
|
|
bool qukey_is_spacecadet = isModifierKey(queue_head_.primary_key);
|
|
|
|
bool qukey_is_spacecadet = isModifierKey(queue_head_.primary_key);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If the qukey press is followed a printable key too closely, it's not
|
|
|
|
|
|
|
|
// eligible to take on its alternate value unless it's a SpaceCadet-type key.
|
|
|
|
|
|
|
|
if (!Runtime.hasTimeExpired(prior_keypress_timestamp_,
|
|
|
|
|
|
|
|
minimum_prior_interval_) &&
|
|
|
|
|
|
|
|
!qukey_is_spacecadet) {
|
|
|
|
|
|
|
|
flushEvent(queue_head_.primary_key);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Now we search the queue for events that will let us decide if the qukey
|
|
|
|
// Now we search the queue for events that will let us decide if the qukey
|
|
|
|
// should be flushed (and if so, in which of its two states). We start with
|
|
|
|
// should be flushed (and if so, in which of its two states). We start with
|
|
|
|
// the second event in the queue (index 1).
|
|
|
|
// the second event in the queue (index 1).
|
|
|
@ -283,6 +299,16 @@ void Qukeys::flushEvent(Key event_key) {
|
|
|
|
KeyAddr queue_head_addr = event_queue_.addr(0);
|
|
|
|
KeyAddr queue_head_addr = event_queue_.addr(0);
|
|
|
|
uint8_t keyswitch_state = event_queue_.isRelease(0) ? WAS_PRESSED : IS_PRESSED;
|
|
|
|
uint8_t keyswitch_state = event_queue_.isRelease(0) ? WAS_PRESSED : IS_PRESSED;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If the flushed event is a keypress of a printable symbol, record its
|
|
|
|
|
|
|
|
// timestamp. This lets us suppress some unintended alternate values seen by
|
|
|
|
|
|
|
|
// fast typists by requiring a minimum interval between this keypress and the
|
|
|
|
|
|
|
|
// next qukey press in order for that qukey to become alternate-eligible.
|
|
|
|
|
|
|
|
if (!event_queue_.isRelease(0) &&
|
|
|
|
|
|
|
|
((event_key >= Key_A && event_key <= Key_0) ||
|
|
|
|
|
|
|
|
(event_key >= Key_Minus && event_key <= Key_Slash))) {
|
|
|
|
|
|
|
|
prior_keypress_timestamp_ = event_queue_.timestamp(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Remove the head event from the queue:
|
|
|
|
// Remove the head event from the queue:
|
|
|
|
event_queue_.shift();
|
|
|
|
event_queue_.shift();
|
|
|
|
// This ensures that the flushed event will be ignored by the event handler hook:
|
|
|
|
// This ensures that the flushed event will be ignored by the event handler hook:
|
|
|
|