summaryrefslogtreecommitdiff
path: root/apps/action.c
diff options
context:
space:
mode:
authorSteve Bavin <pondlife@pondlife.me>2008-01-21 09:48:44 +0000
committerSteve Bavin <pondlife@pondlife.me>2008-01-21 09:48:44 +0000
commitea358a1fdcb74efa645194a9d35f9442a44034c5 (patch)
treef34a7f5f7e369420e87e2fa48ceb4f2c1496b0da /apps/action.c
parentcba886d9b75c21ee1e81b70dbd7fc234d2288f66 (diff)
downloadrockbox-ea358a1fdcb74efa645194a9d35f9442a44034c5.tar.gz
rockbox-ea358a1fdcb74efa645194a9d35f9442a44034c5.zip
Keyclick option (FS#7307). Disabled by default, go into System settings to enable it. WARNING: PortalPlayer targets reportedly have a problem with this, so don't enable it on those unless you want to risk burning your ears with horrible noise. This is probably a bug in pcmbuf_beep(), and I'm hoping that someone who has an affected target will look into it and fix it as a result of this commit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16132 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/action.c')
-rw-r--r--apps/action.c89
1 files changed, 48 insertions, 41 deletions
diff --git a/apps/action.c b/apps/action.c
index 7f445c8b9f..89d6a7ae7a 100644
--- a/apps/action.c
+++ b/apps/action.c
@@ -8,7 +8,7 @@
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2006 Jonathan Gordon 10 * Copyright (C) 2006 Jonathan Gordon
11 * 11 *
12 * All files in this archive are subject to the GNU General Public License. 12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement. 13 * See the file COPYING in the source tree root for full license agreement.
14 * 14 *
@@ -28,8 +28,10 @@
28#include "kernel.h" 28#include "kernel.h"
29#include "debug.h" 29#include "debug.h"
30#include "splash.h" 30#include "splash.h"
31#include "settings.h"
32#include "pcmbuf.h"
31 33
32static int last_button = BUTTON_NONE|BUTTON_REL; /* allow the ipod wheel to 34static int last_button = BUTTON_NONE|BUTTON_REL; /* allow the ipod wheel to
33 work on startup */ 35 work on startup */
34static intptr_t last_data = 0; 36static intptr_t last_data = 0;
35static int last_action = ACTION_NONE; 37static int last_action = ACTION_NONE;
@@ -63,7 +65,7 @@ static inline int do_button_check(const struct button_mapping *items,
63 65
64 while (items[i].button_code != BUTTON_NONE) 66 while (items[i].button_code != BUTTON_NONE)
65 { 67 {
66 if (items[i].button_code == button) 68 if (items[i].button_code == button)
67 { 69 {
68 if ((items[i].pre_button_code == BUTTON_NONE) 70 if ((items[i].pre_button_code == BUTTON_NONE)
69 || (items[i].pre_button_code == last_button)) 71 || (items[i].pre_button_code == last_button))
@@ -82,8 +84,8 @@ static inline int get_next_context(const struct button_mapping *items, int i)
82{ 84{
83 while (items[i].button_code != BUTTON_NONE) 85 while (items[i].button_code != BUTTON_NONE)
84 i++; 86 i++;
85 return (items[i].action_code == ACTION_NONE ) ? 87 return (items[i].action_code == ACTION_NONE ) ?
86 CONTEXT_STD : 88 CONTEXT_STD :
87 items[i].action_code; 89 items[i].action_code;
88} 90}
89/* 91/*
@@ -96,11 +98,11 @@ static inline int get_next_context(const struct button_mapping *items, int i)
96 the last item in the list "points" to the next context in a chain 98 the last item in the list "points" to the next context in a chain
97 so the "chain" is followed until the button is found. 99 so the "chain" is followed until the button is found.
98 putting ACTION_NONE will get CONTEXT_STD which is always the last list checked. 100 putting ACTION_NONE will get CONTEXT_STD which is always the last list checked.
99 101
100 Timeout can be TIMEOUT_NOBLOCK to return immediatly 102 Timeout can be TIMEOUT_NOBLOCK to return immediatly
101 TIMEOUT_BLOCK to wait for a button press 103 TIMEOUT_BLOCK to wait for a button press
102Any number >0 to wait that many ticks for a press 104 Any number >0 to wait that many ticks for a press
103 105
104 */ 106 */
105static int get_action_worker(int context, int timeout, 107static int get_action_worker(int context, int timeout,
106 const struct button_mapping* (*get_context_map)(int) ) 108 const struct button_mapping* (*get_context_map)(int) )
@@ -110,7 +112,7 @@ static int get_action_worker(int context, int timeout,
110 int i=0; 112 int i=0;
111 int ret = ACTION_UNKNOWN; 113 int ret = ACTION_UNKNOWN;
112 static int last_context = CONTEXT_STD; 114 static int last_context = CONTEXT_STD;
113 115
114 if (timeout == TIMEOUT_NOBLOCK) 116 if (timeout == TIMEOUT_NOBLOCK)
115 button = button_get(false); 117 button = button_get(false);
116 else if (timeout == TIMEOUT_BLOCK) 118 else if (timeout == TIMEOUT_BLOCK)
@@ -119,14 +121,19 @@ static int get_action_worker(int context, int timeout,
119 button = button_get_w_tmo(timeout); 121 button = button_get_w_tmo(timeout);
120 122
121 /* Data from sys events can be pulled with button_get_data */ 123 /* Data from sys events can be pulled with button_get_data */
122 if (button == BUTTON_NONE || button&SYS_EVENT) 124 if (button == BUTTON_NONE || button & SYS_EVENT)
123 {
124 return button; 125 return button;
125 } 126
126 127#if CONFIG_CODEC == SWCODEC
127 if ((context != last_context) && ((last_button&BUTTON_REL) == 0)) 128 /* Produce keyclick */
129 if (global_settings.keyclick && !(button & BUTTON_REL))
130 if (!(button & BUTTON_REPEAT) || global_settings.keyclick_repeats)
131 pcmbuf_beep(5000, 2, 2500*global_settings.keyclick);
132#endif
133
134 if ((context != last_context) && ((last_button & BUTTON_REL) == 0))
128 { 135 {
129 if (button&BUTTON_REL) 136 if (button & BUTTON_REL)
130 { 137 {
131 last_button = button; 138 last_button = button;
132 last_action = ACTION_NONE; 139 last_action = ACTION_NONE;
@@ -137,18 +144,18 @@ static int get_action_worker(int context, int timeout,
137 } 144 }
138 last_context = context; 145 last_context = context;
139#ifdef HAVE_TOUCHPAD 146#ifdef HAVE_TOUCHPAD
140 if (button&BUTTON_TOUCHPAD) 147 if (button & BUTTON_TOUCHPAD)
141 { 148 {
142 repeated = false; 149 repeated = false;
143 short_press = false; 150 short_press = false;
144 if (last_button&BUTTON_TOUCHPAD) 151 if (last_button & BUTTON_TOUCHPAD)
145 { 152 {
146 if ((button&BUTTON_REL) && 153 if ((button & BUTTON_REL) &&
147 ((last_button&BUTTON_REPEAT)==0)) 154 ((last_button & BUTTON_REPEAT)==0))
148 { 155 {
149 short_press = true; 156 short_press = true;
150 } 157 }
151 else if (button&BUTTON_REPEAT) 158 else if (button & BUTTON_REPEAT)
152 repeated = true; 159 repeated = true;
153 } 160 }
154 last_button = button; 161 last_button = button;
@@ -156,48 +163,48 @@ static int get_action_worker(int context, int timeout,
156 } 163 }
157#endif 164#endif
158#ifndef HAS_BUTTON_HOLD 165#ifndef HAS_BUTTON_HOLD
159 screen_has_lock = ((context&ALLOW_SOFTLOCK)==ALLOW_SOFTLOCK); 166 screen_has_lock = ((context & ALLOW_SOFTLOCK) == ALLOW_SOFTLOCK);
160 if (screen_has_lock && (keys_locked == true)) 167 if (screen_has_lock && (keys_locked == true))
161 { 168 {
162 if (button == unlock_combo) 169 if (button == unlock_combo)
163 { 170 {
164 last_button = BUTTON_NONE; 171 last_button = BUTTON_NONE;
165 keys_locked = false; 172 keys_locked = false;
166 gui_syncsplash(HZ/2, str(LANG_KEYLOCK_OFF)); 173 gui_syncsplash(HZ/2, str(LANG_KEYLOCK_OFF));
167 return ACTION_REDRAW; 174 return ACTION_REDRAW;
168 } 175 }
169 else 176 else
170#if (BUTTON_REMOTE != 0) 177#if (BUTTON_REMOTE != 0)
171 if ((button&BUTTON_REMOTE) == 0) 178 if ((button & BUTTON_REMOTE) == 0)
172#endif 179#endif
173 { 180 {
174 if ((button&BUTTON_REL)) 181 if ((button & BUTTON_REL))
175 gui_syncsplash(HZ/2, str(LANG_KEYLOCK_ON)); 182 gui_syncsplash(HZ/2, str(LANG_KEYLOCK_ON));
176 return ACTION_REDRAW; 183 return ACTION_REDRAW;
177 } 184 }
178 } 185 }
179 context &= ~ALLOW_SOFTLOCK; 186 context &= ~ALLOW_SOFTLOCK;
180#endif /* HAS_BUTTON_HOLD */ 187#endif /* HAS_BUTTON_HOLD */
181 188
182 /* logf("%x,%x",last_button,button); */ 189 /* logf("%x,%x",last_button,button); */
183 do 190 do
184 { 191 {
185 /* logf("context = %x",context); */ 192 /* logf("context = %x",context); */
186#if (BUTTON_REMOTE != 0) 193#if (BUTTON_REMOTE != 0)
187 if (button&BUTTON_REMOTE) 194 if (button & BUTTON_REMOTE)
188 context |= CONTEXT_REMOTE; 195 context |= CONTEXT_REMOTE;
189#endif 196#endif
190 if ((context&CONTEXT_CUSTOM) && get_context_map) 197 if ((context & CONTEXT_CUSTOM) && get_context_map)
191 items = get_context_map(context); 198 items = get_context_map(context);
192 else 199 else
193 items = get_context_mapping(context); 200 items = get_context_mapping(context);
194 201
195 ret = do_button_check(items,button,last_button,&i); 202 ret = do_button_check(items,button,last_button,&i);
196 203
197 if ((context ==(int)CONTEXT_STOPSEARCHING) || 204 if ((context ==(int)CONTEXT_STOPSEARCHING) ||
198 items == NULL ) 205 items == NULL )
199 break; 206 break;
200 207
201 if (ret == ACTION_UNKNOWN ) 208 if (ret == ACTION_UNKNOWN )
202 { 209 {
203 context = get_next_context(items,i); 210 context = get_next_context(items,i);
@@ -208,19 +215,19 @@ static int get_action_worker(int context, int timeout,
208 /* DEBUGF("ret = %x\n",ret); */ 215 /* DEBUGF("ret = %x\n",ret); */
209#ifndef HAS_BUTTON_HOLD 216#ifndef HAS_BUTTON_HOLD
210 if (screen_has_lock && (ret == ACTION_STD_KEYLOCK)) 217 if (screen_has_lock && (ret == ACTION_STD_KEYLOCK))
211 { 218 {
212 unlock_combo = button; 219 unlock_combo = button;
213 keys_locked = true; 220 keys_locked = true;
214 gui_syncsplash(HZ/2, str(LANG_KEYLOCK_ON)); 221 gui_syncsplash(HZ/2, str(LANG_KEYLOCK_ON));
215 222
216 button_clear_queue(); 223 button_clear_queue();
217 return ACTION_REDRAW; 224 return ACTION_REDRAW;
218 } 225 }
219#endif 226#endif
220 if ((current_tick - last_action_tick < REPEAT_WINDOW_TICKS) 227 if ((current_tick - last_action_tick < REPEAT_WINDOW_TICKS)
221 && (ret == last_action)) 228 && (ret == last_action))
222 repeated = true; 229 repeated = true;
223 else 230 else
224 repeated = false; 231 repeated = false;
225 232
226 last_button = button; 233 last_button = button;
@@ -266,7 +273,7 @@ int get_action_statuscode(int *button)
266 if (button) 273 if (button)
267 *button = last_button; 274 *button = last_button;
268 275
269 if (last_button&BUTTON_REMOTE) 276 if (last_button & BUTTON_REMOTE)
270 ret |= ACTION_REMOTE; 277 ret |= ACTION_REMOTE;
271 if (repeated) 278 if (repeated)
272 ret |= ACTION_REPEAT; 279 ret |= ACTION_REPEAT;
@@ -283,10 +290,10 @@ int action_get_touchpad_press(short *x, short *y)
283{ 290{
284 static int last_data = 0; 291 static int last_data = 0;
285 int data; 292 int data;
286 if ((last_button&BUTTON_TOUCHPAD) == 0) 293 if ((last_button & BUTTON_TOUCHPAD) == 0)
287 return BUTTON_NONE; 294 return BUTTON_NONE;
288 data = button_get_data(); 295 data = button_get_data();
289 if (last_button&BUTTON_REL) 296 if (last_button & BUTTON_REL)
290 { 297 {
291 *x = (last_data&0xffff0000)>>16; 298 *x = (last_data&0xffff0000)>>16;
292 *y = (last_data&0xffff); 299 *y = (last_data&0xffff);