mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
ident properly
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@102 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
feef1ed076
commit
bde61f2206
1 changed files with 66 additions and 60 deletions
|
@ -61,20 +61,20 @@ static int count; /* Number of calls button has been down */
|
||||||
void button_init()
|
void button_init()
|
||||||
{
|
{
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
/* Set PB4 and PB8 as input pins */
|
/* Set PB4 and PB8 as input pins */
|
||||||
PBCR1 &= 0xfffc; /* PB8MD = 00 */
|
PBCR1 &= 0xfffc; /* PB8MD = 00 */
|
||||||
PBCR2 &= 0xfcff; /* PB4MD = 00 */
|
PBCR2 &= 0xfcff; /* PB4MD = 00 */
|
||||||
PBIOR &= ~(PBDR_BTN_ON|PBDR_BTN_OFF); /* Inputs */
|
PBIOR &= ~(PBDR_BTN_ON|PBDR_BTN_OFF); /* Inputs */
|
||||||
|
|
||||||
/* Set A/D to scan AN4 and AN5.
|
/* Set A/D to scan AN4 and AN5.
|
||||||
* This needs to be changed to scan other analog pins
|
* This needs to be changed to scan other analog pins
|
||||||
* for battery level, etc. */
|
* for battery level, etc. */
|
||||||
ADCSR = 0;
|
ADCSR = 0;
|
||||||
ADCR = 0;
|
ADCR = 0;
|
||||||
ADCSR = ADCSR_ADST | ADCSR_SCAN | 0x5;
|
ADCSR = ADCSR_ADST | ADCSR_SCAN | 0x5;
|
||||||
#endif
|
#endif
|
||||||
last = BUTTON_NONE;
|
last = BUTTON_NONE;
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -82,36 +82,36 @@ void button_init()
|
||||||
*/
|
*/
|
||||||
static int get_raw_button (void)
|
static int get_raw_button (void)
|
||||||
{
|
{
|
||||||
/* Check port B pins for ON and OFF */
|
/* Check port B pins for ON and OFF */
|
||||||
int data = PBDR;
|
int data = PBDR;
|
||||||
if ((data & PBDR_BTN_ON) == 0)
|
if ((data & PBDR_BTN_ON) == 0)
|
||||||
return BUTTON_ON;
|
return BUTTON_ON;
|
||||||
else if ((data & PBDR_BTN_OFF) == 0)
|
else if ((data & PBDR_BTN_OFF) == 0)
|
||||||
return BUTTON_OFF;
|
return BUTTON_OFF;
|
||||||
|
|
||||||
/* Check AN4 pin for F1-3 and UP */
|
/* Check AN4 pin for F1-3 and UP */
|
||||||
data = ADDRAH;
|
data = ADDRAH;
|
||||||
if (data >= LEVEL4)
|
if (data >= LEVEL4)
|
||||||
return BUTTON_F3;
|
return BUTTON_F3;
|
||||||
else if (data >= LEVEL3)
|
else if (data >= LEVEL3)
|
||||||
return BUTTON_UP;
|
return BUTTON_UP;
|
||||||
else if (data >= LEVEL2)
|
else if (data >= LEVEL2)
|
||||||
return BUTTON_F2;
|
return BUTTON_F2;
|
||||||
else if (data >= LEVEL1)
|
else if (data >= LEVEL1)
|
||||||
return BUTTON_F1;
|
return BUTTON_F1;
|
||||||
|
|
||||||
/* Check AN5 pin for DOWN, PLAY, LEFT, RIGHT */
|
/* Check AN5 pin for DOWN, PLAY, LEFT, RIGHT */
|
||||||
data = ADDRBH;
|
data = ADDRBH;
|
||||||
if (data >= LEVEL4)
|
if (data >= LEVEL4)
|
||||||
return BUTTON_DOWN;
|
return BUTTON_DOWN;
|
||||||
else if (data >= LEVEL3)
|
else if (data >= LEVEL3)
|
||||||
return BUTTON_PLAY;
|
return BUTTON_PLAY;
|
||||||
else if (data >= LEVEL2)
|
else if (data >= LEVEL2)
|
||||||
return BUTTON_LEFT;
|
return BUTTON_LEFT;
|
||||||
else if (data >= LEVEL1)
|
else if (data >= LEVEL1)
|
||||||
return BUTTON_RIGHT;
|
return BUTTON_RIGHT;
|
||||||
|
|
||||||
return BUTTON_NONE;
|
return BUTTON_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -123,29 +123,35 @@ static int get_raw_button (void)
|
||||||
*/
|
*/
|
||||||
int button_get(void)
|
int button_get(void)
|
||||||
{
|
{
|
||||||
int btn = get_raw_button();
|
int btn = get_raw_button();
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Last button pressed is still down */
|
/* Last button pressed is still down */
|
||||||
if (btn != BUTTON_NONE && btn == last) {
|
if (btn != BUTTON_NONE && btn == last) {
|
||||||
count++;
|
count++;
|
||||||
if (count == BOUNCE_COUNT)
|
if (count == BOUNCE_COUNT)
|
||||||
return btn;
|
return btn;
|
||||||
else if (count >= HOLD_COUNT)
|
else if (count >= HOLD_COUNT)
|
||||||
return btn | BUTTON_HELD;
|
return btn | BUTTON_HELD;
|
||||||
|
else
|
||||||
|
return BUTTON_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Last button pressed now released */
|
||||||
|
if (btn == BUTTON_NONE && last != BUTTON_NONE)
|
||||||
|
ret = last | BUTTON_REL;
|
||||||
else
|
else
|
||||||
return BUTTON_NONE;
|
ret = BUTTON_NONE;
|
||||||
}
|
|
||||||
|
last = btn;
|
||||||
/* Last button pressed now released */
|
count = 0;
|
||||||
if (btn == BUTTON_NONE && last != BUTTON_NONE)
|
return ret;
|
||||||
ret = last | BUTTON_REL;
|
|
||||||
else
|
|
||||||
ret = BUTTON_NONE;
|
|
||||||
|
|
||||||
last = btn;
|
|
||||||
count = 0;
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_RECORDER_KEYPAD */
|
#endif /* HAVE_RECORDER_KEYPAD */
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------
|
||||||
|
* local variables:
|
||||||
|
* eval: (load-file "rockbox-mode.el")
|
||||||
|
* end:
|
||||||
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue