IMS:MotionEvent 坐标点(上)

android12-security-release
主要查看获取hal底层原始坐标,并通过InputChannel发送流程,其中只关注坐标点


Android屏幕x、y轴

屏幕的左上角作为坐标原点,X轴向右为正,Y轴向下为正。

开发者选项中指针位置、ViewRootImpl坐标

打开IMS:开发者选项中指针位置开关,比较直观查看:


X:640.9 Y:1250.9这个就是坐标点(640.9,1250.9),这里(ps.mCoords.x,ps.mCoords.y)通过PointerEventDispatcher/InputChannel传递上来的MotionEvent

ViewRootImpl是通过WindowInputEventReceiver\InputChannel传递上来的MotionEvent,实质都是InputEventReceiver\InputChannel

InputEventReceiver传递MotionEvent

IMS:InputChannel通过socket发送Input给App

frameworks/base/core/java/android/view/InputEventReceiver.java

frameworks/base/core/jni/android_view_InputEventReceiver.cpp

绕不开的JNI

frameworks/base/core/java/android/view/MotionEvent.java
frameworks/base/core/jni/android_view_MotionEvent.cpp
frameworks/native/include/input/Input.h
对象PointerCoords中:

InputDispatcher分发时坐标点

IMS:InputDispatcher线程分发事件
frameworks/native/libs/input/InputTransport.cpp
frameworks/native/services/inputflinger/dispatcher/InputDispatcher.cpp

(motionEntry.xCursorPosition,motionEntry.yCursorPosition)
InputDispatcher.cpp中对象传递:(建议倒着查看流程

mInboundQueue.push_back(std::move(newEntry));【enqueueInboundEventLocked(std::move(newEntry));】
mPendingEvent = mInboundQueue.front();
std::shared_ptr<MotionEntry> motionEntry = std::static_pointer_cast<MotionEntry>(mPendingEvent);
connection->outboundQueue.push_back(dispatchEntry.release());【enqueueDispatchEntryLocked(…)】
DispatchEntry* dispatchEntry = connection->outboundQueue.front();
EventEntry& eventEntry = *(dispatchEntry->eventEntry);
MotionEntry& motionEntry = static_cast<const MotionEntry&>(eventEntry);

InputReader获取处理MotionEvent

IMS:InputReader线程获取输入事件

frameworks/native/services/inputflinger/InputListener.cpp
frameworks/native/services/inputflinger/reader/InputReader.cpp
frameworks/native/services/inputflinger/reader/InputDevice.cpp
size_t count = mEventHub->getEvents(timeoutMillis, mEventBuffer, EVENT_BUFFER_SIZE);
processEventsLocked(mEventBuffer, count);
processEventsForDeviceLocked(deviceId, rawEvent, batchSize);
device->process(rawEvents, count);
mapper.process(rawEvent);

// --- NotifyMotionArgs ---NotifyMotionArgs::NotifyMotionArgs(int32_t id, nsecs_t eventTime, nsecs_t readTime, int32_t deviceId, uint32_t source,int32_t displayId, uint32_t policyFlags, int32_t action, int32_t actionButton,int32_t flags, int32_t metaState, int32_t buttonState, MotionClassification classification,int32_t edgeFlags, uint32_t pointerCount, const PointerProperties* pointerProperties,const PointerCoords* pointerCoords, float xPrecision, float yPrecision,float xCursorPosition, float yCursorPosition, nsecs_t downTime,const std::vector<TouchVideoFrame>& videoFrames): NotifyArgs(id, eventTime),deviceId(deviceId),source(source),displayId(displayId),policyFlags(policyFlags),action(action),actionButton(actionButton),flags(flags),metaState(metaState),buttonState(buttonState),classification(classification),edgeFlags(edgeFlags),pointerCount(pointerCount),xPrecision(xPrecision),yPrecision(yPrecision),xCursorPosition(xCursorPosition),yCursorPosition(yCursorPosition),downTime(downTime),readTime(readTime),videoFrames(videoFrames) {for (uint32_t i = 0; i < pointerCount; i++) {this->pointerProperties[i].copyFrom(pointerProperties[i]);this->pointerCoords[i].copyFrom(pointerCoords[i]);}
}
//... ...
void NotifyMotionArgs::notify(const sp<InputListenerInterface>& listener) const {listener->notifyMotion(this);
}

SingleTouchInputMapper\MultiTouchInputMapper处理

  1. EventHub连接硬件设备\外部设备时,匹配添加相应InputMapper
  2. ......TouchInputMapper::process处理–processRawTouchescookAndDispatchdispatch...dispatchMotion
  3. NotifyMotionArgs 初始化参数xPrecision, yPrecisionmOrientedXPrecision, mOrientedYPrecision
void TouchInputMapper::dispatchMotion(nsecs_t when, nsecs_t readTime, uint32_t policyFlags,uint32_t source, int32_t action, int32_t actionButton,int32_t flags, int32_t metaState, int32_t buttonState,int32_t edgeFlags, const PointerProperties* properties,const PointerCoords* coords, const uint32_t* idToIndex,BitSet32 idBits, int32_t changedId, float xPrecision,float yPrecision, nsecs_t downTime) {// ... ...NotifyMotionArgs args(getContext()->getNextId(), when, readTime, deviceId, source, displayId,policyFlags, action, actionButton, flags, metaState, buttonState,MotionClassification::NONE, edgeFlags, pointerCount, pointerProperties,pointerCoords, xPrecision, yPrecision, xCursorPosition, yCursorPosition,downTime, std::move(frames));getListener()->notifyMotion(&args);
}

  1. RawPointerAxes

