| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_EVENTS_DEVICE_DATA_MANAGER_H_ | |
| 6 #define UI_EVENTS_DEVICE_DATA_MANAGER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/macros.h" | |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/observer_list.h" | |
| 15 #include "ui/events/device_hotplug_event_observer.h" | |
| 16 #include "ui/events/events_base_export.h" | |
| 17 #include "ui/events/keyboard_device.h" | |
| 18 #include "ui/events/touchscreen_device.h" | |
| 19 #include "ui/gfx/transform.h" | |
| 20 | |
| 21 namespace ui { | |
| 22 | |
| 23 class InputDeviceEventObserver; | |
| 24 | |
| 25 // Keeps track of device mappings and event transformations. | |
| 26 class EVENTS_BASE_EXPORT DeviceDataManager : public DeviceHotplugEventObserver { | |
| 27 public: | |
| 28 static const int kMaxDeviceNum = 128; | |
| 29 ~DeviceDataManager() override; | |
| 30 | |
| 31 static void CreateInstance(); | |
| 32 static DeviceDataManager* GetInstance(); | |
| 33 static bool HasInstance(); | |
| 34 | |
| 35 void ClearTouchTransformerRecord(); | |
| 36 void UpdateTouchInfoForDisplay(int64_t display_id, | |
| 37 unsigned int touch_device_id, | |
| 38 const gfx::Transform& touch_transformer); | |
| 39 void ApplyTouchTransformer(unsigned int touch_device_id, float* x, float* y); | |
| 40 int64_t GetDisplayForTouchDevice(unsigned int touch_device_id) const; | |
| 41 | |
| 42 void UpdateTouchRadiusScale(unsigned int touch_device_id, double scale); | |
| 43 void ApplyTouchRadiusScale(unsigned int touch_device_id, double* radius); | |
| 44 | |
| 45 const std::vector<TouchscreenDevice>& touchscreen_devices() const { | |
| 46 return touchscreen_devices_; | |
| 47 } | |
| 48 | |
| 49 const std::vector<KeyboardDevice>& keyboard_devices() const { | |
| 50 return keyboard_devices_; | |
| 51 } | |
| 52 | |
| 53 void AddObserver(InputDeviceEventObserver* observer); | |
| 54 void RemoveObserver(InputDeviceEventObserver* observer); | |
| 55 | |
| 56 protected: | |
| 57 DeviceDataManager(); | |
| 58 | |
| 59 static DeviceDataManager* instance(); | |
| 60 | |
| 61 // DeviceHotplugEventObserver: | |
| 62 void OnTouchscreenDevicesUpdated( | |
| 63 const std::vector<TouchscreenDevice>& devices) override; | |
| 64 void OnKeyboardDevicesUpdated( | |
| 65 const std::vector<KeyboardDevice>& devices) override; | |
| 66 | |
| 67 private: | |
| 68 static DeviceDataManager* instance_; | |
| 69 | |
| 70 bool IsTouchDeviceIdValid(unsigned int touch_device_id) const; | |
| 71 | |
| 72 double touch_radius_scale_map_[kMaxDeviceNum]; | |
| 73 | |
| 74 // Table to keep track of which display id is mapped to which touch device. | |
| 75 int64_t touch_device_to_display_map_[kMaxDeviceNum]; | |
| 76 // Index table to find the TouchTransformer for a touch device. | |
| 77 gfx::Transform touch_device_transformer_map_[kMaxDeviceNum]; | |
| 78 | |
| 79 std::vector<TouchscreenDevice> touchscreen_devices_; | |
| 80 std::vector<KeyboardDevice> keyboard_devices_; | |
| 81 | |
| 82 ObserverList<InputDeviceEventObserver> observers_; | |
| 83 | |
| 84 DISALLOW_COPY_AND_ASSIGN(DeviceDataManager); | |
| 85 }; | |
| 86 | |
| 87 } // namespace ui | |
| 88 | |
| 89 #endif // UI_EVENTS_DEVICE_DATA_MANAGER_H_ | |
| OLD | NEW |