Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1378)

Unified Diff: ppapi/examples/input/pointer_event_input.cc

Issue 10873074: ppapi: Make sure the touch-event interface is detected correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/examples/input/pointer_event_input.cc
diff --git a/ppapi/examples/2d/paint_manager_example.cc b/ppapi/examples/input/pointer_event_input.cc
similarity index 87%
copy from ppapi/examples/2d/paint_manager_example.cc
copy to ppapi/examples/input/pointer_event_input.cc
index 86bdbe79ed8f9f2a8e820cd682f24c57cbb413d7..57c3d313046825ba3c92e8a4bf648d88da516502 100644
--- a/ppapi/examples/2d/paint_manager_example.cc
+++ b/ppapi/examples/input/pointer_event_input.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -43,7 +43,7 @@ class MyInstance : public pp::Instance, public pp::PaintManager::Client {
last_x_(0),
last_y_(0) {
paint_manager_.Initialize(this, this, false);
- RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
+ RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE | PP_INPUTEVENT_CLASS_TOUCH);
}
virtual bool HandleInputEvent(const pp::InputEvent& event) {
@@ -66,6 +66,24 @@ class MyInstance : public pp::Instance, public pp::PaintManager::Client {
}
return true;
}
+
+ case PP_INPUTEVENT_TYPE_TOUCHSTART: {
+ pp::TouchInputEvent touch(event);
+ // Update the square on a touch down.
+ uint32_t count = touch.GetTouchCount(PP_TOUCHLIST_TYPE_CHANGEDTOUCHES);
+ for (uint32_t i = 0; i < count; ++i) {
+ pp::TouchPoint point = touch.GetTouchByIndex(
+ PP_TOUCHLIST_TYPE_CHANGEDTOUCHES, i);
+ UpdateSquare(static_cast<int>(point.position().x()),
+ static_cast<int>(point.position().y()));
+ }
+ return true;
+ }
+ case PP_INPUTEVENT_TYPE_TOUCHMOVE:
+ case PP_INPUTEVENT_TYPE_TOUCHEND:
+ case PP_INPUTEVENT_TYPE_TOUCHCANCEL:
+ return true;
+
default:
return false;
}

Powered by Google App Engine
This is Rietveld 408576698