1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 Jonathan Gordon
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
32 #include "sound_menu.h"
33 #include "exported_menus.h"
40 #include "powermgmt.h"
41 #if CONFIG_CODEC == SWCODEC
47 #include "quickscreen.h"
52 /***********************************/
56 static void tagcache_rebuild_with_splash(void)
59 splash(HZ
*2, ID2P(LANG_TAGCACHE_FORCE_UPDATE_SPLASH
));
62 static void tagcache_update_with_splash(void)
65 splash(HZ
*2, ID2P(LANG_TAGCACHE_FORCE_UPDATE_SPLASH
));
68 #ifdef HAVE_TC_RAMCACHE
69 MENUITEM_SETTING(tagcache_ram
, &global_settings
.tagcache_ram
, NULL
);
71 MENUITEM_SETTING(tagcache_autoupdate
, &global_settings
.tagcache_autoupdate
, NULL
);
72 MENUITEM_FUNCTION(tc_init
, 0, ID2P(LANG_TAGCACHE_FORCE_UPDATE
),
73 (int(*)(void))tagcache_rebuild_with_splash
,
74 NULL
, NULL
, Icon_NOICON
);
75 MENUITEM_FUNCTION(tc_update
, 0, ID2P(LANG_TAGCACHE_UPDATE
),
76 (int(*)(void))tagcache_update_with_splash
,
77 NULL
, NULL
, Icon_NOICON
);
78 MENUITEM_SETTING(runtimedb
, &global_settings
.runtimedb
, NULL
);
79 MENUITEM_FUNCTION(tc_export
, 0, ID2P(LANG_TAGCACHE_EXPORT
),
80 (int(*)(void))tagtree_export
, NULL
,
82 MENUITEM_FUNCTION(tc_import
, 0, ID2P(LANG_TAGCACHE_IMPORT
),
83 (int(*)(void))tagtree_import
, NULL
,
85 MAKE_MENU(tagcache_menu
, ID2P(LANG_TAGCACHE
), 0, Icon_NOICON
,
86 #ifdef HAVE_TC_RAMCACHE
89 &tagcache_autoupdate
, &tc_init
, &tc_update
, &runtimedb
,
90 &tc_export
, &tc_import
);
91 #endif /* HAVE_TAGCACHE */
93 /***********************************/
95 /***********************************/
97 static int fileview_callback(int action
,const struct menu_item_ex
*this_item
);
98 MENUITEM_SETTING(sort_case
, &global_settings
.sort_case
, NULL
);
99 MENUITEM_SETTING(sort_dir
, &global_settings
.sort_dir
, fileview_callback
);
100 MENUITEM_SETTING(sort_file
, &global_settings
.sort_file
, fileview_callback
);
101 MENUITEM_SETTING(interpret_numbers
, &global_settings
.interpret_numbers
, fileview_callback
);
102 MENUITEM_SETTING(dirfilter
, &global_settings
.dirfilter
, NULL
);
103 MENUITEM_SETTING(show_filename_ext
, &global_settings
.show_filename_ext
, NULL
);
104 MENUITEM_SETTING(browse_current
, &global_settings
.browse_current
, NULL
);
105 #ifdef HAVE_LCD_BITMAP
106 MENUITEM_SETTING(show_path_in_browser
, &global_settings
.show_path_in_browser
, NULL
);
108 static int clear_start_directory(void)
110 strcpy(global_settings
.start_directory
, "/");
112 splash(HZ
, ID2P(LANG_RESET_DONE_CLEAR
));
115 MENUITEM_FUNCTION(clear_start_directory_item
, 0, ID2P(LANG_RESET_START_DIR
),
116 clear_start_directory
, NULL
, NULL
, Icon_file_view_menu
);
117 static int fileview_callback(int action
,const struct menu_item_ex
*this_item
)
120 int *variable
= this_item
->variable
;
123 case ACTION_ENTER_MENUITEM
: /* on entering an item */
126 case ACTION_EXIT_MENUITEM
: /* on exit */
127 if (*variable
!= oldval
)
128 reload_directory(); /* force reload if this has changed */
134 MAKE_MENU(file_menu
, ID2P(LANG_FILE
), 0, Icon_file_view_menu
,
135 &sort_case
, &sort_dir
, &sort_file
, &interpret_numbers
,
136 &dirfilter
, &show_filename_ext
, &browse_current
,
137 #ifdef HAVE_LCD_BITMAP
138 &show_path_in_browser
,
140 &clear_start_directory_item
143 /***********************************/
146 /***********************************/
150 #if BATTERY_CAPACITY_INC > 0
151 MENUITEM_SETTING(battery_capacity
, &global_settings
.battery_capacity
, NULL
);
153 #if BATTERY_TYPES_COUNT > 1
154 MENUITEM_SETTING(battery_type
, &global_settings
.battery_type
, NULL
);
156 #ifdef HAVE_USB_CHARGING_ENABLE
157 static int usbcharging_callback(int action
,const struct menu_item_ex
*this_item
)
162 case ACTION_EXIT_MENUITEM
: /* on exit */
163 usb_charging_enable(global_settings
.usb_charging
);
168 MENUITEM_SETTING(usb_charging
, &global_settings
.usb_charging
, usbcharging_callback
);
169 #endif /* HAVE_USB_CHARGING_ENABLE */
170 MAKE_MENU(battery_menu
, ID2P(LANG_BATTERY_MENU
), 0, Icon_NOICON
,
171 #if defined(BATTERY_CAPACITY_INC) && BATTERY_CAPACITY_INC > 0
174 #if BATTERY_TYPES_COUNT > 1
177 #ifdef HAVE_USB_CHARGING_ENABLE
182 #ifdef HAVE_DISK_STORAGE
183 MENUITEM_SETTING(disk_spindown
, &global_settings
.disk_spindown
, NULL
);
186 static int dircache_callback(int action
,const struct menu_item_ex
*this_item
)
191 case ACTION_EXIT_MENUITEM
: /* on exit */
192 if (global_settings
.dircache
&& !dircache_is_enabled())
194 if (dircache_build(0) < 0)
195 splash(HZ
*2, ID2P(LANG_PLEASE_REBOOT
));
197 else if (!global_settings
.dircache
&& dircache_is_enabled())
205 MENUITEM_SETTING(dircache
, &global_settings
.dircache
, dircache_callback
);
207 #if defined(HAVE_DIRCACHE) || defined(HAVE_DISK_STORAGE)
208 MAKE_MENU(disk_menu
, ID2P(LANG_DISK_MENU
), 0, Icon_NOICON
,
209 #ifdef HAVE_DISK_STORAGE
219 MENUITEM_SETTING(poweroff
, &global_settings
.poweroff
, NULL
);
222 MENUITEM_SETTING(max_files_in_dir
, &global_settings
.max_files_in_dir
, NULL
);
223 MENUITEM_SETTING(max_files_in_playlist
, &global_settings
.max_files_in_playlist
, NULL
);
224 MAKE_MENU(limits_menu
, ID2P(LANG_LIMITS_MENU
), 0, Icon_NOICON
,
225 &max_files_in_dir
, &max_files_in_playlist
);
229 #if CONFIG_CODEC == SWCODEC
230 MENUITEM_SETTING(keyclick
, &global_settings
.keyclick
, NULL
);
231 MENUITEM_SETTING(keyclick_repeats
, &global_settings
.keyclick_repeats
, NULL
);
232 #ifdef HAVE_HARDWARE_CLICK
233 MENUITEM_SETTING(keyclick_hardware
, &global_settings
.keyclick_hardware
, NULL
);
234 MAKE_MENU(keyclick_menu
, ID2P(LANG_KEYCLICK
), 0, Icon_NOICON
,
235 &keyclick
, &keyclick_hardware
, &keyclick_repeats
);
237 MAKE_MENU(keyclick_menu
, ID2P(LANG_KEYCLICK
), 0, Icon_NOICON
,
238 &keyclick
, &keyclick_repeats
);
243 #if CONFIG_CODEC == MAS3507D
244 void dac_line_in(bool enable
);
245 static int linein_callback(int action
,const struct menu_item_ex
*this_item
)
250 case ACTION_EXIT_MENUITEM
: /* on exit */
252 dac_line_in(global_settings
.line_in
);
258 MENUITEM_SETTING(line_in
, &global_settings
.line_in
, linein_callback
);
261 MENUITEM_SETTING(car_adapter_mode
, &global_settings
.car_adapter_mode
, NULL
);
263 #ifdef IPOD_ACCESSORY_PROTOCOL
264 MENUITEM_SETTING(serial_bitrate
, &global_settings
.serial_bitrate
, NULL
);
266 #ifdef HAVE_ACCESSORY_SUPPLY
267 MENUITEM_SETTING(accessory_supply
, &global_settings
.accessory_supply
, NULL
);
269 #ifdef HAVE_LINEOUT_POWEROFF
270 MENUITEM_SETTING(lineout_onoff
, &global_settings
.lineout_active
, NULL
);
272 MENUITEM_SETTING(start_screen
, &global_settings
.start_in_screen
, NULL
);
273 #ifdef USB_ENABLE_HID
274 MENUITEM_SETTING(usb_hid
, &global_settings
.usb_hid
, NULL
);
275 MENUITEM_SETTING(usb_keypad_mode
, &global_settings
.usb_keypad_mode
, NULL
);
277 #if defined(USB_ENABLE_STORAGE) && defined(HAVE_MULTIDRIVE)
278 MENUITEM_SETTING(usb_skip_first_drive
, &global_settings
.usb_skip_first_drive
, NULL
);
281 #ifdef HAVE_MORSE_INPUT
282 MENUITEM_SETTING(morse_input
, &global_settings
.morse_input
, NULL
);
285 #ifdef HAVE_BUTTON_LIGHT
286 MENUITEM_SETTING(buttonlight_timeout
, &global_settings
.buttonlight_timeout
, NULL
);
289 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
290 MENUITEM_SETTING(buttonlight_brightness
, &global_settings
.buttonlight_brightness
, NULL
);
293 #ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING
294 MENUITEM_SETTING(touchpad_sensitivity
, &global_settings
.touchpad_sensitivity
, NULL
);
297 MAKE_MENU(system_menu
, ID2P(LANG_SYSTEM
),
300 #if (BATTERY_CAPACITY_INC > 0) || (BATTERY_TYPES_COUNT > 1)
303 #if defined(HAVE_DIRCACHE) || defined(HAVE_DISK_STORAGE)
308 #ifdef HAVE_MORSE_INPUT
311 #if CONFIG_CODEC == MAS3507D
317 #ifdef IPOD_ACCESSORY_PROTOCOL
320 #ifdef HAVE_ACCESSORY_SUPPLY
323 #ifdef HAVE_LINEOUT_POWEROFF
326 #ifdef HAVE_BUTTON_LIGHT
327 &buttonlight_timeout
,
329 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
330 &buttonlight_brightness
,
332 #if CONFIG_CODEC == SWCODEC
335 #ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING
336 &touchpad_sensitivity
,
338 #ifdef USB_ENABLE_HID
342 #if defined(USB_ENABLE_STORAGE) && defined(HAVE_MULTIDRIVE)
343 &usb_skip_first_drive
,
348 /***********************************/
351 /***********************************/
353 static int bmark_callback(int action
,const struct menu_item_ex
*this_item
)
358 case ACTION_EXIT_MENUITEM
: /* on exit */
359 if(global_settings
.autocreatebookmark
== BOOKMARK_RECENT_ONLY_YES
||
360 global_settings
.autocreatebookmark
== BOOKMARK_RECENT_ONLY_ASK
)
362 if(global_settings
.usemrb
== BOOKMARK_NO
)
363 global_settings
.usemrb
= BOOKMARK_YES
;
370 MENUITEM_SETTING(autocreatebookmark
,
371 &global_settings
.autocreatebookmark
, bmark_callback
);
372 MENUITEM_SETTING(autoupdatebookmark
, &global_settings
.autoupdatebookmark
, NULL
);
373 MENUITEM_SETTING(autoloadbookmark
, &global_settings
.autoloadbookmark
, NULL
);
374 MENUITEM_SETTING(usemrb
, &global_settings
.usemrb
, NULL
);
375 MAKE_MENU(bookmark_settings_menu
, ID2P(LANG_BOOKMARK_SETTINGS
), 0,
377 &autocreatebookmark
, &autoupdatebookmark
, &autoloadbookmark
, &usemrb
);
379 /***********************************/
381 /***********************************/
382 /* AUTORESUME MENU */
384 #if CONFIG_CODEC == SWCODEC
386 static int autoresume_callback(int action
, const struct menu_item_ex
*this_item
)
390 if (action
== ACTION_EXIT_MENUITEM
/* on exit */
391 && global_settings
.autoresume_enable
392 && !tagcache_is_usable())
394 static const char *lines
[] = {ID2P(LANG_TAGCACHE_BUSY
),
395 ID2P(LANG_TAGCACHE_FORCE_UPDATE
)};
396 static const struct text_message message
= {lines
, 2};
398 if (gui_syncyesno_run(&message
, NULL
, NULL
) == YESNO_YES
)
399 tagcache_rebuild_with_splash();
404 static int autoresume_nexttrack_callback(int action
,
405 const struct menu_item_ex
*this_item
)
408 static int oldval
= 0;
411 case ACTION_ENTER_MENUITEM
:
412 oldval
= global_settings
.autoresume_automatic
;
414 case ACTION_EXIT_MENUITEM
:
415 if (global_settings
.autoresume_automatic
== AUTORESUME_NEXTTRACK_CUSTOM
416 && kbd_input ((char*) &global_settings
.autoresume_paths
,
419 global_settings
.autoresume_automatic
= oldval
;
425 MENUITEM_SETTING(autoresume_enable
, &global_settings
.autoresume_enable
,
426 autoresume_callback
);
427 MENUITEM_SETTING(autoresume_automatic
, &global_settings
.autoresume_automatic
,
428 autoresume_nexttrack_callback
);
430 MAKE_MENU(autoresume_menu
, ID2P(LANG_AUTORESUME
),
432 &autoresume_enable
, &autoresume_automatic
);
434 #endif /* CONFIG_CODEC == SWCODEC */
435 #endif /* HAVE_TAGCACHE */
436 /* AUTORESUME MENU */
437 /***********************************/
439 /***********************************/
441 static int talk_callback(int action
,const struct menu_item_ex
*this_item
);
442 MENUITEM_SETTING(talk_menu_item
, &global_settings
.talk_menu
, NULL
);
443 MENUITEM_SETTING(talk_dir_item
, &global_settings
.talk_dir
, NULL
);
444 MENUITEM_SETTING(talk_dir_clip_item
, &global_settings
.talk_dir_clip
, talk_callback
);
445 MENUITEM_SETTING(talk_file_item
, &global_settings
.talk_file
, NULL
);
446 MENUITEM_SETTING(talk_file_clip_item
, &global_settings
.talk_file_clip
, talk_callback
);
447 static int talk_callback(int action
,const struct menu_item_ex
*this_item
)
449 static int oldval
= 0;
452 case ACTION_ENTER_MENUITEM
:
453 oldval
= global_settings
.talk_file_clip
;
455 case ACTION_EXIT_MENUITEM
:
456 #ifdef HAVE_CROSSFADE
457 audio_set_crossfade(global_settings
.crossfade
);
459 if (this_item
== &talk_dir_clip_item
)
461 if (!oldval
&& global_settings
.talk_file_clip
)
463 /* force reload if newly talking thumbnails,
464 because the clip presence is cached only if enabled */
471 MENUITEM_SETTING(talk_filetype_item
, &global_settings
.talk_filetype
, NULL
);
472 MENUITEM_SETTING(talk_battery_level_item
,
473 &global_settings
.talk_battery_level
, NULL
);
474 MAKE_MENU(voice_settings_menu
, ID2P(LANG_VOICE
), 0, Icon_Voice
,
475 &talk_menu_item
, &talk_dir_item
, &talk_dir_clip_item
,
476 &talk_file_item
, &talk_file_clip_item
, &talk_filetype_item
,
477 &talk_battery_level_item
);
479 /***********************************/
482 /***********************************/
485 MENUITEM_SETTING(hotkey_wps_item
, &global_settings
.hotkey_wps
, NULL
);
486 MENUITEM_SETTING(hotkey_tree_item
, &global_settings
.hotkey_tree
, NULL
);
487 MAKE_MENU(hotkey_menu
, ID2P(LANG_HOTKEY
), 0, Icon_NOICON
,
488 &hotkey_wps_item
, &hotkey_tree_item
);
489 #endif /*have_hotkey */
491 /***********************************/
494 /***********************************/
497 static struct browse_folder_info langs
= { LANG_DIR
, SHOW_LNG
};
499 MENUITEM_FUNCTION(browse_langs
, MENU_FUNC_USEPARAM
, ID2P(LANG_LANGUAGE
),
500 browse_folder
, (void*)&langs
, NULL
, Icon_Language
);
502 MAKE_MENU(settings_menu_item
, ID2P(LANG_GENERAL_SETTINGS
), 0,
503 Icon_General_settings_menu
,
504 &playlist_settings
, &file_menu
,
508 &display_menu
, &system_menu
,
509 &bookmark_settings_menu
,
511 #if CONFIG_CODEC == SWCODEC
515 &browse_langs
, &voice_settings_menu
,
521 /***********************************/