//鼠标右键模拟(双指点击)
// mbinding.rTv.setOnTouchListener(new View.OnTouchListener() {
// @RequiresApi(api = Build.VERSION_CODES.KITKAT)
// @Override
// public boolean onTouch(View view, MotionEvent motionEvent) {
// int action = motionEvent.getAction();
// switch (action){
// case MotionEvent.ACTION_DOWN:
final MotionEvent downEvent = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, mbinding.ccgamev.getCx(), mbinding.ccgamev.getCy(), 0);
// view.setBackgroundResource(R.drawable.mousebtb);
// MotionEvent.PointerProperties pp1 = new MotionEvent.PointerProperties();
// pp1.id = 0;
// pp1.toolType = MotionEvent.TOOL_TYPE_FINGER;
//
// MotionEvent.PointerProperties pp2 = new MotionEvent.PointerProperties();
// pp2.id = 1;
// pp2.toolType = MotionEvent.TOOL_TYPE_FINGER;
//
//
// MotionEvent.PointerCoords pc1 = new MotionEvent.PointerCoords();
// pc1.x = mbinding.ccgamev.getCx();
// pc1.y = mbinding.ccgamev.getCy();
//
//
// pc1.pressure = 1;
// pc1.size = 1;
// MotionEvent.PointerCoords pc2 = new MotionEvent.PointerCoords();
// pc2.x = mbinding.ccgamev.getCx()-120;
// pc2.y = mbinding.ccgamev.getCy()-120;
//
// pc2.pressure = 1;
// pc2.size = 1;
//
// pointerCoords[0] = pc1;
// pointerCoords[1] = pc2;
// properties[0] = pp1;
// properties[1] = pp2;
// MotionEvent downEvent = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(),
// MotionEvent.ACTION_DOWN, 1, properties, pointerCoords,
// 0, 0, 1, 1, 4, 0, 0x1002, 0);
// MotionEvent downEvent2 = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(),
// MotionEvent.ACTION_POINTER_2_DOWN, 2, properties, pointerCoords,
// 0, 0, 1, 1, 4, 0, 0x1002, 0);
//
// getWebPlayerActivity().getmPlayer().onTouchEvent(downEvent);
// getWebPlayerActivity().getmPlayer().onTouchEvent(downEvent2);
// downEvent.recycle();
// downEvent2.recycle();
// properties[0]=null;
// properties[1]=null;
// pointerCoords[0]=null;
// pointerCoords[1]=null;
// break;
//
//
//
//
//
// case MotionEvent.ACTION_UP:
final MotionEvent upEvent = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis()+1000, MotionEvent.ACTION_UP, mbinding.ccgamev.getCx()+200, mbinding.ccgamev.getCy(), 0);
// view.setBackgroundResource(R.drawable.mousebt);
// MotionEvent.PointerProperties pp3 = new MotionEvent.PointerProperties();
// pp3.id = 0;
// pp3.toolType = MotionEvent.TOOL_TYPE_FINGER;
//
// MotionEvent.PointerProperties pp4 = new MotionEvent.PointerProperties();
// pp4.id = 1;
// pp4.toolType = MotionEvent.TOOL_TYPE_FINGER;
//
// MotionEvent.PointerCoords pc3 = new MotionEvent.PointerCoords();
// pc3.x = mbinding.ccgamev.getCx();
// pc3.y = mbinding.ccgamev.getCy();
//
// pc3.pressure = 1;
// pc3.size = 1;
//
// MotionEvent.PointerCoords pc4 = new MotionEvent.PointerCoords();
// pc4.x = mbinding.ccgamev.getCx()-120;
// pc4.y = mbinding.ccgamev.getCy()-120;
// pc4.pressure = 1;
// pc4.size = 1;
//
// properties[0] = pp3;
// properties[1] = pp4;
// pointerCoords[0] = pc3;
// pointerCoords[1] = pc4;
//
//
//
//
//
//
//
// MotionEvent upEvent2 = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis()+10,
// MotionEvent.ACTION_POINTER_UP, 2, properties, pointerCoords,
// 0, 0, 1, 1, 4, 0, 0x1002, 0);
// getWebPlayerActivity().getmPlayer().onTouchEvent(upEvent2);
//
// properties[0] = pp4;
// pointerCoords[0] = pc4;
// MotionEvent upEvent = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis()+20,
// MotionEvent.ACTION_UP, 1, properties, pointerCoords,
// 0, 0, 1, 1, 4, 0, 0x1002, 0);
// getWebPlayerActivity().getmPlayer().onTouchEvent(upEvent);
// upEvent.recycle();
// upEvent2.recycle();
// properties[0]=null;
// properties[1]=null;
// pointerCoords[0]=null;
// pointerCoords[1]=null;
// break;
//
// }
// return true;
// }
// });
Android双指点击事件模拟
最新推荐文章于 2024-02-01 15:48:48 发布