 Chromium Code Reviews
 Chromium Code Reviews Issue 137273009:
  evdev: Factor common code out of key & touch converters  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 137273009:
  evdev: Factor common code out of key & touch converters  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| OLD | NEW | 
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "ui/events/event_constants.h" | 12 #include "ui/events/event_constants.h" | 
| 13 #include "ui/events/events_export.h" | 13 #include "ui/events/events_export.h" | 
| 14 #include "ui/events/ozone/evdev/event_converter.h" | |
| 15 #include "ui/events/ozone/evdev/event_modifiers.h" | |
| 14 #include "ui/events/ozone/event_converter_ozone.h" | 16 #include "ui/events/ozone/event_converter_ozone.h" | 
| 15 | 17 | 
| 16 namespace ui { | 18 namespace ui { | 
| 17 | 19 | 
| 18 class TouchEvent; | 20 class TouchEvent; | 
| 19 | 21 | 
| 20 class EVENTS_EXPORT TouchEventConverterEvdev : public EventConverterOzone { | 22 class EVENTS_EXPORT TouchEventConverterEvdev : public EventConverterEvdev { | 
| 21 public: | 23 public: | 
| 22 enum { | 24 enum { | 
| 23 MAX_FINGERS = 11 | 25 MAX_FINGERS = 11 | 
| 24 }; | 26 }; | 
| 25 TouchEventConverterEvdev(int fd, base::FilePath path); | 27 TouchEventConverterEvdev(int fd, | 
| 28 base::FilePath path, | |
| 29 EventModifiersEvdev* modifiers); | |
| 26 virtual ~TouchEventConverterEvdev(); | 30 virtual ~TouchEventConverterEvdev(); | 
| 27 | 31 | 
| 32 protected: | |
| 33 void ProcessEvents(const struct input_event* inputs, int count) OVERRIDE; | |
| 34 | |
| 28 private: | 35 private: | 
| 29 friend class MockTouchEventConverterEvdev; | 36 friend class MockTouchEventConverterEvdev; | 
| 30 | 37 | 
| 31 // Unsafe part of initialization. | 38 // Unsafe part of initialization. | 
| 32 void Init(); | 39 void Init(); | 
| 33 | 40 | 
| 34 // Overidden from base::MessagePumpLibevent::Watcher. | |
| 35 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | |
| 36 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; | |
| 37 | |
| 38 // Pressure values. | 41 // Pressure values. | 
| 39 int pressure_min_; | 42 int pressure_min_; | 
| 40 int pressure_max_; // Used to normalize pressure values. | 43 int pressure_max_; // Used to normalize pressure values. | 
| 41 | 44 | 
| 42 // Touch scaling. | 45 // Touch scaling. | 
| 43 float x_scale_; | 46 float x_scale_; | 
| 44 float y_scale_; | 47 float y_scale_; | 
| 45 | 48 | 
| 46 // Maximum coordinate-values allowed for the events. | 49 // Maximum coordinate-values allowed for the events. | 
| 47 int x_max_; | 50 int x_max_; | 
| 48 int y_max_; | 51 int y_max_; | 
| 49 | 52 | 
| 50 // Touch point currently being updated from the /dev/input/event* stream. | 53 // Touch point currently being updated from the /dev/input/event* stream. | 
| 51 int current_slot_; | 54 int current_slot_; | 
| 52 | 55 | 
| 53 // File descriptor for the /dev/input/event* instance. | 56 // File descriptor for the /dev/input/event* instance. | 
| 54 int fd_; | 57 int fd_; | 
| 
rjkroege
2014/01/24 22:25:36
this can be removed?
 
spang
2014/01/24 22:56:35
Oops. Removed.
 | |
| 55 | 58 | 
| 56 // Path to input device. | 59 // Path to input device. | 
| 57 base::FilePath path_; | 60 base::FilePath path_; | 
| 
rjkroege
2014/01/24 22:25:36
this too?
 
spang
2014/01/24 22:56:35
Done.
 | |
| 58 | 61 | 
| 59 // Bit field tracking which in-progress touch points have been modified | 62 // Bit field tracking which in-progress touch points have been modified | 
| 60 // without a syn event. | 63 // without a syn event. | 
| 61 std::bitset<MAX_FINGERS> altered_slots_; | 64 std::bitset<MAX_FINGERS> altered_slots_; | 
| 62 | 65 | 
| 63 struct InProgressEvents { | 66 struct InProgressEvents { | 
| 64 int x_; | 67 int x_; | 
| 65 int y_; | 68 int y_; | 
| 66 int id_; // Device reported "unique" touch point id; -1 means not active | 69 int id_; // Device reported "unique" touch point id; -1 means not active | 
| 67 int finger_; // "Finger" id starting from 0; -1 means not active | 70 int finger_; // "Finger" id starting from 0; -1 means not active | 
| 68 | 71 | 
| 69 EventType type_; | 72 EventType type_; | 
| 70 int major_; | 73 int major_; | 
| 71 float pressure_; | 74 float pressure_; | 
| 72 }; | 75 }; | 
| 73 | 76 | 
| 74 // In-progress touch points. | 77 // In-progress touch points. | 
| 75 InProgressEvents events_[MAX_FINGERS]; | 78 InProgressEvents events_[MAX_FINGERS]; | 
| 76 | 79 | 
| 77 DISALLOW_COPY_AND_ASSIGN(TouchEventConverterEvdev); | 80 DISALLOW_COPY_AND_ASSIGN(TouchEventConverterEvdev); | 
| 78 }; | 81 }; | 
| 79 | 82 | 
| 80 } // namespace ui | 83 } // namespace ui | 
| 81 | 84 | 
| 82 #endif // UI_EVENTS_OZONE_EVDEV_TOUCH_EVENT_CONVERTER_EVDEV_H_ | 85 #endif // UI_EVENTS_OZONE_EVDEV_TOUCH_EVENT_CONVERTER_EVDEV_H_ | 
| 83 | 86 | 
| OLD | NEW |