FS#11417 by Joe Balough: fix audio/tuner on philips hdd6330
[kugel-rb.git] / firmware / target / arm / pnx0101 / iriver-ifp7xx / button-ifp7xx.c
blob45f9fae4785bd984023423273b9d78b733276a8a
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2006 by Barry Wardell
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
23 #include <stdlib.h>
24 #include "config.h"
25 #include "cpu.h"
26 #include "system.h"
27 #include "button.h"
28 #include "kernel.h"
29 #include "backlight.h"
30 #include "adc.h"
33 void button_init_device(void)
38 bool button_hold(void)
40 return (GPIO5_READ & 4) ? false : true;
44 * Get button pressed from hardware
46 int button_read_device(void)
48 int btn = BUTTON_NONE;
49 int data;
50 static bool hold_button = false;
51 bool hold_button_old;
53 /* normal buttons */
54 hold_button_old = hold_button;
55 hold_button = button_hold();
57 if (hold_button != hold_button_old)
58 backlight_hold_changed(hold_button);
60 if (!button_hold())
62 data = adc_read(ADC_BUTTONS);
63 if (data < 0x35c)
65 if (data < 0x151)
66 if (data < 0xc7)
67 if (data < 0x41)
68 btn = BUTTON_LEFT;
69 else
70 btn = BUTTON_RIGHT;
71 else
72 btn = BUTTON_SELECT;
73 else
74 if (data < 0x268)
75 if (data < 0x1d7)
76 btn = BUTTON_UP;
77 else
78 btn = BUTTON_DOWN;
79 else
80 if (data < 0x2f9)
81 btn = BUTTON_EQ;
82 else
83 btn = BUTTON_MODE;
86 if (adc_read(ADC_BUTTON_PLAY) < 0x64)
87 btn |= BUTTON_PLAY;
89 return btn;