Index: remoting/client/plugin/pepper_input_handler.cc |
diff --git a/remoting/client/plugin/pepper_input_handler.cc b/remoting/client/plugin/pepper_input_handler.cc |
index 157efe5eaba5253a699addc563c6799a95ae28d4..5ba1b257f1db93c6db8af09ec5b788f62d42b7b1 100644 |
--- a/remoting/client/plugin/pepper_input_handler.cc |
+++ b/remoting/client/plugin/pepper_input_handler.cc |
@@ -10,6 +10,7 @@ |
#include "ppapi/cpp/module_impl.h" |
#include "ppapi/cpp/mouse_cursor.h" |
#include "ppapi/cpp/point.h" |
+#include "ppapi/cpp/touch_point.h" |
#include "ppapi/cpp/var.h" |
#include "remoting/proto/event.pb.h" |
#include "ui/events/keycodes/dom4/keycode_converter.h" |
@@ -32,6 +33,47 @@ uint32_t MakeLockStates(const pp::InputEvent& event) { |
return lock_states; |
} |
+// Creates a protocol::TouchEvent instance from |pp_touch_event|. |
+// Note that only the changed touches are added to the TouchEvent. |
+protocol::TouchEvent MakeTouchEvent(const pp::TouchInputEvent& pp_touch_event) { |
+ protocol::TouchEvent touch_event; |
+ protocol::TouchEvent::TouchEventType type; |
+ switch (pp_touch_event.GetType()) { |
Wez
2015/02/13 16:51:46
nit: Move this switch into a helper function? You'
Rintaro Kuroiwa
2015/02/17 19:52:11
I added a function that sets the event type instea
|
+ case PP_INPUTEVENT_TYPE_TOUCHSTART: |
+ type = protocol::TouchEvent::TOUCH_POINT_START; |
+ break; |
+ case PP_INPUTEVENT_TYPE_TOUCHMOVE: |
+ type = protocol::TouchEvent::TOUCH_POINT_MOVE; |
+ break; |
+ case PP_INPUTEVENT_TYPE_TOUCHEND: |
+ type = protocol::TouchEvent::TOUCH_POINT_END; |
+ break; |
+ case PP_INPUTEVENT_TYPE_TOUCHCANCEL: |
+ type = protocol::TouchEvent::TOUCH_POINT_CANCEL; |
+ break; |
+ default: |
+ NOTREACHED() << "Unknown event type: " << pp_touch_event.GetType(); |
+ return touch_event; |
+ } |
+ touch_event.set_event_type(type); |
+ |
+ for (uint32_t i = 0; |
+ i < pp_touch_event.GetTouchCount(PP_TOUCHLIST_TYPE_CHANGEDTOUCHES); |
+ ++i) { |
+ pp::TouchPoint pp_point = |
+ pp_touch_event.GetTouchByIndex(PP_TOUCHLIST_TYPE_CHANGEDTOUCHES, i); |
+ protocol::TouchEventPoint* point = touch_event.add_touch_points(); |
+ point->set_id(pp_point.id()); |
+ point->set_x(pp_point.position().x()); |
+ point->set_y(pp_point.position().y()); |
+ point->set_radius_x(pp_point.radii().x()); |
+ point->set_radius_y(pp_point.radii().y()); |
+ point->set_angle(pp_point.rotation_angle()); |
+ } |
+ |
+ return touch_event; |
+} |
+ |
// Builds a protocol::KeyEvent from the supplied PPAPI event. |
protocol::KeyEvent MakeKeyEvent(const pp::KeyboardInputEvent& pp_key_event) { |
protocol::KeyEvent key_event; |
@@ -72,6 +114,18 @@ PepperInputHandler::PepperInputHandler() |
bool PepperInputHandler::HandleInputEvent(const pp::InputEvent& event) { |
switch (event.GetType()) { |
+ // Touch input cases. |
+ case PP_INPUTEVENT_TYPE_TOUCHSTART: |
+ case PP_INPUTEVENT_TYPE_TOUCHMOVE: |
+ case PP_INPUTEVENT_TYPE_TOUCHEND: |
+ case PP_INPUTEVENT_TYPE_TOUCHCANCEL: { |
+ if (!input_stub_) |
+ return true; |
+ pp::TouchInputEvent pp_touch_event(event); |
+ input_stub_->InjectTouchEvent(MakeTouchEvent(pp_touch_event)); |
+ return true; |
+ } |
+ |
case PP_INPUTEVENT_TYPE_CONTEXTMENU: { |
// We need to return true here or else we'll get a local (plugin) context |
// menu instead of the mouseup event for the right click. |