summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/window_glfm.c33
-rw-r--r--src/window_glfm.h2
-rw-r--r--src/window_wayland.c9
-rw-r--r--src/window_win32.c14
4 files changed, 42 insertions, 16 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