shithub: m8c

Download patch

ref: 997a030e208314e5538689d7362cccad61718164
parent: 9c57156dd2c15840b5b9efd0af9a0c36c1e5523a
author: laamaa <jonne.kokkonen@gmail.com>
date: Thu Sep 11 18:10:31 EDT 2025

update gamepad handling: replace GUIDE button logic with BACK button (Guide button not available in iOS :((), adjust hold duration, read config file on ios as well

--- a/README.md
+++ b/README.md
@@ -236,7 +236,7 @@
 
 - **How to open:**
   - Keyboard: press F1.
-  - Gamepad: hold the Guide/Home button for about 1 second.
+  - Gamepad: hold the Back/Select button for about 2 seconds.
 - **How to navigate:**
   - Move: Up/Down arrows or D‑pad.
   - Activate/enter: Enter/Space or South/A.
--- a/src/events.c
+++ b/src/events.c
@@ -8,7 +8,7 @@
 #include <SDL3/SDL.h>
 #include <SDL3/SDL_events.h>
 
-static Uint64 g_guide_pressed_at = 0;
+static Uint64 g_back_pressed_at = 0;
 
 SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event) {
   struct app_context *ctx = appstate;
@@ -83,8 +83,8 @@
 
   case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
     // Start measuring hold time for GUIDE; trigger handled on button up after 1s hold
-    if (event->gbutton.button == SDL_GAMEPAD_BUTTON_GUIDE) {
-      g_guide_pressed_at = SDL_GetTicks();
+    if (event->gbutton.button == SDL_GAMEPAD_BUTTON_BACK) {
+      g_back_pressed_at = SDL_GetTicks();
       return ret_val;
     }
 
@@ -97,12 +97,12 @@
 
   case SDL_EVENT_GAMEPAD_BUTTON_UP:
     // Handle GUIDE release: toggle settings if held for at least 1 second
-    if (event->gbutton.button == SDL_GAMEPAD_BUTTON_GUIDE) {
-      Uint64 now = SDL_GetTicks();
-      if (g_guide_pressed_at != 0 && (now - g_guide_pressed_at) >= 1000) {
+    if (event->gbutton.button == SDL_GAMEPAD_BUTTON_BACK) {
+      const Uint64 now = SDL_GetTicks();
+      if (g_back_pressed_at != 0 && (now - g_back_pressed_at) >= 2000) {
         settings_toggle_open();
       }
-      g_guide_pressed_at = 0;
+      g_back_pressed_at = 0;
       return ret_val;
     }
 
--- a/src/main.c
+++ b/src/main.c
@@ -94,10 +94,9 @@
   if (TARGET_OS_IOS == 1) {
     // Predefined settings for iOS
     conf.init_fullscreen = 1;
-  } else {
-    // On other platforms, read config normally
-    config_read(&conf);
   }
+  config_read(&conf);
+
   return conf;
 }
 
--