| 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/memory/scoped_ptr.h" |
| 12 #include "base/message_loop/message_pump_libevent.h" | 13 #include "base/message_loop/message_pump_libevent.h" |
| 13 #include "ui/events/event_constants.h" | 14 #include "ui/events/event_constants.h" |
| 14 #include "ui/events/ozone/evdev/event_converter_evdev.h" | 15 #include "ui/events/ozone/evdev/event_converter_evdev.h" |
| 15 #include "ui/events/ozone/evdev/event_device_info.h" | 16 #include "ui/events/ozone/evdev/event_device_info.h" |
| 16 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" | 17 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" |
| 17 | 18 |
| 18 namespace ui { | 19 namespace ui { |
| 19 | 20 |
| 21 class DeviceEventDispatcherEvdev; |
| 20 class TouchEvent; | 22 class TouchEvent; |
| 21 | 23 class TouchNoiseFinder; |
| 22 class DeviceEventDispatcherEvdev; | 24 struct InProgressTouchEvdev; |
| 23 | 25 |
| 24 class EVENTS_OZONE_EVDEV_EXPORT TouchEventConverterEvdev | 26 class EVENTS_OZONE_EVDEV_EXPORT TouchEventConverterEvdev |
| 25 : public EventConverterEvdev { | 27 : public EventConverterEvdev { |
| 26 public: | 28 public: |
| 27 enum { MAX_FINGERS = 20 }; | |
| 28 TouchEventConverterEvdev(int fd, | 29 TouchEventConverterEvdev(int fd, |
| 29 base::FilePath path, | 30 base::FilePath path, |
| 30 int id, | 31 int id, |
| 31 InputDeviceType type, | 32 InputDeviceType type, |
| 32 DeviceEventDispatcherEvdev* dispatcher); | 33 DeviceEventDispatcherEvdev* dispatcher); |
| 33 ~TouchEventConverterEvdev() override; | 34 ~TouchEventConverterEvdev() override; |
| 34 | 35 |
| 35 // EventConverterEvdev: | 36 // EventConverterEvdev: |
| 36 bool HasTouchscreen() const override; | 37 bool HasTouchscreen() const override; |
| 37 gfx::Size GetTouchscreenSize() const override; | 38 gfx::Size GetTouchscreenSize() const override; |
| 38 int GetTouchPoints() const override; | 39 int GetTouchPoints() const override; |
| 39 | 40 |
| 40 // Unsafe part of initialization. | 41 // Unsafe part of initialization. |
| 41 virtual void Initialize(const EventDeviceInfo& info); | 42 virtual void Initialize(const EventDeviceInfo& info); |
| 42 | 43 |
| 43 private: | 44 private: |
| 44 friend class MockTouchEventConverterEvdev; | 45 friend class MockTouchEventConverterEvdev; |
| 45 | 46 |
| 46 struct InProgressEvents { | |
| 47 InProgressEvents(); | |
| 48 | |
| 49 bool altered_; | |
| 50 float x_; | |
| 51 float y_; | |
| 52 int id_; // Device reported "unique" touch point id; -1 means not active | |
| 53 int finger_; // "Finger" id starting from 0; -1 means not active | |
| 54 | |
| 55 EventType type_; | |
| 56 float radius_x_; | |
| 57 float radius_y_; | |
| 58 float pressure_; | |
| 59 }; | |
| 60 | |
| 61 // Overidden from base::MessagePumpLibevent::Watcher. | 47 // Overidden from base::MessagePumpLibevent::Watcher. |
| 62 void OnFileCanReadWithoutBlocking(int fd) override; | 48 void OnFileCanReadWithoutBlocking(int fd) override; |
| 63 | 49 |
| 64 virtual bool Reinitialize(); | 50 virtual bool Reinitialize(); |
| 65 | 51 |
| 66 void ProcessInputEvent(const input_event& input); | 52 void ProcessInputEvent(const input_event& input); |
| 67 void ProcessAbs(const input_event& input); | 53 void ProcessAbs(const input_event& input); |
| 68 void ProcessSyn(const input_event& input); | 54 void ProcessSyn(const input_event& input); |
| 69 | 55 |
| 70 void ReportEvent(int touch_id, | 56 // Reports, cancels or drops |event| based on whether the touch was |
| 71 const InProgressEvents& event, const base::TimeDelta& delta); | 57 // previously canceled and on whether |event| is noise. |
| 58 void MaybeReportEvent(const InProgressTouchEvdev& event, |
| 59 const base::TimeDelta& delta, |
| 60 bool* cancelled); |
| 61 |
| 72 void ReportEvents(base::TimeDelta delta); | 62 void ReportEvents(base::TimeDelta delta); |
| 73 | 63 |
| 74 // Dispatcher for events. | 64 // Dispatcher for events. |
| 75 DeviceEventDispatcherEvdev* dispatcher_; | 65 DeviceEventDispatcherEvdev* dispatcher_; |
| 76 | 66 |
| 77 // Set if we have seen a SYN_DROPPED and not yet re-synced with the device. | 67 // Set if we have seen a SYN_DROPPED and not yet re-synced with the device. |
| 78 bool syn_dropped_; | 68 bool syn_dropped_; |
| 79 | 69 |
| 80 // Set if this is a type A device (uses SYN_MT_REPORT). | 70 // Set if this is a type A device (uses SYN_MT_REPORT). |
| 81 bool is_type_a_; | 71 bool is_type_a_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 95 // Size of the touchscreen as reported by the driver. | 85 // Size of the touchscreen as reported by the driver. |
| 96 gfx::Size native_size_; | 86 gfx::Size native_size_; |
| 97 | 87 |
| 98 // Number of touch points reported by driver | 88 // Number of touch points reported by driver |
| 99 int touch_points_; | 89 int touch_points_; |
| 100 | 90 |
| 101 // Touch point currently being updated from the /dev/input/event* stream. | 91 // Touch point currently being updated from the /dev/input/event* stream. |
| 102 size_t current_slot_; | 92 size_t current_slot_; |
| 103 | 93 |
| 104 // In-progress touch points. | 94 // In-progress touch points. |
| 105 std::vector<InProgressEvents> events_; | 95 std::vector<InProgressTouchEvdev> events_; |
| 96 |
| 97 // Finds touch noise. |
| 98 scoped_ptr<TouchNoiseFinder> touch_noise_finder_; |
| 106 | 99 |
| 107 DISALLOW_COPY_AND_ASSIGN(TouchEventConverterEvdev); | 100 DISALLOW_COPY_AND_ASSIGN(TouchEventConverterEvdev); |
| 108 }; | 101 }; |
| 109 | 102 |
| 110 } // namespace ui | 103 } // namespace ui |
| 111 | 104 |
| 112 #endif // UI_EVENTS_OZONE_EVDEV_TOUCH_EVENT_CONVERTER_EVDEV_H_ | 105 #endif // UI_EVENTS_OZONE_EVDEV_TOUCH_EVENT_CONVERTER_EVDEV_H_ |
| OLD | NEW |