diff options
Diffstat (limited to 'firmware/target/hosted')
-rw-r--r-- | firmware/target/hosted/button-devinput.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/firmware/target/hosted/button-devinput.c b/firmware/target/hosted/button-devinput.c index b1b4dfca5d..df2358579b 100644 --- a/firmware/target/hosted/button-devinput.c +++ b/firmware/target/hosted/button-devinput.c | |||
@@ -33,6 +33,22 @@ | |||
33 | #include "button.h" | 33 | #include "button.h" |
34 | #include "panic.h" | 34 | #include "panic.h" |
35 | 35 | ||
36 | #ifdef HAVE_SCROLLWHEEL | ||
37 | #include "powermgmt.h" | ||
38 | #if defined(HAVE_BACKLIGHT) || defined(HAVE_BUTTON_LIGHT) | ||
39 | #include "backlight.h" | ||
40 | #endif | ||
41 | #endif /* HAVE_SCROLLWHEEL */ | ||
42 | |||
43 | /* TODO: HAVE_SCROLLWHEEL is a hack. Instead of posting the exact number | ||
44 | of clicks, instead do it similar to the ipod clickwheel and post | ||
45 | the wheel angular velocity (degrees per second) | ||
46 | |||
47 | * Track the relative position (ie based on click events) | ||
48 | * Use WHEELCLICKS_PER_ROTATION to convert clicks to angular distance | ||
49 | * Compute to angular velocity (degrees per second) | ||
50 | |||
51 | */ | ||
36 | #define NR_POLL_DESC 4 | 52 | #define NR_POLL_DESC 4 |
37 | 53 | ||
38 | static int num_devices = 0; | 54 | static int num_devices = 0; |
@@ -150,8 +166,17 @@ int button_read_device(void) | |||
150 | } | 166 | } |
151 | 167 | ||
152 | #ifdef HAVE_SCROLLWHEEL | 168 | #ifdef HAVE_SCROLLWHEEL |
153 | // TODO: Is there a better way to handle this? | 169 | /* Reset backlight and poweroff timers */ |
154 | // TODO: enable BUTTON_REPEAT if the events happen quickly enough | 170 | if (wheel_ticks) { |
171 | #ifdef HAVE_BACKLIGHT | ||
172 | backlight_on(); | ||
173 | #endif | ||
174 | #ifdef HAVE_BUTTON_LIGHT | ||
175 | buttonlight_on(); | ||
176 | #endif | ||
177 | reset_poweroff_timer(); | ||
178 | } | ||
179 | |||
155 | if (wheel_ticks > 0) | 180 | if (wheel_ticks > 0) |
156 | { | 181 | { |
157 | while (wheel_ticks-- > 0) | 182 | while (wheel_ticks-- > 0) |
@@ -159,14 +184,14 @@ int button_read_device(void) | |||
159 | queue_post(&button_queue, BUTTON_SCROLL_FWD, 0); | 184 | queue_post(&button_queue, BUTTON_SCROLL_FWD, 0); |
160 | } | 185 | } |
161 | } | 186 | } |
162 | else | 187 | else if (wheel_ticks < 0) |
163 | { | 188 | { |
164 | while (wheel_ticks++ < 0) | 189 | while (wheel_ticks++ < 0) |
165 | { | 190 | { |
166 | queue_post(&button_queue, BUTTON_SCROLL_BACK, 0); | 191 | queue_post(&button_queue, BUTTON_SCROLL_BACK, 0); |
167 | } | 192 | } |
168 | } | 193 | } |
169 | #endif | 194 | #endif /* HAVE_SCROLLWHEEL */ |
170 | 195 | ||
171 | return button_bitmap; | 196 | return button_bitmap; |
172 | } | 197 | } |