Skip to content

Commit

Permalink
input lag fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VadimBoev committed Oct 4, 2024
1 parent 0d25fbc commit 6272210
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 20 deletions.
Binary file modified FlappyBird/app/build/outputs/apk/FlappyBird-signed.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions FlappyBird/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
package="com.flappybird.game"

android:versionCode="15"
android:versionName="1.5">
android:versionCode="17"
android:versionName="1.7">

<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" />

Expand Down
21 changes: 13 additions & 8 deletions FlappyBird/app/src/main/jni/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,35 +45,40 @@ int32_t handle_input(struct android_app* app, AInputEvent* event)
bool isReleased = false;
bool isMoved = false;
int index;

for (size_t i = 0; i < pointerCount; ++i)
{
x = AMotionEvent_getX(event, i);
y = AMotionEvent_getY(event, i);
index = AMotionEvent_getPointerId(event, i);

if (action == AMOTION_EVENT_ACTION_POINTER_DOWN || action == AMOTION_EVENT_ACTION_DOWN)
{
int id = index;
if (action == AMOTION_EVENT_ACTION_POINTER_DOWN && id != whichsource) continue;

isDown = true;
mouse.x = x;
mouse.y = y;
mouse.isDown = true;
}
else if (action == AMOTION_EVENT_ACTION_POINTER_UP || action == AMOTION_EVENT_ACTION_UP || action == AMOTION_EVENT_ACTION_CANCEL)
{
int id = index;
if (action == AMOTION_EVENT_ACTION_POINTER_UP && id != whichsource) continue;

isReleased = true;

mouse.x = x;
mouse.y = y;
mouse.isReleased = true;
}
else if (action == AMOTION_EVENT_ACTION_MOVE)
{
isMoved = true;
mouse.isMoved = true;

mouse.x = x;
mouse.y = y;
}
}

MouseUpdate(&mouse, x, y, isDown, isReleased, isMoved);

return 1;
}
//else if (eventType == AINPUT_EVENT_TYPE_KEY) //Apparently, this applies to physical keys, including volume control keys.
Expand Down
11 changes: 2 additions & 9 deletions FlappyBird/app/src/main/jni/mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,10 @@ void MouseInit(MouseState* mouse)
mouse->isMoved = false;
}

void MouseUpdate(MouseState* mouse, float x, float y, bool down, bool released, bool moved)
{
mouse->x = x;
mouse->y = y;
mouse->isDown = down;
mouse->isReleased = released;
mouse->isMoved = moved;
}

void MouseReset(MouseState* mouse)
{
mouse->x = -1.0f;
mouse->y = -1.0f;
mouse->isDown = false;
mouse->isReleased = false;
mouse->isMoved = false;
Expand Down
1 change: 0 additions & 1 deletion FlappyBird/app/src/main/jni/mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ typedef struct {
extern MouseState mouse;

void MouseInit(MouseState* mouse);
void MouseUpdate(MouseState* mouse, float x, float y, bool down, bool released, bool moved);
void MouseReset(MouseState* mouse);
bool IsMouseInSquare(int mouse_x, int mouse_y, int x, int y, int w, int h);

Expand Down
Binary file modified FlappyBird/app/src/main/libs/arm64-v8a/libflappybird.so
Binary file not shown.
Binary file modified FlappyBird/app/src/main/libs/armeabi-v7a/libflappybird.so
Binary file not shown.

0 comments on commit 6272210

Please sign in to comment.