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