mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 21:22:39 -05:00
erosq: Enable HAVE_SCROLLWHEEL for saner scroll wheel handling
Basically no longer treat SCROLL_FWD/BACK as "button" events, instead relying on the scrollwheel hooks to handle things properly. Change-Id: I9bf18595ab3ca68e912f6dfb1f2eac2544578e73
This commit is contained in:
parent
0215c37ceb
commit
02119357dc
2 changed files with 32 additions and 15 deletions
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
/* KeyPad configuration for plugins */
|
/* KeyPad configuration for plugins */
|
||||||
#define CONFIG_KEYPAD EROSQ_PAD
|
#define CONFIG_KEYPAD EROSQ_PAD
|
||||||
|
#define HAVE_SCROLLWHEEL
|
||||||
|
|
||||||
/* define this if the target has volume keys which can be used in the lists */
|
/* define this if the target has volume keys which can be used in the lists */
|
||||||
#define HAVE_VOLUME_IN_LIST
|
#define HAVE_VOLUME_IN_LIST
|
||||||
|
|
|
||||||
|
|
@ -77,16 +77,8 @@ int button_read_device(void)
|
||||||
static int button_bitmap = 0;
|
static int button_bitmap = 0;
|
||||||
struct input_event event;
|
struct input_event event;
|
||||||
|
|
||||||
#if defined(BUTTON_SCROLL_BACK)
|
#ifdef HAVE_SCROLLWHEEL
|
||||||
// FIXME TODO: Make this work via HAVE_SCROLL_WHEEL instead
|
int wheel_ticks = 0;
|
||||||
|
|
||||||
/* Wheel gives us press+release back to back, clear them after time elapses */
|
|
||||||
static long last_tick = 0;
|
|
||||||
if (button_bitmap & (BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD) &&
|
|
||||||
current_tick - last_tick >= 2)
|
|
||||||
{
|
|
||||||
button_bitmap &= ~(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* check if there are any events pending and process them */
|
/* check if there are any events pending and process them */
|
||||||
|
|
@ -110,17 +102,22 @@ int button_read_device(void)
|
||||||
if(press)
|
if(press)
|
||||||
{
|
{
|
||||||
int bmap = button_map(keycode);
|
int bmap = button_map(keycode);
|
||||||
#if defined(BUTTON_SCROLL_BACK)
|
|
||||||
/* Keep track of when the last wheel tick happened */
|
#ifdef HAVE_SCROLLWHEEL
|
||||||
if (bmap & (BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD))
|
/* Filter out wheel ticks */
|
||||||
last_tick = current_tick;
|
if (bmap & BUTTON_SCROLL_BACK)
|
||||||
|
wheel_ticks--;
|
||||||
|
else if (bmap & BUTTON_SCROLL_FWD)
|
||||||
|
wheel_ticks++;
|
||||||
|
bmap &= ~(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD);
|
||||||
#endif
|
#endif
|
||||||
button_bitmap |= bmap;
|
button_bitmap |= bmap;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int bmap = button_map(keycode);
|
int bmap = button_map(keycode);
|
||||||
#if defined(BUTTON_SCROLL_BACK)
|
|
||||||
|
#ifdef HAVE_SCROLLWHEEL
|
||||||
/* Wheel gives us press+release back to back; ignore the release */
|
/* Wheel gives us press+release back to back; ignore the release */
|
||||||
bmap &= ~(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD);
|
bmap &= ~(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -132,5 +129,24 @@ int button_read_device(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_SCROLLWHEEL
|
||||||
|
// TODO: Is there a better way to handle this?
|
||||||
|
// TODO: enable BUTTON_REPEAT if the events happen quickly enough
|
||||||
|
if (wheel_ticks > 0)
|
||||||
|
{
|
||||||
|
while (wheel_ticks-- > 0)
|
||||||
|
{
|
||||||
|
queue_post(&button_queue, BUTTON_SCROLL_FWD, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (wheel_ticks++ < 0)
|
||||||
|
{
|
||||||
|
queue_post(&button_queue, BUTTON_SCROLL_BACK, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return button_bitmap;
|
return button_bitmap;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue