| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "services/ui/public/cpp/input_devices/input_device_client.h" | 5 #include "services/ui/public/cpp/input_devices/input_device_client.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace ui { | 9 namespace ui { |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 const std::vector<ui::InputDevice>& InputDeviceClient::GetMouseDevices() const { | 33 const std::vector<ui::InputDevice>& InputDeviceClient::GetMouseDevices() const { |
| 34 return mouse_devices_; | 34 return mouse_devices_; |
| 35 } | 35 } |
| 36 | 36 |
| 37 const std::vector<ui::InputDevice>& InputDeviceClient::GetTouchpadDevices() | 37 const std::vector<ui::InputDevice>& InputDeviceClient::GetTouchpadDevices() |
| 38 const { | 38 const { |
| 39 return touchpad_devices_; | 39 return touchpad_devices_; |
| 40 } | 40 } |
| 41 | 41 |
| 42 const std::vector<ui::InputDevice>& InputDeviceClient::GetGamepadDevices() |
| 43 const { |
| 44 return gamepad_devices_; |
| 45 } |
| 46 |
| 42 bool InputDeviceClient::AreDeviceListsComplete() const { | 47 bool InputDeviceClient::AreDeviceListsComplete() const { |
| 43 return device_lists_complete_; | 48 return device_lists_complete_; |
| 44 } | 49 } |
| 45 | 50 |
| 46 bool InputDeviceClient::AreTouchscreensEnabled() const { | 51 bool InputDeviceClient::AreTouchscreensEnabled() const { |
| 47 // TODO(kylechar): This obviously isn't right. We either need to pass this | 52 // TODO(kylechar): This obviously isn't right. We either need to pass this |
| 48 // state around or modify the interface. | 53 // state around or modify the interface. |
| 49 return true; | 54 return true; |
| 50 } | 55 } |
| 51 | 56 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 observer.OnMouseDeviceConfigurationChanged(); | 93 observer.OnMouseDeviceConfigurationChanged(); |
| 89 } | 94 } |
| 90 | 95 |
| 91 void InputDeviceClient::OnTouchpadDeviceConfigurationChanged( | 96 void InputDeviceClient::OnTouchpadDeviceConfigurationChanged( |
| 92 const std::vector<ui::InputDevice>& devices) { | 97 const std::vector<ui::InputDevice>& devices) { |
| 93 touchpad_devices_ = devices; | 98 touchpad_devices_ = devices; |
| 94 for (auto& observer : observers_) | 99 for (auto& observer : observers_) |
| 95 observer.OnTouchpadDeviceConfigurationChanged(); | 100 observer.OnTouchpadDeviceConfigurationChanged(); |
| 96 } | 101 } |
| 97 | 102 |
| 103 void InputDeviceClient::OnGamepadDeviceConfigurationChanged( |
| 104 const std::vector<ui::InputDevice>& devices) { |
| 105 gamepad_devices_ = devices; |
| 106 for (auto& observer : observers_) |
| 107 observer.OnGamepadDeviceConfigurationChanged(); |
| 108 } |
| 109 |
| 98 void InputDeviceClient::OnDeviceListsComplete( | 110 void InputDeviceClient::OnDeviceListsComplete( |
| 99 const std::vector<ui::InputDevice>& keyboard_devices, | 111 const std::vector<ui::InputDevice>& keyboard_devices, |
| 100 const std::vector<ui::TouchscreenDevice>& touchscreen_devices, | 112 const std::vector<ui::TouchscreenDevice>& touchscreen_devices, |
| 101 const std::vector<ui::InputDevice>& mouse_devices, | 113 const std::vector<ui::InputDevice>& mouse_devices, |
| 102 const std::vector<ui::InputDevice>& touchpad_devices) { | 114 const std::vector<ui::InputDevice>& touchpad_devices, |
| 115 const std::vector<ui::InputDevice>& gamepad_devices) { |
| 103 // Update the cached device lists if the received list isn't empty. | 116 // Update the cached device lists if the received list isn't empty. |
| 104 if (!keyboard_devices.empty()) | 117 if (!keyboard_devices.empty()) |
| 105 OnKeyboardDeviceConfigurationChanged(keyboard_devices); | 118 OnKeyboardDeviceConfigurationChanged(keyboard_devices); |
| 106 if (!touchscreen_devices.empty()) | 119 if (!touchscreen_devices.empty()) |
| 107 OnTouchscreenDeviceConfigurationChanged(touchscreen_devices); | 120 OnTouchscreenDeviceConfigurationChanged(touchscreen_devices); |
| 108 if (!mouse_devices.empty()) | 121 if (!mouse_devices.empty()) |
| 109 OnMouseDeviceConfigurationChanged(mouse_devices); | 122 OnMouseDeviceConfigurationChanged(mouse_devices); |
| 110 if (!touchpad_devices.empty()) | 123 if (!touchpad_devices.empty()) |
| 111 OnTouchpadDeviceConfigurationChanged(touchpad_devices); | 124 OnTouchpadDeviceConfigurationChanged(touchpad_devices); |
| 125 if (!gamepad_devices_.empty()) |
| 126 OnGamepadDeviceConfigurationChanged(gamepad_devices_); |
| 112 | 127 |
| 113 if (!device_lists_complete_) { | 128 if (!device_lists_complete_) { |
| 114 device_lists_complete_ = true; | 129 device_lists_complete_ = true; |
| 115 for (auto& observer : observers_) | 130 for (auto& observer : observers_) |
| 116 observer.OnDeviceListsComplete(); | 131 observer.OnDeviceListsComplete(); |
| 117 } | 132 } |
| 118 } | 133 } |
| 119 | 134 |
| 120 void InputDeviceClient::OnStylusStateChanged(StylusState state) { | 135 void InputDeviceClient::OnStylusStateChanged(StylusState state) { |
| 121 for (auto& observer : observers_) | 136 for (auto& observer : observers_) |
| 122 observer.OnStylusStateChanged(state); | 137 observer.OnStylusStateChanged(state); |
| 123 } | 138 } |
| 124 | 139 |
| 125 } // namespace ui | 140 } // namespace ui |
| OLD | NEW |