OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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_BASE_LINUX_EVDEV_DELEGATE_TOUCH_H_ |
| 6 #define UI_BASE_LINUX_EVDEV_DELEGATE_TOUCH_H_ |
| 7 |
| 8 #include <bitset> |
| 9 |
| 10 #include "base/message_pump_libevent.h" |
| 11 #include "ui/base/events/event_constants.h" |
| 12 #include "ui/base/events/event.h" |
| 13 #include "ui/base/ui_export.h" |
| 14 |
| 15 namespace ui { |
| 16 |
| 17 class TouchEvent; |
| 18 |
| 19 class UI_EXPORT TouchEventFromEvdevConverter |
| 20 : public base::MessagePumpLibevent::Watcher { |
| 21 public: |
| 22 enum { MAX_FINGERS = 11 }; |
| 23 TouchEventFromEvdevConverter(int fd, int id); |
| 24 virtual ~TouchEventFromEvdevConverter(); |
| 25 |
| 26 private: |
| 27 friend class MockTouchEventFromEvdevConverter; |
| 28 |
| 29 // Unsafe part of initialization. |
| 30 void Init(); |
| 31 |
| 32 // Overidden from base::MessagePumpLibevent::Watcher. |
| 33 void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; |
| 34 void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; |
| 35 |
| 36 // Dispatch a touch event. |
| 37 virtual void DispatchEvent(TouchEvent* tev); |
| 38 |
| 39 // Pressure values. |
| 40 int pressure_min_; |
| 41 int pressure_max_; // Used to normalize pressure values. |
| 42 |
| 43 // Touch scaling. |
| 44 float x_scale_; |
| 45 float y_scale_; |
| 46 |
| 47 // Touch point currently being updated from the /dev/input/event* stream. |
| 48 int current_slot_; |
| 49 |
| 50 // File descriptor for the /dev/input/event* instance. |
| 51 int fd_; |
| 52 |
| 53 // Number corresponding to * in the source evdev device: /dev/input/event* |
| 54 int id_; |
| 55 |
| 56 // Bit field tracking which in-progress touch points have been modified |
| 57 // without a syn event. |
| 58 std::bitset<MAX_FINGERS> altered_slots_; |
| 59 |
| 60 struct InProgressEvents { |
| 61 int x_; |
| 62 int y_; |
| 63 int id_; // Device reported "unique" touch point id; -1 means not active |
| 64 int finger_; // "Finger" id starting from 0; -1 means not active |
| 65 |
| 66 EventType type_; |
| 67 int major_; |
| 68 float pressure_; |
| 69 }; |
| 70 |
| 71 // In-progress touch points. |
| 72 InProgressEvents events_[MAX_FINGERS]; |
| 73 }; |
| 74 |
| 75 } // namespace ui |
| 76 |
| 77 #endif // UI_BASE_LINUX_EVDEV_DELEGATE_TOUCH_H_ |
OLD | NEW |