mirror of
https://github.com/glfw/glfw.git
synced 2025-10-05 06:06:36 +00:00
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:
parent
51000fdbb7
commit
b6d4a0146d
@ -32,7 +32,7 @@ extern int main();
|
|||||||
void handle_cmd(struct android_app* _app, int32_t cmd) {
|
void handle_cmd(struct android_app* _app, int32_t cmd) {
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case APP_CMD_INIT_WINDOW: {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case APP_CMD_LOST_FOCUS: {
|
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
|
pthread_create(&(pthread_t){0}, NULL, (void*)&main, NULL); // Call the main entry point
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int ident;
|
|
||||||
int events;
|
|
||||||
struct android_poll_source* source;
|
struct android_poll_source* source;
|
||||||
|
|
||||||
// Process events
|
// Process events
|
||||||
while ((ident=ALooper_pollAll(0, NULL, &events,(void**)&source)) >= 0)
|
while ((ALooper_pollAll(0, NULL, NULL,(void**)&source)) >= 0)
|
||||||
if (source != NULL)
|
if (source != NULL)
|
||||||
source->process(app, source);
|
source->process(app, source);
|
||||||
}
|
}
|
||||||
@ -71,7 +68,7 @@ void android_main(struct android_app *app) {
|
|||||||
int _glfwPlatformInit(void)
|
int _glfwPlatformInit(void)
|
||||||
{
|
{
|
||||||
_glfwInitTimerPOSIX();
|
_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;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->android->window)
|
#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->android->window)
|
||||||
#define _GLFW_PLATFORM_WINDOW_STATE struct android_app* android
|
#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_MONITOR_STATE
|
||||||
#define _GLFW_PLATFORM_CURSOR_STATE
|
#define _GLFW_PLATFORM_CURSOR_STATE
|
||||||
|
|
||||||
@ -49,7 +49,7 @@
|
|||||||
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
|
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
|
||||||
#define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY
|
#define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY
|
||||||
|
|
||||||
struct android_app *app;
|
float x,y;
|
||||||
|
|
||||||
typedef VkFlags VkAndroidSurfaceCreateFlagsKHR;
|
typedef VkFlags VkAndroidSurfaceCreateFlagsKHR;
|
||||||
|
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
float x,y;
|
|
||||||
|
|
||||||
static int32_t handle_input(struct android_app* app, AInputEvent* event)
|
static int32_t handle_input(struct android_app* app, AInputEvent* event)
|
||||||
{
|
{
|
||||||
if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION)
|
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)
|
if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_KEY)
|
||||||
_glfwInputKey(_glfw.windowListHead, 0 , AKeyEvent_getKeyCode(event), GLFW_PRESS,0);
|
_glfwInputKey(_glfw.windowListHead, 0 , AKeyEvent_getKeyCode(event), GLFW_PRESS,0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +50,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
const _GLFWctxconfig* ctxconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig)
|
const _GLFWfbconfig* fbconfig)
|
||||||
{
|
{
|
||||||
window->android = app;
|
window->android = _glfw.app;
|
||||||
window->android->onInputEvent = handle_input;
|
window->android->onInputEvent = handle_input;
|
||||||
|
|
||||||
ANativeWindow_setBuffersGeometry(window->android->window, wndconfig->width, wndconfig->height, 0);
|
ANativeWindow_setBuffersGeometry(window->android->window, wndconfig->width, wndconfig->height, 0);
|
||||||
@ -213,7 +212,7 @@ int _glfwPlatformWindowVisible(_GLFWwindow* window)
|
|||||||
|
|
||||||
void _glfwPlatformPollEvents(void)
|
void _glfwPlatformPollEvents(void)
|
||||||
{
|
{
|
||||||
_glfwInputCursorPos(_glfw.windowListHead, x ,y);
|
_glfwInputCursorPos(_glfw.windowListHead, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformWaitEvents(void)
|
void _glfwPlatformWaitEvents(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user