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$
*
* Copyright (C) 2006 Jonathan Gordon
*
*
* 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.
*
@ -28,8 +28,10 @@
#include "kernel.h"
#include "debug.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 */
static intptr_t last_data = 0;
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)
{
if (items[i].button_code == button)
if (items[i].button_code == button)
{
if ((items[i].pre_button_code == BUTTON_NONE)
|| (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)
i++;
return (items[i].action_code == ACTION_NONE ) ?
CONTEXT_STD :
return (items[i].action_code == ACTION_NONE ) ?
CONTEXT_STD :
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
so the "chain" is followed until the button is found.
putting ACTION_NONE will get CONTEXT_STD which is always the last list checked.
Timeout can be TIMEOUT_NOBLOCK to return immediatly
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,
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 ret = ACTION_UNKNOWN;
static int last_context = CONTEXT_STD;
if (timeout == TIMEOUT_NOBLOCK)
button = button_get(false);
else if (timeout == TIMEOUT_BLOCK)
@ -119,14 +121,19 @@ static int get_action_worker(int context, int timeout,
button = button_get_w_tmo(timeout);
/* 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;
}
if ((context != last_context) && ((last_button&BUTTON_REL) == 0))
#if CONFIG_CODEC == SWCODEC
/* 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_action = ACTION_NONE;
@ -137,18 +144,18 @@ static int get_action_worker(int context, int timeout,
}
last_context = context;
#ifdef HAVE_TOUCHPAD
if (button&BUTTON_TOUCHPAD)
if (button & BUTTON_TOUCHPAD)
{
repeated = false;
short_press = false;
if (last_button&BUTTON_TOUCHPAD)
if (last_button & BUTTON_TOUCHPAD)
{
if ((button&BUTTON_REL) &&
((last_button&BUTTON_REPEAT)==0))
if ((button & BUTTON_REL) &&
((last_button & BUTTON_REPEAT)==0))
{
short_press = true;
}
else if (button&BUTTON_REPEAT)
else if (button & BUTTON_REPEAT)
repeated = true;
}
last_button = button;
@ -156,48 +163,48 @@ static int get_action_worker(int context, int timeout,
}
#endif
#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 (button == unlock_combo)
if (button == unlock_combo)
{
last_button = BUTTON_NONE;
keys_locked = false;
gui_syncsplash(HZ/2, str(LANG_KEYLOCK_OFF));
return ACTION_REDRAW;
}
else
#if (BUTTON_REMOTE != 0)
if ((button&BUTTON_REMOTE) == 0)
}
else
#if (BUTTON_REMOTE != 0)
if ((button & BUTTON_REMOTE) == 0)
#endif
{
if ((button&BUTTON_REL))
if ((button & BUTTON_REL))
gui_syncsplash(HZ/2, str(LANG_KEYLOCK_ON));
return ACTION_REDRAW;
}
}
context &= ~ALLOW_SOFTLOCK;
#endif /* HAS_BUTTON_HOLD */
/* logf("%x,%x",last_button,button); */
do
do
{
/* logf("context = %x",context); */
#if (BUTTON_REMOTE != 0)
if (button&BUTTON_REMOTE)
if (button & BUTTON_REMOTE)
context |= CONTEXT_REMOTE;
#endif
if ((context&CONTEXT_CUSTOM) && get_context_map)
if ((context & CONTEXT_CUSTOM) && get_context_map)
items = get_context_map(context);
else
items = get_context_mapping(context);
ret = do_button_check(items,button,last_button,&i);
if ((context ==(int)CONTEXT_STOPSEARCHING) ||
items == NULL )
break;
if (ret == ACTION_UNKNOWN )
{
context = get_next_context(items,i);
@ -208,19 +215,19 @@ static int get_action_worker(int context, int timeout,
/* DEBUGF("ret = %x\n",ret); */
#ifndef HAS_BUTTON_HOLD
if (screen_has_lock && (ret == ACTION_STD_KEYLOCK))
{
{
unlock_combo = button;
keys_locked = true;
gui_syncsplash(HZ/2, str(LANG_KEYLOCK_ON));
button_clear_queue();
return ACTION_REDRAW;
}
#endif
if ((current_tick - last_action_tick < REPEAT_WINDOW_TICKS)
if ((current_tick - last_action_tick < REPEAT_WINDOW_TICKS)
&& (ret == last_action))
repeated = true;
else
else
repeated = false;
last_button = button;
@ -266,7 +273,7 @@ int get_action_statuscode(int *button)
if (button)
*button = last_button;
if (last_button&BUTTON_REMOTE)
if (last_button & BUTTON_REMOTE)
ret |= ACTION_REMOTE;
if (repeated)
ret |= ACTION_REPEAT;
@ -283,10 +290,10 @@ int action_get_touchpad_press(short *x, short *y)
{
static int last_data = 0;
int data;
if ((last_button&BUTTON_TOUCHPAD) == 0)
if ((last_button & BUTTON_TOUCHPAD) == 0)
return BUTTON_NONE;
data = button_get_data();
if (last_button&BUTTON_REL)
if (last_button & BUTTON_REL)
{
*x = (last_data&0xffff0000)>>16;
*y = (last_data&0xffff);

View file

@ -11540,3 +11540,37 @@
*: "Save Sound Settings"
</voice>
</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,
&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
void dac_line_in(bool enable);
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);
#endif
MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
0, Icon_System_menu,
&start_screen,
@ -372,7 +383,10 @@ MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
&buttonlight_timeout,
#endif
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
&buttonlight_brightness
&buttonlight_brightness,
#endif
#if CONFIG_CODEC == SWCODEC
&keyclick_menu,
#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));
bool set_int(const unsigned char* string, const char* unit, int voice_unit,
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*) );
/* 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,
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*),
int32_t (*get_talk_id)(int, int));
@ -353,7 +353,7 @@ struct user_settings
1 = main lcd
2 = main and remote lcd
3 = remote lcd */
int rec_start_thres; /* negative: db, positive: % range -87 .. 100 */
int rec_start_duration; /* index of trig_durations */
int rec_stop_thres; /* negative: db, positive: % */
@ -520,7 +520,7 @@ struct user_settings
bool talk_menu; /* enable voice UI */
int talk_dir; /* voiced directories mode: 0=off 1=number 2=spell */
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_filetype; /* say file type */
bool talk_battery_level;
@ -528,7 +528,7 @@ struct user_settings
/* file browser sorting */
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) */
#ifdef HAVE_REMOTE_LCD
/* remote lcd */
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. */
#endif
#endif /* HAVE_REMOTE_LCD */
int next_folder; /* move to next folder */
bool runtimedb; /* runtime database active? */
@ -559,7 +559,7 @@ struct user_settings
shuffle is on, album gain otherwise */
int replaygain_preamp; /* scale replaygained tracks by this */
int beep; /* system beep volume when changing tracks etc. */
/* Crossfeed settings */
bool crossfeed; /* enable crossfeed */
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 */
#endif
bool party_mode; /* party mode - unstoppable music */
#ifdef HAVE_BACKLIGHT
bool bl_filter_first_keypress; /* filter first keypress when dark? */
#ifdef HAVE_REMOTE_LCD
@ -719,6 +719,10 @@ struct user_settings
int usb_stack_mode; /* device or host */
unsigned char usb_stack_device_driver[32]; /* usb device driver to load */
#endif
#if CONFIG_CODEC == SWCODEC
int keyclick; /* keyclick volume */
int keyclick_repeats; /* keyclick on repeats */
#endif
};
/** global variables **/

View file

@ -1180,6 +1180,13 @@ const struct settings_list settings[] = {
#if CONFIG_TUNER
SYSTEM_SETTING(0, statusbar_forced, 0),
#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);