summaryrefslogtreecommitdiff
path: root/firmware/target/arm/philips/sa9200/button-sa9200.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/philips/sa9200/button-sa9200.c')
-rwxr-xr-xfirmware/target/arm/philips/sa9200/button-sa9200.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/firmware/target/arm/philips/sa9200/button-sa9200.c b/firmware/target/arm/philips/sa9200/button-sa9200.c
new file mode 100755
index 0000000000..dc9f3466c2
--- /dev/null
+++ b/firmware/target/arm/philips/sa9200/button-sa9200.c
@@ -0,0 +1,72 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Mark Arigo
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "system.h"
21#include "button.h"
22#include "backlight.h"
23
24void button_init_device(void)
25{
26 /* TODO...for now, hardware initialisation is done by the c200 bootloader */
27}
28
29bool button_hold(void)
30{
31 return !(GPIOL_INPUT_VAL & 0x40);
32}
33
34/*
35 * Get button pressed from hardware
36 */
37int button_read_device(void)
38{
39 int btn = BUTTON_NONE;
40 static bool hold_button = false;
41 bool hold_button_old;
42
43 /* Hold */
44 hold_button_old = hold_button;
45 hold_button = button_hold();
46
47#ifndef BOOTLOADER
48 if (hold_button != hold_button_old)
49 backlight_hold_changed(hold_button);
50#endif
51
52 /* device buttons */
53 if (!hold_button)
54 {
55#if 0
56 if (!(GPIOB_INPUT_VAL & 0x20)) btn |= BUTTON_POWER;
57 if (!(GPIOF_INPUT_VAL & 0x10)) btn |= BUTTON_VOL_UP;
58 if (!(GPIOF_INPUT_VAL & 0x04)) btn |= BUTTON_VOL_DOWN;
59#endif
60 /* A hack until the touchpad works */
61 if (!(GPIOB_INPUT_VAL & 0x20)) btn |= BUTTON_SELECT;
62 if (!(GPIOF_INPUT_VAL & 0x10)) btn |= BUTTON_UP;
63 if (!(GPIOF_INPUT_VAL & 0x04)) btn |= BUTTON_DOWN;
64 }
65
66 return btn;
67}
68
69bool headphones_inserted(void)
70{
71 return (GPIOB_INPUT_VAL & 0x10) ? false : true;
72}