EventHub获取屏幕硬件上报

IMS:EventHub设备底层上报Input事件对象处理

IMS:MotionEvent 坐标点(上)相关推荐

  1. 可视化 —— 二维平面上的散列点在坐标轴方向上的移动

    二维平面可以通过平面直角坐标系表示: 二维平面上不同的散列点,也就是平面直角坐标系上的不同的点, 其在坐标轴方向上的移动,分别在以下两个方向上的移动: 在 xx 轴方向上,(x1,y1)(x_1, y ...

  2. android motionevent 坐标,Android开发中MotionEvent坐标获取方法分析

    本文实例讲述了Android开发中MotionEvent坐标获取方法.分享给大家供大家参考,具体如下: Android MotionEvent中getX()与getRawX()都是获取屏幕坐标(横), ...

  3. android motionevent 坐标,Android MotionEvent详解

    在前边几篇博文中(<图解Android事件传递之ViewGroup篇>,<图解Android事件传递之View篇>),我们已经了解了android触摸事件传递机制,接着我们再来 ...

  4. android motionevent 坐标,Android坐标系、视图坐标系与触控事件(MotionEvent)

    前言:本篇文章讲解Android坐标系.视图坐标系与触控事件(MotionEvent) 一. Android 的坐标系:#### 在Android中,将屏幕左上角的定点座位Android坐标系的原点, ...

  5. android motionevent 坐标,Android MotionEvent中getX()和getRawX()的区别

    RawX,RawY 相对于屏幕位置坐标X,Y 相对于容器的位置坐标 测试代码:public class Res extends Activity implements View.OnTouchList ...

  6. Matlab在坐标点上按顺序标序号

    程序一: clear x=[1 3 7 10]; y=[2 4 9 43]; plot(x,y,'r-') hold on for i=1:4%用这个循环c=num2str(i);c=[' ',c]; ...

  7. stm32开发3D打印机(六)——使用FATFS文件系统读取打印文件 获取信息 执行转换 转换坐标(上)

    这篇文章为读取打印文件(后缀为gcode的文件),并添加USMART功能调试 因为TFATFS移植与USMATRT没有什么好写的,而且在下方的链接:正点原子教程已经有详细的教程了,所以跳过了TATFS ...

  8. Java黑皮书课后题第3章:*3.34(几何:线段上的点)编程练习题3.32显示了如何测试一个点是否在一个无限长的直线上。修改3.32测试一个点是否在一个线段上。编写程序,输入三个点坐标,显示在否线段

    *3.34(几何:线段上的点)编程练习题3.32显示了如何测试一个点是否在一个无限长的直线上.修改3.32测试一个点是否在一个线段上.编写程序,输入三个点p0 p1 p2坐标,显示p2在否线段p0p1 ...

  9. 学习笔记——【python】GetGeoTransform()使用,gdal截取图像,使用GDAL进行影像投影坐标、地理坐标、图上坐标的转换

    1. GetGeoTransform()使用.gdal截取图像 GetGeoTransform() GeoTransform[0],左上角横坐标(应该是投影坐标) GeoTransform[2],行旋 ...

最新文章

  1. 1102面向对象和类原型
  2. 全文搜索引擎选 ElasticSearch 还是 Solr?
  3. svn学习笔记(一)
  4. Socket通信---网络通信学习笔记(一)
  5. Swipper.js实现轮播功能
  6. RDB 和 AOF 持久化的原理是什么?我应该用哪一个?它们的优缺点? 1
  7. 博文视点 疯狂ios讲义之选择器(UIPickerView)
  8. 20200106每日一句
  9. JavaScript高级程序设计 中文PDF下载
  10. echarts 半圆形进度条
  11. 【图像篡改 ECCV2018】Fighting Fake News: Image Splice Detection via Learned Self-Consistency
  12. ps导出gif时是html,ps导出gif图步骤图解
  13. python Graphillion简介
  14. ORA-10458、ORA-01152、ORA-01110 Update20201121
  15. 视角的本质能给我们带来什么?
  16. 计算机速成课 第三集 布尔逻辑和逻辑门
  17. model java_编程中的 Model 到底是什么?
  18. Windows 安装与配置IIS
  19. mysql+过滤纯标点符号,用正则表达式去除标点符号
  20. 冒泡排序Matlab程序超详细注释

热门文章

  1. 【串口按帧接收数据】
  2. Vue使用elementUI实现一个后台管理
  3. Python实例003:海龟绘图——小猪佩奇祝大家“2019新春快乐”
  4. fiddler连接IOS、Android、winphone,以及常见失败解决方法
  5. 吴恩达深度学习学习笔记——C4W1——卷积神经网络——作业2——卷积神经网络应用示例
  6. 《数据库系统概论》学习笔记
  7. 攻击POST 什么意思_使用Web日志还原攻击路径
  8. 第二十七篇 网页数据解析三种方法: 正则表达--BeautifulSoup--xpath 满满的干货
  9. vue调起微信扫一扫
  10. [喵咪开源软件推荐(6)]TCP链路加速技术KcpTun