summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>2013-01-04 16:59:44 +0100
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>2013-01-04 17:00:01 +0100
commita885a5e12c4ed8c4f6bf6547cddea3f3d57bbd43 (patch)
treeabac9523ac02b59b09bda710340e830b4cb1fa13
parent274f1540fea0d976def2486b0725b0b966ccf4f4 (diff)
downloadvdr-plugin-inputdev-a885a5e12c4ed8c4f6bf6547cddea3f3d57bbd43.tar.gz
vdr-plugin-inputdev-a885a5e12c4ed8c4f6bf6547cddea3f3d57bbd43.tar.bz2
fixed magic key behaviour
-rw-r--r--inputdev.cc21
1 files changed, 9 insertions, 12 deletions
diff --git a/inputdev.cc b/inputdev.cc
index addf8ce..c607cf1 100644
--- a/inputdev.cc
+++ b/inputdev.cc
@@ -123,6 +123,7 @@ bool MagicState::process(struct input_event const &ev)
};
unsigned int code;
+ struct timespec now;
assert(state_ < ARRAY_SIZE(SEQUENCE));
@@ -139,22 +140,18 @@ bool MagicState::process(struct input_event const &ev)
default: code = ev.code;
}
- if (state_ > 0) {
- struct timespec now;
-
- clock_gettime(CLOCK_MONOTONIC, &now);
- if (compare(next_, now) < 0)
- // reset state due to timeout
- state_ = 0;
+ clock_gettime(CLOCK_MONOTONIC, &now);
+ if (state_ > 0 && compare(next_, now) < 0)
+ // reset state due to timeout
+ state_ = 0;
+ if (SEQUENCE[state_] != code) {
+ state_ = 0;
+ } else {
+ ++state_;
add(next_, now, TIMEOUT);
}
- if (SEQUENCE[state_] == code)
- ++state_;
- else
- state_ = 0;
-
if (state_ == ARRAY_SIZE(SEQUENCE)) {
state_ = 0;
return true;