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

@ -28,6 +28,8 @@
#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 */
@ -99,7 +101,7 @@ static inline int get_next_context(const struct button_mapping *items, int i)
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,
@ -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 ((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_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,7 +163,7 @@ 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)
@ -168,10 +175,10 @@ static int get_action_worker(int context, int timeout,
} }
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;
} }
@ -184,10 +191,10 @@ static int get_action_worker(int context, int timeout,
{ {
/* 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);
@ -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

@ -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);