mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-06 21:25:03 -05:00
touchscreen: Port quickscreen to gesture API
Use the gesture API to improve reliability, and allow press and hold to repeatedly increment or decrement a value like on button targets. Change-Id: Ic01b7a0802c3dec9f1534f5dd11e006b28a875b6
This commit is contained in:
parent
94468f693f
commit
0f99defe1f
2 changed files with 25 additions and 11 deletions
|
|
@ -50,6 +50,11 @@
|
||||||
#define MARGIN 10
|
#define MARGIN 10
|
||||||
#define CENTER_ICONAREA_SIZE (MARGIN+8*2)
|
#define CENTER_ICONAREA_SIZE (MARGIN+8*2)
|
||||||
|
|
||||||
|
struct gui_quickscreen
|
||||||
|
{
|
||||||
|
const struct settings_list *items[QUICKSCREEN_ITEM_COUNT];
|
||||||
|
};
|
||||||
|
|
||||||
static bool redraw;
|
static bool redraw;
|
||||||
|
|
||||||
static void quickscreen_update_callback(unsigned short id,
|
static void quickscreen_update_callback(unsigned short id,
|
||||||
|
|
@ -297,22 +302,30 @@ static bool gui_quickscreen_do_button(struct gui_quickscreen * qs, int button)
|
||||||
#ifdef HAVE_TOUCHSCREEN
|
#ifdef HAVE_TOUCHSCREEN
|
||||||
static int quickscreen_touchscreen_button(void)
|
static int quickscreen_touchscreen_button(void)
|
||||||
{
|
{
|
||||||
short x,y;
|
struct gesture_event gevent;
|
||||||
if (action_get_touchscreen_press(&x, &y) != BUTTON_REL)
|
if (!action_gesture_get_event(&gevent))
|
||||||
return ACTION_NONE;
|
return ACTION_NONE;
|
||||||
|
|
||||||
|
switch (gevent.id) {
|
||||||
|
case GESTURE_TAP:
|
||||||
|
case GESTURE_HOLD:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return ACTION_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
enum { left=1, right=2, top=4, bottom=8 };
|
enum { left=1, right=2, top=4, bottom=8 };
|
||||||
|
|
||||||
int bits = 0;
|
int bits = 0;
|
||||||
|
|
||||||
if(x < LCD_WIDTH/3)
|
if(gevent.x < LCD_WIDTH/3)
|
||||||
bits |= left;
|
bits |= left;
|
||||||
else if(x > 2*LCD_WIDTH/3)
|
else if(gevent.x > 2*LCD_WIDTH/3)
|
||||||
bits |= right;
|
bits |= right;
|
||||||
|
|
||||||
if(y < LCD_HEIGHT/3)
|
if(gevent.y < LCD_HEIGHT/3)
|
||||||
bits |= top;
|
bits |= top;
|
||||||
else if(y > 2*LCD_HEIGHT/3)
|
else if(gevent.y > 2*LCD_HEIGHT/3)
|
||||||
bits |= bottom;
|
bits |= bottom;
|
||||||
|
|
||||||
switch(bits) {
|
switch(bits) {
|
||||||
|
|
@ -366,6 +379,10 @@ static int gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter
|
||||||
talk_qs_option(qs->items[QUICKSCREEN_LEFT], true);
|
talk_qs_option(qs->items[QUICKSCREEN_LEFT], true);
|
||||||
if (qs->items[QUICKSCREEN_LEFT] != qs->items[QUICKSCREEN_RIGHT])
|
if (qs->items[QUICKSCREEN_LEFT] != qs->items[QUICKSCREEN_RIGHT])
|
||||||
talk_qs_option(qs->items[QUICKSCREEN_RIGHT], true);
|
talk_qs_option(qs->items[QUICKSCREEN_RIGHT], true);
|
||||||
|
|
||||||
|
#ifdef HAVE_TOUCHSCREEN
|
||||||
|
action_gesture_reset();
|
||||||
|
#endif
|
||||||
while (true) {
|
while (true) {
|
||||||
if (redraw)
|
if (redraw)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include "screen_access.h"
|
#include "screen_access.h"
|
||||||
|
|
||||||
|
struct settings_list;
|
||||||
|
|
||||||
enum quickscreen_item {
|
enum quickscreen_item {
|
||||||
QUICKSCREEN_TOP = 0,
|
QUICKSCREEN_TOP = 0,
|
||||||
QUICKSCREEN_LEFT,
|
QUICKSCREEN_LEFT,
|
||||||
|
|
@ -43,11 +45,6 @@ enum quickscreen_return {
|
||||||
QUICKSCREEN_CHANGED = 0x4,
|
QUICKSCREEN_CHANGED = 0x4,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gui_quickscreen
|
|
||||||
{
|
|
||||||
const struct settings_list *items[QUICKSCREEN_ITEM_COUNT];
|
|
||||||
};
|
|
||||||
|
|
||||||
extern int quick_screen_quick(int button_enter);
|
extern int quick_screen_quick(int button_enter);
|
||||||
int quickscreen_set_option(void *data);
|
int quickscreen_set_option(void *data);
|
||||||
bool is_setting_quickscreenable(const struct settings_list *setting);
|
bool is_setting_quickscreenable(const struct settings_list *setting);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue