Advertisement
Guest User

Untitled

a guest
May 6th, 2010
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.18 KB | None | 0 0
  1.  
  2. void usb_connection_gui(void)
  3. {
  4. bool done = false;
  5. struct gui_synclist lists;
  6. int i, action, selection;
  7. FOR_NB_SCREENS(i)
  8. viewportmanager_theme_enable(i, true, NULL);
  9.  
  10.  
  11. gui_synclist_init(&lists, usblist_get_name, NULL,
  12. false, 1, NULL);
  13. gui_synclist_set_title(&lists, "Usb Connection Menu", Icon_Rockbox);
  14. gui_synclist_set_icon_callback(&lists, usblist_get_icon);
  15. gui_synclist_set_nb_items(&lists, 10);
  16. gui_synclist_select_item(&lists, 0);
  17.  
  18.  
  19. while (!done)
  20. {
  21. gui_synclist_draw(&lists);
  22. list_do_action(CONTEXT_STD, HZ,
  23. &lists, &action, LIST_WRAP_UNLESS_HELD);
  24. switch (action)
  25. {
  26. case ACTION_STD_OK:
  27. /* fix the toggles or run the screen */
  28. selection = gui_synclist_get_sel_pos(&lists);
  29. switch (selection)
  30. {
  31. case 0: /* run! */
  32. done = true;
  33. break;
  34. case 1: /* battery only */
  35. break;
  36. case 2: /* headers, do nothing */
  37. case 5:
  38. break;
  39. case 3: /* storage modes */
  40. case 4:
  41. if (!items[selection].enabled)
  42. {
  43. items[selection==3?4:3].enabled = false;
  44. items[selection].enabled = true;
  45. }
  46. else
  47. items[selection].enabled = false;
  48. break;
  49. case 6: /* HID modes */
  50. case 7:
  51. case 8:
  52. case 9:
  53. if (!items[selection].enabled)
  54. {
  55. for (i=6;i<=9;i++)
  56. {
  57. if (i == selection)
  58. items[i].enabled = true;
  59. else
  60. items[i].enabled = false;
  61. }
  62. }
  63. else
  64. items[selection].enabled = false;
  65. break;
  66. } /* switch() */
  67. break;
  68. } /* switch(action) */
  69. }
  70. #ifdef USB_ENABLE_STORAGE
  71. usb_core_enable_driver(USB_DRIVER_MASS_STORAGE, items[3].enabled);
  72. splashf(HZ, "MSC %s", items[3].enabled?"Yes":"no");
  73. #endif
  74. #ifdef USB_ENABLE_HID
  75. bool hid_enabled = false;
  76. for (i=6;i<=9;i++)
  77. {
  78. if (items[i].enabled)
  79. hid_enabled = true;
  80. }
  81. usb_core_enable_driver(USB_DRIVER_HID, hid_enabled);
  82. splashf(HZ, "HID %s", hid_enabled?"Yes":"no");
  83. #endif
  84. #ifdef USB_ENABLE_CHARGING_ONLY
  85. usb_core_enable_driver(USB_DRIVER_CHARGING_ONLY, false);
  86. #endif
  87. usb_core_enable_driver(USB_DRIVER_MTP, items[4].enabled);
  88. splashf(HZ, "MTP %s", items[4].enabled?"Yes":"no");
  89.  
  90. FOR_NB_SCREENS(i)
  91. viewportmanager_theme_undo(i, true);
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement