本文整理汇总了C++中MotionEvent::getPointerCount方法的典型用法代码示例。如果您正苦于以下问题:C++ MotionEvent::getPointerCount方法的具体用法?C++ MotionEvent::getPointerCount怎么用?C++ MotionEvent::getPointerCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MotionEvent
的用法示例。
在下文中一共展示了MotionEvent::getPointerCount方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: android_view_MotionEvent_nativeGetPointerCoords
static void android_view_MotionEvent_nativeGetPointerCoords(JNIEnv* env, jclass clazz,
jlong nativePtr, jint pointerIndex, jint historyPos, jobject outPointerCoordsObj) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
size_t pointerCount = event->getPointerCount();
//ActionsCode(authro:songzhining, comment: fix BUG00232351)
if (pointerIndex >= pointerCount) {
ALOGE("Error pointerIndex! count=%d, index=%d", pointerCount, pointerIndex);
pointerIndex = 0;
}
if (!validatePointerIndex(env, pointerIndex, pointerCount)
|| !validatePointerCoords(env, outPointerCoordsObj)) {
return;
}
const PointerCoords* rawPointerCoords;
if (historyPos == HISTORY_CURRENT) {
rawPointerCoords = event->getRawPointerCoords(pointerIndex);
} else {
size_t historySize = event->getHistorySize();
if (!validateHistoryPos(env, historyPos, historySize)) {
return;
}
rawPointerCoords = event->getHistoricalRawPointerCoords(pointerIndex, historyPos);
}
pointerCoordsFromNative(env, rawPointerCoords, event->getXOffset(), event->getYOffset(),
outPointerCoordsObj);
}
示例2: android_view_MotionEvent_nativeAddBatch
static void android_view_MotionEvent_nativeAddBatch(JNIEnv* env, jclass clazz,
jint nativePtr, jlong eventTimeNanos, jobjectArray pointerCoordsObjArray,
jint metaState) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
size_t pointerCount = event->getPointerCount();
if (!validatePointerCoordsObjArray(env, pointerCoordsObjArray, pointerCount)) {
return;
}
PointerCoords rawPointerCoords[pointerCount];
for (size_t i = 0; i < pointerCount; i++) {
jobject pointerCoordsObj = env->GetObjectArrayElement(pointerCoordsObjArray, i);
if (!pointerCoordsObj) {
jniThrowNullPointerException(env, "pointerCoords");
return;
}
pointerCoordsToNative(env, pointerCoordsObj,
event->getXOffset(), event->getYOffset(), &rawPointerCoords[i]);
env->DeleteLocalRef(pointerCoordsObj);
}
event->addSample(eventTimeNanos, rawPointerCoords);
event->setMetaState(event->getMetaState() | metaState);
}
示例3: android_view_MotionEvent_nativeGetAxisValue
static jfloat android_view_MotionEvent_nativeGetAxisValue(JNIEnv* env, jclass clazz,
jlong nativePtr, jint axis, jint pointerIndex, jint historyPos) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
size_t pointerCount = event->getPointerCount();
//ActionsCode(authro:songzhining, comment: fix BUG00232351)
if (pointerIndex >= pointerCount) {
ALOGE("Error pointerIndex! count=%d, index=%d", pointerCount, pointerIndex);
pointerIndex = 0;
}
if (!validatePointerIndex(env, pointerIndex, pointerCount)) {
return 0;
}
if (historyPos == HISTORY_CURRENT) {
return event->getAxisValue(axis, pointerIndex);
} else {
size_t historySize = event->getHistorySize();
if (!validateHistoryPos(env, historyPos, historySize)) {
return 0;
}
return event->getHistoricalAxisValue(axis, pointerIndex, historyPos);
}
}
示例4: initializeEventWithHistory
TEST_F(MotionEventTest, CopyFrom_DoNotKeepHistory) {
MotionEvent event;
initializeEventWithHistory(&event);
MotionEvent copy;
copy.copyFrom(&event, false /*keepHistory*/);
ASSERT_EQ(event.getPointerCount(), copy.getPointerCount());
ASSERT_EQ(0U, copy.getHistorySize());
ASSERT_EQ(event.getPointerId(0), copy.getPointerId(0));
ASSERT_EQ(event.getPointerId(1), copy.getPointerId(1));
ASSERT_EQ(event.getEventTime(), copy.getEventTime());
ASSERT_EQ(event.getX(0), copy.getX(0));
}
示例5: android_view_MotionEvent_nativeGetToolType
static jint android_view_MotionEvent_nativeGetToolType(JNIEnv* env, jclass clazz,
jint nativePtr, jint pointerIndex) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
size_t pointerCount = event->getPointerCount();
if (!validatePointerIndex(env, pointerIndex, pointerCount)) {
return -1;
}
return event->getToolType(pointerIndex);
}
示例6: android_view_MotionEvent_nativeGetPointerProperties
static void android_view_MotionEvent_nativeGetPointerProperties(JNIEnv* env, jclass clazz,
jint nativePtr, jint pointerIndex, jobject outPointerPropertiesObj) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
size_t pointerCount = event->getPointerCount();
if (!validatePointerIndex(env, pointerIndex, pointerCount)
|| !validatePointerProperties(env, outPointerPropertiesObj)) {
return;
}
const PointerProperties* pointerProperties = event->getPointerProperties(pointerIndex);
pointerPropertiesFromNative(env, pointerProperties, outPointerPropertiesObj);
}
示例7: android_view_MotionEvent_nativeGetToolType
static jint android_view_MotionEvent_nativeGetToolType(JNIEnv* env, jclass clazz,
jlong nativePtr, jint pointerIndex) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
size_t pointerCount = event->getPointerCount();
//ActionsCode(authro:songzhining, comment: fix BUG00232351)
if (pointerIndex >= pointerCount) {
ALOGE("Error pointerIndex! count=%d, index=%d", pointerCount, pointerIndex);
pointerIndex = 0;
}
if (!validatePointerIndex(env, pointerIndex, pointerCount)) {
return -1;
}
return event->getToolType(pointerIndex);
}
示例8: android_view_MotionEvent_nativeGetAxisValue
static jfloat android_view_MotionEvent_nativeGetAxisValue(JNIEnv* env, jclass clazz,
jint nativePtr, jint axis, jint pointerIndex, jint historyPos) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
size_t pointerCount = event->getPointerCount();
if (!validatePointerIndex(env, pointerIndex, pointerCount)) {
return 0;
}
if (historyPos == HISTORY_CURRENT) {
return event->getAxisValue(axis, pointerIndex);
} else {
size_t historySize = event->getHistorySize();
if (!validateHistoryPos(env, historyPos, historySize)) {
return 0;
}
return event->getHistoricalAxisValue(axis, pointerIndex, historyPos);
}
}
示例9: android_view_MotionEvent_nativeGetPointerProperties
static void android_view_MotionEvent_nativeGetPointerProperties(JNIEnv* env, jclass clazz,
jlong nativePtr, jint pointerIndex, jobject outPointerPropertiesObj) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
size_t pointerCount = event->getPointerCount();
//ActionsCode(authro:songzhining, comment: fix BUG00232351)
if (pointerIndex >= pointerCount) {
ALOGE("Error pointerIndex! count=%d, index=%d", pointerCount, pointerIndex);
pointerIndex = 0;
}
if (!validatePointerIndex(env, pointerIndex, pointerCount)
|| !validatePointerProperties(env, outPointerPropertiesObj)) {
return;
}
const PointerProperties* pointerProperties = event->getPointerProperties(pointerIndex);
pointerPropertiesFromNative(env, pointerProperties, outPointerPropertiesObj);
}
示例10: android_view_MotionEvent_nativeGetPointerCoords
static void android_view_MotionEvent_nativeGetPointerCoords(JNIEnv* env, jclass clazz,
jint nativePtr, jint pointerIndex, jint historyPos, jobject outPointerCoordsObj) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
size_t pointerCount = event->getPointerCount();
if (!validatePointerIndex(env, pointerIndex, pointerCount)
|| !validatePointerCoords(env, outPointerCoordsObj)) {
return;
}
const PointerCoords* rawPointerCoords;
if (historyPos == HISTORY_CURRENT) {
rawPointerCoords = event->getRawPointerCoords(pointerIndex);
} else {
size_t historySize = event->getHistorySize();
if (!validateHistoryPos(env, historyPos, historySize)) {
return;
}
rawPointerCoords = event->getHistoricalRawPointerCoords(pointerIndex, historyPos);
}
pointerCoordsFromNative(env, rawPointerCoords, event->getXOffset(), event->getYOffset(),
outPointerCoordsObj);
}
示例11: PublishAndConsumeMotionEvent
void InputPublisherAndConsumerTest::PublishAndConsumeMotionEvent(
size_t samplesToAppendBeforeDispatch, size_t samplesToAppendAfterDispatch) {
status_t status;
const int32_t deviceId = 1;
const int32_t source = AINPUT_SOURCE_TOUCHSCREEN;
const int32_t action = AMOTION_EVENT_ACTION_MOVE;
const int32_t flags = AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED;
const int32_t edgeFlags = AMOTION_EVENT_EDGE_FLAG_TOP;
const int32_t metaState = AMETA_ALT_LEFT_ON | AMETA_ALT_ON;
const float xOffset = -10;
const float yOffset = -20;
const float xPrecision = 0.25;
const float yPrecision = 0.5;
const nsecs_t downTime = 3;
const size_t pointerCount = 3;
const int32_t pointerIds[pointerCount] = { 2, 0, 1 };
Vector<nsecs_t> sampleEventTimes;
Vector<PointerCoords> samplePointerCoords;
for (size_t i = 0; i <= samplesToAppendAfterDispatch + samplesToAppendBeforeDispatch; i++) {
sampleEventTimes.push(i + 10);
for (size_t j = 0; j < pointerCount; j++) {
samplePointerCoords.push();
samplePointerCoords.editTop().x = 100 * i + j;
samplePointerCoords.editTop().y = 200 * i + j;
samplePointerCoords.editTop().pressure = 0.5 * i + j;
samplePointerCoords.editTop().size = 0.7 * i + j;
samplePointerCoords.editTop().touchMajor = 1.5 * i + j;
samplePointerCoords.editTop().touchMinor = 1.7 * i + j;
samplePointerCoords.editTop().toolMajor = 2.5 * i + j;
samplePointerCoords.editTop().toolMinor = 2.7 * i + j;
samplePointerCoords.editTop().orientation = 3.5 * i + j;
}
}
status = mPublisher->publishMotionEvent(deviceId, source, action, flags, edgeFlags,
metaState, xOffset, yOffset, xPrecision, yPrecision,
downTime, sampleEventTimes[0], pointerCount, pointerIds, samplePointerCoords.array());
ASSERT_EQ(OK, status)
<< "publisher publishMotionEvent should return OK";
for (size_t i = 0; i < samplesToAppendBeforeDispatch; i++) {
size_t sampleIndex = i + 1;
status = mPublisher->appendMotionSample(sampleEventTimes[sampleIndex],
samplePointerCoords.array() + sampleIndex * pointerCount);
ASSERT_EQ(OK, status)
<< "publisher appendMotionEvent should return OK";
}
status = mPublisher->sendDispatchSignal();
ASSERT_EQ(OK, status)
<< "publisher sendDispatchSignal should return OK";
for (size_t i = 0; i < samplesToAppendAfterDispatch; i++) {
size_t sampleIndex = i + 1 + samplesToAppendBeforeDispatch;
status = mPublisher->appendMotionSample(sampleEventTimes[sampleIndex],
samplePointerCoords.array() + sampleIndex * pointerCount);
ASSERT_EQ(OK, status)
<< "publisher appendMotionEvent should return OK";
}
status = mConsumer->receiveDispatchSignal();
ASSERT_EQ(OK, status)
<< "consumer receiveDispatchSignal should return OK";
InputEvent* event;
status = mConsumer->consume(& mEventFactory, & event);
ASSERT_EQ(OK, status)
<< "consumer consume should return OK";
ASSERT_TRUE(event != NULL)
<< "consumer should have returned non-NULL event";
ASSERT_EQ(AINPUT_EVENT_TYPE_MOTION, event->getType())
<< "consumer should have returned a motion event";
size_t lastSampleIndex = samplesToAppendBeforeDispatch + samplesToAppendAfterDispatch;
MotionEvent* motionEvent = static_cast<MotionEvent*>(event);
EXPECT_EQ(deviceId, motionEvent->getDeviceId());
EXPECT_EQ(source, motionEvent->getSource());
EXPECT_EQ(action, motionEvent->getAction());
EXPECT_EQ(flags, motionEvent->getFlags());
EXPECT_EQ(edgeFlags, motionEvent->getEdgeFlags());
EXPECT_EQ(metaState, motionEvent->getMetaState());
EXPECT_EQ(xPrecision, motionEvent->getXPrecision());
EXPECT_EQ(yPrecision, motionEvent->getYPrecision());
EXPECT_EQ(downTime, motionEvent->getDownTime());
EXPECT_EQ(sampleEventTimes[lastSampleIndex], motionEvent->getEventTime());
EXPECT_EQ(pointerCount, motionEvent->getPointerCount());
EXPECT_EQ(lastSampleIndex, motionEvent->getHistorySize());
for (size_t i = 0; i < pointerCount; i++) {
SCOPED_TRACE(i);
EXPECT_EQ(pointerIds[i], motionEvent->getPointerId(i));
}
for (size_t sampleIndex = 0; sampleIndex < lastSampleIndex; sampleIndex++) {
SCOPED_TRACE(sampleIndex);
//.........这里部分代码省略.........
示例12: android_view_MotionEvent_nativeGetPointerCount
static jint android_view_MotionEvent_nativeGetPointerCount(JNIEnv* env, jclass clazz,
jint nativePtr) {
MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
return jint(event->getPointerCount());
}
示例13: PublishAndConsumeMotionEvent
void InputPublisherAndConsumerTest::PublishAndConsumeMotionEvent() {
status_t status;
const uint32_t seq = 15;
const int32_t deviceId = 1;
const int32_t source = AINPUT_SOURCE_TOUCHSCREEN;
const int32_t action = AMOTION_EVENT_ACTION_MOVE;
const int32_t actionButton = 0;
const int32_t flags = AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED;
const int32_t edgeFlags = AMOTION_EVENT_EDGE_FLAG_TOP;
const int32_t metaState = AMETA_ALT_LEFT_ON | AMETA_ALT_ON;
const int32_t buttonState = AMOTION_EVENT_BUTTON_PRIMARY;
const float xOffset = -10;
const float yOffset = -20;
const float xPrecision = 0.25;
const float yPrecision = 0.5;
const nsecs_t downTime = 3;
const size_t pointerCount = 3;
const nsecs_t eventTime = 4;
PointerProperties pointerProperties[pointerCount];
PointerCoords pointerCoords[pointerCount];
for (size_t i = 0; i < pointerCount; i++) {
pointerProperties[i].clear();
pointerProperties[i].id = (i + 2) % pointerCount;
pointerProperties[i].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
pointerCoords[i].clear();
pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_X, 100 * i);
pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_Y, 200 * i);
pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 0.5 * i);
pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_SIZE, 0.7 * i);
pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, 1.5 * i);
pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, 1.7 * i);
pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, 2.5 * i);
pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, 2.7 * i);
pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, 3.5 * i);
}
status = mPublisher->publishMotionEvent(seq, deviceId, source, action, actionButton,
flags, edgeFlags, metaState, buttonState, xOffset, yOffset, xPrecision, yPrecision,
downTime, eventTime, pointerCount,
pointerProperties, pointerCoords);
ASSERT_EQ(OK, status)
<< "publisher publishMotionEvent should return OK";
uint32_t consumeSeq;
InputEvent* event;
status = mConsumer->consume(&mEventFactory, true /*consumeBatches*/, -1, &consumeSeq, &event);
ASSERT_EQ(OK, status)
<< "consumer consume should return OK";
ASSERT_TRUE(event != NULL)
<< "consumer should have returned non-NULL event";
ASSERT_EQ(AINPUT_EVENT_TYPE_MOTION, event->getType())
<< "consumer should have returned a motion event";
MotionEvent* motionEvent = static_cast<MotionEvent*>(event);
EXPECT_EQ(seq, consumeSeq);
EXPECT_EQ(deviceId, motionEvent->getDeviceId());
EXPECT_EQ(source, motionEvent->getSource());
EXPECT_EQ(action, motionEvent->getAction());
EXPECT_EQ(flags, motionEvent->getFlags());
EXPECT_EQ(edgeFlags, motionEvent->getEdgeFlags());
EXPECT_EQ(metaState, motionEvent->getMetaState());
EXPECT_EQ(buttonState, motionEvent->getButtonState());
EXPECT_EQ(xPrecision, motionEvent->getXPrecision());
EXPECT_EQ(yPrecision, motionEvent->getYPrecision());
EXPECT_EQ(downTime, motionEvent->getDownTime());
EXPECT_EQ(eventTime, motionEvent->getEventTime());
EXPECT_EQ(pointerCount, motionEvent->getPointerCount());
EXPECT_EQ(0U, motionEvent->getHistorySize());
for (size_t i = 0; i < pointerCount; i++) {
SCOPED_TRACE(i);
EXPECT_EQ(pointerProperties[i].id, motionEvent->getPointerId(i));
EXPECT_EQ(pointerProperties[i].toolType, motionEvent->getToolType(i));
EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_X),
motionEvent->getRawX(i));
EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_Y),
motionEvent->getRawY(i));
EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_X) + xOffset,
motionEvent->getX(i));
EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_Y) + yOffset,
motionEvent->getY(i));
EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_PRESSURE),
motionEvent->getPressure(i));
EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_SIZE),
motionEvent->getSize(i));
EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR),
motionEvent->getTouchMajor(i));
EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR),
motionEvent->getTouchMinor(i));
EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR),
motionEvent->getToolMajor(i));
EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR),
motionEvent->getToolMinor(i));
EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION),
motionEvent->getOrientation(i));
}
//.........这里部分代码省略.........
开发者ID:ishantvivek,项目名称:android_frameworks_native-temasek,代码行数:101,代码来源:InputPublisherAndConsumer_test.cpp