summaryrefslogtreecommitdiff
path: root/firmware/target/arm/pnx0101/iriver-ifp7xx/button-ifp7xx.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/pnx0101/iriver-ifp7xx/button-ifp7xx.c')
-rw-r--r--firmware/target/arm/pnx0101/iriver-ifp7xx/button-ifp7xx.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/button-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/button-ifp7xx.c
new file mode 100644
index 0000000000..52e29fdfdf
--- /dev/null
+++ b/firmware/target/arm/pnx0101/iriver-ifp7xx/button-ifp7xx.c
@@ -0,0 +1,89 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Barry Wardell
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
21#include <stdlib.h>
22#include "config.h"
23#include "cpu.h"
24#include "system.h"
25#include "button.h"
26#include "kernel.h"
27#include "backlight.h"
28#include "adc.h"
29#include "system.h"
30
31
32void button_init_device(void)
33{
34
35}
36
37bool button_hold(void)
38{
39 return (GPIO5_READ & 4) ? false : true;
40}
41
42/*
43 * Get button pressed from hardware
44 */
45int button_read_device(void)
46{
47 int btn = BUTTON_NONE;
48 int data;
49 static bool hold_button = false;
50 bool hold_button_old;
51
52 /* normal buttons */
53 hold_button_old = hold_button;
54 hold_button = button_hold();
55
56 if (hold_button != hold_button_old)
57 backlight_hold_changed(hold_button);
58
59 if (!button_hold())
60 {
61 data = adc_read(ADC_BUTTONS);
62 if (data < 0x35c)
63 {
64 if (data < 0x151)
65 if (data < 0xc7)
66 if (data < 0x41)
67 btn = BUTTON_LEFT;
68 else
69 btn = BUTTON_RIGHT;
70 else
71 btn = BUTTON_SELECT;
72 else
73 if (data < 0x268)
74 if (data < 0x1d7)
75 btn = BUTTON_UP;
76 else
77 btn = BUTTON_DOWN;
78 else
79 if (data < 0x2f9)
80 btn = BUTTON_EQ;
81 else
82 btn = BUTTON_MODE;
83 }
84
85 if (adc_read(ADC_BUTTON_PLAY) < 0x64)
86 btn |= BUTTON_PLAY;
87 }
88 return btn;
89}