Touchscreen: adjust calculation of bar touch position

Increased the precision of the bar from 100 steps to 1000 steps so
it is possible to make finer adjustments, and made it possible to
pick the maximum value in a bar rather than just the maximum - 1.

Change-Id: I2e694d3e86e4a151e014da1bd15ab3ade4c4b95e
This commit is contained in:
Aidan MacDonald 2021-06-16 13:55:35 +01:00
parent 8a6b2f3abc
commit 02860d67c3
2 changed files with 17 additions and 8 deletions

View File

@ -109,12 +109,21 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset,
{
struct progressbar *bar =
SKINOFFSETTOPTR(skin_buffer, r->bar);
if(r->width > r->height)
*edge_offset = vx*100/r->width;
else /* vertical bars are bottom-up by default */
*edge_offset = 100 - vy*100/r->height;
if(r->width > r->height) {
if(r->width > 1)
*edge_offset = vx*1000/(r->width - 1);
else
*edge_offset = 0;
} else {
/* vertical bars are bottom-up by default */
if(r->height > 1)
*edge_offset = 1000 - vy*1000/(r->height - 1);
else
*edge_offset = 0;
}
if (r->reverse_bar || (bar && bar->invert_fill_direction))
*edge_offset = 100 - *edge_offset;
*edge_offset = 1000 - *edge_offset;
}
temp = r;
returncode = r->action;
@ -294,7 +303,7 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset,
{
int val, count;
get_setting_info_for_bar(bar->setting_id, &count, &val);
val = *edge_offset * count / 100;
val = *edge_offset * count / 1000;
update_setting_value_from_touch(bar->setting_id, val);
}
}

View File

@ -182,7 +182,7 @@ static int skintouch_to_wps(struct wps_data *data)
return ACTION_WPS_HOTKEY;
#endif
case ACTION_TOUCH_SCROLLBAR:
skin_get_global_state()->id3->elapsed = skin_get_global_state()->id3->length*offset/100;
skin_get_global_state()->id3->elapsed = skin_get_global_state()->id3->length*offset/1000;
audio_pre_ff_rewind();
audio_ff_rewind(skin_get_global_state()->id3->elapsed);
return ACTION_TOUCHSCREEN;
@ -191,7 +191,7 @@ static int skintouch_to_wps(struct wps_data *data)
const int min_vol = sound_min(SOUND_VOLUME);
const int max_vol = sound_max(SOUND_VOLUME);
const int step_vol = sound_steps(SOUND_VOLUME);
global_settings.volume = (offset * (max_vol - min_vol)) / 100;
global_settings.volume = (offset * (max_vol - min_vol)) / 1000;
global_settings.volume += min_vol;
global_settings.volume -= (global_settings.volume % step_vol);
setvol();