Add _GLFW_PLATFORM_LIBRARY_WINDOW_STATE

I tried adding a cursor state but it resulted in wierd segmentation fault errors
This commit is contained in:
Curi0 2017-10-18 19:24:33 +05:30
parent 51000fdbb7
commit b6d4a0146d
3 changed files with 8 additions and 12 deletions

View File

@ -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;
}

View File

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

View File

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