summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/iriver/h10
diff options
context:
space:
mode:
authorBarry Wardell <rockbox@barrywardell.net>2006-09-29 15:59:08 +0000
committerBarry Wardell <rockbox@barrywardell.net>2006-09-29 15:59:08 +0000
commitb692fb11b3bb081f51a7bab7351ccbfc78df6617 (patch)
tree0ab0d56062d3865e17e9ec77d4da8c368195fc41 /firmware/target/arm/iriver/h10
parentd9fe5a77b0ad3fb03e5381501e76c7f9a97ab944 (diff)
downloadrockbox-b692fb11b3bb081f51a7bab7351ccbfc78df6617.tar.gz
rockbox-b692fb11b3bb081f51a7bab7351ccbfc78df6617.tar.bz2
rockbox-b692fb11b3bb081f51a7bab7351ccbfc78df6617.zip
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
Diffstat (limited to 'firmware/target/arm/iriver/h10')
-rwxr-xr-xfirmware/target/arm/iriver/h10/adc-h10.c4
-rw-r--r--firmware/target/arm/iriver/h10/adc-target.h2
-rw-r--r--firmware/target/arm/iriver/h10/button-h10.c47
-rw-r--r--firmware/target/arm/iriver/h10/button-target.h16
4 files changed, 59 insertions, 10 deletions
diff --git a/firmware/target/arm/iriver/h10/adc-h10.c b/firmware/target/arm/iriver/h10/adc-h10.c
index 0dc0e8aee5..cf937851b9 100755
--- a/firmware/target/arm/iriver/h10/adc-h10.c
+++ b/firmware/target/arm/iriver/h10/adc-h10.c
@@ -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);
diff --git a/firmware/target/arm/iriver/h10/adc-target.h b/firmware/target/arm/iriver/h10/adc-target.h
index 3aab373290..741c293baa 100644
--- a/firmware/target/arm/iriver/h10/adc-target.h
+++ b/firmware/target/arm/iriver/h10/adc-target.h
@@ -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 */
diff --git a/firmware/target/arm/iriver/h10/button-h10.c b/firmware/target/arm/iriver/h10/button-h10.c
index 6980948336..520a616b4c 100644
--- a/firmware/target/arm/iriver/h10/button-h10.c
+++ b/firmware/target/arm/iriver/h10/button-h10.c
@@ -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;
}
diff --git a/firmware/target/arm/iriver/h10/button-target.h b/firmware/target/arm/iriver/h10/button-target.h
index 48aa10c124..4831aa4efb 100644
--- a/firmware/target/arm/iriver/h10/button-target.h
+++ b/firmware/target/arm/iriver/h10/button-target.h
@@ -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_ */