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:
Solomon Peachy 2020-12-16 14:47:50 -05:00
parent 0215c37ceb
commit 02119357dc
2 changed files with 32 additions and 15 deletions

View file

@ -21,6 +21,7 @@
/* KeyPad configuration for plugins */
#define CONFIG_KEYPAD EROSQ_PAD
#define HAVE_SCROLLWHEEL
/* define this if the target has volume keys which can be used in the lists */
#define HAVE_VOLUME_IN_LIST

View file

@ -77,16 +77,8 @@ int button_read_device(void)
static int button_bitmap = 0;
struct input_event event;
#if defined(BUTTON_SCROLL_BACK)
// FIXME TODO: Make this work via HAVE_SCROLL_WHEEL instead
/* 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);
}
#ifdef HAVE_SCROLLWHEEL
int wheel_ticks = 0;
#endif
/* check if there are any events pending and process them */
@ -110,17 +102,22 @@ int button_read_device(void)
if(press)
{
int bmap = button_map(keycode);
#if defined(BUTTON_SCROLL_BACK)
/* Keep track of when the last wheel tick happened */
if (bmap & (BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD))
last_tick = current_tick;
#ifdef HAVE_SCROLLWHEEL
/* Filter out wheel ticks */
if (bmap & BUTTON_SCROLL_BACK)
wheel_ticks--;
else if (bmap & BUTTON_SCROLL_FWD)
wheel_ticks++;
bmap &= ~(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD);
#endif
button_bitmap |= bmap;
}
else
{
int bmap = button_map(keycode);
#if defined(BUTTON_SCROLL_BACK)
#ifdef HAVE_SCROLLWHEEL
/* Wheel gives us press+release back to back; ignore the release */
bmap &= ~(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD);
#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;
}