1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2008 by Mark Arigo
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 ****************************************************************************/
24 #include "backlight.h"
25 #include "synaptics-mep.h"
27 /*#define LOGF_ENABLE*/
30 static int int_btn
= BUTTON_NONE
;
33 * Generate a click sound from the player (not in headphones yet)
34 * TODO: integrate this with the "key click" option
36 void button_click(void)
38 GPO32_ENABLE
|= 0x2000;
45 void button_init_device(void)
47 /* The touchpad is powered on and initialized in power-hdd1630.c
48 since it needs to be ready for both buttons and button lights. */
52 * Button interrupt handler
59 int_btn
= BUTTON_NONE
;
61 val
= touchpad_read_device(data
, 4);
63 if (val
== MEP_BUTTON_HEADER
)
67 int_btn
|= BUTTON_LEFT
;
69 int_btn
|= BUTTON_RIGHT
;
71 else if (val
== MEP_ABSOLUTE_HEADER
)
73 /* Absolute packet - the finger is on the vertical strip.
74 Position ranges from 1-4095, with 1 at the bottom. */
75 val
= ((data
[1] >> 4) << 8) | data
[2]; /* position */
77 if ((val
> 0) && (val
<= 1365))
78 int_btn
|= BUTTON_DOWN
;
79 else if ((val
> 1365) && (val
<= 2730))
80 int_btn
|= BUTTON_SELECT
;
81 else if ((val
> 2730) && (val
<= 4095))
86 void button_init_device(void){}
87 #endif /* bootloader */
89 bool button_hold(void)
91 return !(GPIOJ_INPUT_VAL
& 0x8);
95 * Get button pressed from hardware
97 int button_read_device(void)
99 static int btn_old
= BUTTON_NONE
;
107 if (!(GPIOA_INPUT_VAL
& 0x01)) btn
|= BUTTON_MENU
;
108 if (!(GPIOA_INPUT_VAL
& 0x02)) btn
|= BUTTON_VOL_UP
;
109 if (!(GPIOA_INPUT_VAL
& 0x04)) btn
|= BUTTON_VOL_DOWN
;
110 if (!(GPIOA_INPUT_VAL
& 0x08)) btn
|= BUTTON_VIEW
;
111 if (!(GPIOD_INPUT_VAL
& 0x20)) btn
|= BUTTON_PLAYLIST
;
112 if (!(GPIOD_INPUT_VAL
& 0x40)) btn
|= BUTTON_POWER
;
114 if ((btn
!= btn_old
) && (btn
!= BUTTON_NONE
))
122 bool headphones_inserted(void)
124 return (GPIOE_INPUT_VAL
& 0x80) ? true : false;