mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-10 05:35:20 -05:00
iPod 3G: Ensure wheel repeats are not generated unless the same keycode is posted more than once in a row, regardless of velocity. Remove 'was_hold' from handle_scroll_wheel calls since the call is never reachable with was_hold being true. Just clear pending ints in one spot after setting levels. Init prev_scroll properly again in 3g case.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27025 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
a3541c07de
commit
bd380b3993
1 changed files with 32 additions and 30 deletions
|
|
@ -55,7 +55,7 @@ static int int_btn = BUTTON_NONE;
|
||||||
#define WHEEL_REPEAT_VELOCITY 45 /* deg/s */
|
#define WHEEL_REPEAT_VELOCITY 45 /* deg/s */
|
||||||
#define WHEEL_SMOOTHING_VELOCITY 100 /* deg/s */
|
#define WHEEL_SMOOTHING_VELOCITY 100 /* deg/s */
|
||||||
|
|
||||||
static void handle_scroll_wheel(int new_scroll, int was_hold)
|
static void handle_scroll_wheel(int new_scroll)
|
||||||
{
|
{
|
||||||
static const signed char scroll_state[4][4] = {
|
static const signed char scroll_state[4][4] = {
|
||||||
{0, 1, -1, 0},
|
{0, 1, -1, 0},
|
||||||
|
|
@ -64,7 +64,7 @@ static void handle_scroll_wheel(int new_scroll, int was_hold)
|
||||||
{0, -1, 1, 0}
|
{0, -1, 1, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int prev_scroll = 0;
|
static int prev_scroll = -1;
|
||||||
static int direction = 0;
|
static int direction = 0;
|
||||||
static int count = 0;
|
static int count = 0;
|
||||||
static long next_backlight_on = 0;
|
static long next_backlight_on = 0;
|
||||||
|
|
@ -72,30 +72,30 @@ static void handle_scroll_wheel(int new_scroll, int was_hold)
|
||||||
static unsigned long last_wheel_usec = 0;
|
static unsigned long last_wheel_usec = 0;
|
||||||
static unsigned long wheel_delta = 1ul << 24;
|
static unsigned long wheel_delta = 1ul << 24;
|
||||||
static unsigned long wheel_velocity = 0;
|
static unsigned long wheel_velocity = 0;
|
||||||
|
static int prev_keypost = BUTTON_NONE;
|
||||||
|
|
||||||
int wheel_keycode = BUTTON_NONE;
|
int wheel_keycode = BUTTON_NONE;
|
||||||
int scroll = scroll_state[prev_scroll][new_scroll];
|
int scroll;
|
||||||
unsigned long usec;
|
unsigned long usec;
|
||||||
unsigned long v;
|
unsigned long v;
|
||||||
|
|
||||||
|
if (prev_scroll == -1) {
|
||||||
|
prev_scroll = new_scroll;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
scroll = scroll_state[prev_scroll][new_scroll];
|
||||||
prev_scroll = new_scroll;
|
prev_scroll = new_scroll;
|
||||||
|
|
||||||
if (direction != scroll) {
|
if (direction != scroll) {
|
||||||
/* direction reversal - reset all */
|
/* direction reversal or was hold - reset all */
|
||||||
direction = scroll;
|
direction = scroll;
|
||||||
|
prev_keypost = BUTTON_NONE;
|
||||||
wheel_velocity = 0;
|
wheel_velocity = 0;
|
||||||
wheel_delta = 1ul << 24;
|
wheel_delta = 1ul << 24;
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (was_hold) {
|
|
||||||
/* hold - reset all */
|
|
||||||
wheel_velocity = 0;
|
|
||||||
wheel_delta = 1ul << 24;
|
|
||||||
count = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* poke backlight every 1/4s of activity */
|
/* poke backlight every 1/4s of activity */
|
||||||
if (TIME_AFTER(current_tick, next_backlight_on)) {
|
if (TIME_AFTER(current_tick, next_backlight_on)) {
|
||||||
backlight_on();
|
backlight_on();
|
||||||
|
|
@ -160,14 +160,19 @@ static void handle_scroll_wheel(int new_scroll, int was_hold)
|
||||||
wheel_velocity = (7*wheel_velocity + v) / 8;
|
wheel_velocity = (7*wheel_velocity + v) / 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v >= WHEEL_REPEAT_VELOCITY) {
|
|
||||||
/* quick enough - generate repeats - use unsmoothed v to guage */
|
|
||||||
wheel_keycode |= BUTTON_REPEAT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (queue_empty(&button_queue)) {
|
if (queue_empty(&button_queue)) {
|
||||||
|
int key = wheel_keycode;
|
||||||
|
|
||||||
|
if (v >= WHEEL_REPEAT_VELOCITY && prev_keypost == key) {
|
||||||
|
/* quick enough and same key is being posted more than once in a
|
||||||
|
* row - generate repeats - use unsmoothed v to guage */
|
||||||
|
key |= BUTTON_REPEAT;
|
||||||
|
}
|
||||||
|
|
||||||
|
prev_keypost = wheel_keycode;
|
||||||
|
|
||||||
/* post wheel keycode with wheel data */
|
/* post wheel keycode with wheel data */
|
||||||
queue_post(&button_queue, wheel_keycode,
|
queue_post(&button_queue, key,
|
||||||
(wheel_velocity >= WHEEL_ACCEL_START ? (1ul << 31) : 0)
|
(wheel_velocity >= WHEEL_ACCEL_START ? (1ul << 31) : 0)
|
||||||
| wheel_delta | wheel_velocity);
|
| wheel_delta | wheel_velocity);
|
||||||
/* message posted - reset delta */
|
/* message posted - reset delta */
|
||||||
|
|
@ -184,7 +189,7 @@ static void handle_scroll_wheel(int new_scroll, int was_hold)
|
||||||
last_wheel_usec = usec;
|
last_wheel_usec = usec;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static void handle_scroll_wheel(int new_scroll, int was_hold)
|
static void handle_scroll_wheel(int new_scroll)
|
||||||
{
|
{
|
||||||
int wheel_keycode = BUTTON_NONE;
|
int wheel_keycode = BUTTON_NONE;
|
||||||
static int prev_scroll = -1;
|
static int prev_scroll = -1;
|
||||||
|
|
@ -204,7 +209,7 @@ static void handle_scroll_wheel(int new_scroll, int was_hold)
|
||||||
direction = scroll_state[prev_scroll][new_scroll];
|
direction = scroll_state[prev_scroll][new_scroll];
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
else if (!was_hold) {
|
else {
|
||||||
backlight_on();
|
backlight_on();
|
||||||
reset_poweroff_timer();
|
reset_poweroff_timer();
|
||||||
if (++count == 6) { /* reduce sensitivity */
|
if (++count == 6) { /* reduce sensitivity */
|
||||||
|
|
@ -233,22 +238,24 @@ static void handle_scroll_wheel(int new_scroll, int was_hold)
|
||||||
static int ipod_3g_button_read(void)
|
static int ipod_3g_button_read(void)
|
||||||
{
|
{
|
||||||
unsigned char source, state;
|
unsigned char source, state;
|
||||||
static bool was_hold = false;
|
|
||||||
int btn = BUTTON_NONE;
|
int btn = BUTTON_NONE;
|
||||||
|
|
||||||
/* get source of interupts */
|
/* get source of interupts */
|
||||||
source = GPIOA_INT_STAT;
|
source = GPIOA_INT_STAT;
|
||||||
|
|
||||||
/* get current keypad status */
|
/* get current keypad status */
|
||||||
state = GPIOA_INPUT_VAL;
|
state = GPIOA_INPUT_VAL;
|
||||||
|
|
||||||
/* toggle interrupt level */
|
/* toggle interrupt level */
|
||||||
GPIOA_INT_LEV = ~state;
|
GPIOA_INT_LEV = ~state;
|
||||||
|
|
||||||
|
/* ack any active interrupts */
|
||||||
|
GPIOA_INT_CLR = source;
|
||||||
|
|
||||||
#ifdef IPOD_3G
|
#ifdef IPOD_3G
|
||||||
|
static bool was_hold = false;
|
||||||
|
|
||||||
if (was_hold && source == 0x40 && state == 0xbf) {
|
if (was_hold && source == 0x40 && state == 0xbf) {
|
||||||
/* ack any active interrupts */
|
|
||||||
GPIOA_INT_CLR = source;
|
|
||||||
return BUTTON_NONE;
|
return BUTTON_NONE;
|
||||||
}
|
}
|
||||||
was_hold = false;
|
was_hold = false;
|
||||||
|
|
@ -258,13 +265,11 @@ static int ipod_3g_button_read(void)
|
||||||
was_hold = true;
|
was_hold = true;
|
||||||
/* hold switch on 3g causes all outputs to go low */
|
/* hold switch on 3g causes all outputs to go low */
|
||||||
/* we shouldn't interpret these as key presses */
|
/* we shouldn't interpret these as key presses */
|
||||||
GPIOA_INT_CLR = source;
|
|
||||||
return BUTTON_NONE;
|
return BUTTON_NONE;
|
||||||
}
|
}
|
||||||
#elif defined IPOD_1G2G
|
#elif defined IPOD_1G2G
|
||||||
if (state & 0x20) {
|
if (state & 0x20) {
|
||||||
/* 1g/2g hold switch is active high */
|
/* 1g/2g hold switch is active high */
|
||||||
GPIOA_INT_CLR = source;
|
|
||||||
return BUTTON_NONE;
|
return BUTTON_NONE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -285,12 +290,9 @@ static int ipod_3g_button_read(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source & 0xc0) {
|
if (source & 0xc0) {
|
||||||
handle_scroll_wheel((state & 0xc0) >> 6, was_hold);
|
handle_scroll_wheel((state & 0xc0) >> 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ack any active interrupts */
|
|
||||||
GPIOA_INT_CLR = source;
|
|
||||||
|
|
||||||
return btn;
|
return btn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue