1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Steve Bavin 2008-01-21 09:48:44 +00:00
parent cba886d9b7
commit ea358a1fdc
5 changed files with 116 additions and 50 deletions

View file

@ -8,7 +8,7 @@
* $Id$ * $Id$
* *
* Copyright (C) 2006 Jonathan Gordon * Copyright (C) 2006 Jonathan Gordon
* *
* All files in this archive are subject to the GNU General Public License. * All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement. * See the file COPYING in the source tree root for full license agreement.
* *
@ -28,8 +28,10 @@
#include "kernel.h" #include "kernel.h"
#include "debug.h" #include "debug.h"
#include "splash.h" #include "splash.h"
#include "settings.h"
#include "pcmbuf.h"
static int last_button = BUTTON_NONE|BUTTON_REL; /* allow the ipod wheel to static int last_button = BUTTON_NONE|BUTTON_REL; /* allow the ipod wheel to
work on startup */ work on startup */
static intptr_t last_data = 0; static intptr_t last_data = 0;
static int last_action = ACTION_NONE; static int last_action = ACTION_NONE;
@ -63,7 +65,7 @@ static inline int do_button_check(const struct button_mapping *items,
while (items[i].button_code != BUTTON_NONE) while (items[i].button_code != BUTTON_NONE)
{ {
if (items[i].button_code == button) if (items[i].button_code == button)
{ {
if ((items[i].pre_button_code == BUTTON_NONE) if ((items[i].pre_button_code == BUTTON_NONE)
|| (items[i].pre_button_code == last_button)) || (items[i].pre_button_code == last_button))
@ -82,8 +84,8 @@ static inline int get_next_context(const struct button_mapping *items, int i)
{ {
while (items[i].button_code != BUTTON_NONE) while (items[i].button_code != BUTTON_NONE)
i++; i++;
return (items[i].action_code == ACTION_NONE ) ? return (items[i].action_code == ACTION_NONE ) ?
CONTEXT_STD : CONTEXT_STD :
items[i].action_code; items[i].action_code;
} }
/* /*
@ -96,11 +98,11 @@ static inline int get_next_context(const struct button_mapping *items, int i)
the last item in the list "points" to the next context in a chain the last item in the list "points" to the next context in a chain
so the "chain" is followed until the button is found. so the "chain" is followed until the button is found.
putting ACTION_NONE will get CONTEXT_STD which is always the last list checked. putting ACTION_NONE will get CONTEXT_STD which is always the last list checked.
Timeout can be TIMEOUT_NOBLOCK to return immediatly Timeout can be TIMEOUT_NOBLOCK to return immediatly
TIMEOUT_BLOCK to wait for a button press TIMEOUT_BLOCK to wait for a button press
Any number >0 to wait that many ticks for a press Any number >0 to wait that many ticks for a press
*/ */
static int get_action_worker(int context, int timeout, static int get_action_worker(int context, int timeout,
const struct button_mapping* (*get_context_map)(int) ) const struct button_mapping* (*get_context_map)(int) )
@ -110,7 +112,7 @@ static int get_action_worker(int context, int timeout,
int i=0; int i=0;
int ret = ACTION_UNKNOWN; int ret = ACTION_UNKNOWN;
static int last_context = CONTEXT_STD; static int last_context = CONTEXT_STD;
if (timeout == TIMEOUT_NOBLOCK) if (timeout == TIMEOUT_NOBLOCK)
button = button_get(false); button = button_get(false);
else if (timeout == TIMEOUT_BLOCK) else if (timeout == TIMEOUT_BLOCK)
@ -119,14 +121,19 @@ static int get_action_worker(int context, int timeout,
button = button_get_w_tmo(timeout); button = button_get_w_tmo(timeout);
/* Data from sys events can be pulled with button_get_data */ /* Data from sys events can be pulled with button_get_data */
if (button == BUTTON_NONE || button&SYS_EVENT) if (button == BUTTON_NONE || button & SYS_EVENT)
{
return button; return button;
}
#if CONFIG_CODEC == SWCODEC
if ((context != last_context) && ((last_button&BUTTON_REL) == 0)) /* Produce keyclick */
if (global_settings.keyclick && !(button & BUTTON_REL))
if (!(button & BUTTON_REPEAT) || global_settings.keyclick_repeats)
pcmbuf_beep(5000, 2, 2500*global_settings.keyclick);
#endif
if ((context != last_context) && ((last_button & BUTTON_REL) == 0))
{ {
if (button&BUTTON_REL) if (button & BUTTON_REL)
{ {
last_button = button; last_button = button;
last_action = ACTION_NONE; last_action = ACTION_NONE;
@ -137,18 +144,18 @@ static int get_action_worker(int context, int timeout,
} }
last_context = context; last_context = context;
#ifdef HAVE_TOUCHPAD #ifdef HAVE_TOUCHPAD
if (button&BUTTON_TOUCHPAD) if (button & BUTTON_TOUCHPAD)
{ {
repeated = false; repeated = false;
short_press = false; short_press = false;
if (last_button&BUTTON_TOUCHPAD) if (last_button & BUTTON_TOUCHPAD)
{ {
if ((button&BUTTON_REL) && if ((button & BUTTON_REL) &&
((last_button&BUTTON_REPEAT)==0)) ((last_button & BUTTON_REPEAT)==0))
{ {
short_press = true; short_press = true;
} }
else if (button&BUTTON_REPEAT) else if (button & BUTTON_REPEAT)
repeated = true; repeated = true;
} }
last_button = button; last_button = button;
@ -156,48 +163,48 @@ static int get_action_worker(int context, int timeout,
} }
#endif #endif
#ifndef HAS_BUTTON_HOLD #ifndef HAS_BUTTON_HOLD
screen_has_lock = ((context&ALLOW_SOFTLOCK)==ALLOW_SOFTLOCK); screen_has_lock = ((context & ALLOW_SOFTLOCK) == ALLOW_SOFTLOCK);
if (screen_has_lock && (keys_locked == true)) if (screen_has_lock && (keys_locked == true))
{ {
if (button == unlock_combo) if (button == unlock_combo)
{ {
last_button = BUTTON_NONE; last_button = BUTTON_NONE;
keys_locked = false; keys_locked = false;
gui_syncsplash(HZ/2, str(LANG_KEYLOCK_OFF)); gui_syncsplash(HZ/2, str(LANG_KEYLOCK_OFF));
return ACTION_REDRAW; return ACTION_REDRAW;
} }
else else
#if (BUTTON_REMOTE != 0) #if (BUTTON_REMOTE != 0)
if ((button&BUTTON_REMOTE) == 0) if ((button & BUTTON_REMOTE) == 0)
#endif #endif
{ {
if ((button&BUTTON_REL)) if ((button & BUTTON_REL))
gui_syncsplash(HZ/2, str(LANG_KEYLOCK_ON)); gui_syncsplash(HZ/2, str(LANG_KEYLOCK_ON));
return ACTION_REDRAW; return ACTION_REDRAW;
} }
} }
context &= ~ALLOW_SOFTLOCK; context &= ~ALLOW_SOFTLOCK;
#endif /* HAS_BUTTON_HOLD */ #endif /* HAS_BUTTON_HOLD */
/* logf("%x,%x",last_button,button); */ /* logf("%x,%x",last_button,button); */
do do
{ {
/* logf("context = %x",context); */ /* logf("context = %x",context); */
#if (BUTTON_REMOTE != 0) #if (BUTTON_REMOTE != 0)
if (button&BUTTON_REMOTE) if (button & BUTTON_REMOTE)
context |= CONTEXT_REMOTE; context |= CONTEXT_REMOTE;
#endif #endif
if ((context&CONTEXT_CUSTOM) && get_context_map) if ((context & CONTEXT_CUSTOM) && get_context_map)
items = get_context_map(context); items = get_context_map(context);
else else
items = get_context_mapping(context); items = get_context_mapping(context);
ret = do_button_check(items,button,last_button,&i); ret = do_button_check(items,button,last_button,&i);
if ((context ==(int)CONTEXT_STOPSEARCHING) || if ((context ==(int)CONTEXT_STOPSEARCHING) ||
items == NULL ) items == NULL )
break; break;
if (ret == ACTION_UNKNOWN ) if (ret == ACTION_UNKNOWN )
{ {
context = get_next_context(items,i); context = get_next_context(items,i);
@ -208,19 +215,19 @@ static int get_action_worker(int context, int timeout,
/* DEBUGF("ret = %x\n",ret); */ /* DEBUGF("ret = %x\n",ret); */
#ifndef HAS_BUTTON_HOLD #ifndef HAS_BUTTON_HOLD
if (screen_has_lock && (ret == ACTION_STD_KEYLOCK)) if (screen_has_lock && (ret == ACTION_STD_KEYLOCK))
{ {
unlock_combo = button; unlock_combo = button;
keys_locked = true; keys_locked = true;
gui_syncsplash(HZ/2, str(LANG_KEYLOCK_ON)); gui_syncsplash(HZ/2, str(LANG_KEYLOCK_ON));
button_clear_queue(); button_clear_queue();
return ACTION_REDRAW; return ACTION_REDRAW;
} }
#endif #endif
if ((current_tick - last_action_tick < REPEAT_WINDOW_TICKS) if ((current_tick - last_action_tick < REPEAT_WINDOW_TICKS)
&& (ret == last_action)) && (ret == last_action))
repeated = true; repeated = true;
else else
repeated = false; repeated = false;
last_button = button; last_button = button;
@ -266,7 +273,7 @@ int get_action_statuscode(int *button)
if (button) if (button)
*button = last_button; *button = last_button;
if (last_button&BUTTON_REMOTE) if (last_button & BUTTON_REMOTE)
ret |= ACTION_REMOTE; ret |= ACTION_REMOTE;
if (repeated) if (repeated)
ret |= ACTION_REPEAT; ret |= ACTION_REPEAT;
@ -283,10 +290,10 @@ int action_get_touchpad_press(short *x, short *y)
{ {
static int last_data = 0; static int last_data = 0;
int data; int data;
if ((last_button&BUTTON_TOUCHPAD) == 0) if ((last_button & BUTTON_TOUCHPAD) == 0)
return BUTTON_NONE; return BUTTON_NONE;
data = button_get_data(); data = button_get_data();
if (last_button&BUTTON_REL) if (last_button & BUTTON_REL)
{ {
*x = (last_data&0xffff0000)>>16; *x = (last_data&0xffff0000)>>16;
*y = (last_data&0xffff); *y = (last_data&0xffff);

View file

@ -11540,3 +11540,37 @@
*: "Save Sound Settings" *: "Save Sound Settings"
</voice> </voice>
</phrase> </phrase>
<phrase>
id: LANG_KEYCLICK
desc: in keyclick settings men
user:
<source>
*: none
swcodec: "Keyclick"
</source>
<dest>
*: none
swcodec: "Keyclick"
</dest>
<voice>
*: none
swcodec: "Keyclick"
</voice>
</phrase>
<phrase>
id: LANG_KEYCLICK_REPEATS
desc: in keyclick settings men
user:
<source>
*: none
swcodec: "Keyclick Repeats"
</source>
<dest>
*: none
swcodec: "Keyclick Repeats"
</dest>
<voice>
*: none
swcodec: "Keyclick Repeats"
</voice>
</phrase>

View file

@ -312,6 +312,16 @@ MENUITEM_SETTING(max_files_in_playlist, &global_settings.max_files_in_playlist,
MAKE_MENU(limits_menu, ID2P(LANG_LIMITS_MENU), 0, Icon_NOICON, MAKE_MENU(limits_menu, ID2P(LANG_LIMITS_MENU), 0, Icon_NOICON,
&max_files_in_dir, &max_files_in_playlist); &max_files_in_dir, &max_files_in_playlist);
/* Keyclick menu */
#if CONFIG_CODEC == SWCODEC
MENUITEM_SETTING(keyclick, &global_settings.keyclick, NULL);
MENUITEM_SETTING(keyclick_repeats, &global_settings.keyclick_repeats, NULL);
MAKE_MENU(keyclick_menu, ID2P(LANG_KEYCLICK), 0, Icon_NOICON,
&keyclick, &keyclick_repeats);
#endif
#if CONFIG_CODEC == MAS3507D #if CONFIG_CODEC == MAS3507D
void dac_line_in(bool enable); void dac_line_in(bool enable);
static int linein_callback(int action,const struct menu_item_ex *this_item) static 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
MENUITEM_SETTING(buttonlight_brightness, &global_settings.buttonlight_brightness, NULL); MENUITEM_SETTING(buttonlight_brightness, &global_settings.buttonlight_brightness, NULL);
#endif #endif
MAKE_MENU(system_menu, ID2P(LANG_SYSTEM), MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
0, Icon_System_menu, 0, Icon_System_menu,
&start_screen, &start_screen,
@ -372,7 +383,10 @@ MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
&buttonlight_timeout, &buttonlight_timeout,
#endif #endif
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
&buttonlight_brightness &buttonlight_brightness,
#endif
#if CONFIG_CODEC == SWCODEC
&keyclick_menu,
#endif #endif
); );

View file

@ -237,12 +237,12 @@ bool set_option(const char* string, void* variable, enum optiontype type,
const struct opt_items* options, int numoptions, void (*function)(int)); const struct opt_items* options, int numoptions, void (*function)(int));
bool set_int(const unsigned char* string, const char* unit, int voice_unit, bool set_int(const unsigned char* string, const char* unit, int voice_unit,
int* variable, int* variable,
void (*function)(int), int step, int min, int max, void (*function)(int), int step, int min, int max,
void (*formatter)(char*, size_t, int, const char*) ); void (*formatter)(char*, size_t, int, const char*) );
/* use this one if you need to create a lang from the value (i.e with TALK_ID()) */ /* use this one if you need to create a lang from the value (i.e with TALK_ID()) */
bool set_int_ex(const unsigned char* string, const char* unit, int voice_unit, bool set_int_ex(const unsigned char* string, const char* unit, int voice_unit,
int* variable, int* variable,
void (*function)(int), int step, int min, int max, void (*function)(int), int step, int min, int max,
void (*formatter)(char*, size_t, int, const char*), void (*formatter)(char*, size_t, int, const char*),
int32_t (*get_talk_id)(int, int)); int32_t (*get_talk_id)(int, int));
@ -353,7 +353,7 @@ struct user_settings
1 = main lcd 1 = main lcd
2 = main and remote lcd 2 = main and remote lcd
3 = remote lcd */ 3 = remote lcd */
int rec_start_thres; /* negative: db, positive: % range -87 .. 100 */ int rec_start_thres; /* negative: db, positive: % range -87 .. 100 */
int rec_start_duration; /* index of trig_durations */ int rec_start_duration; /* index of trig_durations */
int rec_stop_thres; /* negative: db, positive: % */ int rec_stop_thres; /* negative: db, positive: % */
@ -520,7 +520,7 @@ struct user_settings
bool talk_menu; /* enable voice UI */ bool talk_menu; /* enable voice UI */
int talk_dir; /* voiced directories mode: 0=off 1=number 2=spell */ int talk_dir; /* voiced directories mode: 0=off 1=number 2=spell */
bool talk_dir_clip; /* use directory .talk clips */ bool talk_dir_clip; /* use directory .talk clips */
int talk_file; /* voice file mode: 0=off, 1=number, 2=spell */ int talk_file; /* voice file mode: 0=off, 1=number, 2=spell */
bool talk_file_clip; /* use file .talk clips */ bool talk_file_clip; /* use file .talk clips */
bool talk_filetype; /* say file type */ bool talk_filetype; /* say file type */
bool talk_battery_level; bool talk_battery_level;
@ -528,7 +528,7 @@ struct user_settings
/* file browser sorting */ /* file browser sorting */
int sort_file; /* 0=alpha, 1=date, 2=date (new first), 3=type */ int sort_file; /* 0=alpha, 1=date, 2=date (new first), 3=type */
int sort_dir; /* 0=alpha, 1=date (old first), 2=date (new first) */ int sort_dir; /* 0=alpha, 1=date (old first), 2=date (new first) */
#ifdef HAVE_REMOTE_LCD #ifdef HAVE_REMOTE_LCD
/* remote lcd */ /* remote lcd */
int remote_contrast; /* lcd contrast: 0-63 0=low 63=high */ int remote_contrast; /* lcd contrast: 0-63 0=low 63=high */
@ -548,7 +548,7 @@ struct user_settings
1=EMI reduce on with cost more CPU. */ 1=EMI reduce on with cost more CPU. */
#endif #endif
#endif /* HAVE_REMOTE_LCD */ #endif /* HAVE_REMOTE_LCD */
int next_folder; /* move to next folder */ int next_folder; /* move to next folder */
bool runtimedb; /* runtime database active? */ bool runtimedb; /* runtime database active? */
@ -559,7 +559,7 @@ struct user_settings
shuffle is on, album gain otherwise */ shuffle is on, album gain otherwise */
int replaygain_preamp; /* scale replaygained tracks by this */ int replaygain_preamp; /* scale replaygained tracks by this */
int beep; /* system beep volume when changing tracks etc. */ int beep; /* system beep volume when changing tracks etc. */
/* Crossfeed settings */ /* Crossfeed settings */
bool crossfeed; /* enable crossfeed */ bool crossfeed; /* enable crossfeed */
unsigned int crossfeed_direct_gain; /* dB x 10 */ unsigned int crossfeed_direct_gain; /* dB x 10 */
@ -631,7 +631,7 @@ struct user_settings
int lst_color; /* color of the text for the selector */ int lst_color; /* color of the text for the selector */
#endif #endif
bool party_mode; /* party mode - unstoppable music */ bool party_mode; /* party mode - unstoppable music */
#ifdef HAVE_BACKLIGHT #ifdef HAVE_BACKLIGHT
bool bl_filter_first_keypress; /* filter first keypress when dark? */ bool bl_filter_first_keypress; /* filter first keypress when dark? */
#ifdef HAVE_REMOTE_LCD #ifdef HAVE_REMOTE_LCD
@ -719,6 +719,10 @@ struct user_settings
int usb_stack_mode; /* device or host */ int usb_stack_mode; /* device or host */
unsigned char usb_stack_device_driver[32]; /* usb device driver to load */ unsigned char usb_stack_device_driver[32]; /* usb device driver to load */
#endif #endif
#if CONFIG_CODEC == SWCODEC
int keyclick; /* keyclick volume */
int keyclick_repeats; /* keyclick on repeats */
#endif
}; };
/** global variables **/ /** global variables **/

View file

@ -1180,6 +1180,13 @@ const struct settings_list settings[] = {
#if CONFIG_TUNER #if CONFIG_TUNER
SYSTEM_SETTING(0, statusbar_forced, 0), SYSTEM_SETTING(0, statusbar_forced, 0),
#endif #endif
#if CONFIG_CODEC == SWCODEC
/* keyclick */
CHOICE_SETTING(0, keyclick, LANG_KEYCLICK, 0,
"keyclick", "off,weak,moderate,strong", NULL, 4,
ID2P(LANG_OFF), ID2P(LANG_WEAK), ID2P(LANG_MODERATE), ID2P(LANG_STRONG)),
OFFON_SETTING(0, keyclick_repeats, LANG_KEYCLICK_REPEATS, false, "keyclick repeats", NULL),
#endif /* CONFIG_CODEC == SWCODEC */
}; };
const int nb_settings = sizeof(settings)/sizeof(*settings); const int nb_settings = sizeof(settings)/sizeof(*settings);