301 {
302 final boolean isPointer = event.isFromSource(InputDevice.SOURCE_CLASS_POINTER);
303 if (!isPointer)
304 return false;
305
306 final boolean isMouse = event.isFromSource(InputDevice.SOURCE_MOUSE);
307 int action = event.getActionMasked();
308
309 if (isMouse && (action == MotionEvent.ACTION_BUTTON_PRESS ||
310 action == MotionEvent.ACTION_BUTTON_RELEASE))
311 {
312 boolean down = action == MotionEvent.ACTION_BUTTON_PRESS;
313 MotionEvent mapped = mapTouchEvent(event);
314 int x = (int)mapped.getX();
315 int y = (int)mapped.getY();
316 mapped.recycle();
317
318 switch (event.getActionButton())
319 {
320 case MotionEvent.BUTTON_PRIMARY:
321 if (down)
322 sessionViewListener.onSessionViewBeginTouch();
323 sessionViewListener.onSessionViewLeftTouch(x, y, down);
324 if (!down)
325 sessionViewListener.onSessionViewEndTouch();
326 return true;
327 case MotionEvent.BUTTON_SECONDARY:
328 if (down)
329 sessionViewListener.onSessionViewBeginTouch();
330 sessionViewListener.onSessionViewRightTouch(x, y, down);
331 return true;
332 case MotionEvent.BUTTON_TERTIARY:
333 sessionViewListener.onSessionViewMiddleTouch(x, y, down);
334 return true;
335 default:
336 return true;
337 }
338 }
339
340 if (action == MotionEvent.ACTION_SCROLL)
341 {
342 float vScroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
343 float hScroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
344 if (vScroll != 0)
345 sessionViewListener.onSessionViewScroll(vScroll > 0);
346 if (hScroll != 0)
347 sessionViewListener.onSessionViewHScroll(hScroll > 0);
348 return true;
349 }
350
351 return false;
352 }