1
0
Fork 0
forked from len0rd/rockbox

Add support for H10 remote. Remote buttons have the same keymappings as their counterparts on the H10 itself, with vol-/vol+ being the same as scroll up/down.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11093 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Barry Wardell 2006-09-29 15:59:08 +00:00
parent d9fe5a77b0
commit b692fb11b3
6 changed files with 192 additions and 14 deletions

View file

@ -1125,11 +1125,11 @@ bool dbg_ports(void)
lcd_puts(0, line++, buf);
#if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
line++;
snprintf(buf, sizeof(buf), "ADC_BATTERY: %02x", adc_read(ADC_BATTERY));
snprintf(buf, sizeof(buf), "ADC_BATTERY: %02x", adc_read(ADC_BATTERY));
lcd_puts(0, line++, buf);
snprintf(buf, sizeof(buf), "ADC_UNKNOWN_1: %02x", adc_read(ADC_UNKNOWN_1));
snprintf(buf, sizeof(buf), "ADC_UNKNOWN_1: %02x", adc_read(ADC_UNKNOWN_1));
lcd_puts(0, line++, buf);
snprintf(buf, sizeof(buf), "ADC_UNKNOWN_2: %02x", adc_read(ADC_UNKNOWN_2));
snprintf(buf, sizeof(buf), "ADC_REMOTE: %02x", adc_read(ADC_REMOTE));
lcd_puts(0, line++, buf);
snprintf(buf, sizeof(buf), "ADC_SCROLLPAD: %02x", adc_read(ADC_SCROLLPAD));
lcd_puts(0, line++, buf);

View file

