fix android gestures pinch and pan, supports only two fingers
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user