summaryrefslogtreecommitdiff
path: root/firmware/target/arm/gigabeat/meg-fx/button-meg-fx.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/gigabeat/meg-fx/button-meg-fx.c')
-rw-r--r--firmware/target/arm/gigabeat/meg-fx/button-meg-fx.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/firmware/target/arm/gigabeat/meg-fx/button-meg-fx.c b/firmware/target/arm/gigabeat/meg-fx/button-meg-fx.c
new file mode 100644
index 0000000000..88a1b4de09
--- /dev/null
+++ b/firmware/target/arm/gigabeat/meg-fx/button-meg-fx.c
@@ -0,0 +1,84 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Linus Nielsen Feltzing
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 <stdlib.h>
21#include "config.h"
22#include "cpu.h"
23#include "system.h"
24#include "button.h"
25#include "kernel.h"
26#include "backlight.h"
27#include "adc.h"
28#include "system.h"
29
30void button_init_device(void)
31{
32 /* Power, Remote Play & Hold switch */
33}
34
35bool button_hold(void)
36{
37 return (GPGDAT & (1 << 15));
38}
39
40int button_read_device(void)
41{
42 int btn = BUTTON_NONE;
43 int touchpad = GPJDAT;
44 int buttons = GPGDAT;
45
46 /* Check for hold first */
47 if (buttons & (1 << 15))
48 return btn;
49
50 /* the side buttons */
51 if (buttons & (1 << 0))
52 btn |= BUTTON_POWER;
53
54 if (buttons & (1 << 1))
55 btn |= BUTTON_MENU;
56
57 if (buttons & (1 << 2))
58 btn |= BUTTON_VOL_UP;
59
60 if (buttons & (1 << 3))
61 btn |= BUTTON_VOL_DOWN;
62
63 if (buttons & (1 << 4))
64 btn |= BUTTON_A;
65
66 /* the touchpad */
67 if (touchpad & (1 << 0))
68 btn |= BUTTON_UP;
69
70 if (touchpad & (1 << 12))
71 btn |= BUTTON_RIGHT;
72
73 if (touchpad & (1 << 6))
74 btn |= BUTTON_DOWN;
75
76 if (touchpad & (1 << 7))
77 btn |= BUTTON_LEFT;
78
79 if (touchpad & (1 << 3))
80 btn |= BUTTON_SELECT;
81
82 return btn;
83}
84