开发学院手机开发Android 开发 Android多点触摸的实现 阅读

Android多点触摸的实现

 2010-09-10 00:51:00 来源:WEB开发网   
核心提示:int classes = getDeviceClasses(deviceId);String name = getDeviceName(deviceId);InputDevice.AbsoluteInfo absX;InputDevice.AbsoluteInfo absY;InputDevice.AbsoluteI

int classes = getDeviceClasses(deviceId);

String name = getDeviceName(deviceId);

InputDevice.AbsoluteInfo absX;

InputDevice.AbsoluteInfo absY;

InputDevice.AbsoluteInfo absPressure;

InputDevice.AbsoluteInfo absSize;

if ((classes&RawInputEvent.CLASS_TOUCHSCREEN_MT) != 0) {

absX = loadAbsoluteInfo(deviceId,

RawInputEvent.ABS_MT_POSITION_X, "X");

absY = loadAbsoluteInfo(deviceId,

RawInputEvent.ABS_MT_POSITION_Y, "Y");

absPressure = loadAbsoluteInfo(deviceId,

RawInputEvent.ABS_MT_TOUCH_MAJOR, "Pressure");

absSize = loadAbsoluteInfo(deviceId,

RawInputEvent.ABS_MT_WIDTH_MAJOR, "Size");

} else if ((classes&RawInputEvent.CLASS_TOUCHSCREEN) != 0) {

absX = loadAbsoluteInfo(deviceId,

RawInputEvent.ABS_X, "X");

absY = loadAbsoluteInfo(deviceId,

RawInputEvent.ABS_Y, "Y");

absPressure = loadAbsoluteInfo(deviceId,

RawInputEvent.ABS_PRESSURE, "Pressure");

absSize = loadAbsoluteInfo(deviceId,

RawInputEvent.ABS_TOOL_WIDTH, "Size");

} else {

absX = null;

absY = null;

absPressure = null;

absSize = null;

}

return new InputDevice(deviceId, classes, name, absX, absY, absPressure, absSize);

}

第四章 触摸事件 数组的处理

上面我们曾说到 generateAbsMotion 这个方法,它们在InputDevice 类的内部类 MotionState 中实现,该类被定义为 InputDevice 类的静态成员类 (static class) ,调用它们可以直接使用:

InputDeviceClass.MotionStateClass.generateAbsMotion()。

public class InputDevice {

……………………………

static class MotionState { //下面是这个内部类的几个函数

……………………………… .

/* mLastNumPointers 为上一个动作在触屏上按键的个数 */

上一页  2 3 4 5 6 7 8 9  下一页

Tags:Android 多点 触摸

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接