| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "remoting/host/touch_injector_win.h" | 5 #include "remoting/host/touch_injector_win.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 pointer_touch_info->pointerInfo.pointerId = touch_point.id(); | 79 pointer_touch_info->pointerInfo.pointerId = touch_point.id(); |
| 80 pointer_touch_info->pointerInfo.ptPixelLocation.x = touch_point.x(); | 80 pointer_touch_info->pointerInfo.ptPixelLocation.x = touch_point.x(); |
| 81 pointer_touch_info->pointerInfo.ptPixelLocation.y = touch_point.y(); | 81 pointer_touch_info->pointerInfo.ptPixelLocation.y = touch_point.y(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 } // namespace | 84 } // namespace |
| 85 | 85 |
| 86 TouchInjectorWinDelegate::~TouchInjectorWinDelegate() {} | 86 TouchInjectorWinDelegate::~TouchInjectorWinDelegate() {} |
| 87 | 87 |
| 88 // static. | 88 // static. |
| 89 scoped_ptr<TouchInjectorWinDelegate> TouchInjectorWinDelegate::Create() { | 89 std::unique_ptr<TouchInjectorWinDelegate> TouchInjectorWinDelegate::Create() { |
| 90 base::ScopedNativeLibrary library(base::FilePath(L"User32.dll")); | 90 base::ScopedNativeLibrary library(base::FilePath(L"User32.dll")); |
| 91 if (!library.is_valid()) { | 91 if (!library.is_valid()) { |
| 92 PLOG(INFO) << "Failed to get library module for touch injection functions."; | 92 PLOG(INFO) << "Failed to get library module for touch injection functions."; |
| 93 return scoped_ptr<TouchInjectorWinDelegate>(); | 93 return std::unique_ptr<TouchInjectorWinDelegate>(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 InitializeTouchInjectionFunction init_func = | 96 InitializeTouchInjectionFunction init_func = |
| 97 reinterpret_cast<InitializeTouchInjectionFunction>( | 97 reinterpret_cast<InitializeTouchInjectionFunction>( |
| 98 library.GetFunctionPointer("InitializeTouchInjection")); | 98 library.GetFunctionPointer("InitializeTouchInjection")); |
| 99 if (!init_func) { | 99 if (!init_func) { |
| 100 PLOG(INFO) << "Failed to get InitializeTouchInjection function handle."; | 100 PLOG(INFO) << "Failed to get InitializeTouchInjection function handle."; |
| 101 return scoped_ptr<TouchInjectorWinDelegate>(); | 101 return std::unique_ptr<TouchInjectorWinDelegate>(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 InjectTouchInputFunction inject_touch_func = | 104 InjectTouchInputFunction inject_touch_func = |
| 105 reinterpret_cast<InjectTouchInputFunction>( | 105 reinterpret_cast<InjectTouchInputFunction>( |
| 106 library.GetFunctionPointer("InjectTouchInput")); | 106 library.GetFunctionPointer("InjectTouchInput")); |
| 107 if (!inject_touch_func) { | 107 if (!inject_touch_func) { |
| 108 PLOG(INFO) << "Failed to get InjectTouchInput."; | 108 PLOG(INFO) << "Failed to get InjectTouchInput."; |
| 109 return scoped_ptr<TouchInjectorWinDelegate>(); | 109 return std::unique_ptr<TouchInjectorWinDelegate>(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 return scoped_ptr<TouchInjectorWinDelegate>( | 112 return std::unique_ptr<TouchInjectorWinDelegate>(new TouchInjectorWinDelegate( |
| 113 new TouchInjectorWinDelegate( | 113 library.Release(), init_func, inject_touch_func)); |
| 114 library.Release(), init_func, inject_touch_func)); | |
| 115 } | 114 } |
| 116 | 115 |
| 117 TouchInjectorWinDelegate::TouchInjectorWinDelegate( | 116 TouchInjectorWinDelegate::TouchInjectorWinDelegate( |
| 118 base::NativeLibrary library, | 117 base::NativeLibrary library, |
| 119 InitializeTouchInjectionFunction initialize_touch_injection_func, | 118 InitializeTouchInjectionFunction initialize_touch_injection_func, |
| 120 InjectTouchInputFunction inject_touch_input_func) | 119 InjectTouchInputFunction inject_touch_input_func) |
| 121 : library_module_(library), | 120 : library_module_(library), |
| 122 initialize_touch_injection_func_(initialize_touch_injection_func), | 121 initialize_touch_injection_func_(initialize_touch_injection_func), |
| 123 inject_touch_input_func_(inject_touch_input_func) {} | 122 inject_touch_input_func_(inject_touch_input_func) {} |
| 124 | 123 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 case TouchEvent::TOUCH_POINT_CANCEL: | 182 case TouchEvent::TOUCH_POINT_CANCEL: |
| 184 CancelTouchPoints(event); | 183 CancelTouchPoints(event); |
| 185 break; | 184 break; |
| 186 default: | 185 default: |
| 187 NOTREACHED(); | 186 NOTREACHED(); |
| 188 return; | 187 return; |
| 189 } | 188 } |
| 190 } | 189 } |
| 191 | 190 |
| 192 void TouchInjectorWin::SetInjectorDelegateForTest( | 191 void TouchInjectorWin::SetInjectorDelegateForTest( |
| 193 scoped_ptr<TouchInjectorWinDelegate> functions) { | 192 std::unique_ptr<TouchInjectorWinDelegate> functions) { |
| 194 delegate_ = std::move(functions); | 193 delegate_ = std::move(functions); |
| 195 } | 194 } |
| 196 | 195 |
| 197 void TouchInjectorWin::AddNewTouchPoints(const TouchEvent& event) { | 196 void TouchInjectorWin::AddNewTouchPoints(const TouchEvent& event) { |
| 198 DCHECK_EQ(event.event_type(), TouchEvent::TOUCH_POINT_START); | 197 DCHECK_EQ(event.event_type(), TouchEvent::TOUCH_POINT_START); |
| 199 | 198 |
| 200 std::vector<POINTER_TOUCH_INFO> touches; | 199 std::vector<POINTER_TOUCH_INFO> touches; |
| 201 // Must inject already touching points as move events. | 200 // Must inject already touching points as move events. |
| 202 AppendMapValuesToVector(&touches_in_contact_, &touches); | 201 AppendMapValuesToVector(&touches_in_contact_, &touches); |
| 203 | 202 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 touches.push_back(pointer_touch_info); | 272 touches.push_back(pointer_touch_info); |
| 274 } | 273 } |
| 275 | 274 |
| 276 AppendMapValuesToVector(&touches_in_contact_, &touches); | 275 AppendMapValuesToVector(&touches_in_contact_, &touches); |
| 277 if (delegate_->InjectTouchInput(touches.size(), touches.data()) == 0) { | 276 if (delegate_->InjectTouchInput(touches.size(), touches.data()) == 0) { |
| 278 PLOG(ERROR) << "Failed to inject a touch cancel event."; | 277 PLOG(ERROR) << "Failed to inject a touch cancel event."; |
| 279 } | 278 } |
| 280 } | 279 } |
| 281 | 280 |
| 282 } // namespace remoting | 281 } // namespace remoting |
| OLD | NEW |