OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/client/plugin/pepper_input_handler.h" | 5 #include "remoting/client/plugin/pepper_input_handler.h" |
6 | 6 |
7 #include "ppapi/c/pp_input_event.h" | 7 #include "ppapi/c/pp_input_event.h" |
8 #include "remoting/client/chromoting_view.h" | 8 #include "remoting/client/chromoting_view.h" |
9 #include "ui/gfx/point.h" | 9 #include "ui/gfx/point.h" |
10 | 10 |
11 namespace remoting { | 11 namespace remoting { |
12 | 12 |
13 using protocol::KeyEvent; | 13 using protocol::KeyEvent; |
14 using protocol::MouseEvent; | 14 using protocol::MouseEvent; |
15 | 15 |
16 PepperInputHandler::PepperInputHandler(ClientContext* context, | 16 PepperInputHandler::PepperInputHandler(ClientContext* context, |
17 protocol::ConnectionToHost* connection, | 17 protocol::ConnectionToHost* connection, |
18 ChromotingView* view) | 18 ChromotingView* view) |
19 : InputHandler(context, connection, view) { | 19 : InputHandler(context, connection, view) { |
20 } | 20 } |
21 | 21 |
22 PepperInputHandler::~PepperInputHandler() { | 22 PepperInputHandler::~PepperInputHandler() { |
23 } | 23 } |
24 | 24 |
25 void PepperInputHandler::Initialize() { | 25 void PepperInputHandler::Initialize() { |
26 } | 26 } |
27 | 27 |
28 void PepperInputHandler::HandleKeyEvent(bool keydown, | 28 void PepperInputHandler::HandleKeyEvent(bool keydown, |
29 const PP_InputEvent_Key& event) { | 29 const PP_InputEvent_Key& event) { |
| 30 if (keydown) { |
| 31 pressed_keys_.insert(event.key_code); |
| 32 } else { |
| 33 pressed_keys_.erase(event.key_code); |
| 34 } |
30 SendKeyEvent(keydown, event.key_code); | 35 SendKeyEvent(keydown, event.key_code); |
31 } | 36 } |
32 | 37 |
33 void PepperInputHandler::HandleCharacterEvent( | 38 void PepperInputHandler::HandleCharacterEvent( |
34 const PP_InputEvent_Character& event) { | 39 const PP_InputEvent_Character& event) { |
35 // TODO(garykac): Coordinate key and char events. | 40 // TODO(garykac): Coordinate key and char events. |
36 } | 41 } |
37 | 42 |
38 void PepperInputHandler::HandleMouseMoveEvent( | 43 void PepperInputHandler::HandleMouseMoveEvent( |
39 const PP_InputEvent_Mouse& event) { | 44 const PP_InputEvent_Mouse& event) { |
(...skipping 14 matching lines...) Expand all Loading... |
54 button = MouseEvent::BUTTON_MIDDLE; | 59 button = MouseEvent::BUTTON_MIDDLE; |
55 } else if (event.button == PP_INPUTEVENT_MOUSEBUTTON_RIGHT) { | 60 } else if (event.button == PP_INPUTEVENT_MOUSEBUTTON_RIGHT) { |
56 button = MouseEvent::BUTTON_RIGHT; | 61 button = MouseEvent::BUTTON_RIGHT; |
57 } | 62 } |
58 | 63 |
59 if (button != MouseEvent::BUTTON_UNDEFINED) { | 64 if (button != MouseEvent::BUTTON_UNDEFINED) { |
60 SendMouseButtonEvent(button_down, button); | 65 SendMouseButtonEvent(button_down, button); |
61 } | 66 } |
62 } | 67 } |
63 | 68 |
| 69 void PepperInputHandler::ReleaseAllKeys() { |
| 70 std::set<int>::iterator i; |
| 71 for (i = pressed_keys_.begin(); i != pressed_keys_.end(); ++i) { |
| 72 SendKeyEvent(false, *i); |
| 73 } |
| 74 pressed_keys_.clear(); |
| 75 } |
| 76 |
64 } // namespace remoting | 77 } // namespace remoting |
OLD | NEW |