Example #1
0
        internal static Pointer GetPointer(this MotionEvent ev, int pointerIndex)
        {
            var properties = new MotionEvent.PointerProperties();

            ev.GetPointerProperties(pointerIndex, properties);

            return(new Pointer(properties));
        }
        // E/JniUtils(11823): couldn't get gazeEventFromNative, (FFZZLandroid/app/Activity;)V
        private static void gazeEventFromNative(float x, float y, bool press, bool release, Activity target)
        {
            Log.d(TAG, "gazeEventFromNative( " + x + " " + y + " " + press + " " + release + " " + target);

            (new Handler(Looper.getMainLooper())).post(

                new xRunnable()
            {
                yield = delegate
                {
                    long now = SystemClock.uptimeMillis();
                    if (press)
                    {
                        downTime = now;
                    }

                    MotionEvent.PointerProperties pp = new MotionEvent.PointerProperties();
                    pp.toolType = MotionEvent.TOOL_TYPE_FINGER;
                    pp.id       = 0;
                    MotionEvent.PointerProperties[] ppa = new MotionEvent.PointerProperties[1];
                    ppa[0] = pp;

                    MotionEvent.PointerCoords pc = new MotionEvent.PointerCoords();
                    pc.x = x;
                    pc.y = y;
                    MotionEvent.PointerCoords[] pca = new MotionEvent.PointerCoords[1];
                    pca[0] = pc;

                    int eventType = MotionEvent.ACTION_MOVE;
                    if (press)
                    {
                        eventType = MotionEvent.ACTION_DOWN;
                    }
                    else if (release)
                    {
                        eventType = MotionEvent.ACTION_UP;
                    }

                    MotionEvent ev = MotionEvent.obtain(
                        downTime, now,
                        eventType,
                        1, ppa, pca,
                        0,          /* meta state */
                        0,          /* button state */
                        1.0f, 1.0f, /* precision */
                        10,         /* device ID */
                        0,          /* edgeFlags */
                        InputDevice.SOURCE_TOUCHSCREEN,
                        0 /* flags */);

                    Log.d(TAG, "Synthetic:" + ev);
                    Window w = target.getWindow();
                    View v   = w.getDecorView();
                    v.dispatchTouchEvent(ev);
                }
            });
        }