@ -52,6 +52,15 @@ const struct button_mapping button_context_standard[] = {
LAST_ITEM_IN_LIST
}; /* button_context_standard */
const struct button_mapping remote_button_context_standard[] = {
{ ACTION_STD_PREV, BUTTON_RC_VOL_UP, BUTTON_NONE },
{ ACTION_STD_PREVREPEAT, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_STD_NEXT, BUTTON_RC_VOL_DOWN, BUTTON_NONE },
{ ACTION_STD_NEXTREPEAT, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
LAST_ITEM_IN_LIST
}; /* remote_button_context_standard */
const struct button_mapping button_context_wps[] = {
{ ACTION_WPS_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
{ ACTION_WPS_STOP, BUTTON_PLAY|BUTTON_REPEAT,BUTTON_PLAY },
@ -77,6 +86,27 @@ const struct button_mapping button_context_wps[] = {
LAST_ITEM_IN_LIST
}; /* button_context_wps */
const struct button_mapping remote_button_context_wps[] = {
{ ACTION_WPS_PLAY, BUTTON_RC_PLAY|BUTTON_REL, BUTTON_RC_PLAY },
{ ACTION_WPS_STOP, BUTTON_RC_PLAY|BUTTON_REPEAT,BUTTON_RC_PLAY },
{ ACTION_WPS_SKIPPREV, BUTTON_RC_REW|BUTTON_REL, BUTTON_RC_REW},
{ ACTION_WPS_SEEKBACK, BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_WPS_STOPSEEK, BUTTON_RC_REW|BUTTON_REL, BUTTON_RC_REW|BUTTON_REPEAT },
{ ACTION_WPS_SKIPNEXT, BUTTON_RC_FF|BUTTON_REL, BUTTON_RC_FF },
{ ACTION_WPS_SEEKFWD, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_WPS_STOPSEEK, BUTTON_RC_FF|BUTTON_REL, BUTTON_RC_FF|BUTTON_REPEAT },
{ ACTION_WPS_VOLDOWN, BUTTON_RC_VOL_DOWN, BUTTON_NONE },
{ ACTION_WPS_VOLDOWN, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_WPS_VOLUP, BUTTON_RC_VOL_UP, BUTTON_NONE },
{ ACTION_WPS_VOLUP, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_WPS_PITCHSCREEN, BUTTON_RC_PLAY|BUTTON_LEFT, BUTTON_RC_PLAY },
{ ACTION_WPS_ID3SCREEN, BUTTON_RC_PLAY|BUTTON_RIGHT, BUTTON_RC_PLAY },
LAST_ITEM_IN_LIST
}; /* remote_button_context_wps */
const struct button_mapping button_context_settings[] = {
{ ACTION_SETTINGS_INC, BUTTON_SCROLL_UP, BUTTON_NONE },
{ ACTION_SETTINGS_INCREPEAT,BUTTON_SCROLL_UP|BUTTON_REPEAT, BUTTON_NONE },
@ -98,6 +128,13 @@ const struct button_mapping button_context_list[] = {
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
}; /* button_context_list */
const struct button_mapping remote_button_context_list[] = {
{ ACTION_LISTTREE_PGUP, BUTTON_RC_REW|BUTTON_REL, BUTTON_RC_REW },
{ ACTION_LISTTREE_PGDOWN, BUTTON_RC_FF|BUTTON_REL, BUTTON_RC_FF },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
}; /* button_context_list */
const struct button_mapping button_context_tree[] = {
{ ACTION_TREE_WPS, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
{ ACTION_TREE_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
@ -105,6 +142,13 @@ const struct button_mapping button_context_tree[] = {
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST),
}; /* button_context_tree */
const struct button_mapping remote_button_context_tree[] = {
{ ACTION_TREE_WPS, BUTTON_RC_PLAY|BUTTON_REL, BUTTON_RC_PLAY },
{ ACTION_TREE_STOP, BUTTON_RC_PLAY|BUTTON_REPEAT, BUTTON_RC_PLAY },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST),
}; /* button_context_tree */
const struct button_mapping button_context_listtree_scroll_without_combo[] = {
{ ACTION_TREE_ROOT_INIT, BUTTON_REW|BUTTON_REPEAT, BUTTON_REW },
{ ACTION_TREE_PGLEFT, BUTTON_REW|BUTTON_REPEAT, BUTTON_NONE },
@ -112,6 +156,13 @@ const struct button_mapping button_context_listtree_scroll_without_combo[] = {
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE),
}; /* button_context_listtree_scroll_without_combo */
const struct button_mapping remote_button_context_listtree_scroll_without_combo[] = {
{ ACTION_TREE_ROOT_INIT, BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_RC_REW },
{ ACTION_TREE_PGLEFT, BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_TREE_PGRIGHT, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE),
}; /* button_context_listtree_scroll_without_combo */
const struct button_mapping button_context_listtree_scroll_with_combo[] = {
{ ACTION_LISTTREE_PGUP, BUTTON_REW|BUTTON_REPEAT, BUTTON_REW },
{ ACTION_LISTTREE_PGDOWN, BUTTON_FF|BUTTON_REPEAT, BUTTON_FF },
@ -127,6 +178,21 @@ const struct button_mapping button_context_listtree_scroll_with_combo[] = {
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE),
}; /* button_context_listtree_scroll_with_combo */
const struct button_mapping remote_button_context_listtree_scroll_with_combo[] = {
{ ACTION_LISTTREE_PGUP, BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_RC_REW },
{ ACTION_LISTTREE_PGDOWN, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_RC_FF },
{ ACTION_TREE_PGLEFT, BUTTON_RC_REW|BUTTON_RC_PLAY, BUTTON_RC_PLAY },
{ ACTION_TREE_PGLEFT, BUTTON_RC_REW|BUTTON_REL, BUTTON_RC_REW|BUTTON_RC_PLAY },
{ ACTION_TREE_PGLEFT, BUTTON_RC_REW|BUTTON_RC_PLAY, BUTTON_RC_REW|BUTTON_REL },
{ ACTION_TREE_ROOT_INIT, BUTTON_RC_REW|BUTTON_RC_PLAY|BUTTON_REPEAT, BUTTON_RC_REW|BUTTON_RC_PLAY },
{ ACTION_TREE_PGLEFT, BUTTON_RC_REW|BUTTON_RC_PLAY|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_TREE_PGRIGHT, BUTTON_RC_FF|BUTTON_RC_PLAY, BUTTON_RC_PLAY },
{ ACTION_TREE_PGRIGHT, BUTTON_RC_FF|BUTTON_REL, BUTTON_RC_FF|BUTTON_RC_PLAY },
{ ACTION_TREE_PGRIGHT, BUTTON_RC_FF|BUTTON_RC_PLAY, BUTTON_RC_FF|BUTTON_REL },
{ ACTION_TREE_PGRIGHT, BUTTON_RC_FF|BUTTON_RC_PLAY|BUTTON_REPEAT, BUTTON_NONE },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE),
}; /* button_context_listtree_scroll_with_combo */
const struct button_mapping button_context_yesno[] = {
{ ACTION_YESNO_ACCEPT, BUTTON_RIGHT, BUTTON_NONE },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD),
@ -145,6 +211,19 @@ const struct button_mapping button_context_quickscreen[] = {
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD),
}; /* button_context_quickscreen */
const struct button_mapping remote_button_context_quickscreen[] = {
{ ACTION_QS_DOWNINV, BUTTON_RC_VOL_UP, BUTTON_NONE },
{ ACTION_QS_DOWNINV, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_QS_DOWN, BUTTON_RC_VOL_DOWN, BUTTON_NONE },
{ ACTION_QS_DOWN, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_QS_LEFT, BUTTON_RC_REW, BUTTON_NONE },
{ ACTION_QS_LEFT, BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_QS_RIGHT, BUTTON_RC_FF, BUTTON_NONE },
{ ACTION_QS_RIGHT, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD),
}; /* button_context_quickscreen */
const struct button_mapping button_context_settings_right_is_inc[] = {
{ ACTION_SETTINGS_INC, BUTTON_SCROLL_UP, BUTTON_NONE },
{ ACTION_SETTINGS_INCREPEAT, BUTTON_SCROLL_UP|BUTTON_REPEAT, BUTTON_NONE },
@ -177,6 +256,20 @@ const struct button_mapping button_context_pitchscreen[] = {
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD),
}; /* button_context_pitchscreen */
const struct button_mapping remote_button_context_pitchscreen[] = {
{ ACTION_PS_INC_SMALL, BUTTON_RC_VOL_UP, BUTTON_NONE },
{ ACTION_PS_INC_BIG, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_PS_DEC_SMALL, BUTTON_RC_VOL_DOWN, BUTTON_NONE },
{ ACTION_PS_DEC_BIG, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_PS_NUDGE_LEFT, BUTTON_RC_REW, BUTTON_NONE },
{ ACTION_PS_NUDGE_LEFTOFF, BUTTON_RC_REW|BUTTON_REL, BUTTON_NONE },
{ ACTION_PS_NUDGE_RIGHT, BUTTON_RC_FF, BUTTON_NONE },
{ ACTION_PS_NUDGE_RIGHTOFF, BUTTON_RC_FF|BUTTON_REL, BUTTON_NONE },
{ ACTION_PS_RESET, BUTTON_RC_PLAY, BUTTON_NONE },
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD),
}; /* button_context_pitchscreen */
const struct button_mapping button_context_keyboard[] = {
{ ACTION_KBD_LEFT, BUTTON_LEFT, BUTTON_NONE },
{ ACTION_KBD_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
@ -200,9 +293,45 @@ const struct button_mapping button_context_bmark[] = {
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD),
}; /* button_context_bmark */
static const struct button_mapping* get_context_mapping_remote( int context )
{
context ^= CONTEXT_REMOTE;
switch (context)
{
case CONTEXT_STD:
case CONTEXT_MAINMENU:
return remote_button_context_standard;
case CONTEXT_WPS:
return remote_button_context_wps;
case CONTEXT_LIST:
return remote_button_context_list;
case CONTEXT_TREE:
if (global_settings.hold_lr_for_scroll_in_list)
return remote_button_context_listtree_scroll_without_combo;
else
return remote_button_context_listtree_scroll_with_combo;
case CONTEXT_CUSTOM|CONTEXT_TREE:
return remote_button_context_tree;
case CONTEXT_QUICKSCREEN:
return remote_button_context_quickscreen;
case CONTEXT_PITCHSCREEN:
return remote_button_context_pitchscreen;
default:
return remote_button_context_standard;
}
}
/* get_context_mapping returns a pointer to one of the above defined arrays depending on the context */
const struct button_mapping* get_context_mapping(int context)
{
if (context&CONTEXT_REMOTE)
return get_context_mapping_remote(context);
switch (context)
{
case CONTEXT_STD:
@ -220,7 +349,7 @@ const struct button_mapping* get_context_mapping(int context)
else
return button_context_listtree_scroll_with_combo;
case CONTEXT_CUSTOM|CONTEXT_TREE:
return button_context_tree;
return remote_button_context_tree;
case CONTEXT_SETTINGS:
return button_context_settings;

View file

@ -69,7 +69,7 @@ static void adc_tick(void)
adc_counter = 0;
adc_scan(ADC_BATTERY);
adc_scan(ADC_UNKNOWN_1);
adc_scan(ADC_UNKNOWN_2);
adc_scan(ADC_REMOTE);
adc_scan(ADC_SCROLLPAD);
}
}
@ -85,7 +85,7 @@ void adc_init(void)
/* Force a scan of all channels to get initial values */
adc_scan(ADC_BATTERY);
adc_scan(ADC_UNKNOWN_1);
adc_scan(ADC_UNKNOWN_2);
adc_scan(ADC_REMOTE);
adc_scan(ADC_SCROLLPAD);
tick_add_task(adc_tick);

View file

@ -32,7 +32,7 @@
#define ADC_BATTERY 0
#define ADC_UNKNOWN_1 1
#define ADC_UNKNOWN_2 2
#define ADC_REMOTE 2
#define ADC_SCROLLPAD 3
#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */

View file

@ -50,15 +50,23 @@ bool button_hold(void)
return (GPIOA_INPUT_VAL & 0x4)?false:true;
}
bool remote_button_hold(void)
{
return adc_scan(ADC_REMOTE) < 0x17;
}
/*
* Get button pressed from hardware
*/
int button_read_device(void)
{
int btn = BUTTON_NONE;
int data;
unsigned char state;
static bool hold_button = false;
static bool remote_hold_button = false;
bool hold_button_old;
bool remote_hold_button_old;
/* Hold */
hold_button_old = hold_button;
@ -72,6 +80,7 @@ int button_read_device(void)
}
#endif
/* device buttons */
if (!hold_button)
{
/* Read normal buttons */
@ -88,14 +97,12 @@ int button_read_device(void)
/* Read scroller */
if ( GPIOD_INPUT_VAL & 0x20 )
{
int scroll_pos;
GPIOD_OUTPUT_VAL &=~ 0x40;
udelay(50);
scroll_pos = adc_scan(ADC_SCROLLPAD);
data = adc_scan(ADC_SCROLLPAD);
GPIOD_OUTPUT_VAL |= 0x40;
if(scroll_pos < 0x210)
if(data < 0x210)
{
btn |= BUTTON_SCROLL_DOWN;
} else {
@ -104,5 +111,37 @@ int button_read_device(void)
}
}
/* remote buttons */
remote_hold_button_old = remote_hold_button;
data = adc_scan(ADC_REMOTE);
remote_hold_button = data < 0x17;
#ifndef BOOTLOADER
if (remote_hold_button != remote_hold_button_old)
backlight_hold_changed(remote_hold_button);
#endif
if(!remote_hold_button)
{
if (data < 0x3FF)
{
if(data < 0x1F0)
if(data < 0x141)
btn |= BUTTON_RC_FF;
else
btn |= BUTTON_RC_REW;
else
if(data < 0x2BC)
btn |= BUTTON_RC_VOL_DOWN;
else
btn |= BUTTON_RC_VOL_UP;
}
}
/* remote play button should be dead if hold */
if (!remote_hold_button && !(GPIOA_INPUT_VAL & 0x1))
btn |= BUTTON_RC_PLAY;
return btn;
}

View file

@ -26,8 +26,10 @@
#include "config.h"
#define HAS_BUTTON_HOLD
#define HAS_REMOTE_BUTTON_HOLD
bool button_hold(void);
bool remote_button_hold(void);
void button_init_device(void);
int button_read_device(void);
@ -49,10 +51,18 @@ int button_read_device(void);
#define BUTTON_MAIN (BUTTON_POWER|BUTTON_O|BUTTON_BACK|BUTTON_REW\
|BUTTON_PLAY|BUTTON_FF)
/* No Remote control */
#define BUTTON_REMOTE 0
/* Remote control's buttons */
#define BUTTON_RC_REW 0x00080000
#define BUTTON_RC_PLAY 0x00100000
#define BUTTON_RC_FF 0x00200000
#define BUTTON_RC_VOL_UP 0x00400000
#define BUTTON_RC_VOL_DOWN 0x00800000
#define POWEROFF_BUTTON BUTTON_POWER
#define BUTTON_REMOTE (BUTTON_RC_PLAY|BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN\
|BUTTON_RC_REW|BUTTON_RC_FF)
#define POWEROFF_BUTTON BUTTON_POWER
#define RC_POWEROFF_BUTTON BUTTON_RC_PLAY
#define POWEROFF_COUNT 10
#endif /* _BUTTON_TARGET_H_ */