summaryrefslogtreecommitdiff
path: root/src/t5r2_correcting_filter_interpreter.cc
blob: 3a8832fa24a806cbed95bda8773a5e0cb5ef5966 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2012 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "include/t5r2_correcting_filter_interpreter.h"

namespace gestures {

// Takes ownership of |next|:
T5R2CorrectingFilterInterpreter::T5R2CorrectingFilterInterpreter(
    PropRegistry* prop_reg, Interpreter* next, Tracer* tracer)
    : FilterInterpreter(NULL, next, tracer, false),
      last_finger_cnt_(0),
      last_touch_cnt_(0),
      touch_cnt_correct_enabled_(prop_reg,
                                 "T5R2 Touch Count Correct Enabled", true) {
  InitName();
}

void T5R2CorrectingFilterInterpreter::SyncInterpretImpl(
    HardwareState* hwstate,
    stime_t* timeout) {
  if (touch_cnt_correct_enabled_.val_ &&
      hwstate->finger_cnt == 0 && last_finger_cnt_ == 0 &&
      hwstate->touch_cnt != 0 && hwstate->touch_cnt == last_touch_cnt_) {
    hwstate->touch_cnt = 0;
  }
  last_touch_cnt_ = hwstate->touch_cnt;
  last_finger_cnt_ = hwstate->finger_cnt;
  next_->SyncInterpret(hwstate, timeout);
}

};  // namespace gestures