summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2014-02-21 11:25:07 +0100
committerThomas Martitz <kugel@rockbox.org>2014-02-23 20:23:51 +0100
commitfacbaab1953f9ab355fb3a3259dc0acbaabd9cc5 (patch)
treec1fa92517f9eca705f66a1b88667aa41b3299fe3
parent77f19f75eb3661b3e3966da20effa2631ed380f1 (diff)
downloadrockbox-facbaab1953f9ab355fb3a3259dc0acbaabd9cc5.tar.gz
rockbox-facbaab1953f9ab355fb3a3259dc0acbaabd9cc5.zip
simulator: Simulate external storage for HAVE_MULTIDRIVE.
The virtual external storage can be inserted/extracted with the e key. This has little effect because there is no way to access the storage (yet, a later commit will change this). Except on ondio where the mmc needs to be extracted before entering USB (like on real target). Change-Id: I523402832f3b4ae71e0603b281aba4fb8592a897
-rw-r--r--firmware/export/config/sim.h3
-rw-r--r--firmware/target/hosted/sdl/button-sdl.c7
-rw-r--r--uisimulator/common/sim_tasks.c58
-rw-r--r--uisimulator/common/sim_tasks.h1
-rw-r--r--uisimulator/common/stubs.c7
5 files changed, 66 insertions, 10 deletions
diff --git a/firmware/export/config/sim.h b/firmware/export/config/sim.h
index cec500e75d..2f819b733e 100644
--- a/firmware/export/config/sim.h
+++ b/firmware/export/config/sim.h
@@ -29,9 +29,6 @@
#undef AMS_OF_SIZE
-#undef HAVE_MULTIDRIVE
-#undef NUM_DRIVES
-#undef HAVE_HOTSWAP
#undef HAVE_HOTSWAP_STORAGE_AS_MAIN
#undef HAVE_STORAGE_FLUSH
diff --git a/firmware/target/hosted/sdl/button-sdl.c b/firmware/target/hosted/sdl/button-sdl.c
index 1ed07c153c..9677f1dd23 100644
--- a/firmware/target/hosted/sdl/button-sdl.c
+++ b/firmware/target/hosted/sdl/button-sdl.c
@@ -56,6 +56,7 @@ static int mouse_coords = 0;
#else
#define USB_KEY SDLK_u
#endif
+#define EXT_KEY SDLK_e
#if defined(IRIVER_H100_SERIES) || defined (IRIVER_H300_SERIES)
int _remote_type=REMOTETYPE_H100_LCD;
@@ -322,6 +323,12 @@ static void button_event(int key, bool pressed)
sim_trigger_usb(usb_connected);
}
return;
+#ifdef HAVE_MULTIDRIVE
+ case EXT_KEY:
+ if (!pressed)
+ sim_trigger_external(!storage_present(1));
+ return;
+#endif
#endif
#if (CONFIG_PLATFORM & PLATFORM_PANDORA)
case SDLK_LCTRL:
diff --git a/uisimulator/common/sim_tasks.c b/uisimulator/common/sim_tasks.c
index 46e893b437..1299a69302 100644
--- a/uisimulator/common/sim_tasks.c
+++ b/uisimulator/common/sim_tasks.c
@@ -40,6 +40,10 @@ enum {
SIM_SCREENDUMP,
SIM_USB_INSERTED,
SIM_USB_EXTRACTED,
+#ifdef HAVE_MULTIDRIVE
+ SIM_EXT_INSERTED,
+ SIM_EXT_EXTRACTED,
+#endif
};
void sim_thread(void)
@@ -95,6 +99,15 @@ void sim_thread(void)
* do it here anyway but don't depend on the acks */
queue_broadcast(SYS_USB_DISCONNECTED, 0);
break;
+#ifdef HAVE_MULTIDRIVE
+ case SIM_EXT_INSERTED:
+ case SIM_EXT_EXTRACTED:
+ queue_broadcast(ev.id == SIM_EXT_INSERTED ?
+ SYS_HOTSWAP_INSERTED : SYS_HOTSWAP_EXTRACTED, 0);
+ sleep(HZ/20);
+ queue_broadcast(SYS_FS_CHANGED, 0);
+ break;
+#endif /* HAVE_MULTIDRIVE */
default:
DEBUGF("sim_tasks: unhandled event: %ld\n", ev.id);
break;
@@ -155,3 +168,48 @@ void usb_wait_for_disconnect(struct event_queue *q)
return;
}
}
+
+#ifdef HAVE_MULTIDRIVE
+static bool is_ext_inserted;
+
+void sim_trigger_external(bool inserted)
+{
+ if (inserted)
+ queue_post(&sim_queue, SIM_EXT_INSERTED, 0);
+ else
+ queue_post(&sim_queue, SIM_EXT_EXTRACTED, 0);
+ is_ext_inserted = inserted;
+}
+
+bool hostfs_present(int drive)
+{
+ return drive > 0 ? is_ext_inserted : true;
+}
+
+bool hostfs_removable(int drive)
+{
+ return drive > 0;
+}
+
+#ifdef HAVE_MULTIVOLUME
+bool volume_removable(int volume)
+{
+ /* volume == drive for now */
+ return hostfs_removable(volume);
+}
+
+bool volume_present(int volume)
+{
+ /* volume == drive for now */
+ return hostfs_present(volume);
+}
+#endif
+
+#if (CONFIG_STORAGE & STORAGE_MMC)
+bool mmc_touched(void)
+{
+ return hostfs_present(1);
+}
+#endif
+
+#endif
diff --git a/uisimulator/common/sim_tasks.h b/uisimulator/common/sim_tasks.h
index dfecd4448e..2bcd09d114 100644
--- a/uisimulator/common/sim_tasks.h
+++ b/uisimulator/common/sim_tasks.h
@@ -28,5 +28,6 @@
void sim_tasks_init(void);
void sim_trigger_screendump(void);
void sim_trigger_usb(bool inserted);
+void sim_trigger_external(bool inserted);
#endif
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c
index 480c2a90d8..18f60ce6b3 100644
--- a/uisimulator/common/stubs.c
+++ b/uisimulator/common/stubs.c
@@ -395,10 +395,3 @@ void touchpad_enable_device(bool en)
(void)en;
}
#endif
-
-#if (CONFIG_STORAGE & STORAGE_MMC)
-bool mmc_touched(void)
-{
- return false;
-}
-#endif