diff options
Diffstat (limited to 'firmware/target')
-rw-r--r-- | firmware/target/arm/ipod/button-1g-3g.c | 49 | ||||
-rw-r--r-- | firmware/target/arm/ipod/button-mini1g.c | 25 | ||||
-rw-r--r-- | firmware/target/arm/ipod/button-target.h | 1 |
3 files changed, 24 insertions, 51 deletions
diff --git a/firmware/target/arm/ipod/button-1g-3g.c b/firmware/target/arm/ipod/button-1g-3g.c index d5592f0447..74af4c2cd2 100644 --- a/firmware/target/arm/ipod/button-1g-3g.c +++ b/firmware/target/arm/ipod/button-1g-3g.c | |||
@@ -47,11 +47,9 @@ static int int_btn = BUTTON_NONE; | |||
47 | * we only enable it for a very short time to check for changes every | 47 | * we only enable it for a very short time to check for changes every |
48 | * tick, and only keep it enabled if there is activity. */ | 48 | * tick, and only keep it enabled if there is activity. */ |
49 | #define WHEEL_TIMEOUT (HZ/4) | 49 | #define WHEEL_TIMEOUT (HZ/4) |
50 | static int wheel_timeout = 0; | ||
51 | #endif | 50 | #endif |
52 | 51 | ||
53 | /* iPod 3G and mini 1G, mini 2G uses iPod 4G code */ | 52 | static void handle_scroll_wheel(int new_scroll, int was_hold) |
54 | void handle_scroll_wheel(int new_scroll, int was_hold, int reverse) | ||
55 | { | 53 | { |
56 | int wheel_keycode = BUTTON_NONE; | 54 | int wheel_keycode = BUTTON_NONE; |
57 | static int prev_scroll = -1; | 55 | static int prev_scroll = -1; |
@@ -64,10 +62,6 @@ void handle_scroll_wheel(int new_scroll, int was_hold, int reverse) | |||
64 | {0, -1, 1, 0} | 62 | {0, -1, 1, 0} |
65 | }; | 63 | }; |
66 | 64 | ||
67 | #ifdef IPOD_1G2G | ||
68 | wheel_timeout = WHEEL_TIMEOUT; | ||
69 | #endif | ||
70 | |||
71 | if ( prev_scroll == -1 ) { | 65 | if ( prev_scroll == -1 ) { |
72 | prev_scroll = new_scroll; | 66 | prev_scroll = new_scroll; |
73 | } | 67 | } |
@@ -80,26 +74,14 @@ void handle_scroll_wheel(int new_scroll, int was_hold, int reverse) | |||
80 | reset_poweroff_timer(); | 74 | reset_poweroff_timer(); |
81 | if (++count == 6) { /* reduce sensitivity */ | 75 | if (++count == 6) { /* reduce sensitivity */ |
82 | count = 0; | 76 | count = 0; |
77 | /* 1st..3rd Gen wheel has inverse direction mapping | ||
78 | * compared to Mini 1st Gen wheel. */ | ||
83 | switch (direction) { | 79 | switch (direction) { |
84 | case 1: | 80 | case 1: |
85 | if (reverse) { | 81 | wheel_keycode = BUTTON_SCROLL_BACK; |
86 | /* 'r' keypress */ | ||
87 | wheel_keycode = BUTTON_SCROLL_FWD; | ||
88 | } | ||
89 | else { | ||
90 | /* 'l' keypress */ | ||
91 | wheel_keycode = BUTTON_SCROLL_BACK; | ||
92 | } | ||
93 | break; | 82 | break; |
94 | case -1: | 83 | case -1: |
95 | if (reverse) { | 84 | wheel_keycode = BUTTON_SCROLL_FWD; |
96 | /* 'l' keypress */ | ||
97 | wheel_keycode = BUTTON_SCROLL_BACK; | ||
98 | } | ||
99 | else { | ||
100 | /* 'r' keypress */ | ||
101 | wheel_keycode = BUTTON_SCROLL_FWD; | ||
102 | } | ||
103 | break; | 85 | break; |
104 | default: | 86 | default: |
105 | /* only happens if we get out of sync */ | 87 | /* only happens if we get out of sync */ |
@@ -174,7 +156,7 @@ static int ipod_3g_button_read(void) | |||
174 | } | 156 | } |
175 | 157 | ||
176 | if (source & 0xc0) { | 158 | if (source & 0xc0) { |
177 | handle_scroll_wheel((state & 0xc0) >> 6, was_hold, 0); | 159 | handle_scroll_wheel((state & 0xc0) >> 6, was_hold); |
178 | } | 160 | } |
179 | 161 | ||
180 | /* ack any active interrupts */ | 162 | /* ack any active interrupts */ |
@@ -219,6 +201,7 @@ int button_read_device(void) | |||
219 | static bool hold_button = false; | 201 | static bool hold_button = false; |
220 | bool hold_button_old; | 202 | bool hold_button_old; |
221 | #ifdef IPOD_1G2G | 203 | #ifdef IPOD_1G2G |
204 | static int wheel_timeout = 0; | ||
222 | static unsigned char last_wheel_value = 0; | 205 | static unsigned char last_wheel_value = 0; |
223 | unsigned char wheel_value; | 206 | unsigned char wheel_value; |
224 | 207 | ||
@@ -228,17 +211,21 @@ int button_read_device(void) | |||
228 | { | 211 | { |
229 | GPIOB_OUTPUT_VAL |= 0x01; /* enable wheel */ | 212 | GPIOB_OUTPUT_VAL |= 0x01; /* enable wheel */ |
230 | udelay(50); /* let the voltage settle */ | 213 | udelay(50); /* let the voltage settle */ |
231 | wheel_value = GPIOA_INPUT_VAL >> 6; | 214 | GPIOA_INT_EN = 0xff; /* enable wheel interrupts */ |
232 | if (wheel_value != last_wheel_value) | 215 | } |
233 | { | 216 | wheel_value = GPIOA_INPUT_VAL >> 6; |
234 | last_wheel_value = wheel_value; | 217 | if (wheel_value != last_wheel_value) |
235 | wheel_timeout = WHEEL_TIMEOUT; /* keep wheel enabled */ | 218 | { |
236 | } | 219 | last_wheel_value = wheel_value; |
237 | } | 220 | wheel_timeout = WHEEL_TIMEOUT; /* keep wheel enabled */ |
221 | } | ||
238 | if (wheel_timeout) | 222 | if (wheel_timeout) |
239 | wheel_timeout--; | 223 | wheel_timeout--; |
240 | else | 224 | else |
225 | { | ||
226 | GPIOA_INT_EN = 0x3f; /* disable wheel interrupts */ | ||
241 | GPIOB_OUTPUT_VAL &= ~0x01; /* disable wheel */ | 227 | GPIOB_OUTPUT_VAL &= ~0x01; /* disable wheel */ |
228 | } | ||
242 | } | 229 | } |
243 | #endif | 230 | #endif |
244 | 231 | ||
diff --git a/firmware/target/arm/ipod/button-mini1g.c b/firmware/target/arm/ipod/button-mini1g.c index f02e6acaac..1ff0a19bdb 100644 --- a/firmware/target/arm/ipod/button-mini1g.c +++ b/firmware/target/arm/ipod/button-mini1g.c | |||
@@ -47,8 +47,7 @@ int int_btn = BUTTON_NONE; | |||
47 | static bool send_events = true; | 47 | static bool send_events = true; |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | /* iPod 3G and mini 1G, mini 2G uses iPod 4G code */ | 50 | static void handle_scroll_wheel(int new_scroll, int was_hold) |
51 | void handle_scroll_wheel(int new_scroll, int was_hold, int reverse) | ||
52 | { | 51 | { |
53 | int wheel_keycode = BUTTON_NONE; | 52 | int wheel_keycode = BUTTON_NONE; |
54 | static int prev_scroll = -1; | 53 | static int prev_scroll = -1; |
@@ -73,26 +72,14 @@ void handle_scroll_wheel(int new_scroll, int was_hold, int reverse) | |||
73 | reset_poweroff_timer(); | 72 | reset_poweroff_timer(); |
74 | if (++count == 6) { /* reduce sensitivity */ | 73 | if (++count == 6) { /* reduce sensitivity */ |
75 | count = 0; | 74 | count = 0; |
75 | /* Mini 1st Gen wheel has inverse direction mapping | ||
76 | * compared to 1st..3rd Gen wheel. */ | ||
76 | switch (direction) { | 77 | switch (direction) { |
77 | case 1: | 78 | case 1: |
78 | if (reverse) { | 79 | wheel_keycode = BUTTON_SCROLL_FWD; |
79 | /* 'r' keypress */ | ||
80 | wheel_keycode = BUTTON_SCROLL_FWD; | ||
81 | } | ||
82 | else { | ||
83 | /* 'l' keypress */ | ||
84 | wheel_keycode = BUTTON_SCROLL_BACK; | ||
85 | } | ||
86 | break; | 80 | break; |
87 | case -1: | 81 | case -1: |
88 | if (reverse) { | 82 | wheel_keycode = BUTTON_SCROLL_BACK; |
89 | /* 'l' keypress */ | ||
90 | wheel_keycode = BUTTON_SCROLL_BACK; | ||
91 | } | ||
92 | else { | ||
93 | /* 'r' keypress */ | ||
94 | wheel_keycode = BUTTON_SCROLL_FWD; | ||
95 | } | ||
96 | break; | 83 | break; |
97 | default: | 84 | default: |
98 | /* only happens if we get out of sync */ | 85 | /* only happens if we get out of sync */ |
@@ -147,7 +134,7 @@ static int ipod_mini_button_read(void) | |||
147 | btn |= BUTTON_LEFT; | 134 | btn |= BUTTON_LEFT; |
148 | 135 | ||
149 | if (wheel_source & 0x30) { | 136 | if (wheel_source & 0x30) { |
150 | handle_scroll_wheel((wheel_state & 0x30) >> 4, was_hold, 1); | 137 | handle_scroll_wheel((wheel_state & 0x30) >> 4, was_hold); |
151 | } | 138 | } |
152 | } | 139 | } |
153 | 140 | ||
diff --git a/firmware/target/arm/ipod/button-target.h b/firmware/target/arm/ipod/button-target.h index d736effb72..540981af8f 100644 --- a/firmware/target/arm/ipod/button-target.h +++ b/firmware/target/arm/ipod/button-target.h | |||
@@ -28,7 +28,6 @@ bool button_hold(void); | |||
28 | void button_init_device(void); | 28 | void button_init_device(void); |
29 | int button_read_device(void); | 29 | int button_read_device(void); |
30 | 30 | ||
31 | void handle_scroll_wheel(int new_scroll, int was_hold, int reverse); | ||
32 | void ipod_mini_button_int(void); | 31 | void ipod_mini_button_int(void); |
33 | void ipod_4g_button_int(void); | 32 | void ipod_4g_button_int(void); |
34 | 33 | ||