mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[ion/events_keyboard] Fix selection on long press
A previous fix to prevent AlphaLock from interfering with the long press feature broke the long press selection. Revert the changes and find another solution to the previous problem. We compare the alpha status to both the state of the Alpha key and the Lock, which makes sense : Lock is supposed to mimic Alpha being continuously pressed. Change-Id: I1349eb83f8971d3a5efcb10de020bb6c0aed64a1
This commit is contained in:
committed by
Émilie Feral
parent
2740056472
commit
3a90ed6109
@@ -50,10 +50,6 @@ void resetLongRepetition() {
|
||||
ComputeAndSetRepetionFactor(sEventRepetitionCount);
|
||||
}
|
||||
|
||||
static Keyboard::Key keyFromState(Keyboard::State state) {
|
||||
return static_cast<Keyboard::Key>(63 - __builtin_clzll(state));
|
||||
}
|
||||
|
||||
Event getEvent(int * timeout) {
|
||||
assert(*timeout > delayBeforeRepeat);
|
||||
assert(*timeout > delayBetweenRepeat);
|
||||
@@ -70,9 +66,6 @@ Event getEvent(int * timeout) {
|
||||
keysSeenUp |= ~state;
|
||||
keysSeenTransitionningFromUpToDown = keysSeenUp & state;
|
||||
|
||||
Keyboard::Key key;
|
||||
bool shift = isShiftActive() || state.keyDown(Keyboard::Key::Shift);
|
||||
bool alpha = isAlphaActive() || state.keyDown(Keyboard::Key::Alpha);
|
||||
bool lock = isLockActive();
|
||||
|
||||
if (keysSeenTransitionningFromUpToDown != 0) {
|
||||
@@ -84,7 +77,9 @@ Event getEvent(int * timeout) {
|
||||
* processors have an instruction (ARM thumb uses CLZ).
|
||||
* Unfortunately there's no way to express this in standard C, so we have
|
||||
* to resort to using a builtin function. */
|
||||
key = keyFromState(keysSeenTransitionningFromUpToDown);
|
||||
Keyboard::Key key = (Keyboard::Key)(63-__builtin_clzll(keysSeenTransitionningFromUpToDown));
|
||||
bool shift = isShiftActive() || state.keyDown(Keyboard::Key::Shift);
|
||||
bool alpha = isAlphaActive() || state.keyDown(Keyboard::Key::Alpha);
|
||||
Event event(key, shift, alpha, lock);
|
||||
sLastEventShift = shift;
|
||||
sLastEventAlpha = alpha;
|
||||
@@ -103,11 +98,10 @@ Event getEvent(int * timeout) {
|
||||
|
||||
// At this point, we know that keysSeenTransitionningFromUpToDown has *always* been zero
|
||||
// In other words, no new key has been pressed
|
||||
key = keyFromState(state);
|
||||
Event event(key, shift, alpha, lock);
|
||||
if (canRepeatEvent(sLastEvent)
|
||||
&& state == sLastKeyboardState
|
||||
&& sLastEvent == event)
|
||||
&& sLastEventShift == state.keyDown(Keyboard::Key::Shift)
|
||||
&& sLastEventAlpha == (state.keyDown(Keyboard::Key::Alpha) || lock))
|
||||
{
|
||||
int delay = (sEventIsRepeating ? delayBetweenRepeat : delayBeforeRepeat);
|
||||
if (time >= delay) {
|
||||
|
||||
Reference in New Issue
Block a user