Set mouse position in software

后端 未结 2 798
感动是毒
感动是毒 2021-02-14 09:42

I am using an Android Stick (http://www.geekbuying.com/item/Uhost-2-Dual-Core-TV-Box-Mini-PC-Android-4-0-4-RK3066-Cortex-A9-1-6GHZ-1GB-RAM-4G-ROM-with-Bluetooth-WIFI-Skype-XBMC-

2条回答
  •  星月不相逢
    2021-02-14 10:29

    I additionally require to reset the position of the mouse to the center after every single interaction with the user.

    This is now possible with the pointer capture API in Android 8.0+ (released August 2017). Summary:

    To request pointer capture, call the requestPointerCapture() method on the view.

    Once the request to capture the pointer is successful, Android calls onPointerCaptureChange(true), and starts delivering the mouse events.

    Your focused view can handle the events by performing one of the following tasks:

    1. If you're using a custom view, override onCapturedPointerEvent(MotionEvent).

    2. Otherwise, register an OnCapturedPointerListener.

    The view in your app can release the pointer capture by calling releasePointerCapture().

提交回复
热议问题