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 switch (global_settings
.dircache
)
195 if (!dircache_is_enabled())
196 splash(HZ
*2, ID2P(LANG_PLEASE_REBOOT
));
199 if (dircache_is_enabled())
207 MENUITEM_SETTING(dircache
, &global_settings
.dircache
, dircache_callback
);
209 #if defined(HAVE_DIRCACHE) || defined(HAVE_DISK_STORAGE)
210 MAKE_MENU(disk_menu
, ID2P(LANG_DISK_MENU
), 0, Icon_NOICON
,
211 #ifdef HAVE_DISK_STORAGE
221 MENUITEM_SETTING(poweroff
, &global_settings
.poweroff
, NULL
);
224 MENUITEM_SETTING(max_files_in_dir
, &global_settings
.max_files_in_dir
, NULL
);
225 MENUITEM_SETTING(max_files_in_playlist
, &global_settings
.max_files_in_playlist
, NULL
);
226 MAKE_MENU(limits_menu
, ID2P(LANG_LIMITS_MENU
), 0, Icon_NOICON
,
227 &max_files_in_dir
, &max_files_in_playlist
);
231 #if CONFIG_CODEC == SWCODEC
232 MENUITEM_SETTING(keyclick
, &global_settings
.keyclick
, NULL
);
233 MENUITEM_SETTING(keyclick_repeats
, &global_settings
.keyclick_repeats
, NULL
);
234 MAKE_MENU(keyclick_menu
, ID2P(LANG_KEYCLICK
), 0, Icon_NOICON
,
235 &keyclick
, &keyclick_repeats
);
239 #if CONFIG_CODEC == MAS3507D
240 void dac_line_in(bool enable
);
241 static int linein_callback(int action
,const struct menu_item_ex
*this_item
)
246 case ACTION_EXIT_MENUITEM
: /* on exit */
248 dac_line_in(global_settings
.line_in
);
254 MENUITEM_SETTING(line_in
, &global_settings
.line_in
, linein_callback
);
257 MENUITEM_SETTING(car_adapter_mode
, &global_settings
.car_adapter_mode
, NULL
);
259 #ifdef IPOD_ACCESSORY_PROTOCOL
260 MENUITEM_SETTING(serial_bitrate
, &global_settings
.serial_bitrate
, NULL
);
262 #ifdef HAVE_ACCESSORY_SUPPLY
263 MENUITEM_SETTING(accessory_supply
, &global_settings
.accessory_supply
, NULL
);
265 #ifdef HAVE_LINEOUT_POWEROFF
266 MENUITEM_SETTING(lineout_onoff
, &global_settings
.lineout_active
, NULL
);
268 MENUITEM_SETTING(start_screen
, &global_settings
.start_in_screen
, NULL
);
269 #ifdef USB_ENABLE_HID
270 MENUITEM_SETTING(usb_hid
, &global_settings
.usb_hid
, NULL
);
271 MENUITEM_SETTING(usb_keypad_mode
, &global_settings
.usb_keypad_mode
, NULL
);
274 #ifdef HAVE_MORSE_INPUT
275 MENUITEM_SETTING(morse_input
, &global_settings
.morse_input
, NULL
);
278 #ifdef HAVE_BUTTON_LIGHT
279 MENUITEM_SETTING(buttonlight_timeout
, &global_settings
.buttonlight_timeout
, NULL
);
282 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
283 MENUITEM_SETTING(buttonlight_brightness
, &global_settings
.buttonlight_brightness
, NULL
);
286 #ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING
287 MENUITEM_SETTING(touchpad_sensitivity
, &global_settings
.touchpad_sensitivity
, NULL
);
290 MAKE_MENU(system_menu
, ID2P(LANG_SYSTEM
),
293 #if (BATTERY_CAPACITY_INC > 0) || (BATTERY_TYPES_COUNT > 1)
296 #if defined(HAVE_DIRCACHE) || defined(HAVE_DISK_STORAGE)
301 #ifdef HAVE_MORSE_INPUT
304 #if CONFIG_CODEC == MAS3507D
310 #ifdef IPOD_ACCESSORY_PROTOCOL
313 #ifdef HAVE_ACCESSORY_SUPPLY
316 #ifdef HAVE_LINEOUT_POWEROFF
319 #ifdef HAVE_BUTTON_LIGHT
320 &buttonlight_timeout
,
322 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
323 &buttonlight_brightness
,
325 #if CONFIG_CODEC == SWCODEC
328 #ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING
329 &touchpad_sensitivity
,
331 #ifdef USB_ENABLE_HID
338 /***********************************/
341 /***********************************/
343 static int bmark_callback(int action
,const struct menu_item_ex
*this_item
)
348 case ACTION_EXIT_MENUITEM
: /* on exit */
349 if(global_settings
.autocreatebookmark
== BOOKMARK_RECENT_ONLY_YES
||
350 global_settings
.autocreatebookmark
== BOOKMARK_RECENT_ONLY_ASK
)
352 if(global_settings
.usemrb
== BOOKMARK_NO
)
353 global_settings
.usemrb
= BOOKMARK_YES
;
360 MENUITEM_SETTING(autocreatebookmark
,
361 &global_settings
.autocreatebookmark
, bmark_callback
);
362 MENUITEM_SETTING(autoupdatebookmark
, &global_settings
.autoupdatebookmark
, NULL
);
363 MENUITEM_SETTING(autoloadbookmark
, &global_settings
.autoloadbookmark
, NULL
);
364 MENUITEM_SETTING(usemrb
, &global_settings
.usemrb
, NULL
);
365 MAKE_MENU(bookmark_settings_menu
, ID2P(LANG_BOOKMARK_SETTINGS
), 0,
367 &autocreatebookmark
, &autoupdatebookmark
, &autoloadbookmark
, &usemrb
);
369 /***********************************/
371 /***********************************/
372 /* AUTORESUME MENU */
374 #if CONFIG_CODEC == SWCODEC
376 static int autoresume_callback(int action
, const struct menu_item_ex
*this_item
)
380 if (action
== ACTION_EXIT_MENUITEM
/* on exit */
381 && global_settings
.autoresume_enable
382 && !tagcache_is_usable())
384 static const char *lines
[] = {ID2P(LANG_TAGCACHE_BUSY
),
385 ID2P(LANG_TAGCACHE_FORCE_UPDATE
)};
386 static const struct text_message message
= {lines
, 2};
388 if (gui_syncyesno_run(&message
, NULL
, NULL
) == YESNO_YES
)
389 tagcache_rebuild_with_splash();
394 static int autoresume_nexttrack_callback(int action
,
395 const struct menu_item_ex
*this_item
)
398 static int oldval
= 0;
401 case ACTION_ENTER_MENUITEM
:
402 oldval
= global_settings
.autoresume_automatic
;
404 case ACTION_EXIT_MENUITEM
:
405 if (global_settings
.autoresume_automatic
== AUTORESUME_NEXTTRACK_CUSTOM
406 && kbd_input ((char*) &global_settings
.autoresume_paths
,
409 global_settings
.autoresume_automatic
= oldval
;
415 MENUITEM_SETTING(autoresume_enable
, &global_settings
.autoresume_enable
,
416 autoresume_callback
);
417 MENUITEM_SETTING(autoresume_automatic
, &global_settings
.autoresume_automatic
,
418 autoresume_nexttrack_callback
);
420 MAKE_MENU(autoresume_menu
, ID2P(LANG_AUTORESUME
),
422 &autoresume_enable
, &autoresume_automatic
);
424 #endif /* CONFIG_CODEC == SWCODEC */
425 #endif /* HAVE_TAGCACHE */
426 /* AUTORESUME MENU */
427 /***********************************/
429 /***********************************/
431 static int talk_callback(int action
,const struct menu_item_ex
*this_item
);
432 MENUITEM_SETTING(talk_menu_item
, &global_settings
.talk_menu
, NULL
);
433 MENUITEM_SETTING(talk_dir_item
, &global_settings
.talk_dir
, NULL
);
434 MENUITEM_SETTING(talk_dir_clip_item
, &global_settings
.talk_dir_clip
, talk_callback
);
435 MENUITEM_SETTING(talk_file_item
, &global_settings
.talk_file
, NULL
);
436 MENUITEM_SETTING(talk_file_clip_item
, &global_settings
.talk_file_clip
, talk_callback
);
437 static int talk_callback(int action
,const struct menu_item_ex
*this_item
)
439 static int oldval
= 0;
442 case ACTION_ENTER_MENUITEM
:
443 oldval
= global_settings
.talk_file_clip
;
445 case ACTION_EXIT_MENUITEM
:
446 #ifdef HAVE_CROSSFADE
447 audio_set_crossfade(global_settings
.crossfade
);
449 if (this_item
== &talk_dir_clip_item
)
451 if (!oldval
&& global_settings
.talk_file_clip
)
453 /* force reload if newly talking thumbnails,
454 because the clip presence is cached only if enabled */
461 MENUITEM_SETTING(talk_filetype_item
, &global_settings
.talk_filetype
, NULL
);
462 MENUITEM_SETTING(talk_battery_level_item
,
463 &global_settings
.talk_battery_level
, NULL
);
464 MAKE_MENU(voice_settings_menu
, ID2P(LANG_VOICE
), 0, Icon_Voice
,
465 &talk_menu_item
, &talk_dir_item
, &talk_dir_clip_item
,
466 &talk_file_item
, &talk_file_clip_item
, &talk_filetype_item
,
467 &talk_battery_level_item
);
469 /***********************************/
472 /***********************************/
475 MENUITEM_SETTING(hotkey_wps_item
, &global_settings
.hotkey_wps
, NULL
);
476 MENUITEM_SETTING(hotkey_tree_item
, &global_settings
.hotkey_tree
, NULL
);
477 MAKE_MENU(hotkey_menu
, ID2P(LANG_HOTKEY
), 0, Icon_NOICON
,
478 &hotkey_wps_item
, &hotkey_tree_item
);
479 #endif /*have_hotkey */
481 /***********************************/
484 /***********************************/
487 static struct browse_folder_info langs
= { LANG_DIR
, SHOW_LNG
};
489 MENUITEM_FUNCTION(browse_langs
, MENU_FUNC_USEPARAM
, ID2P(LANG_LANGUAGE
),
490 browse_folder
, (void*)&langs
, NULL
, Icon_Language
);
492 MAKE_MENU(settings_menu_item
, ID2P(LANG_GENERAL_SETTINGS
), 0,
493 Icon_General_settings_menu
,
494 &playlist_settings
, &file_menu
,
498 &display_menu
, &system_menu
,
499 &bookmark_settings_menu
,
501 #if CONFIG_CODEC == SWCODEC
505 &browse_langs
, &voice_settings_menu
,
511 /***********************************/