From 605e2d0e90b335897cc1e29c575a27dabc778491 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Thu, 13 Jan 2011 10:56:23 +0000 Subject: [PATCH] New Touchscreen region type... 'mute' which un/mutes volume without pausing playback git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29046 a1c6a512-1295-4272-9138-f99709370657 --- apps/action.h | 1 + apps/gui/skin_engine/skin_parser.c | 12 ++++++++++-- apps/gui/skin_engine/wps_internals.h | 5 ++++- apps/gui/statusbar-skinned.c | 19 ++++++++++++++++++- apps/gui/wps.c | 15 ++++++++++++++- apps/radio/radio_skin.c | 19 ++++++++++++++++++- manual/appendix/wps_tags.tex | 1 + 7 files changed, 66 insertions(+), 6 deletions(-) diff --git a/apps/action.h b/apps/action.h index 260d868ba9..e664c03fdf 100644 --- a/apps/action.h +++ b/apps/action.h @@ -246,6 +246,7 @@ enum { * being used, but are nice additions if the touchscreen is used */ ACTION_TOUCH_SHUFFLE, ACTION_TOUCH_REPMODE, + ACTION_TOUCH_MUTE, #endif /* USB HID codes */ diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 5a90873d86..e23f84207e 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -880,6 +880,7 @@ static const struct touchaction touchactions[] = { { "resumeplayback", ACTION_TREE_WPS}, /* returns to previous music, WPS/FM */ /* not really WPS specific, but no equivilant ACTION_STD_* */ {"voldown", ACTION_WPS_VOLDOWN}, {"volup", ACTION_WPS_VOLUP}, + {"mute", ACTION_TOUCH_MUTE }, /* generic settings changers */ {"setting_inc", ACTION_SETTINGS_INC}, {"setting_dec", ACTION_SETTINGS_DEC}, @@ -945,7 +946,7 @@ static int parse_touchregion(struct skin_element *element, region->wvp = curr_vp; region->armed = false; region->reverse_bar = false; - region->extradata = NULL; + region->data = NULL; action = element->params[4].data.text; strcpy(temp, action); @@ -998,7 +999,7 @@ static int parse_touchregion(struct skin_element *element, break; if (j==nb_settings) return WPS_ERROR_INVALID_PARAM; - region->extradata = (void*)&settings[j]; + region->data = (void*)&settings[j]; } } break; @@ -1011,6 +1012,13 @@ static int parse_touchregion(struct skin_element *element, if (!item) return WPS_ERROR_INVALID_PARAM; add_to_ll_chain(&wps_data->touchregions, item); + + if (region->action == ACTION_TOUCH_MUTE) + { + region->value = global_settings.volume; + } + + return 0; } #endif diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index 24edde7b93..02585f22b2 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h @@ -196,7 +196,10 @@ struct touchregion { int action; /* action this button will return */ bool armed; /* A region is armed on press. Only armed regions are triggered on repeat or release. */ - void* extradata; + union { /* Extra data, action dependant */ + void* data; + int value; + }; }; #endif diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c index a5c751b804..ad89f7a6cb 100644 --- a/apps/gui/statusbar-skinned.c +++ b/apps/gui/statusbar-skinned.c @@ -39,6 +39,10 @@ #include "font.h" #include "icon.h" #include "option_select.h" +#ifdef HAVE_TOUCHSCREEN +#include "sound.h" +#include "misc.h" +#endif /* initial setup of wps_data */ static int update_delay = DEFAULT_UPDATE_DELAY; @@ -296,10 +300,23 @@ int sb_touch_to_button(int context) case ACTION_SETTINGS_INC: case ACTION_SETTINGS_DEC: { - const struct settings_list *setting = region->extradata; + const struct settings_list *setting = region->data; option_select_next_val(setting, button == ACTION_SETTINGS_DEC, true); } return ACTION_REDRAW; + case ACTION_TOUCH_MUTE: + { + const int min_vol = sound_min(SOUND_VOLUME); + if (global_settings.volume == min_vol) + global_settings.volume = region->value; + else + { + region->value = global_settings.volume; + global_settings.volume = min_vol; + } + setvol(); + } + return ACTION_REDRAW; /* TODO */ } return button; diff --git a/apps/gui/wps.c b/apps/gui/wps.c index 7d633ad4e8..e528380576 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c @@ -242,10 +242,23 @@ static int skintouch_to_wps(struct wps_data *data) case ACTION_SETTINGS_INC: case ACTION_SETTINGS_DEC: { - const struct settings_list *setting = region->extradata; + const struct settings_list *setting = region->data; option_select_next_val(setting, button == ACTION_SETTINGS_DEC, true); } return ACTION_REDRAW; + case ACTION_TOUCH_MUTE: + { + const int min_vol = sound_min(SOUND_VOLUME); + if (global_settings.volume == min_vol) + global_settings.volume = region->value; + else + { + region->value = global_settings.volume; + global_settings.volume = min_vol; + } + setvol(); + } + return ACTION_REDRAW; } return button; } diff --git a/apps/radio/radio_skin.c b/apps/radio/radio_skin.c index 68314d62b5..2e329230f7 100644 --- a/apps/radio/radio_skin.c +++ b/apps/radio/radio_skin.c @@ -32,6 +32,10 @@ #include "appevents.h" #include "statusbar-skinned.h" #include "option_select.h" +#ifdef HAVE_TOUCHSCREEN +#include "sound.h" +#include "misc.h" +#endif char* default_radio_skin(enum screen_type screen) @@ -120,10 +124,23 @@ int fms_do_button_loop(bool update_screen) case ACTION_SETTINGS_INC: case ACTION_SETTINGS_DEC: { - const struct settings_list *setting = region->extradata; + const struct settings_list *setting = region->data; option_select_next_val(setting, button == ACTION_SETTINGS_DEC, true); } return ACTION_REDRAW; + case ACTION_TOUCH_MUTE: + { + const int min_vol = sound_min(SOUND_VOLUME); + if (global_settings.volume == min_vol) + global_settings.volume = region->value; + else + { + region->value = global_settings.volume; + global_settings.volume = min_vol; + } + setvol(); + } + return ACTION_REDRAW; } #endif return button; diff --git a/manual/appendix/wps_tags.tex b/manual/appendix/wps_tags.tex index f6b348bbb1..92bc209728 100644 --- a/manual/appendix/wps_tags.tex +++ b/manual/appendix/wps_tags.tex @@ -615,6 +615,7 @@ display cycling round the defined sublines. See \item[pitch] -- Open the pitchscreen. \item[voldown] -- Decrease the volume by one step. \item[volup] -- Increase the volume by one step. + \item[mute] -- Un/Mute playback. \end{description} \section{Last Touchscreen Press}