aboutsummaryrefslogtreecommitdiff
path: root/patches/0010-yp3-ignore-the-power-on-key-until-it-is-released.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/0010-yp3-ignore-the-power-on-key-until-it-is-released.patch')
-rw-r--r--patches/0010-yp3-ignore-the-power-on-key-until-it-is-released.patch82
1 files changed, 82 insertions, 0 deletions
diff --git a/patches/0010-yp3-ignore-the-power-on-key-until-it-is-released.patch b/patches/0010-yp3-ignore-the-power-on-key-until-it-is-released.patch
new file mode 100644
index 0000000..7561192
--- /dev/null
+++ b/patches/0010-yp3-ignore-the-power-on-key-until-it-is-released.patch
@@ -0,0 +1,82 @@
+From a7863201fe90839c670bfe6373e7d88360518835 Mon Sep 17 00:00:00 2001
+From: YP3 Audiobook <noreply@example.invalid>
+Date: Fri, 27 Nov 2026 00:30:35 +0000
+Subject: [PATCH 10/11] yp3: ignore the power-on key until it is released
+
+The player powers on with a long press of Center. Held until Rockbox
+was up (~5 s), its release reached Now Playing as Center, play/pause,
+and paused the book being resumed: the boots that "loaded the book
+twice" were these (with rewind-on-pause seeking during the load), and
+the book then stayed paused.
+
+A key held when the buttons start is now ignored until it is released.
+
+---
+ apps/main.c | 15 +++++++++++++++
+ firmware/export/config/yp3.h | 3 +++
+ 2 files changed, 18 insertions(+)
+
+diff --git a/apps/main.c b/apps/main.c
+index ca189b07..6034408f 100644
+--- a/apps/main.c
++++ b/apps/main.c
+@@ -31,6 +31,7 @@
+ #include "led.h"
+ #include "../kernel-internal.h"
+ #include "button.h"
++#include "action.h"
+ #include "core_keymap.h"
+ #include "tree.h"
+ #include "filetypes.h"
+@@ -167,6 +168,9 @@
+ // #define AUTOROCK VIEWERS_DATA_DIR"/imageviewer.rock"
+ // #define AUTOROCK_ARG "/jpegs/sample.jpg"
+
++#ifdef IGNORE_POWER_ON_KEY
++static bool key_held_at_boot;
++#endif
+ static void init(void);
+ /* main(), and various functions called by main() and init() may be
+ * be INIT_ATTR. These functions must not be called after the final call
+@@ -258,6 +262,12 @@ int main(void)
+ #endif
+ #ifdef HAVE_BATTLOG
+ battlog_start();
++#endif
++#ifdef IGNORE_POWER_ON_KEY
++ /* Ignore the power-on key until it is released (its press and
++ release may already be queued; other events are kept) */
++ if (key_held_at_boot)
++ action_wait_for_release();
+ #endif
+ CHART(">root_menu");
+ root_menu();
+@@ -592,6 +602,11 @@ static void init(void)
+ backlight_init();
+
+ button_init();
++#ifdef IGNORE_POWER_ON_KEY
++ /* The key that powered the player on, if still held: Center on the
++ YP3, whose release (play/pause) paused the book while it loaded */
++ key_held_at_boot = (button_read_device() & BUTTON_MAIN) != 0;
++#endif
+
+ /* Don't initialize power management here if it could incorrectly
+ * measure battery voltage, and it's not needed for charging. */
+diff --git a/firmware/export/config/yp3.h b/firmware/export/config/yp3.h
+index ec0ccdab..4624ad2d 100644
+--- a/firmware/export/config/yp3.h
++++ b/firmware/export/config/yp3.h
+@@ -26,6 +26,9 @@
+ * carries on, otherwise playback pauses, writes are dropped instead of
+ * panicking, and the player powers off a few seconds later. */
+ #define HAVE_SD_CARD_SWAP
++/* The key held to power on (Center) is ignored until released: its
++ * release toggled play/pause while a resumed book loaded (apps/main.c) */
++#define IGNORE_POWER_ON_KEY
+ #endif
+ #define CONFIG_CPU SL6801
+ #define CPU_FREQ 192000000
+--
+2.56.1
+