diff options
| author | 2026-09-07 14:42:21 -0400 | |
|---|---|---|
| committer | 2026-09-07 14:42:21 -0400 | |
| commit | e72c336d01b32bee304c8a2989e2335fcc26c143 (patch) | |
| tree | 62b69b421936114835481c27612aad023e070c4f | |
| parent | 9c4a7eb845126f068aaac0173453e803e5ea6bf8 (diff) | |
| download | stela-e72c336d01b32bee304c8a2989e2335fcc26c143.tar.gz stela-e72c336d01b32bee304c8a2989e2335fcc26c143.tar.bz2 stela-e72c336d01b32bee304c8a2989e2335fcc26c143.zip | |
Android improvements, update deps
Signed-off-by: Andrew Opalach <andrew@akon.city>
| -rw-r--r-- | src/window_glfm.c | 33 | ||||
| -rw-r--r-- | src/window_glfm.h | 2 | ||||
| -rw-r--r-- | src/window_wayland.c | 9 | ||||
| -rw-r--r-- | src/window_win32.c | 14 | ||||
| -rw-r--r-- | subprojects/glfm.wrap | 2 | ||||
| -rw-r--r-- | subprojects/libalabaster.wrap | 4 | ||||
| -rw-r--r-- | subprojects/libnaunet.wrap | 4 | ||||
| -rw-r--r-- | subprojects/packagefiles/glfm/android_additions.diff | 59 | ||||
| -rw-r--r-- | subprojects/packagefiles/glfm/android_get_egl_internal.diff (renamed from subprojects/packagefiles/glfm/get_egl_internal.diff) | 0 |
9 files changed, 106 insertions, 21 deletions
diff --git a/src/window_glfm.c b/src/window_glfm.c index 7fdb26a..cc1979d 100644 --- a/src/window_glfm.c +++ b/src/window_glfm.c @@ -78,9 +78,9 @@ static s32 jniGetFDFromFileDescriptor(JNIEnv *jni, jobject fileDescriptor) return glfm__getJavaField(jni, fileDescriptor, "descriptor", "I", Int); } -static u32 parse_intent(ANativeActivity *activity, JNIEnv *jni) +static s32 parse_intent(ANativeActivity *activity, JNIEnv *jni) { - u32 main_arg_index = 0; + s32 main_arg_index = 0; jobject intent = glfm__callJavaMethod(jni, activity->clazz, "getIntent", "()Landroid/content/Intent;", Object); @@ -132,7 +132,7 @@ static u32 parse_intent(ANativeActivity *activity, JNIEnv *jni) str *arg; al_array_foreach_ptr(global.args, i, arg) { if (al_str_eq(arg, &main_arg)) { - main_arg_index = i; + main_arg_index = (s32)i; break; } } @@ -228,6 +228,12 @@ static void onSurfaceCreated(GLFMDisplay *display, s32 width, s32 height) api == GLFMRenderingAPIOpenGLES3 ? "3.0" : "2.0"); } +static void onSurfaceRefresh(GLFMDisplay *display) +{ + struct stl_window_glfm *glfm = (struct stl_window_glfm *)glfmGetUserData(display); + glfm->w.pending_refresh = true; +} + static void onDraw(GLFMDisplay *display) { struct stl_window_glfm *glfm = (struct stl_window_glfm *)glfmGetUserData(display); @@ -272,10 +278,20 @@ static bool onKey(GLFMDisplay *display, GLFMKeyCode key, GLFMKeyAction action, s (void)modifiers; u8 mapped_action = glfm_to_stela_button_action[action]; switch (key) { + case GLFMKeyCodeArrowRight: + stl_window_send_key_event(&glfm->w, mapped_action, STELA_KEY_RIGHT); + break; + case GLFMKeyCodeArrowLeft: + stl_window_send_key_event(&glfm->w, mapped_action, STELA_KEY_LEFT); + break; case GLFMKeyCodeVolumeUp: return stl_window_send_key_immediate_event(&glfm->w, mapped_action, STELA_KEY_RIGHT); case GLFMKeyCodeVolumeDown: return stl_window_send_key_immediate_event(&glfm->w, mapped_action, STELA_KEY_LEFT); + case GLFMKeyCodeMediaSelect: + case GLFMKeyCodeMediaPlayPause: + stl_window_send_key_event(&glfm->w, mapped_action, STELA_KEY_SPACE); + break; case GLFMKeyCodeNavigationBack: return false; default: @@ -330,6 +346,7 @@ void glfmMain(GLFMDisplay *display) glfmSetDisplayChrome(display, GLFMUserInterfaceChromeNone); glfmSetMultitouchEnabled(display, true); glfmSetSurfaceCreatedFunc(display, onSurfaceCreated); + glfmSetSurfaceRefreshFunc(display, onSurfaceRefresh); glfmSetRenderFunc(display, onDraw); glfmSetSurfaceDestroyedFunc(display, onSurfaceDestroyed); glfmSetOrientationChangedFunc(display, onOrientationChanged); @@ -388,7 +405,8 @@ static void window_glfm_poll(struct stl_window *window, bool block) #ifdef STELA_PAUSE static void window_glfm_wake(struct stl_window *window) { - (void)window; + struct stl_window_glfm *glfm = (struct stl_window_glfm *)window; + glfm->w.pending_refresh = true; } #endif #endif @@ -401,8 +419,7 @@ static void window_glfm_process_events(struct stl_window *window) #ifdef STELA_PAUSE static bool window_glfm_should_refresh(struct stl_window *window) { - (void)window; - return true; + return stl_should_refresh_common(window); } #endif @@ -418,6 +435,7 @@ static bool window_glfm_gl_loader_load(void *window) return true; } +// Always current. static bool window_glfm_gl_make_current(void *window) { (void)window; @@ -431,8 +449,7 @@ static void window_glfm_gl_release_current(void *window) static void window_glfm_gl_swap_buffers(void *window) { - struct stl_window_glfm *glfm = (struct stl_window_glfm *)window; - (void)glfm; + (void)window; glfmSwapBuffers(global.display); } #endif diff --git a/src/window_glfm.h b/src/window_glfm.h index b9c6c69..5214292 100644 --- a/src/window_glfm.h +++ b/src/window_glfm.h @@ -8,7 +8,7 @@ struct stl_glfm_global { GLFMDisplay *display; bool did_main; array(str) args; - u32 main_arg_index; + s32 main_arg_index; GLFMInterfaceOrientation orientation; }; diff --git a/src/window_wayland.c b/src/window_wayland.c index e019002..e22c206 100644 --- a/src/window_wayland.c +++ b/src/window_wayland.c @@ -920,6 +920,7 @@ static struct stl_monitor_wayland *monitor_from_name(const char *name) return NULL; } +#ifndef NAUNET_NEEDS_STDIO_ASSIST // https://wayland-book.com/surfaces/shared-memory.html static s32 create_shm_file(char *name, char *suffix) { @@ -990,6 +991,14 @@ static struct xdg_toplevel_icon_v1 *create_icon(struct stl_window_wayland *wl, u return icon; } +#else +static struct xdg_toplevel_icon_v1 *create_icon(struct stl_window_wayland *wl, u32 size) +{ + (void)wl; + (void)size; + return NULL; +} +#endif static bool create_toplevel(struct stl_window_wayland *wl, s32 scale, const char *name, const char *app_id) { diff --git a/src/window_win32.c b/src/window_win32.c index adc6e26..bf9ad87 100644 --- a/src/window_win32.c +++ b/src/window_win32.c @@ -303,9 +303,9 @@ bool stl_global_init(bool skip_graphics) al_array_init(Global.monitors); EnumDisplayMonitors(NULL, NULL, MonitorInfoProc, 0); - Global.Cursors[STELA_CURSOR_NORMAL] = LoadCursor(NULL, IDC_ARROW); - Global.Cursors[STELA_CURSOR_MOVE] = LoadCursor(NULL, IDC_HAND); - Global.Cursors[STELA_CURSOR_CROSSHAIR] = LoadCursor(NULL, IDC_CROSS); + Global.Cursors[STELA_CURSOR_NORMAL] = LoadCursorW(NULL, IDC_ARROW); + Global.Cursors[STELA_CURSOR_MOVE] = LoadCursorW(NULL, IDC_HAND); + Global.Cursors[STELA_CURSOR_CROSSHAIR] = LoadCursorW(NULL, IDC_CROSS); set_keycodes_for_win32(); @@ -328,8 +328,8 @@ s32 stl_swallow_main(u32 argc, str *argv, s32 (*main)(u32, str *, void *), void WindowClass.cbSize = sizeof(WindowClass); WindowClass.lpfnWndProc = &ServiceWndProc; WindowClass.hInstance = Global.ModuleHandle; - WindowClass.hIcon = LoadIconA(NULL, IDI_APPLICATION); - WindowClass.hCursor = LoadCursorA(NULL, IDC_ARROW); + WindowClass.hIcon = LoadIconW(NULL, IDI_APPLICATION); + WindowClass.hCursor = LoadCursorW(NULL, IDC_ARROW); WindowClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); WindowClass.lpszClassName = L"DTCClass"; RegisterClassExW(&WindowClass); @@ -949,9 +949,9 @@ static bool window_win32_create_window(struct stl_window *window, u32 width, u32 WindowClass.hInstance = Global.ModuleHandle; HANDLE Icon = LoadImageW(Global.ModuleHandle, L"CMV_ICON", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED); - if (!Icon) Icon = LoadIconA(NULL, IDI_APPLICATION); + if (!Icon) Icon = LoadIconW(NULL, IDI_APPLICATION); WindowClass.hIcon = Icon; - WindowClass.hCursor = LoadCursorA(NULL, IDC_ARROW); + WindowClass.hCursor = LoadCursorW(NULL, IDC_ARROW); WindowClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); WindowClass.lpszClassName = DangerousClass; // https://learn.microsoft.com/en-us/windows/win32/winmsg/window-class-styles diff --git a/subprojects/glfm.wrap b/subprojects/glfm.wrap index e5e5d84..e2ce200 100644 --- a/subprojects/glfm.wrap +++ b/subprojects/glfm.wrap @@ -4,5 +4,5 @@ url = https://github.com/brackeen/glfm.git revision = 4130516b06a625266d1f71a174bfe80656920907 depth = 1 patch_directory = glfm -diff_files = glfm/get_egl_internal.diff +diff_files = glfm/android_get_egl_internal.diff, glfm/android_additions.diff method = cmake diff --git a/subprojects/libalabaster.wrap b/subprojects/libalabaster.wrap index 5323646..7b8a7bf 100644 --- a/subprojects/libalabaster.wrap +++ b/subprojects/libalabaster.wrap @@ -1,5 +1,5 @@ [wrap-git] -directory = libalabaster-b617e3c +directory = libalabaster-81a7b4b url = https://git.akon.city/libalabaster.git -revision = b617e3ccb25a0ac3c22f8c02722c8108b2f78d6e +revision = 81a7b4ba322aeddf52207fdcd2213e5f5a493471 depth = 1 diff --git a/subprojects/libnaunet.wrap b/subprojects/libnaunet.wrap index 2c321b0..7217ef4 100644 --- a/subprojects/libnaunet.wrap +++ b/subprojects/libnaunet.wrap @@ -1,5 +1,5 @@ [wrap-git] -directory = libnaunet-3a51988 +directory = libnaunet-36f09a0 url = https://git.akon.city/libnaunet.git -revision = 3a51988d764d54723288dc31a1779ece44cac1e9 +revision = 36f09a0c35657f5c7379624c8a2463aafb953bd4 depth = 1 diff --git a/subprojects/packagefiles/glfm/android_additions.diff b/subprojects/packagefiles/glfm/android_additions.diff new file mode 100644 index 0000000..81b1059 --- /dev/null +++ b/subprojects/packagefiles/glfm/android_additions.diff @@ -0,0 +1,59 @@ +diff --git a/include/glfm.h b/include/glfm.h +index ceace39..cf7ee70 100644 +--- a/include/glfm.h ++++ b/include/glfm.h +@@ -272,6 +272,8 @@ typedef enum { + GLFMKeyCodePrintScreen = 0x9B, ///< Print Screen or System Request key. + GLFMKeyCodeScrollLock = 0x9C, + GLFMKeyCodePause = 0x9D, ///< Pause/Break key. ++ GLFMKeyCodeVolumeUp = 0x9E, ++ GLFMKeyCodeVolumeDown = 0x9F, + + GLFMKeyCodeNumLock = 0xA0, ///< NumLock key ("clear" on Apple platforms). + GLFMKeyCodeNumpadDecimal = 0xA1, +@@ -890,7 +892,7 @@ ANativeActivity *glfmAndroidGetActivity(void) GLFM_DEPRECATED("Use glfmGetAndroi + /// The returned `ANativeActivity` may be invalidated when the surface is destroyed. If a reference to the + /// `ANativeActivity` is kept, call this function again to get an updated reference in ``GLFMSurfaceCreatedFunc`` or + /// ``GLFMAppFocusFunc``. +-void *glfmGetAndroidActivity(const GLFMDisplay *display); ++void *glfmGetAndroidActivity(const GLFMDisplay *display, void **jni); + + #endif // GLFM_EXPOSE_NATIVE_ANDROID + +diff --git a/src/glfm_android.c b/src/glfm_android.c +index 12f3c63..6f77d0a 100644 +--- a/src/glfm_android.c ++++ b/src/glfm_android.c +@@ -1117,6 +1117,8 @@ static bool glfm__onKeyEvent(GLFMPlatformData *platformData, AInputEvent *event) + [AKEYCODE_DPAD_RIGHT] = GLFMKeyCodeArrowRight, + + [AKEYCODE_POWER] = GLFMKeyCodePower, ++ [AKEYCODE_VOLUME_UP] = GLFMKeyCodeVolumeUp, ++ [AKEYCODE_VOLUME_DOWN] = GLFMKeyCodeVolumeDown, + + [AKEYCODE_A] = GLFMKeyCodeA, + [AKEYCODE_B] = GLFMKeyCodeB, +@@ -1215,6 +1217,9 @@ static bool glfm__onKeyEvent(GLFMPlatformData *platformData, AInputEvent *event) + [AKEYCODE_NUMPAD_DOT] = GLFMKeyCodeNumpadDecimal, + [AKEYCODE_NUMPAD_ENTER] = GLFMKeyCodeNumpadEnter, + [AKEYCODE_NUMPAD_EQUALS] = GLFMKeyCodeNumpadEqual, ++ ++ [AKEYCODE_DPAD_CENTER] = GLFMKeyCodeMediaSelect, ++ [AKEYCODE_MEDIA_PLAY_PAUSE] = GLFMKeyCodeMediaPlayPause + }; + + GLFMKeyCode keyCode = GLFMKeyCodeUnknown; +@@ -2794,11 +2799,12 @@ ANativeActivity *glfmAndroidGetActivity(void) { + return platformDataGlobal->activity; + } + +-void *glfmGetAndroidActivity(const GLFMDisplay *display) { ++void *glfmGetAndroidActivity(const GLFMDisplay *display, void **jni) { + if (!display || !display->platformData) { + return NULL; + } + GLFMPlatformData *platformData = display->platformData; ++ *jni = platformData->jniEnv; + return platformData->activity; + } + diff --git a/subprojects/packagefiles/glfm/get_egl_internal.diff b/subprojects/packagefiles/glfm/android_get_egl_internal.diff index 3c9098c..3c9098c 100644 --- a/subprojects/packagefiles/glfm/get_egl_internal.diff +++ b/subprojects/packagefiles/glfm/android_get_egl_internal.diff |