diff options
Diffstat (limited to 'firmware/target/arm/s5l8700/meizu-m3/button-m3.c')
-rw-r--r-- | firmware/target/arm/s5l8700/meizu-m3/button-m3.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/firmware/target/arm/s5l8700/meizu-m3/button-m3.c b/firmware/target/arm/s5l8700/meizu-m3/button-m3.c new file mode 100644 index 0000000000..a99a99ec82 --- /dev/null +++ b/firmware/target/arm/s5l8700/meizu-m3/button-m3.c | |||
@@ -0,0 +1,69 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2009 Bertrik Sikken | ||
11 | * | ||
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. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <stdbool.h> | ||
23 | #include "config.h" | ||
24 | |||
25 | #include "inttypes.h" | ||
26 | #include "s5l8700.h" | ||
27 | #include "button-target.h" | ||
28 | |||
29 | /* Button driver for the meizu M3 | ||
30 | |||
31 | TODO: implement buttons based on on touch strip events, for example | ||
32 | short touch (select), slide up and down, touching the <> button, etc. | ||
33 | */ | ||
34 | |||
35 | |||
36 | void button_init_device(void) | ||
37 | { | ||
38 | PCON0 &= ~(3 << 10); /* P0.5 hold switch */ | ||
39 | PCON1 &= ~(0xF << 0); /* P1.0 menu button */ | ||
40 | PCON1 &= ~(0xF << 16); /* P1.4 play button */ | ||
41 | PCON3 &= ~(0xF << 12); /* P3.3 <> button */ | ||
42 | } | ||
43 | |||
44 | int button_read_device(void) | ||
45 | { | ||
46 | int buttons = 0; | ||
47 | |||
48 | if (button_hold()) { | ||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | if ((PDAT1 & (1 << 0)) == 0) { | ||
53 | buttons |= BUTTON_MENU; | ||
54 | } | ||
55 | if ((PDAT1 & (1 << 4)) == 0) { | ||
56 | buttons |= BUTTON_PLAY; | ||
57 | } | ||
58 | if ((PDAT3 & (1 << 3)) == 0) { | ||
59 | buttons |= BUTTON_PREVNEXT; | ||
60 | } | ||
61 | |||
62 | return buttons; | ||
63 | } | ||
64 | |||
65 | bool button_hold(void) | ||
66 | { | ||
67 | return ((PDAT0 & (1 << 5)) != 0); | ||
68 | } | ||
69 | |||