2010-06-21 06:04:19 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 - Jonathan Gordon
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "action.h"
|
|
|
|
#include "skin_engine.h"
|
|
|
|
#include "wps_internals.h"
|
2011-03-01 07:26:11 +00:00
|
|
|
#include "misc.h"
|
|
|
|
#include "option_select.h"
|
|
|
|
#include "sound.h"
|
2011-03-01 12:31:03 +00:00
|
|
|
#include "settings_list.h"
|
2011-03-22 09:31:45 +00:00
|
|
|
#include "wps.h"
|
|
|
|
#include "lang.h"
|
|
|
|
#include "splash.h"
|
|
|
|
#include "playlist.h"
|
2012-04-29 21:31:30 +00:00
|
|
|
#include "dsp_misc.h"
|
2010-06-21 06:04:19 +00:00
|
|
|
|
|
|
|
/** Disarms all touchregions. */
|
|
|
|
void skin_disarm_touchregions(struct wps_data *data)
|
|
|
|
{
|
2011-11-15 14:11:08 +00:00
|
|
|
char* skin_buffer = get_skin_buffer(data);
|
|
|
|
struct skin_token_list *regions = SKINOFFSETTOPTR(skin_buffer, data->touchregions);
|
2010-06-21 06:04:19 +00:00
|
|
|
while (regions)
|
|
|
|
{
|
2011-11-15 14:11:08 +00:00
|
|
|
struct wps_token *token = SKINOFFSETTOPTR(skin_buffer, regions->token);
|
|
|
|
struct touchregion *region = SKINOFFSETTOPTR(skin_buffer, token->value.data);
|
|
|
|
region->armed = false;
|
|
|
|
regions = SKINOFFSETTOPTR(skin_buffer, regions->next);
|
2010-06-21 06:04:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the touched action.
|
|
|
|
* egde_offset is a percentage value for the position of the touch
|
|
|
|
* inside the bar for regions which arnt WPS_TOUCHREGION_ACTION type.
|
|
|
|
*/
|
2010-09-06 13:33:49 +00:00
|
|
|
int skin_get_touchaction(struct wps_data *data, int* edge_offset,
|
|
|
|
struct touchregion **retregion)
|
2010-06-21 06:04:19 +00:00
|
|
|
{
|
|
|
|
int returncode = ACTION_NONE;
|
|
|
|
short x,y;
|
|
|
|
short vx, vy;
|
|
|
|
int type = action_get_touchscreen_press(&x, &y);
|
2011-11-15 14:11:08 +00:00
|
|
|
struct skin_viewport *wvp;
|
2011-03-01 09:01:45 +00:00
|
|
|
struct touchregion *r, *temp = NULL;
|
2011-11-15 14:11:08 +00:00
|
|
|
char* skin_buffer = get_skin_buffer(data);
|
2010-06-21 06:04:19 +00:00
|
|
|
bool repeated = (type == BUTTON_REPEAT);
|
|
|
|
bool released = (type == BUTTON_REL);
|
|
|
|
bool pressed = (type == BUTTON_TOUCHSCREEN);
|
2011-11-15 14:11:08 +00:00
|
|
|
struct skin_token_list *regions = SKINOFFSETTOPTR(skin_buffer, data->touchregions);
|
2011-03-27 07:23:38 +00:00
|
|
|
bool needs_repeat;
|
2010-06-21 06:04:19 +00:00
|
|
|
|
|
|
|
while (regions)
|
|
|
|
{
|
2011-11-15 14:11:08 +00:00
|
|
|
struct wps_token *token = SKINOFFSETTOPTR(skin_buffer, regions->token);
|
|
|
|
r = SKINOFFSETTOPTR(skin_buffer, token->value.data);
|
|
|
|
wvp = SKINOFFSETTOPTR(skin_buffer, r->wvp);
|
2010-06-21 06:04:19 +00:00
|
|
|
/* make sure this region's viewport is visible */
|
2011-11-15 14:11:08 +00:00
|
|
|
if (wvp->hidden_flags&VP_DRAW_HIDDEN)
|
2010-06-21 06:04:19 +00:00
|
|
|
{
|
2011-11-15 14:11:08 +00:00
|
|
|
regions = SKINOFFSETTOPTR(skin_buffer, regions->next);
|
2010-06-21 06:04:19 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-07-28 11:26:01 +00:00
|
|
|
if (data->touchscreen_locked &&
|
|
|
|
(r->action != ACTION_TOUCH_SOFTLOCK && !r->allow_while_locked))
|
|
|
|
{
|
2011-11-15 14:11:08 +00:00
|
|
|
regions = SKINOFFSETTOPTR(skin_buffer, regions->next);
|
2011-07-28 11:26:01 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-03-27 07:23:38 +00:00
|
|
|
needs_repeat = r->press_length != PRESS;
|
2010-06-21 06:04:19 +00:00
|
|
|
/* check if it's inside this viewport */
|
2011-11-15 14:11:08 +00:00
|
|
|
if (viewport_point_within_vp(&(wvp->vp), x, y))
|
2010-06-21 06:04:19 +00:00
|
|
|
{ /* reposition the touch inside the viewport since touchregions
|
|
|
|
* are relative to a preceding viewport */
|
2011-11-15 14:11:08 +00:00
|
|
|
vx = x - wvp->vp.x;
|
|
|
|
vy = y - wvp->vp.y;
|
2010-06-21 06:04:19 +00:00
|
|
|
/* now see if the point is inside this region */
|
|
|
|
if (vx >= r->x && vx < r->x+r->width &&
|
|
|
|
vy >= r->y && vy < r->y+r->height)
|
|
|
|
{
|
|
|
|
/* reposition the touch within the area */
|
|
|
|
vx -= r->x;
|
|
|
|
vy -= r->y;
|
|
|
|
|
2011-03-27 07:23:38 +00:00
|
|
|
switch(r->action)
|
2010-06-21 06:04:19 +00:00
|
|
|
{
|
2011-03-27 07:23:38 +00:00
|
|
|
case ACTION_TOUCH_SCROLLBAR:
|
|
|
|
case ACTION_TOUCH_VOLUME:
|
2012-07-06 04:28:34 +00:00
|
|
|
case ACTION_TOUCH_SETTING:
|
2010-06-21 06:04:19 +00:00
|
|
|
if (edge_offset)
|
|
|
|
{
|
2012-06-24 11:52:18 +00:00
|
|
|
struct progressbar *bar =
|
|
|
|
SKINOFFSETTOPTR(skin_buffer, r->bar);
|
2010-06-21 06:04:19 +00:00
|
|
|
if(r->width > r->height)
|
|
|
|
*edge_offset = vx*100/r->width;
|
2014-01-12 10:02:02 +00:00
|
|
|
else /* vertical bars are bottom-up by default */
|
|
|
|
*edge_offset = 100 - vy*100/r->height;
|
2012-06-24 11:52:18 +00:00
|
|
|
if (r->reverse_bar || (bar && bar->invert_fill_direction))
|
2010-06-21 12:43:08 +00:00
|
|
|
*edge_offset = 100 - *edge_offset;
|
2010-06-21 06:04:19 +00:00
|
|
|
}
|
2011-03-01 07:26:11 +00:00
|
|
|
temp = r;
|
2011-03-27 07:23:38 +00:00
|
|
|
returncode = r->action;
|
2011-05-23 06:23:04 +00:00
|
|
|
r->last_press = current_tick;
|
2011-03-27 07:23:38 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (r->armed && ((repeated && needs_repeat) ||
|
|
|
|
(released && !needs_repeat)))
|
|
|
|
{
|
|
|
|
returncode = r->action;
|
|
|
|
temp = r;
|
|
|
|
}
|
|
|
|
if (pressed)
|
|
|
|
{
|
|
|
|
r->armed = true;
|
|
|
|
r->last_press = current_tick;
|
|
|
|
}
|
2010-06-21 06:04:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-11-15 14:11:08 +00:00
|
|
|
regions = SKINOFFSETTOPTR(skin_buffer, regions->next);
|
2010-06-21 06:04:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* On release, all regions are disarmed. */
|
|
|
|
if (released)
|
|
|
|
skin_disarm_touchregions(data);
|
2011-03-01 09:01:45 +00:00
|
|
|
if (retregion && temp)
|
2011-03-01 07:26:11 +00:00
|
|
|
*retregion = temp;
|
2011-03-27 07:23:38 +00:00
|
|
|
if (temp && temp->press_length == LONG_PRESS)
|
|
|
|
temp->armed = false;
|
2010-06-21 06:04:19 +00:00
|
|
|
|
|
|
|
if (returncode != ACTION_NONE)
|
2011-03-01 07:26:11 +00:00
|
|
|
{
|
2011-03-22 09:31:45 +00:00
|
|
|
if (global_settings.party_mode)
|
|
|
|
{
|
|
|
|
switch (returncode)
|
|
|
|
{
|
|
|
|
case ACTION_WPS_PLAY:
|
|
|
|
case ACTION_WPS_SKIPPREV:
|
|
|
|
case ACTION_WPS_SKIPNEXT:
|
|
|
|
case ACTION_WPS_STOP:
|
|
|
|
returncode = ACTION_NONE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-03-01 07:26:11 +00:00
|
|
|
switch (returncode)
|
|
|
|
{
|
2011-07-28 11:26:01 +00:00
|
|
|
case ACTION_TOUCH_SOFTLOCK:
|
|
|
|
data->touchscreen_locked = !data->touchscreen_locked;
|
|
|
|
returncode = ACTION_NONE;
|
|
|
|
break;
|
2011-03-22 09:31:45 +00:00
|
|
|
case ACTION_WPS_PLAY:
|
|
|
|
if (!audio_status())
|
|
|
|
{
|
|
|
|
if ( global_status.resume_index != -1 )
|
|
|
|
{
|
|
|
|
if (playlist_resume() != -1)
|
|
|
|
{
|
|
|
|
playlist_start(global_status.resume_index,
|
2013-07-14 11:59:39 +00:00
|
|
|
global_status.resume_elapsed,
|
2011-03-22 09:31:45 +00:00
|
|
|
global_status.resume_offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
splash(HZ*2, ID2P(LANG_NOTHING_TO_RESUME));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wps_do_playpause(false);
|
|
|
|
}
|
|
|
|
returncode = ACTION_REDRAW;
|
|
|
|
break;
|
|
|
|
case ACTION_WPS_SKIPPREV:
|
|
|
|
audio_prev();
|
|
|
|
returncode = ACTION_REDRAW;
|
|
|
|
break;
|
|
|
|
case ACTION_WPS_SKIPNEXT:
|
|
|
|
audio_next();
|
|
|
|
returncode = ACTION_REDRAW;
|
|
|
|
break;
|
|
|
|
case ACTION_WPS_STOP:
|
|
|
|
audio_stop();
|
|
|
|
returncode = ACTION_REDRAW;
|
|
|
|
break;
|
2011-03-01 07:26:11 +00:00
|
|
|
case ACTION_SETTINGS_INC:
|
|
|
|
case ACTION_SETTINGS_DEC:
|
|
|
|
{
|
2011-03-01 12:31:03 +00:00
|
|
|
const struct settings_list *setting =
|
|
|
|
temp->setting_data.setting;
|
|
|
|
option_select_next_val(setting,
|
|
|
|
returncode == ACTION_SETTINGS_DEC,
|
|
|
|
true);
|
|
|
|
returncode = ACTION_REDRAW;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ACTION_SETTINGS_SET:
|
|
|
|
{
|
|
|
|
struct touchsetting *data = &temp->setting_data;
|
|
|
|
const struct settings_list *s = data->setting;
|
|
|
|
void (*f)(int) = NULL;
|
|
|
|
switch (s->flags&F_T_MASK)
|
|
|
|
{
|
|
|
|
case F_T_CUSTOM:
|
|
|
|
s->custom_setting
|
2011-11-15 14:11:08 +00:00
|
|
|
->load_from_cfg(s->setting, SKINOFFSETTOPTR(skin_buffer, data->value.text));
|
2011-03-01 12:31:03 +00:00
|
|
|
break;
|
|
|
|
case F_T_INT:
|
|
|
|
case F_T_UINT:
|
|
|
|
*(int*)s->setting = data->value.number;
|
2011-09-15 06:51:47 +00:00
|
|
|
if ((s->flags & F_T_SOUND) == F_T_SOUND)
|
|
|
|
sound_set(s->sound_setting->setting, data->value.number);
|
|
|
|
else if (s->flags&F_CHOICE_SETTING)
|
2011-03-01 12:31:03 +00:00
|
|
|
f = s->choice_setting->option_callback;
|
|
|
|
else if (s->flags&F_TABLE_SETTING)
|
|
|
|
f = s->table_setting->option_callback;
|
|
|
|
else
|
|
|
|
f = s->int_setting->option_callback;
|
|
|
|
|
|
|
|
if (f)
|
|
|
|
f(data->value.number);
|
|
|
|
break;
|
|
|
|
case F_T_BOOL:
|
|
|
|
*(bool*)s->setting = data->value.number ? true : false;
|
|
|
|
if (s->bool_setting->option_callback)
|
|
|
|
s->bool_setting
|
|
|
|
->option_callback(data->value.number ? true : false);
|
|
|
|
break;
|
|
|
|
}
|
2011-03-01 07:26:11 +00:00
|
|
|
returncode = ACTION_REDRAW;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ACTION_TOUCH_MUTE:
|
|
|
|
{
|
|
|
|
const int min_vol = sound_min(SOUND_VOLUME);
|
|
|
|
if (global_settings.volume == min_vol)
|
|
|
|
global_settings.volume = temp->value;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
temp->value = global_settings.volume;
|
|
|
|
global_settings.volume = min_vol;
|
|
|
|
}
|
|
|
|
setvol();
|
|
|
|
returncode = ACTION_REDRAW;
|
|
|
|
}
|
|
|
|
break;
|
2011-03-22 09:41:11 +00:00
|
|
|
case ACTION_TOUCH_SHUFFLE: /* toggle shuffle mode */
|
|
|
|
{
|
|
|
|
global_settings.playlist_shuffle =
|
|
|
|
!global_settings.playlist_shuffle;
|
2012-04-30 20:27:01 +00:00
|
|
|
replaygain_update();
|
2011-03-22 09:41:11 +00:00
|
|
|
if (global_settings.playlist_shuffle)
|
|
|
|
playlist_randomise(NULL, current_tick, true);
|
|
|
|
else
|
|
|
|
playlist_sort(NULL, true);
|
|
|
|
returncode = ACTION_REDRAW;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ACTION_TOUCH_REPMODE: /* cycle the repeat mode setting */
|
|
|
|
{
|
|
|
|
const struct settings_list *rep_setting =
|
|
|
|
find_setting(&global_settings.repeat_mode, NULL);
|
|
|
|
option_select_next_val(rep_setting, false, true);
|
|
|
|
audio_flush_and_reload_tracks();
|
|
|
|
returncode = ACTION_REDRAW;
|
|
|
|
}
|
|
|
|
break;
|
2012-07-06 04:28:34 +00:00
|
|
|
case ACTION_TOUCH_SETTING:
|
|
|
|
{
|
|
|
|
struct progressbar *bar =
|
|
|
|
SKINOFFSETTOPTR(skin_buffer, temp->bar);
|
|
|
|
if (bar && edge_offset)
|
|
|
|
{
|
|
|
|
int val, count;
|
|
|
|
get_setting_info_for_bar(bar->setting_id, &count, &val);
|
|
|
|
val = *edge_offset * count / 100;
|
|
|
|
update_setting_value_from_touch(bar->setting_id, val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2011-03-01 07:26:11 +00:00
|
|
|
}
|
2010-06-21 06:04:19 +00:00
|
|
|
return returncode;
|
2011-03-01 07:26:11 +00:00
|
|
|
}
|
2011-05-22 13:53:31 +00:00
|
|
|
|
2010-06-21 06:04:19 +00:00
|
|
|
return ACTION_TOUCHSCREEN;
|
|
|
|
}
|