summaryrefslogtreecommitdiff
path: root/firmware/drivers/button.c
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2006-09-26 10:03:56 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2006-09-26 10:03:56 +0000
commit537c7546f946d266e55fdbce03558352a3342908 (patch)
tree9e594c9d40ec54047fa858472f737bc4d7b7d406 /firmware/drivers/button.c
parent9f960e405f72e1f624797547e1ad8e9584206118 (diff)
downloadrockbox-537c7546f946d266e55fdbce03558352a3342908.zip
rockbox-537c7546f946d266e55fdbce03558352a3342908.tar.gz
rockbox-537c7546f946d266e55fdbce03558352a3342908.tar.bz2
rockbox-537c7546f946d266e55fdbce03558352a3342908.tar.xz
Patch #4899 by Robert Keevil - Automatic pause on iPod when removing the headphones
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11057 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/button.c')
-rw-r--r--firmware/drivers/button.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 5add6cb..0042d9b 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -92,6 +92,10 @@ static bool remote_button_hold_only(void);
int int_btn = BUTTON_NONE;
#endif
+#ifdef HAVE_HEADPHONE_DETECTION
+bool phones_present = false;
+#endif
+
#if (CONFIG_KEYPAD == IPOD_4G_PAD) && !defined(IPOD_MINI)
static void opto_i2c_init(void)
{
@@ -433,6 +437,23 @@ static void button_tick(void)
}
#endif
+#ifdef HAVE_HEADPHONE_DETECTION
+ if ( headphones_inserted() )
+ {
+ if (! phones_present )
+ {
+ queue_post(&button_queue, SYS_PHONE_PLUGGED, NULL);
+ phones_present = true;
+ }
+ } else {
+ if ( phones_present )
+ {
+ queue_post(&button_queue, SYS_PHONE_UNPLUGGED, NULL);
+ phones_present = false;
+ }
+ }
+#endif
+
btn = button_read();
/* Find out if a key has been released */
@@ -1327,3 +1348,10 @@ void button_clear_queue(void)
queue_clear(&button_queue);
}
+#ifdef HAVE_HEADPHONE_DETECTION
+bool headphones_inserted(void)
+{
+ return (GPIOA_INPUT_VAL & 0x80)?true:false;
+}
+#endif
+