blob: 71d42c42606182b6f78744b356a7c4af08a6c320 [file] [log] [blame]
// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef INPUT_EVENT_FILTER_H__
#define INPUT_EVENT_FILTER_H__
#include <linux/input.h>
#include <stdint.h>
#include <base/memory/scoped_ptr.h>
#include "touch_noise_filter/filter.h"
// This class is the glue that connects xf86-input-evdev into the filter
// library. It passes in each input_event. After the SYN_REPORT is passed in
// it should call GetCancelledTouches() to find out which slots have been
// cancelled.
// Non-X clients that just have finger data could call this object's next_
// directly.
namespace touch_noise_filter {
class InputEventFilter {
private:
struct Frame {
Finger fingers_[TOUCH_NOISE_MAX_SLOTS];
};
public:
InputEventFilter(NoiseFilter* next);
void HandleInputEvent(const struct input_event* ev);
void GetCancelledTouches(uint64_t* slots_mask);
private:
Frame* CurrentFrame() { return &frames_[current_frame_]; }
Frame* PrevFrame() { return &frames_[current_frame_ ^ 1]; }
Frame frames_[1];
size_t current_frame_;
// bitmasks of which slots have touches
uint64_t current_touching_;
uint64_t prev_touching_;
scoped_ptr<NoiseFilter> next_;
size_t current_slot_;
};
} // namespace touch_noise_filter
#endif // INPUT_EVENT_FILTER_H__