aboutsummaryrefslogtreecommitdiff
path: root/patches/0010-yp3-ignore-the-power-on-key-until-it-is-released.patch
blob: 75611921863e039416d693123fb7b65591e4b070 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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