forked from len0rd/rockbox
Multiple remote support for iriver Hxxx stage 2: now button_read() returns correct buttons for each remote type.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8752 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
e48e60b3e0
commit
7f6fe6aa35
1 changed files with 110 additions and 102 deletions
|
|
@ -40,6 +40,11 @@
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "powermgmt.h"
|
#include "powermgmt.h"
|
||||||
|
|
||||||
|
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) \
|
||||||
|
|| (CONFIG_KEYPAD == IRIVER_H300_PAD)
|
||||||
|
#include "lcd-remote.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
struct event_queue button_queue;
|
struct event_queue button_queue;
|
||||||
|
|
||||||
static long lastbtn; /* Last valid button status */
|
static long lastbtn; /* Last valid button status */
|
||||||
|
|
@ -703,7 +708,8 @@ static int button_read(void)
|
||||||
|
|
||||||
int data;
|
int data;
|
||||||
|
|
||||||
#if CONFIG_KEYPAD == IRIVER_H100_PAD
|
#if (CONFIG_KEYPAD == IRIVER_H100_PAD)\
|
||||||
|
|| (CONFIG_KEYPAD == IRIVER_H300_PAD)
|
||||||
|
|
||||||
static bool hold_button = false;
|
static bool hold_button = false;
|
||||||
static bool remote_hold_button = false;
|
static bool remote_hold_button = false;
|
||||||
|
|
@ -725,7 +731,7 @@ static int button_read(void)
|
||||||
if (!hold_button)
|
if (!hold_button)
|
||||||
{
|
{
|
||||||
data = adc_scan(ADC_BUTTONS);
|
data = adc_scan(ADC_BUTTONS);
|
||||||
|
#if CONFIG_KEYPAD == IRIVER_H100_PAD
|
||||||
if (data < 0x80)
|
if (data < 0x80)
|
||||||
if (data < 0x30)
|
if (data < 0x30)
|
||||||
if (data < 0x18)
|
if (data < 0x18)
|
||||||
|
|
@ -749,74 +755,7 @@ static int button_read(void)
|
||||||
else
|
else
|
||||||
if (data < 0xf0)
|
if (data < 0xf0)
|
||||||
btn = BUTTON_REC;
|
btn = BUTTON_REC;
|
||||||
}
|
#else /* H300 */
|
||||||
|
|
||||||
/* remote buttons */
|
|
||||||
if (!remote_hold_button)
|
|
||||||
{
|
|
||||||
data = adc_scan(ADC_REMOTE);
|
|
||||||
|
|
||||||
if (data < 0x74)
|
|
||||||
if (data < 0x40)
|
|
||||||
if (data < 0x20)
|
|
||||||
if(data < 0x10)
|
|
||||||
btn = BUTTON_RC_STOP;
|
|
||||||
else
|
|
||||||
btn = BUTTON_RC_VOL_DOWN;
|
|
||||||
else
|
|
||||||
btn = BUTTON_RC_MODE;
|
|
||||||
else
|
|
||||||
if (data < 0x58)
|
|
||||||
btn = BUTTON_RC_VOL_UP;
|
|
||||||
else
|
|
||||||
btn = BUTTON_RC_BITRATE;
|
|
||||||
else
|
|
||||||
if (data < 0xb0)
|
|
||||||
if (data < 0x88)
|
|
||||||
btn = BUTTON_RC_REC;
|
|
||||||
else
|
|
||||||
btn = BUTTON_RC_SOURCE;
|
|
||||||
else
|
|
||||||
if (data < 0xd8)
|
|
||||||
if(data < 0xc0)
|
|
||||||
btn = BUTTON_RC_FF;
|
|
||||||
else
|
|
||||||
btn = BUTTON_RC_MENU;
|
|
||||||
else
|
|
||||||
if (data < 0xf0)
|
|
||||||
btn = BUTTON_RC_REW;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* special buttons */
|
|
||||||
data = GPIO1_READ;
|
|
||||||
if (!hold_button && ((data & 0x20) == 0))
|
|
||||||
btn |= BUTTON_ON;
|
|
||||||
if (!remote_hold_button && ((data & 0x40) == 0))
|
|
||||||
btn |= BUTTON_RC_ON;
|
|
||||||
|
|
||||||
#elif CONFIG_KEYPAD == IRIVER_H300_PAD
|
|
||||||
|
|
||||||
static bool hold_button = false;
|
|
||||||
static bool remote_hold_button = false;
|
|
||||||
|
|
||||||
/* light handling */
|
|
||||||
if (hold_button && !button_hold())
|
|
||||||
{
|
|
||||||
backlight_on();
|
|
||||||
}
|
|
||||||
if (remote_hold_button && !remote_button_hold_only())
|
|
||||||
{
|
|
||||||
remote_backlight_on();
|
|
||||||
}
|
|
||||||
|
|
||||||
hold_button = button_hold();
|
|
||||||
remote_hold_button = remote_button_hold_only();
|
|
||||||
|
|
||||||
/* normal buttons */
|
|
||||||
if (!hold_button)
|
|
||||||
{
|
|
||||||
data = adc_scan(ADC_BUTTONS);
|
|
||||||
|
|
||||||
if (data < 0x54)
|
if (data < 0x54)
|
||||||
if (data < 0x30)
|
if (data < 0x30)
|
||||||
if (data < 0x10)
|
if (data < 0x10)
|
||||||
|
|
@ -834,45 +773,96 @@ static int button_read(void)
|
||||||
else
|
else
|
||||||
if(data < 0xba)
|
if(data < 0xba)
|
||||||
btn = BUTTON_OFF;
|
btn = BUTTON_OFF;
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remote buttons */
|
/* remote buttons */
|
||||||
if (!remote_hold_button)
|
if (!remote_hold_button)
|
||||||
{
|
{
|
||||||
data = adc_scan(ADC_REMOTE);
|
data = adc_scan(ADC_REMOTE);
|
||||||
|
switch(remote_type())
|
||||||
if (data < 0x74)
|
{
|
||||||
if (data < 0x40)
|
case REMOTETYPE_H100_LCD:
|
||||||
if (data < 0x20)
|
if (data < 0x73)
|
||||||
if(data < 0x10)
|
if (data < 0x3f)
|
||||||
|
if (data < 0x25)
|
||||||
|
if(data < 0x0c)
|
||||||
btn = BUTTON_RC_STOP;
|
btn = BUTTON_RC_STOP;
|
||||||
else
|
else
|
||||||
btn = BUTTON_RC_VOL_DOWN;
|
btn = BUTTON_RC_VOL_DOWN;
|
||||||
else
|
else
|
||||||
btn = BUTTON_RC_MODE;
|
btn = BUTTON_RC_MODE;
|
||||||
else
|
else
|
||||||
if (data < 0x58)
|
if (data < 0x5a)
|
||||||
btn = BUTTON_RC_VOL_UP;
|
btn = BUTTON_RC_VOL_UP;
|
||||||
else
|
else
|
||||||
btn = BUTTON_RC_BITRATE;
|
btn = BUTTON_RC_BITRATE;
|
||||||
else
|
else
|
||||||
if (data < 0xb0)
|
if (data < 0xa8)
|
||||||
if (data < 0x88)
|
if (data < 0x8c)
|
||||||
btn = BUTTON_RC_REC;
|
btn = BUTTON_RC_REC;
|
||||||
else
|
else
|
||||||
btn = BUTTON_RC_SOURCE;
|
btn = BUTTON_RC_SOURCE;
|
||||||
else
|
else
|
||||||
if (data < 0xd8)
|
if (data < 0xdf)
|
||||||
if(data < 0xc0)
|
if(data < 0xc5)
|
||||||
btn = BUTTON_RC_FF;
|
btn = BUTTON_RC_FF;
|
||||||
else
|
else
|
||||||
btn = BUTTON_RC_MENU;
|
btn = BUTTON_RC_MENU;
|
||||||
else
|
else
|
||||||
if (data < 0xf0)
|
if (data < 0xf5)
|
||||||
btn = BUTTON_RC_REW;
|
btn = BUTTON_RC_REW;
|
||||||
|
break;
|
||||||
|
case REMOTETYPE_H300_LCD:
|
||||||
|
if (data < 0x73)
|
||||||
|
if (data < 0x42)
|
||||||
|
if (data < 0x27)
|
||||||
|
if(data < 0x0c)
|
||||||
|
btn = BUTTON_RC_VOL_DOWN;
|
||||||
|
else
|
||||||
|
btn = BUTTON_RC_FF;
|
||||||
|
else
|
||||||
|
btn = BUTTON_RC_STOP;
|
||||||
|
else
|
||||||
|
if (data < 0x5b)
|
||||||
|
btn = BUTTON_RC_MODE;
|
||||||
|
else
|
||||||
|
btn = BUTTON_RC_REC;
|
||||||
|
else
|
||||||
|
if (data < 0xab)
|
||||||
|
if (data < 0x8e)
|
||||||
|
btn = BUTTON_RC_ON;
|
||||||
|
else
|
||||||
|
btn = BUTTON_RC_BITRATE;
|
||||||
|
else
|
||||||
|
if (data < 0xde)
|
||||||
|
if(data < 0xc5)
|
||||||
|
btn = BUTTON_RC_SOURCE;
|
||||||
|
else
|
||||||
|
btn = BUTTON_RC_VOL_UP;
|
||||||
|
else
|
||||||
|
if (data < 0xf5)
|
||||||
|
btn = BUTTON_RC_REW;
|
||||||
|
break;
|
||||||
|
case REMOTETYPE_H300_NONLCD:
|
||||||
|
if(data<0x7d)
|
||||||
|
if(data<0x25)
|
||||||
|
btn = BUTTON_RC_FF;
|
||||||
|
else
|
||||||
|
btn = BUTTON_RC_REW;
|
||||||
|
else
|
||||||
|
if(data<0xd5)
|
||||||
|
btn = BUTTON_RC_VOL_DOWN;
|
||||||
|
else
|
||||||
|
if(data<0xf1) /* 0xff no button pressed */
|
||||||
|
btn = BUTTON_RC_VOL_UP;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* special buttons */
|
/* special buttons */
|
||||||
|
#if CONFIG_KEYPAD == IRIVER_H300_PAD
|
||||||
if (!hold_button)
|
if (!hold_button)
|
||||||
{
|
{
|
||||||
data = GPIO_READ;
|
data = GPIO_READ;
|
||||||
|
|
@ -881,12 +871,22 @@ static int button_read(void)
|
||||||
if ((data & 0x8000) == 0)
|
if ((data & 0x8000) == 0)
|
||||||
btn |= BUTTON_REC;
|
btn |= BUTTON_REC;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
data = GPIO1_READ;
|
data = GPIO1_READ;
|
||||||
if (!hold_button && ((data & 0x20) == 0))
|
if (!hold_button && ((data & 0x20) == 0))
|
||||||
btn |= BUTTON_ON;
|
btn |= BUTTON_ON;
|
||||||
if (!remote_hold_button && ((data & 0x40) == 0))
|
if (!remote_hold_button && ((data & 0x40) == 0))
|
||||||
|
switch(remote_type())
|
||||||
|
{
|
||||||
|
case REMOTETYPE_H100_LCD:
|
||||||
|
case REMOTETYPE_H300_NONLCD:
|
||||||
btn |= BUTTON_RC_ON;
|
btn |= BUTTON_RC_ON;
|
||||||
|
break;
|
||||||
|
case REMOTETYPE_H300_LCD:
|
||||||
|
btn |= BUTTON_RC_MENU;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
#elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
|
#elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
|
||||||
|
|
||||||
|
|
@ -1073,11 +1073,19 @@ bool button_hold(void)
|
||||||
|
|
||||||
static bool remote_button_hold_only(void)
|
static bool remote_button_hold_only(void)
|
||||||
{
|
{
|
||||||
|
if(remote_type() == REMOTETYPE_H300_NONLCD)
|
||||||
|
return adc_scan(ADC_REMOTE)<0x0d; /* hold should be 0x00 */
|
||||||
|
else
|
||||||
return (GPIO1_READ & 0x00100000)?true:false;
|
return (GPIO1_READ & 0x00100000)?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* returns true only if there is remote present */
|
||||||
bool remote_button_hold(void)
|
bool remote_button_hold(void)
|
||||||
{
|
{
|
||||||
|
/* H300's NON-LCD remote doesn't set the "remote present" bit */
|
||||||
|
if(remote_type() == REMOTETYPE_H300_NONLCD)
|
||||||
|
return remote_button_hold_only();
|
||||||
|
else
|
||||||
return ((GPIO_READ & 0x40000000) == 0)?remote_button_hold_only():false;
|
return ((GPIO_READ & 0x40000000) == 0)?remote_button_hold_only():false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue