Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / ui / events / ozone / evdev / touch_event_converter.h
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_EVENTS_OZONE_EVDEV_TOUCH_EVENT_CONVERTER_EVDEV_H_
6 #define UI_EVENTS_OZONE_EVDEV_TOUCH_EVENT_CONVERTER_EVDEV_H_
7
8 #include <bitset>
9
10 #include "base/compiler_specific.h"
11 #include "base/files/file_path.h"
12 #include "ui/events/event_constants.h"
13 #include "ui/events/events_export.h"
14 #include "ui/events/ozone/event_converter_ozone.h"
15
16 namespace ui {
17
18 class TouchEvent;
19
20 class EVENTS_EXPORT TouchEventConverterEvdev : public EventConverterOzone {
21  public:
22   enum {
23     MAX_FINGERS = 11
24   };
25   TouchEventConverterEvdev(int fd, base::FilePath path);
26   virtual ~TouchEventConverterEvdev();
27
28  private:
29   friend class MockTouchEventConverterEvdev;
30
31   // Unsafe part of initialization.
32   void Init();
33
34   // Overidden from base::MessagePumpLibevent::Watcher.
35   virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
36   virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
37
38   // Pressure values.
39   int pressure_min_;
40   int pressure_max_;  // Used to normalize pressure values.
41
42   // Touch scaling.
43   float x_scale_;
44   float y_scale_;
45
46   // Maximum coordinate-values allowed for the events.
47   int x_max_;
48   int y_max_;
49
50   // Touch point currently being updated from the /dev/input/event* stream.
51   int current_slot_;
52
53   // File descriptor for the /dev/input/event* instance.
54   int fd_;
55
56   // Path to input device.
57   base::FilePath path_;
58
59   // Bit field tracking which in-progress touch points have been modified
60   // without a syn event.
61   std::bitset<MAX_FINGERS> altered_slots_;
62
63   struct InProgressEvents {
64     int x_;
65     int y_;
66     int id_;  // Device reported "unique" touch point id; -1 means not active
67     int finger_;  // "Finger" id starting from 0; -1 means not active
68
69     EventType type_;
70     int major_;
71     float pressure_;
72   };
73
74   // In-progress touch points.
75   InProgressEvents events_[MAX_FINGERS];
76
77   DISALLOW_COPY_AND_ASSIGN(TouchEventConverterEvdev);
78 };
79
80 }  // namespace ui
81
82 #endif  // UI_EVENTS_OZONE_EVDEV_TOUCH_EVENT_CONVERTER_EVDEV_H_
83