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