MCPcopy Create free account
hub / github.com/GarageGames/Torque2D / engine_handle_input

Function engine_handle_input

engine/source/platformAndroid/T2DActivity.cpp:443–572  ·  view source on GitHub ↗

Handle touch and keyboard input from android OS

Source from the content-addressed store, hash-verified

441
442// Handle touch and keyboard input from android OS
443static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) {
444
445 struct engine* engine = (struct engine*)app->userData;
446
447 if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) {
448
449 int32_t eventValue = (AMotionEvent_getAction(event) & AMOTION_EVENT_ACTION_MASK);
450
451 if (eventValue == AMOTION_EVENT_ACTION_DOWN || eventValue == AMOTION_EVENT_ACTION_POINTER_DOWN) {
452
453 size_t touchCount = AMotionEvent_getPointerCount(event);
454 for (U8 i = 0; i < touchCount; i++)
455 {
456 Point2I point;
457 point.x = AMotionEvent_getX(event, i);
458 point.y = AMotionEvent_getY(event, i);
459
460 rawLastTouches[i].x = point.x;
461 rawLastTouches[i].y = point.y;
462
463 createMouseDownEvent(i, point.x, point.y, touchCount);
464 }
465
466 }
467
468 if (eventValue == AMOTION_EVENT_ACTION_UP || eventValue == AMOTION_EVENT_ACTION_POINTER_UP) {
469
470 size_t touchCount = AMotionEvent_getPointerCount(event);
471 for (U8 i = 0; i < touchCount; i++)
472 {
473 Point2I point;
474 point.x = AMotionEvent_getX(event, i);
475 point.y = AMotionEvent_getY(event, i);
476 Point2I prevPoint = rawLastTouches[i];
477
478 createMouseUpEvent(i, point.x, point.y, prevPoint.x, prevPoint.y, touchCount);
479
480 if (touchCount > 0)
481 {
482 // this was a tap, so create a tap event
483 createMouseTapEvent(touchCount, (int) point.x, (int) point.y);
484 }
485 }
486 }
487
488 if (eventValue == AMOTION_EVENT_ACTION_MOVE) {
489
490 size_t touchCount = AMotionEvent_getPointerCount(event);
491 for (U8 i = 0; i < touchCount; i++)
492 {
493 Point2I point;
494 point.x = AMotionEvent_getX(event, i);
495 point.y = AMotionEvent_getY(event, i);
496 Point2I prevPoint = rawLastTouches[i];
497
498 createMouseMoveEvent(i, point.x, point.y, prevPoint.x, prevPoint.y);
499
500 rawLastTouches[i].x = point.x;

Callers

nothing calls this directly

Calls 9

createMouseDownEventFunction · 0.85
createMouseUpEventFunction · 0.85
createMouseTapEventFunction · 0.85
createMouseMoveEventFunction · 0.85
ChangeVolumeFunction · 0.85
executefFunction · 0.85
getBoolArgFunction · 0.85
androidKeyboardEventFunction · 0.85
displayKeyboardFunction · 0.85

Tested by

no test coverage detected