summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers')
-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 5add6cb817..0042d9b8eb 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -92,6 +92,10 @@ static bool remote_button_hold_only(void);
92int int_btn = BUTTON_NONE; 92int int_btn = BUTTON_NONE;
93#endif 93#endif
94 94
95#ifdef HAVE_HEADPHONE_DETECTION
96bool phones_present = false;
97#endif
98
95#if (CONFIG_KEYPAD == IPOD_4G_PAD) && !defined(IPOD_MINI) 99#if (CONFIG_KEYPAD == IPOD_4G_PAD) && !defined(IPOD_MINI)
96static void opto_i2c_init(void) 100static void opto_i2c_init(void)
97{ 101{
@@ -433,6 +437,23 @@ static void button_tick(void)
433 } 437 }
434#endif 438#endif
435 439
440#ifdef HAVE_HEADPHONE_DETECTION
441 if ( headphones_inserted() )
442 {
443 if (! phones_present )
444 {
445 queue_post(&button_queue, SYS_PHONE_PLUGGED, NULL);
446 phones_present = true;
447 }
448 } else {
449 if ( phones_present )
450 {
451 queue_post(&button_queue, SYS_PHONE_UNPLUGGED, NULL);
452 phones_present = false;
453 }
454 }
455#endif
456
436 btn = button_read(); 457 btn = button_read();
437 458
438 /* Find out if a key has been released */ 459 /* Find out if a key has been released */
@@ -1327,3 +1348,10 @@ void button_clear_queue(void)
1327 queue_clear(&button_queue); 1348 queue_clear(&button_queue);
1328} 1349}
1329 1350
1351#ifdef HAVE_HEADPHONE_DETECTION
1352bool headphones_inserted(void)
1353{
1354 return (GPIOA_INPUT_VAL & 0x80)?true:false;
1355}
1356#endif
1357