diff --git a/frontend/drivers/platform_linux.h b/frontend/drivers/platform_linux.h index e507f34327..8a3dd41fdb 100644 --- a/frontend/drivers/platform_linux.h +++ b/frontend/drivers/platform_linux.h @@ -21,6 +21,8 @@ #include #include +#include + typedef enum { CPU_FAMILY_UNKNOWN = 0, @@ -82,6 +84,7 @@ struct android_app int msgread; int msgwrite; int running; + bool unfocused; unsigned accelerometer_event_rate; const ASensor* accelerometerSensor; uint64_t sensor_state_mask; diff --git a/gfx/drivers_context/androidegl_ctx.c b/gfx/drivers_context/androidegl_ctx.c index 7d08b5539c..edd9f2b07e 100644 --- a/gfx/drivers_context/androidegl_ctx.c +++ b/gfx/drivers_context/androidegl_ctx.c @@ -176,8 +176,11 @@ static bool android_gfx_ctx_bind_api(void *data, static bool android_gfx_ctx_has_focus(void *data) { - (void)data; - return true; + struct android_app *android_app = (struct android_app*)g_android; + + if (!android_app) + return true; + return (android_app->unfocused == true ) ? false : true; } static bool android_gfx_ctx_suppress_screensaver(void *data, bool enable) diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index bd48838493..fe3a15e457 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -393,6 +393,10 @@ static void engine_handle_cmd(void) RETRO_SENSOR_ACCELEROMETER_ENABLE, android_app->accelerometer_event_rate); } + slock_lock(android_app->mutex); + android_app->unfocused = false; + scond_broadcast(android_app->cond); + slock_unlock(android_app->mutex); break; case APP_CMD_LOST_FOCUS: { @@ -410,6 +414,10 @@ static void engine_handle_cmd(void) RETRO_SENSOR_ACCELEROMETER_DISABLE, android_app->accelerometer_event_rate); } + slock_lock(android_app->mutex); + android_app->unfocused = true; + scond_broadcast(android_app->cond); + slock_unlock(android_app->mutex); break; case APP_CMD_DESTROY: