Skip to content

Commit 8961f0c

Browse files
committed
Revert "GameActivity PATCH: Support InputAvailable events"
This reverts commit 9835d1d.
1 parent 20ca6f9 commit 8961f0c

File tree

2 files changed

+0
-53
lines changed

2 files changed

+0
-53
lines changed

android-activity/game-activity-csrc/game-activity/native_app_glue/android_native_app_glue.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -477,29 +477,6 @@ void android_app_set_motion_event_filter(struct android_app* app,
477477
pthread_mutex_unlock(&app->mutex);
478478
}
479479

480-
bool android_app_input_available_wake_up(struct android_app* app) {
481-
pthread_mutex_lock(&app->mutex);
482-
bool available = app->inputAvailableWakeUp;
483-
app->inputAvailableWakeUp = false;
484-
pthread_mutex_unlock(&app->mutex);
485-
return available;
486-
}
487-
488-
// NB: should be called with the android_app->mutex held already
489-
static void notifyInput(struct android_app* android_app) {
490-
// Don't spam the mainloop with wake ups if we've already sent one
491-
if (android_app->inputSwapPending) {
492-
return;
493-
}
494-
495-
if (android_app->looper != NULL) {
496-
// for the app thread to know why it received the wake() up
497-
android_app->inputAvailableWakeUp = true;
498-
android_app->inputSwapPending = true;
499-
ALooper_wake(android_app->looper);
500-
}
501-
}
502-
503480
static bool onTouchEvent(GameActivity* activity,
504481
const GameActivityMotionEvent* event) {
505482
struct android_app* android_app = ToApp(activity);
@@ -529,7 +506,6 @@ static bool onTouchEvent(GameActivity* activity,
529506
int new_ix = inputBuffer->motionEventsCount;
530507
memcpy(&inputBuffer->motionEvents[new_ix], event, sizeof(GameActivityMotionEvent));
531508
++inputBuffer->motionEventsCount;
532-
notifyInput(android_app);
533509

534510
pthread_mutex_unlock(&android_app->mutex);
535511
return true;
@@ -551,9 +527,6 @@ struct android_input_buffer* android_app_swap_input_buffers(
551527
NATIVE_APP_GLUE_MAX_INPUT_BUFFERS;
552528
}
553529

554-
android_app->inputSwapPending = false;
555-
android_app->inputAvailableWakeUp = false;
556-
557530
pthread_mutex_unlock(&android_app->mutex);
558531

559532
return inputBuffer;
@@ -606,7 +579,6 @@ static bool onKey(GameActivity* activity, const GameActivityKeyEvent* event) {
606579
int new_ix = inputBuffer->keyEventsCount;
607580
memcpy(&inputBuffer->keyEvents[new_ix], event, sizeof(GameActivityKeyEvent));
608581
++inputBuffer->keyEventsCount;
609-
notifyInput(android_app);
610582

611583
pthread_mutex_unlock(&android_app->mutex);
612584
return true;

android-activity/game-activity-csrc/game-activity/native_app_glue/android_native_app_glue.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -263,26 +263,6 @@ struct android_app {
263263
android_key_event_filter keyEventFilter;
264264
android_motion_event_filter motionEventFilter;
265265

266-
// When new input is received we set both of these flags and use the looper to
267-
// wake up the application mainloop.
268-
//
269-
// To avoid spamming the mainloop with wake ups from lots of input though we
270-
// don't sent a wake up if the inputSwapPending flag is already set. (i.e.
271-
// we already expect input to be processed in a finite amount of time due to
272-
// our previous wake up)
273-
//
274-
// When a wake up is received then we will check this flag (clearing it
275-
// at the same time). If it was set then an InputAvailable event is sent to
276-
// the application - which should lead to all input being processed within
277-
// a finite amount of time.
278-
//
279-
// The next time android_app_swap_input_buffers is called, both flags will be
280-
// cleared.
281-
//
282-
// NB: both of these should only be read with the app mutex held
283-
bool inputAvailableWakeUp;
284-
bool inputSwapPending;
285-
286266
/** @endcond */
287267
};
288268

@@ -495,11 +475,6 @@ void android_app_set_key_event_filter(struct android_app* app,
495475
void android_app_set_motion_event_filter(struct android_app* app,
496476
android_motion_event_filter filter);
497477

498-
/**
499-
* Determines if a looper wake up was due to new input becoming available
500-
*/
501-
bool android_app_input_available_wake_up(struct android_app* app);
502-
503478
#ifdef __cplusplus
504479
}
505480
#endif

0 commit comments

Comments
 (0)