From 333e7dcc05cf507bf192ee03ec81f580e0edd530 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 6 Jul 2023 22:57:09 +1000 Subject: [PATCH] Bump android build gradle versions, also provide delta to Window_ProcessEvents for windowing backends that require knowing how much time has elapsed --- .gitignore | 1 + src/Game.c | 6 +++--- src/Launcher.c | 2 +- src/Window.h | 2 +- src/Window_3DS.c | 2 +- src/Window_Android.c | 6 +++--- src/Window_Carbon.c | 2 +- src/Window_GCWii.c | 4 ++-- src/Window_SDL.c | 2 +- src/Window_Web.c | 2 +- src/Window_Win.c | 4 ++-- src/Window_X11.c | 8 ++++---- src/interop_BeOS.cpp | 2 +- src/interop_cocoa.m | 2 +- src/interop_ios.m | 4 ++-- 15 files changed, 25 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 2fffb0a4c..bf9a9a67c 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ *.VC.VC.opendb # Android build results +android/.cxx/ android/.idea/ android/.gradle/ android/build/ diff --git a/src/Game.c b/src/Game.c index 73df361bd..763a9a8bd 100644 --- a/src/Game.c +++ b/src/Game.c @@ -637,11 +637,11 @@ void Game_Free(void* obj) { #define Game_DoFrameBody() \ render = Stopwatch_Measure();\ - Window_ProcessEvents();\ - if (!WindowInfo.Exists) return;\ - \ delta = Stopwatch_ElapsedMicroseconds(Game_FrameStart, render) / (1000.0 * 1000.0);\ \ + Window_ProcessEvents(delta);\ + if (!WindowInfo.Exists) return;\ + \ if (delta > 1.0) delta = 1.0; /* avoid large delta with suspended process */ \ if (delta > 0.0) { Game_FrameStart = render; Game_RenderFrame(delta); } diff --git a/src/Launcher.c b/src/Launcher.c index cd11ba330..d6e47229d 100644 --- a/src/Launcher.c +++ b/src/Launcher.c @@ -263,7 +263,7 @@ void Launcher_Run(void) { #endif for (;;) { - Window_ProcessEvents(); + Window_ProcessEvents(10 / 1000.0); if (!WindowInfo.Exists || Launcher_ShouldExit) break; Launcher_Active->Tick(Launcher_Active); diff --git a/src/Window.h b/src/Window.h index beeffafe1..5377f7cb5 100644 --- a/src/Window.h +++ b/src/Window.h @@ -121,7 +121,7 @@ void Window_SetSize(int width, int height); /* Raises the WindowClosing and WindowClosed events. */ void Window_Close(void); /* Processes all pending window messages/events. */ -void Window_ProcessEvents(void); +void Window_ProcessEvents(double delta); /* Sets the position of the cursor. */ /* NOTE: This should be avoided because it is unsupported on some platforms. */ diff --git a/src/Window_3DS.c b/src/Window_3DS.c index b3f431447..6f76fb83d 100644 --- a/src/Window_3DS.c +++ b/src/Window_3DS.c @@ -57,7 +57,7 @@ void Window_Close(void) { /* TODO implement */ } -void Window_ProcessEvents(void) { +void Window_ProcessEvents(double delta) { hidScanInput(); /* TODO implement */ diff --git a/src/Window_Android.c b/src/Window_Android.c index 72360e53d..75ff7566b 100644 --- a/src/Window_Android.c +++ b/src/Window_Android.c @@ -278,7 +278,7 @@ static void RemakeWindowSurface(void) { /* Loop until window gets created by main UI thread */ /* (i.e. until processSurfaceCreated is received) */ while (!winCreated) { - Window_ProcessEvents(); + Window_ProcessEvents(0.0); Thread_Sleep(10); } @@ -338,7 +338,7 @@ void Window_Close(void) { /* ANativeActivity_finish(app->activity); */ } -void Window_ProcessEvents(void) { +void Window_ProcessEvents(double delta) { JNIEnv* env; JavaGetCurrentEnv(env); /* TODO: Cache the java env */ @@ -358,7 +358,7 @@ static void ShowDialogCore(const char* title, const char* msg) { Platform_LogConst(title); Platform_LogConst(msg); /* in case surface destroyed message has arrived */ - Window_ProcessEvents(); + Window_ProcessEvents(0.0); args[0].l = JavaMakeConst(env, title); args[1].l = JavaMakeConst(env, msg); diff --git a/src/Window_Carbon.c b/src/Window_Carbon.c index 7d175777f..da5306891 100644 --- a/src/Window_Carbon.c +++ b/src/Window_Carbon.c @@ -551,7 +551,7 @@ void Window_Close(void) { WindowInfo.Exists = false; } -void Window_ProcessEvents(void) { +void Window_ProcessEvents(double delta) { EventRef theEvent; EventTargetRef target = GetEventDispatcherTarget(); OSStatus res; diff --git a/src/Window_GCWii.c b/src/Window_GCWii.c index 7114d8f53..dfcecccfd 100644 --- a/src/Window_GCWii.c +++ b/src/Window_GCWii.c @@ -81,7 +81,7 @@ void Window_Close(void) { } #if defined HW_RVL -void Window_ProcessEvents(void) { +void Window_ProcessEvents(double delta) { /* TODO implement */ WPAD_ScanPads(); u32 mods = WPAD_ButtonsDown(0) | WPAD_ButtonsHeld(0); @@ -108,7 +108,7 @@ void Window_ProcessEvents(void) { } #elif defined HW_DOL -void Window_ProcessEvents(void) { +void Window_ProcessEvents(double delta) { /* TODO implement */ PADStatus pads[4]; PAD_Read(pads); diff --git a/src/Window_SDL.c b/src/Window_SDL.c index 0a22f1d69..dfb88a92b 100644 --- a/src/Window_SDL.c +++ b/src/Window_SDL.c @@ -227,7 +227,7 @@ static void OnWindowEvent(const SDL_Event* e) { } } -void Window_ProcessEvents(void) { +void Window_ProcessEvents(double delta) { SDL_Event e; while (SDL_PollEvent(&e)) { switch (e.type) { diff --git a/src/Window_Web.c b/src/Window_Web.c index 8eec8ab65..c880271de 100644 --- a/src/Window_Web.c +++ b/src/Window_Web.c @@ -513,7 +513,7 @@ void Window_Close(void) { } extern void interop_RequestCanvasResize(void); -void Window_ProcessEvents(void) { +void Window_ProcessEvents(double delta) { if (!needResize) return; needResize = false; if (!WindowInfo.Exists) return; diff --git a/src/Window_Win.c b/src/Window_Win.c index 59e27bfe9..bd101239a 100644 --- a/src/Window_Win.c +++ b/src/Window_Win.c @@ -463,7 +463,7 @@ static void ToggleFullscreen(cc_bool fullscreen, UINT finalShow) { SetWindowLongA(win_handle, GWL_STYLE, style); SetWindowPos(win_handle, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); ShowWindow(win_handle, finalShow); - Window_ProcessEvents(); + Window_ProcessEvents(0.0); } suppress_resize = false; @@ -509,7 +509,7 @@ void Window_Close(void) { PostMessageA(win_handle, WM_CLOSE, 0, 0); } -void Window_ProcessEvents(void) { +void Window_ProcessEvents(double delta) { HWND foreground; MSG msg; diff --git a/src/Window_X11.c b/src/Window_X11.c index 9cb8c7fa8..d4c1f8761 100644 --- a/src/Window_X11.c +++ b/src/Window_X11.c @@ -370,7 +370,7 @@ void Clipboard_GetText(cc_string* value) { /* wait up to 1 second for SelectionNotify event to arrive */ for (i = 0; i < 100; i++) { - Window_ProcessEvents(); + Window_ProcessEvents(0.0); if (clipboard_paste_received) { String_AppendString(value, &clipboard_paste_text); return; @@ -427,7 +427,7 @@ static void ToggleFullscreen(long op) { SubstructureRedirectMask | SubstructureNotifyMask, &ev); XSync(win_display, false); XRaiseWindow(win_display, win_handle); - Window_ProcessEvents(); + Window_ProcessEvents(0.0); } cc_result Window_EnterFullscreen(void) { @@ -443,7 +443,7 @@ void Window_Show(void) { XMapWindow(win_display, win_handle); } void Window_SetSize(int width, int height) { XResizeWindow(win_display, win_handle, width, height); - Window_ProcessEvents(); + Window_ProcessEvents(0.0); } void Window_Close(void) { @@ -513,7 +513,7 @@ static void HandleWMPing(XEvent* e) { } static void HandleGenericEvent(XEvent* e); -void Window_ProcessEvents(void) { +void Window_ProcessEvents(double delta) { XEvent e; Window focus; int focusRevert; diff --git a/src/interop_BeOS.cpp b/src/interop_BeOS.cpp index 092859d2c..f489f8b4d 100644 --- a/src/interop_BeOS.cpp +++ b/src/interop_BeOS.cpp @@ -460,7 +460,7 @@ static int MapNativeKey(int raw) { return key; } -void Window_ProcessEvents(void) { +void Window_ProcessEvents(double delta) { CCEvent event; int key; diff --git a/src/interop_cocoa.m b/src/interop_cocoa.m index b11555238..9f619b256 100644 --- a/src/interop_cocoa.m +++ b/src/interop_cocoa.m @@ -453,7 +453,7 @@ static void DebugScrollEvent(NSEvent* ev) { Platform_Log3("SCROLL: %i.0 = (%i, %f3)", &steps, &raw, &dy); } -void Window_ProcessEvents(void) { +void Window_ProcessEvents(double delta) { NSEvent* ev; int key, type, steps, x, y; CGFloat dx, dy; diff --git a/src/interop_ios.m b/src/interop_ios.m index e89bcf83d..33f92d697 100644 --- a/src/interop_ios.m +++ b/src/interop_ios.m @@ -386,7 +386,7 @@ void Window_Close(void) { Event_RaiseVoid(&WindowEvents.Closing); } -void Window_ProcessEvents(void) { +void Window_ProcessEvents(double delta) { SInt32 res; // manually tick event queue do { @@ -408,7 +408,7 @@ void ShowDialogCore(const char* title, const char* msg) { // TODO clicking outside message box crashes launcher // loop until alert is closed TODO avoid sleeping while (!completed) { - Window_ProcessEvents(); + Window_ProcessEvents(0.0); Thread_Sleep(16); } }