开发者

Android touch events are always InputDevice.SOURCE_TOUCHSCREEN?

开发者 https://www.devze.com 2023-04-02 01:06 出处:网络
I have made an event injector for Android based on code from the AndroidScreencast project. I\'m trying to simulate the Xperia Play touchpad on other devices. My code works great when I\'m simulating

I have made an event injector for Android based on code from the AndroidScreencast project. I'm trying to simulate the Xperia Play touchpad on other devices. My code works great when I'm simulating normal touchscreen events, but does something unexpected when I try to actually simulate the touchpad. Here's my code:

MotionEvent.PointerCoords[] coords = { new MotionEvent.PointerCoords() };
coords[0].x = 200;
coords[0].y = 200;
int[] ptrs = { 0 };
MotionEvent event = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), action, 1, ptrs, coords, 0, 1, 1, 0, 0, InputDevice.SOURCE_T开发者_开发知识库OUCHPAD, 0);
windowManager.injectPointerEvent(event, false);

Here's the strange part: the event is sent, but in my little testing app, it shows up as SOURCE_TOUCHSCREEN!

Am I doing something wrong, or is this some Android quirk where it converts non-supported sources?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号