summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-12-16 14:47:50 -0500
committerSolomon Peachy <pizza@shaftnet.org>2020-12-16 14:54:11 -0500
commit02119357dc729076b5c104dacf3fc4f73a7eb68a (patch)
tree9cfb00f0294b8e128f852410aa4ef549f2d93df4
parent0215c37ceb86dfb40dd915bd13ce25933031d05d (diff)
downloadrockbox-02119357dc.tar.gz
rockbox-02119357dc.zip
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
-rw-r--r--firmware/export/config/aigoerosq.h1
-rw-r--r--firmware/target/hosted/button-devinput.c46
2 files changed, 32 insertions, 15 deletions
diff --git a/firmware/export/config/aigoerosq.h b/firmware/export/config/aigoerosq.h
index 6dc14c9205..6ae8ad049f 100644
--- a/firmware/export/config/aigoerosq.h
+++ b/firmware/export/config/aigoerosq.h
@@ -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
diff --git a/firmware/target/hosted/button-devinput.c b/firmware/target/hosted/button-devinput.c
index 448be2c5c4..90e6fb0340 100644
--- a/firmware/target/hosted/button-devinput.c
+++ b/firmware/target/hosted/button-devinput.c
@@ -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;
}