summaryrefslogtreecommitdiff
path: root/firmware/target/coldfire/iaudio/x5/button-x5.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/coldfire/iaudio/x5/button-x5.c')
-rwxr-xr-xfirmware/target/coldfire/iaudio/x5/button-x5.c131
1 files changed, 131 insertions, 0 deletions
diff --git a/firmware/target/coldfire/iaudio/x5/button-x5.c b/firmware/target/coldfire/iaudio/x5/button-x5.c
new file mode 100755
index 0000000000..07bc7bf3f7
--- /dev/null
+++ b/firmware/target/coldfire/iaudio/x5/button-x5.c
@@ -0,0 +1,131 @@
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 GPIO_FUNCTION |= 0x0e000000;
34 GPIO_ENABLE &= ~0x0e000000;
35}
36
37bool button_hold(void)
38{
39 return (GPIO_READ & 0x08000000)?false:true;
40}
41
42bool remote_button_hold(void)
43{
44 return false; /* TODO X5 */
45}
46
47int button_read_device(void)
48{
49 int data;
50 int btn = BUTTON_NONE;
51 static bool hold_button = false;
52 static bool remote_hold_button = false;
53
54 /* backlight handling */
55 if (hold_button && !button_hold())
56 {
57 backlight_on();
58 }
59 /* TODO: add light handling for the remote */
60
61 hold_button = button_hold();
62 remote_hold_button = remote_button_hold();
63
64 /* normal buttons */
65 if (!hold_button)
66 {
67 data = adc_scan(ADC_BUTTONS);
68 if (data < 0xf0)
69 {
70 if(data < 0x7c)
71 if(data < 0x42)
72 btn = BUTTON_LEFT;
73 else
74 if(data < 0x62)
75 btn = BUTTON_RIGHT;
76 else
77 btn = BUTTON_SELECT;
78 else
79 if(data < 0xb6)
80 if(data < 0x98)
81 btn = BUTTON_REC;
82 else
83 btn = BUTTON_PLAY;
84 else
85 if(data < 0xd3)
86 btn = BUTTON_DOWN;
87 else
88 btn = BUTTON_UP;
89 }
90 }
91
92 /* remote buttons */
93 data = adc_scan(ADC_REMOTE);
94 if(data < 0x17)
95 remote_hold_button = true;
96
97 if(!remote_hold_button)
98 {
99 if (data < 0xee)
100 {
101 if(data < 0x7a)
102 if(data < 0x41)
103 btn |= BUTTON_RC_REW;
104 else
105 if(data < 0x61)
106 btn |= BUTTON_RC_FF;
107 else
108 btn |= BUTTON_RC_MODE;
109 else
110 if(data < 0xb4)
111 if(data < 0x96)
112 btn |= BUTTON_RC_REC;
113 else
114 btn |= BUTTON_RC_MENU;
115 else
116 if(data < 0xd1)
117 btn |= BUTTON_RC_VOL_UP;
118 else
119 btn |= BUTTON_RC_VOL_DOWN;
120 }
121 }
122
123 data = GPIO_READ;
124 if (!(data & 0x04000000))
125 btn |= BUTTON_POWER;
126
127 if (!(data & 0x02000000))
128 btn |= BUTTON_RC_PLAY;
129
130 return btn;
131}