diff --git a/src/android_init.c b/src/android_init.c index 590e21252..ba572a4d6 100644 --- a/src/android_init.c +++ b/src/android_init.c @@ -32,7 +32,7 @@ extern int main(); void handle_cmd(struct android_app* _app, int32_t cmd) { switch (cmd) { case APP_CMD_INIT_WINDOW: { - app = _app; // The window is being shown so the initialization is finished. + _glfw.app = _app; // The window is being shown so the initialization is finished. break; } case APP_CMD_LOST_FOCUS: { @@ -53,12 +53,9 @@ void android_main(struct android_app *app) { pthread_create(&(pthread_t){0}, NULL, (void*)&main, NULL); // Call the main entry point while (1) { - int ident; - int events; struct android_poll_source* source; - // Process events - while ((ident=ALooper_pollAll(0, NULL, &events,(void**)&source)) >= 0) + while ((ALooper_pollAll(0, NULL, NULL,(void**)&source)) >= 0) if (source != NULL) source->process(app, source); } @@ -71,7 +68,7 @@ void android_main(struct android_app *app) { int _glfwPlatformInit(void) { _glfwInitTimerPOSIX(); - while (app == NULL); // Wait for the app to be initialized or the app will crash occasionally + while (_glfw.app == NULL); // Wait for the app to be initialized or the app will crash occasionally return GLFW_TRUE; } diff --git a/src/android_platform.h b/src/android_platform.h index ea33266f2..1e9da6210 100644 --- a/src/android_platform.h +++ b/src/android_platform.h @@ -41,7 +41,7 @@ #define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->android->window) #define _GLFW_PLATFORM_WINDOW_STATE struct android_app* android -#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE +#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE struct android_app* app #define _GLFW_PLATFORM_MONITOR_STATE #define _GLFW_PLATFORM_CURSOR_STATE @@ -49,7 +49,7 @@ #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE #define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY -struct android_app *app; +float x,y; typedef VkFlags VkAndroidSurfaceCreateFlagsKHR; diff --git a/src/android_window.c b/src/android_window.c index 75b52ca20..708aeda01 100644 --- a/src/android_window.c +++ b/src/android_window.c @@ -27,8 +27,6 @@ #include "internal.h" -float x,y; - static int32_t handle_input(struct android_app* app, AInputEvent* event) { if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) @@ -39,6 +37,7 @@ static int32_t handle_input(struct android_app* app, AInputEvent* event) } if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_KEY) _glfwInputKey(_glfw.windowListHead, 0 , AKeyEvent_getKeyCode(event), GLFW_PRESS,0); + return 0; } @@ -51,7 +50,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) { - window->android = app; + window->android = _glfw.app; window->android->onInputEvent = handle_input; ANativeWindow_setBuffersGeometry(window->android->window, wndconfig->width, wndconfig->height, 0); @@ -213,7 +212,7 @@ int _glfwPlatformWindowVisible(_GLFWwindow* window) void _glfwPlatformPollEvents(void) { - _glfwInputCursorPos(_glfw.windowListHead, x ,y); + _glfwInputCursorPos(_glfw.windowListHead, x, y); } void _glfwPlatformWaitEvents(void)