summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2024-05-30 12:12:29 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2024-05-30 12:12:29 -0400
commitaca41be3cae3278f102671f9b914d0c9f2b8920d (patch)
treeb4294b9a4c8164786cd685b722072557aac47e48
parent7ec1151dddb0b15796113e41284757408e94a63f (diff)
downloadrockbox-aca41be3ca.tar.gz
rockbox-aca41be3ca.zip
[Feature] Simulator add headphone and lineout toggling
Change-Id: I0b019414643e5c9037c0128093488da49e1a4c0d
-rw-r--r--firmware/target/hosted/sdl/button-sdl.c20
-rw-r--r--uisimulator/common/sim_tasks.c30
-rw-r--r--uisimulator/common/sim_tasks.h3
-rw-r--r--uisimulator/common/stubs.c14
4 files changed, 52 insertions, 15 deletions
diff --git a/firmware/target/hosted/sdl/button-sdl.c b/firmware/target/hosted/sdl/button-sdl.c
index dea25bff27..ccfb557014 100644
--- a/firmware/target/hosted/sdl/button-sdl.c
+++ b/firmware/target/hosted/sdl/button-sdl.c
@@ -320,6 +320,26 @@ static void button_event(int key, bool pressed)
sim_trigger_usb(usb_connected);
}
return;
+#ifdef HAVE_HEADPHONE_DETECTION
+ case SDLK_p:
+ if (!pressed)
+ {
+ static bool hp_connected = false;
+ hp_connected = !hp_connected;
+ sim_trigger_hp(hp_connected);
+ }
+ return;
+#endif
+#ifdef HAVE_LINEOUT_DETECTION
+ case SDLK_l:
+ if (!pressed)
+ {
+ static bool lo_connected = false;
+ lo_connected = !lo_connected;
+ sim_trigger_lo(lo_connected);
+ }
+ return;
+#endif
#ifdef HAVE_MULTIDRIVE
case EXT_KEY:
if (!pressed)
diff --git a/uisimulator/common/sim_tasks.c b/uisimulator/common/sim_tasks.c
index c53b9990fd..03e68c111f 100644
--- a/uisimulator/common/sim_tasks.c
+++ b/uisimulator/common/sim_tasks.c
@@ -144,6 +144,32 @@ void sim_trigger_screendump(void)
queue_post(&sim_queue, SIM_SCREENDUMP, 0);
}
+#ifdef HAVE_HEADPHONE_DETECTION
+static bool is_hp_inserted = true;
+bool headphones_inserted(void)
+{
+ return is_hp_inserted;
+}
+void sim_trigger_hp(bool inserted)
+{
+ is_hp_inserted = inserted;
+ DEBUGF("Headphone %s.\n", inserted ? "inserted":"removed");
+}
+#endif
+
+#ifdef HAVE_LINEOUT_DETECTION
+static bool is_lo_inserted = false;
+bool lineout_inserted(void)
+{
+ return is_lo_inserted;
+}
+void sim_trigger_lo(bool inserted)
+{
+ is_lo_inserted = inserted;
+ DEBUGF("Lineout %s.\n", inserted ? "inserted":"removed");
+}
+#endif
+
static bool is_usb_inserted;
void sim_trigger_usb(bool inserted)
{
@@ -157,8 +183,10 @@ void sim_trigger_usb(bool inserted)
{
send_event(SYS_EVENT_USB_EXTRACTED, NULL);
queue_post(&sim_queue, SIM_USB_EXTRACTED, 0);
+ DEBUGF("USB %s.\n", inserted ? "inserted":"removed");
}
is_usb_inserted = inserted;
+
}
int usb_detect(void)
@@ -204,6 +232,8 @@ void sim_trigger_external(bool inserted)
queue_post(&sim_queue, SIM_EXT_INSERTED, drive);
else
queue_post(&sim_queue, SIM_EXT_EXTRACTED, drive);
+
+ DEBUGF("Ext %s\n", inserted ? "inserted":"removed");
}
bool hostfs_present(int drive)
diff --git a/uisimulator/common/sim_tasks.h b/uisimulator/common/sim_tasks.h
index 2bcd09d114..689a4a8566 100644
--- a/uisimulator/common/sim_tasks.h
+++ b/uisimulator/common/sim_tasks.h
@@ -29,5 +29,6 @@ void sim_tasks_init(void);
void sim_trigger_screendump(void);
void sim_trigger_usb(bool inserted);
void sim_trigger_external(bool inserted);
-
+void sim_trigger_hp(bool inserted);
+void sim_trigger_lo(bool inserted);
#endif
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c
index 5c8e03d6f8..bce7e07227 100644
--- a/uisimulator/common/stubs.c
+++ b/uisimulator/common/stubs.c
@@ -172,20 +172,6 @@ bool rtc_check_alarm_flag(void)
}
#endif
-#ifdef HAVE_HEADPHONE_DETECTION
-bool headphones_inserted(void)
-{
- return true;
-}
-#endif
-
-#ifdef HAVE_LINEOUT_DETECTION
-bool lineout_inserted(void)
-{
- return false;
-}
-#endif
-
#ifdef HAVE_SPDIF_POWER
void spdif_power_enable(bool on)
{