Index: ui/base/linux/touch_event_from_evdev_converter.h |
diff --git a/ui/base/linux/touch_event_from_evdev_converter.h b/ui/base/linux/touch_event_from_evdev_converter.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..80f7e89285ef38610c4004612746b18bf6b765f4 |
--- /dev/null |
+++ b/ui/base/linux/touch_event_from_evdev_converter.h |
@@ -0,0 +1,77 @@ |
+// Copyright (c) 2013 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_BASE_LINUX_EVDEV_DELEGATE_TOUCH_H_ |
+#define UI_BASE_LINUX_EVDEV_DELEGATE_TOUCH_H_ |
+ |
+#include <bitset> |
+ |
+#include "base/message_pump_libevent.h" |
+#include "ui/base/events/event_constants.h" |
+#include "ui/base/events/event.h" |
+#include "ui/base/ui_export.h" |
+ |
+namespace ui { |
+ |
+class TouchEvent; |
+ |
+class UI_EXPORT TouchEventFromEvdevConverter |
+ : public base::MessagePumpLibevent::Watcher { |
+ public: |
+ enum { MAX_FINGERS = 11 }; |
+ TouchEventFromEvdevConverter(int fd, int id); |
+ virtual ~TouchEventFromEvdevConverter(); |
+ |
+ private: |
+ friend class MockTouchEventFromEvdevConverter; |
+ |
+ // Unsafe part of initialization. |
+ void Init(); |
+ |
+ // Overidden from base::MessagePumpLibevent::Watcher. |
+ void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; |
+ void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; |
+ |
+ // Dispatch a touch event. |
+ virtual void DispatchEvent(TouchEvent* tev); |
+ |
+ // Pressure values. |
+ int pressure_min_; |
+ int pressure_max_; // Used to normalize pressure values. |
+ |
+ // Touch scaling. |
+ float x_scale_; |
+ float y_scale_; |
+ |
+ // Touch point currently being updated from the /dev/input/event* stream. |
+ int current_slot_; |
+ |
+ // File descriptor for the /dev/input/event* instance. |
+ int fd_; |
+ |
+ // Number corresponding to * in the source evdev device: /dev/input/event* |
+ int id_; |
+ |
+ // Bit field tracking which in-progress touch points have been modified |
+ // without a syn event. |
+ std::bitset<MAX_FINGERS> altered_slots_; |
+ |
+ struct InProgressEvents { |
+ int x_; |
+ int y_; |
+ int id_; // Device reported "unique" touch point id; -1 means not active |
+ int finger_; // "Finger" id starting from 0; -1 means not active |
+ |
+ EventType type_; |
+ int major_; |
+ float pressure_; |
+ }; |
+ |
+ // In-progress touch points. |
+ InProgressEvents events_[MAX_FINGERS]; |
+}; |
+ |
+} // namespace ui |
+ |
+#endif // UI_BASE_LINUX_EVDEV_DELEGATE_TOUCH_H_ |