summaryrefslogtreecommitdiff
path: root/uisimulator
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 /uisimulator
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
Diffstat (limited to 'uisimulator')
-rw-r--r--uisimulator/common/sim_tasks.c58
-rw-r--r--uisimulator/common/sim_tasks.h1
-rw-r--r--uisimulator/common/stubs.c7
3 files changed, 59 insertions, 7 deletions
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