mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[ion] Implement dynamic scroll speed profile
Change-Id: Ib3ec2ef63d19bfb88b627f06bcc185fa1b232223
This commit is contained in:
committed by
Émilie Feral
parent
2bfdc482a6
commit
433639c471
@@ -57,7 +57,7 @@ void removeShift();
|
||||
bool isShiftActive();
|
||||
bool isAlphaActive();
|
||||
bool isLockActive();
|
||||
void setLongRepetition(bool longRepetition);
|
||||
void setLongRepetition(int longRepetition);
|
||||
int repetitionFactor();
|
||||
void updateModifiersFromEvent(Event e);
|
||||
void didPressNewKey();
|
||||
|
||||
@@ -25,7 +25,6 @@ bool sEventIsRepeating = 0;
|
||||
int sEventRepetitionCount = 0;
|
||||
constexpr int delayBeforeRepeat = 200;
|
||||
constexpr int delayBetweenRepeat = 50;
|
||||
constexpr int numberOfRepetitionsBeforeLongRepetition = 20;
|
||||
|
||||
static bool canRepeatEvent(Event e) {
|
||||
return e == Events::Left
|
||||
@@ -41,9 +40,14 @@ static bool canRepeatEvent(Event e) {
|
||||
|
||||
Event getPlatformEvent();
|
||||
|
||||
void ComputeAndSetRepetionFactor(int eventRepetitionCount) {
|
||||
// The Repetition factor is increased by 4 every 20 loops in getEvent(2 sec)
|
||||
setLongRepetition((eventRepetitionCount / 20) * 4 + 1);
|
||||
}
|
||||
|
||||
void resetLongRepetition() {
|
||||
sEventRepetitionCount = 0;
|
||||
setLongRepetition(false);
|
||||
ComputeAndSetRepetionFactor(sEventRepetitionCount);
|
||||
}
|
||||
|
||||
Event getEvent(int * timeout) {
|
||||
@@ -85,7 +89,7 @@ Event getEvent(int * timeout) {
|
||||
}
|
||||
|
||||
if (sleepWithTimeout(10, timeout)) {
|
||||
// Timeout occured
|
||||
// Timeout occurred
|
||||
resetLongRepetition();
|
||||
return Events::None;
|
||||
}
|
||||
@@ -101,12 +105,8 @@ Event getEvent(int * timeout) {
|
||||
int delay = (sEventIsRepeating ? delayBetweenRepeat : delayBeforeRepeat);
|
||||
if (time >= delay) {
|
||||
sEventIsRepeating = true;
|
||||
if (sEventRepetitionCount < numberOfRepetitionsBeforeLongRepetition) {
|
||||
sEventRepetitionCount++;
|
||||
if (sEventRepetitionCount == numberOfRepetitionsBeforeLongRepetition) {
|
||||
setLongRepetition(true);
|
||||
}
|
||||
}
|
||||
sEventRepetitionCount++;
|
||||
ComputeAndSetRepetionFactor(sEventRepetitionCount);
|
||||
return sLastEvent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Ion {
|
||||
namespace Events {
|
||||
|
||||
static ShiftAlphaStatus sShiftAlphaStatus = ShiftAlphaStatus::Default;
|
||||
static bool sLongRepetition = false;
|
||||
static int sLongRepetition = 1;
|
||||
|
||||
ShiftAlphaStatus shiftAlphaStatus() {
|
||||
return sShiftAlphaStatus;
|
||||
@@ -33,12 +33,12 @@ bool isLockActive() {
|
||||
return sShiftAlphaStatus == ShiftAlphaStatus::AlphaLock || sShiftAlphaStatus == ShiftAlphaStatus::ShiftAlphaLock;
|
||||
}
|
||||
|
||||
void setLongRepetition(bool longRepetition) {
|
||||
void setLongRepetition(int longRepetition) {
|
||||
sLongRepetition = longRepetition;
|
||||
}
|
||||
|
||||
int repetitionFactor() {
|
||||
return sLongRepetition ? 5 : 1;
|
||||
return sLongRepetition;
|
||||
};
|
||||
|
||||
void setShiftAlphaStatus(ShiftAlphaStatus s) {
|
||||
|
||||
Reference in New Issue
Block a user