http://blog.csdn.net/zuosifengli/article/details/7398661
app
Android 中多點觸摸協議:ssh
參考: http://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txtide
1, 兩種多點觸摸協議:ui
1)A類: 處理無關聯的接觸: 用於直接發送原始數據;this
B類: 處理跟蹤識別類的接觸: 經過事件slot發送相關聯的獨立接觸更新。spa
2, 觸摸協議的使用:.net
A類協議: orm
A類協議在每發送完一個接觸數據包後會調用 input_mt_sync() 聲明 一次數據的結束; input_mt_sync() 會發出一個 SYN_MT_REPORTblog
提示接收器接收數據並準備下一次數據的接收。事件
B類協議:
與A類協議不一樣的是, B類在使用input_mt_slot()的時候會帶有一個slot的參數,在每一個數據包開始時 產生一個ABS_MT_SLOT事件,提示接收器更新數據。
最終A,B類協議均會調用 input_sync();
A類與B類協議不一樣的在於: B類協議 經過B類協議 slot 協議須要是用到ABS_MT_TRACKING_ID------ 能夠從硬件上獲取,或者從原始數據中計算。
3, B類協議: ABS_MT_TRACKING_ID 表示一次接觸; -1 表明一個不用的slot;
使用參考例子:
釋放事件:
input_mt_slot(data->input_dev, i);
input_mt_report_slot_state(data->input_dev, MT_TOOL_FINGER, false); ---------------釋放
點擊事件:
input_mt_slot(data->input_dev, i);
input_mt_report_slot_state(data->input_dev, MT_TOOL_FINGER, true);
input_report_abs(data->input_dev, ABS_MT_TOUCH_MAJOR, 1);
input_report_abs(data->input_dev, ABS_MT_POSITION_X, current_events[i].x);
input_report_abs(data->input_dev, ABS_MT_POSITION_Y, current_events[i].y)
補充: 不一樣事件的標記: 備忘。
ABS_MT_TOUCH_MAJOR
The length of the major axis of the contact. The length should be given insurface units. If the surface has an X times Y resolution, the largestpossible value of ABS_MT_TOUCH_MAJOR is sqrt(X^2 + Y^2), the diagonal [4].
ABS_MT_TOUCH_MINOR
The length, in surface units, of the minor axis of the contact. If thecontact is circular, this event can be omitted [4].
ABS_MT_WIDTH_MAJOR
The length, in surface units, of the major axis of the approachingtool. This should be understood as the size of the tool itself. Theorientation of the contact and the approaching tool are assumed to be thesame [4].
ABS_MT_WIDTH_MINOR
The length, in surface units, of the minor axis of the approachingtool. Omit if circular [4].The above four values can be used to derive additional information aboutthe contact. The ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR approximatesthe notion of pressure. The fingers of the hand and the palm all havedifferent characteristic widths [1].
ABS_MT_PRESSURE
The pressure, in arbitrary units, on the contact area. May be used insteadof TOUCH and WIDTH for pressure-based devices or any device with a spatialsignal intensity distribution.
ABS_MT_DISTANCE
The distance, in surface units, between the contact and the surface. Zerodistance means the contact is touching the surface. A positive number meansthe contact is hovering above the surface.
ABS_MT_ORIENTATION
The orientation of the ellipse. The value should describe a signed quarterof a revolution clockwise around the touch center. The signed value rangeis arbitrary, but zero should be returned for a finger aligned along the Yaxis of the surface, a negative value when finger is turned to the left, anda positive value when finger turned to the right. When completely aligned withthe X axis, the range max should be returned. Orientation can be omittedif the touching object is circular, or if the information is not availablein the kernel driver. Partial orientation support is possible if the devicecan distinguish between the two axis, but not (uniquely) any values inbetween. In such cases, the range of ABS_MT_ORIENTATION should be [0, 1][4].
ABS_MT_POSITION_X
The surface X coordinate of the center of the touching ellipse.ABS_MT_POSITION_YThe surface Y coordinate of the center of the touching ellipse.
ABS_MT_TOOL_TYPE
The type of approaching tool. A lot of kernel drivers cannot distinguishbetween different tool types, such as a finger or a pen. In such cases, theevent should be omitted. The protocol currently supports MT_TOOL_FINGER andMT_TOOL_PEN [2]. For type B devices, this event is handled by input core;drivers should instead use input_mt_report_slot_state().
ABS_MT_BLOB_ID
The BLOB_ID groups several packets together into one arbitrarily shapedcontact. The sequence of points forms a polygon which defines the shape ofthe contact. This is a low-level anonymous grouping for type A devices, andshould not be confused with the high-level trackingID [5]. Most type Adevices do not have blob capability, so drivers can safely omit this event.
ABS_MT_TRACKING_ID
The TRACKING_ID identifies an initiated contact throughout its life cycle[5]. The value range of the TRACKING_ID should be large enough to ensureunique identification of a contact maintained over an extended period oftime. For type B devices, this event is handled by input core; driversshould instead use input_mt_report_slot_state().