fix android gestures pinch and pan, supports only two fingers

This commit is contained in:
2017-04-24 11:32:08 +01:00
parent d558bc1e04
commit 5ac666f911
2 changed files with 17 additions and 4 deletions

View File

@@ -404,6 +404,8 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
switch (action) {
case AMOTION_EVENT_ACTION_DOWN:
{
float y = AMotionEvent_getY(event, 0);
float x = AMotionEvent_getX(event, 0);
p0.id = AMotionEvent_getPointerId(event, 0);
p0.pos = {x, y};
p0.idx = index;
@@ -417,6 +419,8 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
LOG("pointer down index %d", index);
if (count == 2)
{
float y = AMotionEvent_getY(event, 1);
float x = AMotionEvent_getX(event, 1);
p1.id = AMotionEvent_getPointerId(event, 1);
p1.idx = index;
p1.pos = {x, y};
@@ -429,6 +433,8 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
}
case AMOTION_EVENT_ACTION_UP:
{
float y = AMotionEvent_getY(event, 0);
float x = AMotionEvent_getX(event, 0);
tracked = 0;
p0.id = -1;
p1.id = -1;
@@ -445,12 +451,18 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
}
return 1;
case AMOTION_EVENT_ACTION_HOVER_MOVE: // pen move before touching
{
float y = AMotionEvent_getY(event, 0);
float x = AMotionEvent_getX(event, 0);
App::I.mouse_move(x, y);
LOG("single move");
return 1;
}
case AMOTION_EVENT_ACTION_MOVE:
if (count == 1)
{
float y = AMotionEvent_getY(event, 0);
float x = AMotionEvent_getX(event, 0);
App::I.mouse_move(x, y);
LOG("single move");
}