summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/action.c89
-rw-r--r--apps/lang/english.lang34
-rw-r--r--apps/menus/settings_menu.c16
-rw-r--r--apps/settings.h20
-rw-r--r--apps/settings_list.c7
5 files changed, 116 insertions, 50 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);
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 3e918ff62e..a51291a8ac 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -11540,3 +11540,37 @@
11540 *: "Save Sound Settings" 11540 *: "Save Sound Settings"
11541 </voice> 11541 </voice>
11542</phrase> 11542</phrase>
11543<phrase>
11544 id: LANG_KEYCLICK
11545 desc: in keyclick settings men
11546 user:
11547 <source>
11548 *: none
11549 swcodec: "Keyclick"
11550 </source>
11551 <dest>
11552 *: none
11553 swcodec: "Keyclick"
11554 </dest>
11555 <voice>
11556 *: none
11557 swcodec: "Keyclick"
11558 </voice>
11559</phrase>
11560<phrase>
11561 id: LANG_KEYCLICK_REPEATS
11562 desc: in keyclick settings men
11563 user:
11564 <source>
11565 *: none
11566 swcodec: "Keyclick Repeats"
11567 </source>
11568 <dest>
11569 *: none
11570 swcodec: "Keyclick Repeats"
11571 </dest>
11572 <voice>
11573 *: none
11574 swcodec: "Keyclick Repeats"
11575 </voice>
11576</phrase>
diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c
index cbd2faf40b..08fd071a36 100644
--- a/apps/menus/settings_menu.c
+++ b/apps/menus/settings_menu.c
@@ -312,6 +312,16 @@ MENUITEM_SETTING(max_files_in_playlist, &global_settings.max_files_in_playlist,
312MAKE_MENU(limits_menu, ID2P(LANG_LIMITS_MENU), 0, Icon_NOICON, 312MAKE_MENU(limits_menu, ID2P(LANG_LIMITS_MENU), 0, Icon_NOICON,
313 &max_files_in_dir, &max_files_in_playlist); 313 &max_files_in_dir, &max_files_in_playlist);
314 314
315
316/* Keyclick menu */
317#if CONFIG_CODEC == SWCODEC
318MENUITEM_SETTING(keyclick, &global_settings.keyclick, NULL);
319MENUITEM_SETTING(keyclick_repeats, &global_settings.keyclick_repeats, NULL);
320MAKE_MENU(keyclick_menu, ID2P(LANG_KEYCLICK), 0, Icon_NOICON,
321 &keyclick, &keyclick_repeats);
322#endif
323
324
315#if CONFIG_CODEC == MAS3507D 325#if CONFIG_CODEC == MAS3507D
316void dac_line_in(bool enable); 326void dac_line_in(bool enable);
317static int linein_callback(int action,const struct menu_item_ex *this_item) 327static int linein_callback(int action,const struct menu_item_ex *this_item)
@@ -342,6 +352,7 @@ MENUITEM_SETTING(buttonlight_timeout, &global_settings.buttonlight_timeout, NULL
342MENUITEM_SETTING(buttonlight_brightness, &global_settings.buttonlight_brightness, NULL); 352MENUITEM_SETTING(buttonlight_brightness, &global_settings.buttonlight_brightness, NULL);
343#endif 353#endif
344 354
355
345MAKE_MENU(system_menu, ID2P(LANG_SYSTEM), 356MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
346 0, Icon_System_menu, 357 0, Icon_System_menu,
347 &start_screen, 358 &start_screen,
@@ -372,7 +383,10 @@ MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
372 &buttonlight_timeout, 383 &buttonlight_timeout,
373#endif 384#endif
374#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS 385#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
375 &buttonlight_brightness 386 &buttonlight_brightness,
387#endif
388#if CONFIG_CODEC == SWCODEC
389 &keyclick_menu,
376#endif 390#endif
377 ); 391 );
378 392
diff --git a/apps/settings.h b/apps/settings.h
index 39ff4da25b..179a3390d7 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -237,12 +237,12 @@ bool set_option(const char* string, void* variable, enum optiontype type,
237 const struct opt_items* options, int numoptions, void (*function)(int)); 237 const struct opt_items* options, int numoptions, void (*function)(int));
238bool set_int(const unsigned char* string, const char* unit, int voice_unit, 238bool set_int(const unsigned char* string, const char* unit, int voice_unit,
239 int* variable, 239 int* variable,
240 void (*function)(int), int step, int min, int max, 240 void (*function)(int), int step, int min, int max,
241 void (*formatter)(char*, size_t, int, const char*) ); 241 void (*formatter)(char*, size_t, int, const char*) );
242/* use this one if you need to create a lang from the value (i.e with TALK_ID()) */ 242/* use this one if you need to create a lang from the value (i.e with TALK_ID()) */
243bool set_int_ex(const unsigned char* string, const char* unit, int voice_unit, 243bool set_int_ex(const unsigned char* string, const char* unit, int voice_unit,
244 int* variable, 244 int* variable,
245 void (*function)(int), int step, int min, int max, 245 void (*function)(int), int step, int min, int max,
246 void (*formatter)(char*, size_t, int, const char*), 246 void (*formatter)(char*, size_t, int, const char*),
247 int32_t (*get_talk_id)(int, int)); 247 int32_t (*get_talk_id)(int, int));
248 248
@@ -353,7 +353,7 @@ struct user_settings
353 1 = main lcd 353 1 = main lcd
354 2 = main and remote lcd 354 2 = main and remote lcd
355 3 = remote lcd */ 355 3 = remote lcd */
356 356
357 int rec_start_thres; /* negative: db, positive: % range -87 .. 100 */ 357 int rec_start_thres; /* negative: db, positive: % range -87 .. 100 */
358 int rec_start_duration; /* index of trig_durations */ 358 int rec_start_duration; /* index of trig_durations */
359 int rec_stop_thres; /* negative: db, positive: % */ 359 int rec_stop_thres; /* negative: db, positive: % */
@@ -520,7 +520,7 @@ struct user_settings
520 bool talk_menu; /* enable voice UI */ 520 bool talk_menu; /* enable voice UI */
521 int talk_dir; /* voiced directories mode: 0=off 1=number 2=spell */ 521 int talk_dir; /* voiced directories mode: 0=off 1=number 2=spell */
522 bool talk_dir_clip; /* use directory .talk clips */ 522 bool talk_dir_clip; /* use directory .talk clips */
523 int talk_file; /* voice file mode: 0=off, 1=number, 2=spell */ 523 int talk_file; /* voice file mode: 0=off, 1=number, 2=spell */
524 bool talk_file_clip; /* use file .talk clips */ 524 bool talk_file_clip; /* use file .talk clips */
525 bool talk_filetype; /* say file type */ 525 bool talk_filetype; /* say file type */
526 bool talk_battery_level; 526 bool talk_battery_level;
@@ -528,7 +528,7 @@ struct user_settings
528 /* file browser sorting */ 528 /* file browser sorting */
529 int sort_file; /* 0=alpha, 1=date, 2=date (new first), 3=type */ 529 int sort_file; /* 0=alpha, 1=date, 2=date (new first), 3=type */
530 int sort_dir; /* 0=alpha, 1=date (old first), 2=date (new first) */ 530 int sort_dir; /* 0=alpha, 1=date (old first), 2=date (new first) */
531 531
532#ifdef HAVE_REMOTE_LCD 532#ifdef HAVE_REMOTE_LCD
533 /* remote lcd */ 533 /* remote lcd */
534 int remote_contrast; /* lcd contrast: 0-63 0=low 63=high */ 534 int remote_contrast; /* lcd contrast: 0-63 0=low 63=high */
@@ -548,7 +548,7 @@ struct user_settings
548 1=EMI reduce on with cost more CPU. */ 548 1=EMI reduce on with cost more CPU. */
549#endif 549#endif
550#endif /* HAVE_REMOTE_LCD */ 550#endif /* HAVE_REMOTE_LCD */
551 551
552 int next_folder; /* move to next folder */ 552 int next_folder; /* move to next folder */
553 bool runtimedb; /* runtime database active? */ 553 bool runtimedb; /* runtime database active? */
554 554
@@ -559,7 +559,7 @@ struct user_settings
559 shuffle is on, album gain otherwise */ 559 shuffle is on, album gain otherwise */
560 int replaygain_preamp; /* scale replaygained tracks by this */ 560 int replaygain_preamp; /* scale replaygained tracks by this */
561 int beep; /* system beep volume when changing tracks etc. */ 561 int beep; /* system beep volume when changing tracks etc. */
562 562
563 /* Crossfeed settings */ 563 /* Crossfeed settings */
564 bool crossfeed; /* enable crossfeed */ 564 bool crossfeed; /* enable crossfeed */
565 unsigned int crossfeed_direct_gain; /* dB x 10 */ 565 unsigned int crossfeed_direct_gain; /* dB x 10 */
@@ -631,7 +631,7 @@ struct user_settings
631 int lst_color; /* color of the text for the selector */ 631 int lst_color; /* color of the text for the selector */
632#endif 632#endif
633 bool party_mode; /* party mode - unstoppable music */ 633 bool party_mode; /* party mode - unstoppable music */
634 634
635#ifdef HAVE_BACKLIGHT 635#ifdef HAVE_BACKLIGHT
636 bool bl_filter_first_keypress; /* filter first keypress when dark? */ 636 bool bl_filter_first_keypress; /* filter first keypress when dark? */
637#ifdef HAVE_REMOTE_LCD 637#ifdef HAVE_REMOTE_LCD
@@ -719,6 +719,10 @@ struct user_settings
719 int usb_stack_mode; /* device or host */ 719 int usb_stack_mode; /* device or host */
720 unsigned char usb_stack_device_driver[32]; /* usb device driver to load */ 720 unsigned char usb_stack_device_driver[32]; /* usb device driver to load */
721#endif 721#endif
722#if CONFIG_CODEC == SWCODEC
723 int keyclick; /* keyclick volume */
724 int keyclick_repeats; /* keyclick on repeats */
725#endif
722}; 726};
723 727
724/** global variables **/ 728/** global variables **/
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 1abc154825..a767732c3e 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -1180,6 +1180,13 @@ const struct settings_list settings[] = {
1180#if CONFIG_TUNER 1180#if CONFIG_TUNER
1181 SYSTEM_SETTING(0, statusbar_forced, 0), 1181 SYSTEM_SETTING(0, statusbar_forced, 0),
1182#endif 1182#endif
1183#if CONFIG_CODEC == SWCODEC
1184 /* keyclick */
1185 CHOICE_SETTING(0, keyclick, LANG_KEYCLICK, 0,
1186 "keyclick", "off,weak,moderate,strong", NULL, 4,
1187 ID2P(LANG_OFF), ID2P(LANG_WEAK), ID2P(LANG_MODERATE), ID2P(LANG_STRONG)),
1188 OFFON_SETTING(0, keyclick_repeats, LANG_KEYCLICK_REPEATS, false, "keyclick repeats", NULL),
1189#endif /* CONFIG_CODEC == SWCODEC */
1183}; 1190};
1184 1191
1185const int nb_settings = sizeof(settings)/sizeof(*settings); 1192const int nb_settings = sizeof(settings)/sizeof(*settings);