From 537c7546f946d266e55fdbce03558352a3342908 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Tue, 26 Sep 2006 10:03:56 +0000 Subject: 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 --- firmware/drivers/button.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'firmware/drivers/button.c') diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index 5add6cb817..0042d9b8eb 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 + -- cgit v1.2.3