diff options
Diffstat (limited to 'firmware/drivers/button.c')
-rw-r--r-- | firmware/drivers/button.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index 20b725c3d4..599c22bc80 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c | |||
@@ -90,6 +90,10 @@ static bool remote_button_hold_only(void); | |||
90 | #if CONFIG_KEYPAD == IPOD_4G_PAD | 90 | #if CONFIG_KEYPAD == IPOD_4G_PAD |
91 | /* Variable to use for setting button status in interrupt handler */ | 91 | /* Variable to use for setting button status in interrupt handler */ |
92 | int int_btn = BUTTON_NONE; | 92 | int int_btn = BUTTON_NONE; |
93 | #ifdef HAVE_WHEEL_POSITION | ||
94 | static int wheel_position = -1; | ||
95 | static bool send_events = true; | ||
96 | #endif | ||
93 | #endif | 97 | #endif |
94 | 98 | ||
95 | #ifdef HAVE_HEADPHONE_DETECTION | 99 | #ifdef HAVE_HEADPHONE_DETECTION |
@@ -131,6 +135,8 @@ static void opto_i2c_init(void) | |||
131 | 135 | ||
132 | static inline int ipod_4g_button_read(void) | 136 | static inline int ipod_4g_button_read(void) |
133 | { | 137 | { |
138 | int whl = -1; | ||
139 | |||
134 | /* The ipodlinux source had a udelay(250) here, but testing has shown that | 140 | /* The ipodlinux source had a udelay(250) here, but testing has shown that |
135 | it is not needed - tested on Nano, Color/Photo and Video. */ | 141 | it is not needed - tested on Nano, Color/Photo and Video. */ |
136 | /* udelay(250);*/ | 142 | /* udelay(250);*/ |
@@ -160,6 +166,7 @@ static inline int ipod_4g_button_read(void) | |||
160 | if (status & 0x40000000) { | 166 | if (status & 0x40000000) { |
161 | /* NB: highest wheel = 0x5F, clockwise increases */ | 167 | /* NB: highest wheel = 0x5F, clockwise increases */ |
162 | int new_wheel_value = (status << 9) >> 25; | 168 | int new_wheel_value = (status << 9) >> 25; |
169 | whl = new_wheel_value; | ||
163 | backlight_on(); | 170 | backlight_on(); |
164 | /* The queue should have no other events when scrolling */ | 171 | /* The queue should have no other events when scrolling */ |
165 | if (queue_empty(&button_queue) && old_wheel_value >= 0) { | 172 | if (queue_empty(&button_queue) && old_wheel_value >= 0) { |
@@ -180,9 +187,14 @@ static inline int ipod_4g_button_read(void) | |||
180 | wheel_keycode = BUTTON_SCROLL_BACK; | 187 | wheel_keycode = BUTTON_SCROLL_BACK; |
181 | } else goto wheel_end; | 188 | } else goto wheel_end; |
182 | 189 | ||
183 | data = (wheel_delta << 16) | new_wheel_value; | 190 | #ifdef HAVE_WHEEL_POSITION |
184 | queue_post(&button_queue, wheel_keycode | wheel_repeat, | 191 | if (send_events) |
185 | (void *)data); | 192 | #endif |
193 | { | ||
194 | data = (wheel_delta << 16) | new_wheel_value; | ||
195 | queue_post(&button_queue, wheel_keycode | wheel_repeat, | ||
196 | (void *)data); | ||
197 | } | ||
186 | 198 | ||
187 | if (!wheel_repeat) wheel_repeat = BUTTON_REPEAT; | 199 | if (!wheel_repeat) wheel_repeat = BUTTON_REPEAT; |
188 | } | 200 | } |
@@ -205,6 +217,8 @@ wheel_end: | |||
205 | outl(0xffffffff, 0x7000c120); | 217 | outl(0xffffffff, 0x7000c120); |
206 | outl(0xffffffff, 0x7000c124); | 218 | outl(0xffffffff, 0x7000c124); |
207 | } | 219 | } |
220 | /* Save the new absolute wheel position */ | ||
221 | wheel_position = whl; | ||
208 | return btn; | 222 | return btn; |
209 | } | 223 | } |
210 | 224 | ||
@@ -1343,6 +1357,18 @@ int button_status(void) | |||
1343 | return lastbtn; | 1357 | return lastbtn; |
1344 | } | 1358 | } |
1345 | 1359 | ||
1360 | #ifdef HAVE_WHEEL_POSITION | ||
1361 | int wheel_status(void) | ||
1362 | { | ||
1363 | return wheel_position; | ||
1364 | } | ||
1365 | |||
1366 | void wheel_send_events(bool send) | ||
1367 | { | ||
1368 | send_events = send; | ||
1369 | } | ||
1370 | #endif | ||
1371 | |||
1346 | void button_clear_queue(void) | 1372 | void button_clear_queue(void) |
1347 | { | 1373 | { |
1348 | queue_clear(&button_queue); | 1374 | queue_clear(&button_queue); |