summaryrefslogtreecommitdiff
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 @@
29 29
30#undef AMS_OF_SIZE 30#undef AMS_OF_SIZE
31 31
32#undef HAVE_MULTIDRIVE
33#undef NUM_DRIVES
34#undef HAVE_HOTSWAP
35#undef HAVE_HOTSWAP_STORAGE_AS_MAIN 32#undef HAVE_HOTSWAP_STORAGE_AS_MAIN
36#undef HAVE_STORAGE_FLUSH 33#undef HAVE_STORAGE_FLUSH
37 34
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;
56#else 56#else
57#define USB_KEY SDLK_u 57#define USB_KEY SDLK_u
58#endif 58#endif
59#define EXT_KEY SDLK_e
59 60
60#if defined(IRIVER_H100_SERIES) || defined (IRIVER_H300_SERIES) 61#if defined(IRIVER_H100_SERIES) || defined (IRIVER_H300_SERIES)
61int _remote_type=REMOTETYPE_H100_LCD; 62int _remote_type=REMOTETYPE_H100_LCD;
@@ -322,6 +323,12 @@ static void button_event(int key, bool pressed)
322 sim_trigger_usb(usb_connected); 323 sim_trigger_usb(usb_connected);
323 } 324 }
324 return; 325 return;
326#ifdef HAVE_MULTIDRIVE
327 case EXT_KEY:
328 if (!pressed)
329 sim_trigger_external(!storage_present(1));
330 return;
331#endif
325#endif 332#endif
326#if (CONFIG_PLATFORM & PLATFORM_PANDORA) 333#if (CONFIG_PLATFORM & PLATFORM_PANDORA)
327 case SDLK_LCTRL: 334 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 {
40 SIM_SCREENDUMP, 40 SIM_SCREENDUMP,
41 SIM_USB_INSERTED, 41 SIM_USB_INSERTED,
42 SIM_USB_EXTRACTED, 42 SIM_USB_EXTRACTED,
43#ifdef HAVE_MULTIDRIVE
44 SIM_EXT_INSERTED,
45 SIM_EXT_EXTRACTED,
46#endif
43}; 47};
44 48
45void sim_thread(void) 49void sim_thread(void)
@@ -95,6 +99,15 @@ void sim_thread(void)
95 * do it here anyway but don't depend on the acks */ 99 * do it here anyway but don't depend on the acks */
96 queue_broadcast(SYS_USB_DISCONNECTED, 0); 100 queue_broadcast(SYS_USB_DISCONNECTED, 0);
97 break; 101 break;
102#ifdef HAVE_MULTIDRIVE
103 case SIM_EXT_INSERTED:
104 case SIM_EXT_EXTRACTED:
105 queue_broadcast(ev.id == SIM_EXT_INSERTED ?
106 SYS_HOTSWAP_INSERTED : SYS_HOTSWAP_EXTRACTED, 0);
107 sleep(HZ/20);
108 queue_broadcast(SYS_FS_CHANGED, 0);
109 break;
110#endif /* HAVE_MULTIDRIVE */
98 default: 111 default:
99 DEBUGF("sim_tasks: unhandled event: %ld\n", ev.id); 112 DEBUGF("sim_tasks: unhandled event: %ld\n", ev.id);
100 break; 113 break;
@@ -155,3 +168,48 @@ void usb_wait_for_disconnect(struct event_queue *q)
155 return; 168 return;
156 } 169 }
157} 170}
171
172#ifdef HAVE_MULTIDRIVE
173static bool is_ext_inserted;
174
175void sim_trigger_external(bool inserted)
176{
177 if (inserted)
178 queue_post(&sim_queue, SIM_EXT_INSERTED, 0);
179 else
180 queue_post(&sim_queue, SIM_EXT_EXTRACTED, 0);
181 is_ext_inserted = inserted;
182}
183
184bool hostfs_present(int drive)
185{
186 return drive > 0 ? is_ext_inserted : true;
187}
188
189bool hostfs_removable(int drive)
190{
191 return drive > 0;
192}
193
194#ifdef HAVE_MULTIVOLUME
195bool volume_removable(int volume)
196{
197 /* volume == drive for now */
198 return hostfs_removable(volume);
199}
200
201bool volume_present(int volume)
202{
203 /* volume == drive for now */
204 return hostfs_present(volume);
205}
206#endif
207
208#if (CONFIG_STORAGE & STORAGE_MMC)
209bool mmc_touched(void)
210{
211 return hostfs_present(1);
212}
213#endif
214
215#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 @@
28void sim_tasks_init(void); 28void sim_tasks_init(void);
29void sim_trigger_screendump(void); 29void sim_trigger_screendump(void);
30void sim_trigger_usb(bool inserted); 30void sim_trigger_usb(bool inserted);
31void sim_trigger_external(bool inserted);
31 32
32#endif 33#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)
395 (void)en; 395 (void)en;
396} 396}
397#endif 397#endif
398
399#if (CONFIG_STORAGE & STORAGE_MMC)
400bool mmc_touched(void)
401{
402 return false;
403}
404#endif