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

Unified Diff: ppapi/thunk/ppb_input_event_thunk.cc

Issue 10543159: ppapi: Add support for touch events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 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/thunk/ppb_input_event_thunk.cc
diff --git a/ppapi/thunk/ppb_input_event_thunk.cc b/ppapi/thunk/ppb_input_event_thunk.cc
index 47f9e51f325f3387fc5372f6d523a8b77fccbeaa..b6a76d0f715945a321178779b5c4db455d958280 100644
--- a/ppapi/thunk/ppb_input_event_thunk.cc
+++ b/ppapi/thunk/ppb_input_event_thunk.cc
@@ -379,6 +379,52 @@ const PPB_IMEInputEvent_Dev_0_2 g_ppb_ime_input_event_0_2_thunk = {
&GetIMESelection
};
+// Touch -----------------------------------------------------------------------
+
+PP_Bool IsTouchInputEvent(PP_Resource resource) {
+ if (!IsInputEvent(resource))
+ return PP_FALSE; // Prevent warning log in GetType.
+ PP_InputEvent_Type type = GetType(resource);
+ return PP_FromBool(type == PP_INPUTEVENT_TYPE_TOUCHSTART ||
+ type == PP_INPUTEVENT_TYPE_TOUCHMOVE ||
+ type == PP_INPUTEVENT_TYPE_TOUCHEND ||
+ type == PP_INPUTEVENT_TYPE_TOUCHCANCEL);
+}
+
+uint32_t GetTouchCount(PP_Resource touch_event, PP_TouchListType list) {
+ EnterInputEvent enter(touch_event, true);
+ if (enter.failed())
+ return 0;
+ return enter.object()->GetTouchCount(list);
+}
+
+struct PP_TouchPoint_Dev GetTouchByIndex(PP_Resource touch_event,
+ PP_TouchListType list,
+ uint32_t index) {
+ EnterInputEvent enter(touch_event, true);
+ if (enter.failed()) {
brettw 2012/06/19 21:20:52 No {}. Same on the next fn.
sadrul 2012/06/20 20:19:03 Done.
+ return PP_MakeTouchPoint();
+ }
+ return enter.object()->GetTouchByIndex(list, index);
+}
+
+struct PP_TouchPoint_Dev GetTouchById(PP_Resource touch_event,
+ PP_TouchListType list,
+ uint32_t id) {
+ EnterInputEvent enter(touch_event, true);
+ if (enter.failed()) {
+ return PP_MakeTouchPoint();
+ }
+ return enter.object()->GetTouchById(list, id);
+}
+
+const PPB_TouchInputEvent_Dev g_ppb_touch_input_event_thunk = {
+ &IsTouchInputEvent,
+ &GetTouchCount,
+ &GetTouchByIndex,
+ &GetTouchById
+};
+
} // namespace
const PPB_InputEvent_1_0* GetPPB_InputEvent_1_0_Thunk() {
@@ -414,5 +460,9 @@ const PPB_IMEInputEvent_Dev_0_2* GetPPB_IMEInputEvent_Dev_0_2_Thunk() {
return &g_ppb_ime_input_event_0_2_thunk;
}
+const PPB_TouchInputEvent_Dev* GetPPB_TouchInputEvent_Thunk() {
+ return &g_ppb_touch_input_event_thunk;
+}
+
} // namespace thunk
} // namespace ppapi

Powered by Google App Engine
This is Rietveld 408576698