| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/protocol/input_event_tracker.h" | 5 #include "remoting/protocol/input_event_tracker.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "remoting/proto/event.pb.h" | 8 #include "remoting/proto/event.pb.h" |
| 9 | 9 |
| 10 namespace remoting { | 10 namespace remoting { |
| 11 namespace protocol { | 11 namespace protocol { |
| 12 | 12 |
| 13 InputEventTracker::InputEventTracker(InputStub* input_stub) | 13 InputEventTracker::InputEventTracker(InputStub* input_stub) |
| 14 : input_stub_(input_stub), | 14 : input_stub_(input_stub), |
| 15 mouse_pos_(SkIPoint::Make(0, 0)), | |
| 16 mouse_button_state_(0) { | 15 mouse_button_state_(0) { |
| 17 } | 16 } |
| 18 | 17 |
| 19 InputEventTracker::~InputEventTracker() { | 18 InputEventTracker::~InputEventTracker() { |
| 20 } | 19 } |
| 21 | 20 |
| 22 bool InputEventTracker::IsKeyPressed(uint32 usb_keycode) const { | 21 bool InputEventTracker::IsKeyPressed(uint32 usb_keycode) const { |
| 23 return pressed_keys_.find(usb_keycode) != pressed_keys_.end(); | 22 return pressed_keys_.find(usb_keycode) != pressed_keys_.end(); |
| 24 } | 23 } |
| 25 | 24 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } else { | 66 } else { |
| 68 pressed_keys_.erase(event.usb_keycode()); | 67 pressed_keys_.erase(event.usb_keycode()); |
| 69 } | 68 } |
| 70 } | 69 } |
| 71 } | 70 } |
| 72 input_stub_->InjectKeyEvent(event); | 71 input_stub_->InjectKeyEvent(event); |
| 73 } | 72 } |
| 74 | 73 |
| 75 void InputEventTracker::InjectMouseEvent(const MouseEvent& event) { | 74 void InputEventTracker::InjectMouseEvent(const MouseEvent& event) { |
| 76 if (event.has_x() && event.has_y()) { | 75 if (event.has_x() && event.has_y()) { |
| 77 mouse_pos_ = SkIPoint::Make(event.x(), event.y()); | 76 mouse_pos_ = webrtc::DesktopVector(event.x(), event.y()); |
| 78 } | 77 } |
| 79 if (event.has_button() && event.has_button_down()) { | 78 if (event.has_button() && event.has_button_down()) { |
| 80 // Button values are defined in remoting/proto/event.proto. | 79 // Button values are defined in remoting/proto/event.proto. |
| 81 if (event.button() >= 1 && event.button() < MouseEvent::BUTTON_MAX) { | 80 if (event.button() >= 1 && event.button() < MouseEvent::BUTTON_MAX) { |
| 82 uint32 button_change = 1 << (event.button() - 1); | 81 uint32 button_change = 1 << (event.button() - 1); |
| 83 if (event.button_down()) { | 82 if (event.button_down()) { |
| 84 mouse_button_state_ |= button_change; | 83 mouse_button_state_ |= button_change; |
| 85 } else { | 84 } else { |
| 86 mouse_button_state_ &= ~button_change; | 85 mouse_button_state_ &= ~button_change; |
| 87 } | 86 } |
| 88 } | 87 } |
| 89 } | 88 } |
| 90 input_stub_->InjectMouseEvent(event); | 89 input_stub_->InjectMouseEvent(event); |
| 91 } | 90 } |
| 92 | 91 |
| 93 } // namespace protocol | 92 } // namespace protocol |
| 94 } // namespace remoting | 93 } // namespace remoting |
| OLD | NEW |