blob: 30d8f62ab90eba2cbb618a842ce43f7dedf0c389 (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
// Copyright 2014 The Chromium 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 UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_INTERPRETER_LIBEVDEV_CROS_H_
#define UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_INTERPRETER_LIBEVDEV_CROS_H_
#include <gestures/gestures.h>
#include <libevdev/libevdev.h>
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
#include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
#include "ui/events/ozone/evdev/libgestures_glue/event_reader_libevdev_cros.h"
namespace ui {
class Event;
class EventDeviceInfo;
class EventModifiersEvdev;
class CursorDelegateEvdev;
typedef base::Callback<void(Event*)> EventDispatchCallback;
// Convert libevdev-cros events to ui::Events using libgestures.
//
// This builds a GestureInterpreter for an input device (touchpad or
// mouse).
//
// Raw input events must be preprocessed into a form suitable for
// libgestures. The kernel protocol only emits changes to the device state,
// so changes must be accumulated until a sync event. The full device state
// at sync is then processed by libgestures.
//
// Once we have the state at sync, we convert it to a HardwareState object
// and forward it to libgestures. If any gestures are produced, they are
// converted to ui::Events and dispatched.
class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros
: public EventReaderLibevdevCros::Delegate {
public:
GestureInterpreterLibevdevCros(EventModifiersEvdev* modifiers,
CursorDelegateEvdev* cursor,
const EventDispatchCallback& callback);
virtual ~GestureInterpreterLibevdevCros();
// Overriden from ui::EventReaderLibevdevCros::Delegate
virtual void OnLibEvdevCrosOpen(Evdev* evdev,
EventStateRec* evstate) OVERRIDE;
virtual void OnLibEvdevCrosEvent(Evdev* evdev,
EventStateRec* evstate,
const timeval& time) OVERRIDE;
// Handler for gesture events generated from libgestures.
void OnGestureReady(const Gesture* gesture);
private:
void OnGestureMove(const Gesture* gesture, const GestureMove* move);
void OnGestureScroll(const Gesture* gesture, const GestureScroll* move);
void OnGestureButtonsChange(const Gesture* gesture,
const GestureButtonsChange* move);
void Dispatch(Event* event);
void DispatchMouseButton(unsigned int modifier, bool down);
// Shared modifier state.
EventModifiersEvdev* modifiers_;
// Shared cursor state.
CursorDelegateEvdev* cursor_;
// Callback for dispatching events.
EventDispatchCallback dispatch_callback_;
// Gestures interpretation state.
gestures::GestureInterpreter* interpreter_;
DISALLOW_COPY_AND_ASSIGN(GestureInterpreterLibevdevCros);
};
} // namspace ui
#endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_INTERPRETER_LIBEVDEV_CROS_H_
|