(Android) Implement 'focused' callback for androidegl_ctx

This commit is contained in:
twinaphex 2015-11-27 20:38:29 +01:00
parent f42098013f
commit a8d868f187
3 changed files with 16 additions and 2 deletions

View File

@ -21,6 +21,8 @@
#include <stdint.h>
#include <sys/cdefs.h>
#include <boolean.h>
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;

View File

@ -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)

View File

@ -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: