diff options
author | Bertrik Sikken <bertrik@sikken.nl> | 2009-11-07 21:37:28 +0000 |
---|---|---|
committer | Bertrik Sikken <bertrik@sikken.nl> | 2009-11-07 21:37:28 +0000 |
commit | c87270fb751c7ae8c8c7094dee53a40a18c18b0a (patch) | |
tree | f28380f7c743b33e9aae0cd0b65f34888e88f2e3 | |
parent | 8e47406b76ebd34df155d3cc1e0781a69dae315b (diff) | |
download | rockbox-c87270fb751c7ae8c8c7094dee53a40a18c18b0a.tar.gz rockbox-c87270fb751c7ae8c8c7094dee53a40a18c18b0a.zip |
Meizu M6SP: initial button driver (adapted from Meizu M3)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23559 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/target/arm/s5l8700/meizu-m6sp/button-m6sp.c | 72 | ||||
-rw-r--r-- | firmware/target/arm/s5l8700/meizu-m6sp/button-target.h | 17 |
2 files changed, 79 insertions, 10 deletions
diff --git a/firmware/target/arm/s5l8700/meizu-m6sp/button-m6sp.c b/firmware/target/arm/s5l8700/meizu-m6sp/button-m6sp.c new file mode 100644 index 0000000000..a2c7604a85 --- /dev/null +++ b/firmware/target/arm/s5l8700/meizu-m6sp/button-m6sp.c | |||
@@ -0,0 +1,72 @@ | |||
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 M6SP | ||
30 | |||
31 | Future improvements: | ||
32 | * touch strip support | ||
33 | * left/right buttons (probably part of touch strip) | ||
34 | * unify with m3/m6sl button driver if possible | ||
35 | |||
36 | */ | ||
37 | |||
38 | |||
39 | void button_init_device(void) | ||
40 | { | ||
41 | PCON0 &= ~(0x3 << 10); /* P0.5 hold switch */ | ||
42 | PCON0 &= ~(0x3 << 14); /* P0.7 enter button */ | ||
43 | PCON1 &= ~(0xF << 12); /* P1.3 menu button */ | ||
44 | PCON1 &= ~(0xF << 16); /* P1.4 play button */ | ||
45 | } | ||
46 | |||
47 | int button_read_device(void) | ||
48 | { | ||
49 | int buttons = 0; | ||
50 | |||
51 | if (button_hold()) { | ||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | if ((PDAT0 & (1 << 7)) == 0) { | ||
56 | buttons |= BUTTON_ENTER; | ||
57 | } | ||
58 | if ((PDAT1 & (1 << 3)) == 0) { | ||
59 | buttons |= BUTTON_MENU; | ||
60 | } | ||
61 | if ((PDAT1 & (1 << 4)) == 0) { | ||
62 | buttons |= BUTTON_PLAY; | ||
63 | } | ||
64 | |||
65 | return buttons; | ||
66 | } | ||
67 | |||
68 | bool button_hold(void) | ||
69 | { | ||
70 | return ((PDAT0 & (1 << 5)) != 0); | ||
71 | } | ||
72 | |||
diff --git a/firmware/target/arm/s5l8700/meizu-m6sp/button-target.h b/firmware/target/arm/s5l8700/meizu-m6sp/button-target.h index 7fab9c4d64..db6445fe30 100644 --- a/firmware/target/arm/s5l8700/meizu-m6sp/button-target.h +++ b/firmware/target/arm/s5l8700/meizu-m6sp/button-target.h | |||
@@ -30,21 +30,18 @@ bool button_hold(void); | |||
30 | void button_init_device(void); | 30 | void button_init_device(void); |
31 | int button_read_device(void); | 31 | int button_read_device(void); |
32 | 32 | ||
33 | /* Toshiba Gigabeat specific button codes */ | 33 | /* Meizu M6 specific button codes */ |
34 | 34 | ||
35 | #define BUTTON_LEFT 0x00000001 | 35 | #define BUTTON_LEFT 0x00000001 |
36 | #define BUTTON_RIGHT 0x00000002 | 36 | #define BUTTON_RIGHT 0x00000002 |
37 | #define BUTTON_UP 0x00000004 | 37 | #define BUTTON_PLAY 0x00000004 |
38 | #define BUTTON_DOWN 0x00000008 | 38 | #define BUTTON_MENU 0x00000008 |
39 | #define BUTTON_SELECT 0x00000010 /* TODO: tap on the touch strip */ | ||
40 | #define BUTTON_ENTER 0x00000020 | ||
39 | 41 | ||
40 | #define BUTTON_SELECT 0x00000010 | ||
41 | 42 | ||
42 | #define BUTTON_MENU 0x00000020 | 43 | #define BUTTON_MAIN (BUTTON_LEFT|BUTTON_RIGHT|BUTTON_PLAY|BUTTON_MENU\ |
43 | #define BUTTON_PLAY 0x00000040 | 44 | |BUTTON_SELECT|BUTTON_ENTER) |
44 | |||
45 | |||
46 | #define BUTTON_MAIN (BUTTON_MENU|BUTTON_LEFT|BUTTON_RIGHT\ | ||
47 | |BUTTON_UP|BUTTON_DOWN|BUTTON_SELECT|BUTTON_PLAY) | ||
48 | 45 | ||
49 | #define BUTTON_REMOTE 0 | 46 | #define BUTTON_REMOTE 0 |
50 | 47 | ||