Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1570154
  • 博文数量: 596
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 173
  • 用 户 组: 普通用户
  • 注册时间: 2016-07-06 15:50
个人简介

在线笔记

文章分类

全部博文(596)

文章存档

2016年(1)

2015年(104)

2014年(228)

2013年(226)

2012年(26)

2011年(11)

分类: Android平台

2015-05-15 11:52:59


  1. //触屏模式
  2. SimulatedTouchpadInputHandler.onScroll {
  3.         RemotePointer p = canvas.getPointer();
  4.         final int action = e2.getActionMasked();
  5.         final int meta = e2.getMetaState();
  6.         
  7.         // TODO: This is a workaround for Android 4.2
  8.         //多手指检测
  9.         boolean twoFingers = false;
  10.         if (e1 != null)
  11.             twoFingers = (e1.getPointerCount() > 1);
  12.         if (e2 != null)
  13.             twoFingers = twoFingers || (e2.getPointerCount() > 1);

  14.         // onScroll called while scaling/swiping gesture is in effect. We ignore the event and pretend it was
  15.         // consumed. This prevents the mouse pointer from flailing around while we are scaling.
  16.         // Also, if one releases one finger slightly earlier than the other when scaling, it causes Android
  17.         // to stick a spiteful onScroll with a MASSIVE delta here.
  18.         // This would cause the mouse pointer to jump to another place suddenly.
  19.         // Hence, we ignore onScroll after scaling until we lift all pointers up.
  20.         // 多手指,滑动模式,缩放模式,缩放模式结束
  21.         if (twoFingers||inSwiping||inScaling||scalingJustFinished)
  22.             return true;

  23.         activity.showZoomer(true);

  24.         // If the gesture has just began, then don't allow a big delta to prevent
  25.         // pointer jumps at the start of scrolling.
  26.         if (!inScrolling) {
  27.             inScrolling = true;
  28.             distanceX = sign(distanceX);
  29.             distanceY = sign(distanceY);
  30.         } else {
  31.             // Make distanceX/Y display density independent.
  32.             distanceX = sensitivity * distanceX / displayDensity;
  33.             distanceY = sensitivity * distanceY / displayDensity;
  34.         }
  35.         
  36.         // Compute the absolute new mouse position on the remote site.
  37.         int newRemoteX = (int) (p.getX() + getDelta(-distanceX));
  38.         int newRemoteY = (int) (p.getY() + getDelta(-distanceY));
  39.         p.processPointerEvent(newRemoteX, newRemoteY, action, meta, false, false, false, false, 0);
  40.         canvas.panToMouse();
  41.         return true;
  42.     }
  43. //SimulatedTouchpadInputHandler.onScale(IBCScaleGestureDetector) line: 1
  44. //ScaleGestureDetector.onTouchEvent(MotionEvent) line: 258
  45. SimulatedTouchpadInputHandler(AbstractGestureInputHandler).onTouchEvent(MotionEvent)
  46. line: 460 {
  47.         //多点触控手势
  48.         scaleGestures.onTouchEvent(e);
  49.     //单点手势
  50.         return gestures.onTouchEvent(e);
  51.     }
  52. //SimulatedTouchpadInputHandler.onTouchEvent(MotionEvent) line: 1
  53. RemoteCanvasActivity.onTouchEvent(MotionEvent) line: 1217 {
  54.     try {
  55.         //activity检测到TouchEvent
  56.      return inputHandler.onTouchEvent(event);
  57.     } catch (NullPointerException e) { }
  58.     return false;
  59.     }

阅读(1000) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~