| 484 | } |
| 485 | |
| 486 | int32_t OnAppInput(android_app* app, AInputEvent* inputEvent) |
| 487 | { |
| 488 | switch (AInputEvent_getType(inputEvent)) |
| 489 | { |
| 490 | case AINPUT_EVENT_TYPE_MOTION: |
| 491 | { |
| 492 | const int32_t action = AMotionEvent_getAction(inputEvent); |
| 493 | switch (action & AMOTION_EVENT_ACTION_MASK) |
| 494 | { |
| 495 | case AMOTION_EVENT_ACTION_DOWN: |
| 496 | { |
| 497 | const int32 pointerCount = (int32)AMotionEvent_getPointerCount(inputEvent); |
| 498 | for (int32 i = 0; i < pointerCount; i++) |
| 499 | { |
| 500 | const int32 pointerId = AMotionEvent_getPointerId(inputEvent, i); |
| 501 | const float x = AMotionEvent_getX(inputEvent, i); |
| 502 | const float y = AMotionEvent_getY(inputEvent, i); |
| 503 | TouchScreenImpl->OnTouch(InputDevice::EventType::TouchDown, x, y, pointerId); |
| 504 | } |
| 505 | break; |
| 506 | } |
| 507 | case AMOTION_EVENT_ACTION_UP: |
| 508 | { |
| 509 | const int32 pointerCount = (int32)AMotionEvent_getPointerCount(inputEvent); |
| 510 | for (int32 i = 0; i < pointerCount; i++) |
| 511 | { |
| 512 | const int32 pointerId = AMotionEvent_getPointerId(inputEvent, i); |
| 513 | const float x = AMotionEvent_getX(inputEvent, i); |
| 514 | const float y = AMotionEvent_getY(inputEvent, i); |
| 515 | TouchScreenImpl->OnTouch(InputDevice::EventType::TouchUp, x, y, pointerId); |
| 516 | } |
| 517 | break; |
| 518 | } |
| 519 | case AMOTION_EVENT_ACTION_MOVE: |
| 520 | { |
| 521 | const int32 pointerCount = (int32)AMotionEvent_getPointerCount(inputEvent); |
| 522 | for (int32 i = 0; i < pointerCount; i++) |
| 523 | { |
| 524 | const int32 pointerId = AMotionEvent_getPointerId(inputEvent, i); |
| 525 | const float x = AMotionEvent_getX(inputEvent, i); |
| 526 | const float y = AMotionEvent_getY(inputEvent, i); |
| 527 | TouchScreenImpl->OnTouch(InputDevice::EventType::TouchMove, x, y, pointerId); |
| 528 | } |
| 529 | break; |
| 530 | } |
| 531 | case AMOTION_EVENT_ACTION_POINTER_DOWN: |
| 532 | { |
| 533 | const int32 pointerIndex = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; |
| 534 | const int32 pointerId = AMotionEvent_getPointerId(inputEvent, pointerIndex); |
| 535 | const float x = AMotionEvent_getX(inputEvent, pointerIndex); |
| 536 | const float y = AMotionEvent_getY(inputEvent, pointerIndex); |
| 537 | TouchScreenImpl->OnTouch(InputDevice::EventType::TouchDown, x, y, pointerId); |
| 538 | break; |
| 539 | } |
| 540 | case AMOTION_EVENT_ACTION_POINTER_UP: |
| 541 | { |
| 542 | const int32 pointerIndex = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; |
| 543 | const int32 pointerId = AMotionEvent_getPointerId(inputEvent, pointerIndex); |