Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void usb_connection_gui(void)
- {
- bool done = false;
- struct gui_synclist lists;
- int i, action, selection;
- FOR_NB_SCREENS(i)
- viewportmanager_theme_enable(i, true, NULL);
- gui_synclist_init(&lists, usblist_get_name, NULL,
- false, 1, NULL);
- gui_synclist_set_title(&lists, "Usb Connection Menu", Icon_Rockbox);
- gui_synclist_set_icon_callback(&lists, usblist_get_icon);
- gui_synclist_set_nb_items(&lists, 10);
- gui_synclist_select_item(&lists, 0);
- while (!done)
- {
- gui_synclist_draw(&lists);
- list_do_action(CONTEXT_STD, HZ,
- &lists, &action, LIST_WRAP_UNLESS_HELD);
- switch (action)
- {
- case ACTION_STD_OK:
- /* fix the toggles or run the screen */
- selection = gui_synclist_get_sel_pos(&lists);
- switch (selection)
- {
- case 0: /* run! */
- done = true;
- break;
- case 1: /* battery only */
- break;
- case 2: /* headers, do nothing */
- case 5:
- break;
- case 3: /* storage modes */
- case 4:
- if (!items[selection].enabled)
- {
- items[selection==3?4:3].enabled = false;
- items[selection].enabled = true;
- }
- else
- items[selection].enabled = false;
- break;
- case 6: /* HID modes */
- case 7:
- case 8:
- case 9:
- if (!items[selection].enabled)
- {
- for (i=6;i<=9;i++)
- {
- if (i == selection)
- items[i].enabled = true;
- else
- items[i].enabled = false;
- }
- }
- else
- items[selection].enabled = false;
- break;
- } /* switch() */
- break;
- } /* switch(action) */
- }
- #ifdef USB_ENABLE_STORAGE
- usb_core_enable_driver(USB_DRIVER_MASS_STORAGE, items[3].enabled);
- splashf(HZ, "MSC %s", items[3].enabled?"Yes":"no");
- #endif
- #ifdef USB_ENABLE_HID
- bool hid_enabled = false;
- for (i=6;i<=9;i++)
- {
- if (items[i].enabled)
- hid_enabled = true;
- }
- usb_core_enable_driver(USB_DRIVER_HID, hid_enabled);
- splashf(HZ, "HID %s", hid_enabled?"Yes":"no");
- #endif
- #ifdef USB_ENABLE_CHARGING_ONLY
- usb_core_enable_driver(USB_DRIVER_CHARGING_ONLY, false);
- #endif
- usb_core_enable_driver(USB_DRIVER_MTP, items[4].enabled);
- splashf(HZ, "MTP %s", items[4].enabled?"Yes":"no");
- FOR_NB_SCREENS(i)
- viewportmanager_theme_undo(i, true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement