OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_EVENTS_OZONE_EVDEV_TOUCH_EVENT_CONVERTER_EVDEV_H_ | 5 #ifndef UI_EVENTS_OZONE_EVDEV_TOUCH_EVENT_CONVERTER_EVDEV_H_ |
6 #define UI_EVENTS_OZONE_EVDEV_TOUCH_EVENT_CONVERTER_EVDEV_H_ | 6 #define UI_EVENTS_OZONE_EVDEV_TOUCH_EVENT_CONVERTER_EVDEV_H_ |
7 | 7 |
8 #include <bitset> | 8 #include <bitset> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/message_loop/message_pump_libevent.h" | 12 #include "base/message_loop/message_pump_libevent.h" |
13 #include "ui/events/event_constants.h" | 13 #include "ui/events/event_constants.h" |
14 #include "ui/events/ozone/evdev/event_converter_evdev.h" | 14 #include "ui/events/ozone/evdev/event_converter_evdev.h" |
15 #include "ui/events/ozone/evdev/event_device_info.h" | 15 #include "ui/events/ozone/evdev/event_device_info.h" |
16 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" | 16 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" |
17 | 17 |
18 namespace ui { | 18 namespace ui { |
19 | 19 |
20 class TouchEvent; | 20 class TouchEvent; |
21 | 21 |
22 class EVENTS_OZONE_EVDEV_EXPORT TouchEventConverterEvdev | 22 class EVENTS_OZONE_EVDEV_EXPORT TouchEventConverterEvdev |
23 : public EventConverterEvdev { | 23 : public EventConverterEvdev { |
24 public: | 24 public: |
25 enum { | 25 enum { |
26 MAX_FINGERS = 11 | 26 MAX_FINGERS = 11 |
27 }; | 27 }; |
28 TouchEventConverterEvdev(int fd, | 28 TouchEventConverterEvdev(int fd, |
29 base::FilePath path, | 29 base::FilePath path, |
| 30 int id, |
30 const EventDeviceInfo& info, | 31 const EventDeviceInfo& info, |
31 const EventDispatchCallback& dispatch); | 32 const EventDispatchCallback& dispatch); |
32 virtual ~TouchEventConverterEvdev(); | 33 virtual ~TouchEventConverterEvdev(); |
33 | 34 |
| 35 // EventConverterEvdev: |
| 36 virtual bool HasTouchscreen() const OVERRIDE; |
| 37 virtual gfx::Size GetTouchscreenSize() const OVERRIDE; |
| 38 |
34 private: | 39 private: |
35 friend class MockTouchEventConverterEvdev; | 40 friend class MockTouchEventConverterEvdev; |
36 | 41 |
37 // Unsafe part of initialization. | 42 // Unsafe part of initialization. |
38 void Init(const EventDeviceInfo& info); | 43 void Init(const EventDeviceInfo& info); |
39 | 44 |
40 // Overidden from base::MessagePumpLibevent::Watcher. | 45 // Overidden from base::MessagePumpLibevent::Watcher. |
41 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | 46 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; |
42 | 47 |
43 virtual bool Reinitialize(); | 48 virtual bool Reinitialize(); |
(...skipping 26 matching lines...) Expand all Loading... |
70 float y_num_tuxels_; | 75 float y_num_tuxels_; |
71 | 76 |
72 // Output range for x-axis. | 77 // Output range for x-axis. |
73 float x_min_pixels_; | 78 float x_min_pixels_; |
74 float x_num_pixels_; | 79 float x_num_pixels_; |
75 | 80 |
76 // Output range for y-axis. | 81 // Output range for y-axis. |
77 float y_min_pixels_; | 82 float y_min_pixels_; |
78 float y_num_pixels_; | 83 float y_num_pixels_; |
79 | 84 |
| 85 // Size of the touchscreen as reported by the driver. |
| 86 gfx::Size native_size_; |
| 87 |
80 // Touch point currently being updated from the /dev/input/event* stream. | 88 // Touch point currently being updated from the /dev/input/event* stream. |
81 int current_slot_; | 89 int current_slot_; |
82 | 90 |
83 // Bit field tracking which in-progress touch points have been modified | 91 // Bit field tracking which in-progress touch points have been modified |
84 // without a syn event. | 92 // without a syn event. |
85 std::bitset<MAX_FINGERS> altered_slots_; | 93 std::bitset<MAX_FINGERS> altered_slots_; |
86 | 94 |
87 struct InProgressEvents { | 95 struct InProgressEvents { |
88 float x_; | 96 float x_; |
89 float y_; | 97 float y_; |
90 int id_; // Device reported "unique" touch point id; -1 means not active | 98 int id_; // Device reported "unique" touch point id; -1 means not active |
91 int finger_; // "Finger" id starting from 0; -1 means not active | 99 int finger_; // "Finger" id starting from 0; -1 means not active |
92 | 100 |
93 EventType type_; | 101 EventType type_; |
94 float radius_x_; | 102 float radius_x_; |
95 float radius_y_; | 103 float radius_y_; |
96 float pressure_; | 104 float pressure_; |
97 }; | 105 }; |
98 | 106 |
99 // In-progress touch points. | 107 // In-progress touch points. |
100 InProgressEvents events_[MAX_FINGERS]; | 108 InProgressEvents events_[MAX_FINGERS]; |
101 | 109 |
102 DISALLOW_COPY_AND_ASSIGN(TouchEventConverterEvdev); | 110 DISALLOW_COPY_AND_ASSIGN(TouchEventConverterEvdev); |
103 }; | 111 }; |
104 | 112 |
105 } // namespace ui | 113 } // namespace ui |
106 | 114 |
107 #endif // UI_EVENTS_OZONE_EVDEV_TOUCH_EVENT_CONVERTER_EVDEV_H_ | 115 #endif // UI_EVENTS_OZONE_EVDEV_TOUCH_EVENT_CONVERTER_EVDEV_H_ |
OLD | NEW |