From a885a5e12c4ed8c4f6bf6547cddea3f3d57bbd43 Mon Sep 17 00:00:00 2001 From: Enrico Scholz Date: Fri, 4 Jan 2013 16:59:44 +0100 Subject: fixed magic key behaviour --- inputdev.cc | 21 +++++++++------------ 1 file 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; -- cgit v1.2.3