diff options
author | Szymon Dziok <b0hoon@o2.pl> | 2010-07-04 12:27:39 +0000 |
---|---|---|
committer | Szymon Dziok <b0hoon@o2.pl> | 2010-07-04 12:27:39 +0000 |
commit | b43c43c591de2490d7b87a40c8c2cf4246361e0d (patch) | |
tree | 672187daadbfc91be51b58d4a542a9eab6ce1a67 | |
parent | 63c795a3496bc322a9e6118a3b08d0a7029b0b7d (diff) | |
download | rockbox-b43c43c591de2490d7b87a40c8c2cf4246361e0d.tar.gz rockbox-b43c43c591de2490d7b87a40c8c2cf4246361e0d.zip |
hdd6330: enable full touchpad support - code cleanup, all buttons should work now correctly, scrollstrip should work like in the OF.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27274 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/target/arm/philips/hdd6330/button-hdd6330.c | 81 | ||||
-rw-r--r-- | firmware/target/arm/philips/hdd6330/button-target.h | 29 |
2 files changed, 82 insertions, 28 deletions
diff --git a/firmware/target/arm/philips/hdd6330/button-hdd6330.c b/firmware/target/arm/philips/hdd6330/button-hdd6330.c index ab06c0cf1a..1d15b11a1e 100644 --- a/firmware/target/arm/philips/hdd6330/button-hdd6330.c +++ b/firmware/target/arm/philips/hdd6330/button-hdd6330.c | |||
@@ -22,12 +22,17 @@ | |||
22 | #include "system.h" | 22 | #include "system.h" |
23 | #include "button.h" | 23 | #include "button.h" |
24 | #include "backlight.h" | 24 | #include "backlight.h" |
25 | #include "powermgmt.h" | ||
25 | #include "synaptics-mep.h" | 26 | #include "synaptics-mep.h" |
26 | 27 | ||
27 | /*#define LOGF_ENABLE*/ | 28 | /*#define LOGF_ENABLE*/ |
28 | #include "logf.h" | 29 | #include "logf.h" |
29 | 30 | ||
30 | static int int_btn = BUTTON_NONE; | 31 | static int int_btn = BUTTON_NONE; |
32 | static int old_pos = -1; | ||
33 | |||
34 | static int scroll_repeat = BUTTON_NONE; | ||
35 | static int repeat = 0; | ||
31 | 36 | ||
32 | /* | 37 | /* |
33 | * Generate a click sound from the player (not in headphones yet) | 38 | * Generate a click sound from the player (not in headphones yet) |
@@ -59,27 +64,61 @@ void button_int(void) | |||
59 | int_btn = BUTTON_NONE; | 64 | int_btn = BUTTON_NONE; |
60 | 65 | ||
61 | val = touchpad_read_device(data, 4); | 66 | val = touchpad_read_device(data, 4); |
62 | 67 | ||
63 | if (val == MEP_BUTTON_HEADER) | 68 | if (data[0] == MEP_BUTTON_HEADER) |
64 | { | 69 | { |
65 | /* Buttons packet */ | 70 | /* Buttons packet */ |
66 | if (data[1] & 0x1) | 71 | if (data[1] & 0x1) |
67 | int_btn |= BUTTON_LEFT; | 72 | int_btn |= BUTTON_LEFT; |
68 | if (data[1] & 0x2) | 73 | if (data[1] & 0x2) |
74 | int_btn |= BUTTON_MENU; | ||
75 | if (data[1] & 0x4) | ||
69 | int_btn |= BUTTON_RIGHT; | 76 | int_btn |= BUTTON_RIGHT; |
77 | if (data[1] & 0x8) | ||
78 | int_btn |= BUTTON_VIEW; | ||
70 | } | 79 | } |
71 | else if (val == MEP_ABSOLUTE_HEADER) | 80 | else if ((data[0] == MEP_ABSOLUTE_HEADER)) |
72 | { | 81 | { |
73 | /* Absolute packet - the finger is on the vertical strip. | 82 | if (data[1] & MEP_FINGER) |
74 | Position ranges from 1-4095, with 1 at the bottom. */ | 83 | { |
75 | val = ((data[1] >> 4) << 8) | data[2]; /* position */ | 84 | /* Absolute packet - the finger is on the horizontal strip. |
76 | 85 | Position ranges from 1-4095, with 1 at the bottom. */ | |
77 | if ((val > 0) && (val <= 1365)) | 86 | val = ((data[1] >> 4) << 8) | data[2]; /* position */ |
78 | int_btn |= BUTTON_DOWN; | 87 | |
79 | else if ((val > 1365) && (val <= 2730)) | 88 | /* The HDD63x0 actually has 2 scrollbars. One vertical and one horizontal |
80 | int_btn |= BUTTON_SELECT; | 89 | (where the prev, play, and next buttons are). Because of that, we need to know |
81 | else if ((val > 2730) && (val <= 4095)) | 90 | which sensor is reporting data. */ |
82 | int_btn |= BUTTON_UP; | 91 | if ((data[3] >> 6) == 1) /* index = 1 */ |
92 | { | ||
93 | if ((val > 0) && (val <= 1365)) | ||
94 | int_btn |= BUTTON_PREV; | ||
95 | else if ((val > 1365) && (val <= 2730)) | ||
96 | int_btn |= BUTTON_PLAY; | ||
97 | else if ((val > 2730) && (val <= 4095)) | ||
98 | int_btn |= BUTTON_NEXT; | ||
99 | } else | ||
100 | { | ||
101 | int scr_pos = val >> 8; /* split the scrollstrip into 16 regions */ | ||
102 | if ((old_pos<scr_pos)&&(old_pos!=-1)) int_btn = BUTTON_UP; | ||
103 | if ((old_pos>scr_pos)&&(old_pos!=-1)) int_btn = BUTTON_DOWN; | ||
104 | |||
105 | old_pos = scr_pos; | ||
106 | |||
107 | /* repeat button */ | ||
108 | repeat = 0; | ||
109 | if (int_btn != BUTTON_NONE) | ||
110 | { | ||
111 | if (int_btn != scroll_repeat) | ||
112 | scroll_repeat = int_btn; | ||
113 | else repeat = BUTTON_REPEAT; | ||
114 | } | ||
115 | } | ||
116 | } | ||
117 | else | ||
118 | { | ||
119 | old_pos = -1; | ||
120 | scroll_repeat = BUTTON_NONE; | ||
121 | } | ||
83 | } | 122 | } |
84 | } | 123 | } |
85 | #else | 124 | #else |
@@ -104,13 +143,23 @@ int button_read_device(void) | |||
104 | return BUTTON_NONE; | 143 | return BUTTON_NONE; |
105 | 144 | ||
106 | /* Device buttons */ | 145 | /* Device buttons */ |
107 | if (!(GPIOA_INPUT_VAL & 0x01)) btn |= BUTTON_MENU; | ||
108 | if (!(GPIOA_INPUT_VAL & 0x02)) btn |= BUTTON_VOL_UP; | 146 | if (!(GPIOA_INPUT_VAL & 0x02)) btn |= BUTTON_VOL_UP; |
109 | if (!(GPIOA_INPUT_VAL & 0x04)) btn |= BUTTON_VOL_DOWN; | 147 | 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; | 148 | if (!(GPIOD_INPUT_VAL & 0x40)) btn |= BUTTON_POWER; |
113 | 149 | ||
150 | /* Scrollstrip direct button post - much better response */ | ||
151 | if ((btn == BUTTON_UP) || (btn == BUTTON_DOWN)) | ||
152 | { | ||
153 | queue_post(&button_queue,btn|repeat,0); | ||
154 | backlight_on(); | ||
155 | buttonlight_on(); | ||
156 | reset_poweroff_timer(); | ||
157 | |||
158 | int_btn = BUTTON_NONE; | ||
159 | repeat = BUTTON_NONE; | ||
160 | btn = BUTTON_NONE; | ||
161 | } | ||
162 | |||
114 | if ((btn != btn_old) && (btn != BUTTON_NONE)) | 163 | if ((btn != btn_old) && (btn != BUTTON_NONE)) |
115 | button_click(); | 164 | button_click(); |
116 | 165 | ||
diff --git a/firmware/target/arm/philips/hdd6330/button-target.h b/firmware/target/arm/philips/hdd6330/button-target.h index b7fc21aca2..07d8d9b0de 100644 --- a/firmware/target/arm/philips/hdd6330/button-target.h +++ b/firmware/target/arm/philips/hdd6330/button-target.h | |||
@@ -28,6 +28,7 @@ | |||
28 | #define MEP_BUTTON_HEADER 0x19 | 28 | #define MEP_BUTTON_HEADER 0x19 |
29 | #define MEP_BUTTON_ID 0x9 | 29 | #define MEP_BUTTON_ID 0x9 |
30 | #define MEP_ABSOLUTE_HEADER 0x0b | 30 | #define MEP_ABSOLUTE_HEADER 0x0b |
31 | #define MEP_FINGER 0x01 | ||
31 | 32 | ||
32 | #define HAS_BUTTON_HOLD | 33 | #define HAS_BUTTON_HOLD |
33 | 34 | ||
@@ -41,18 +42,22 @@ void button_int(void); | |||
41 | 42 | ||
42 | /* Main unit's buttons */ | 43 | /* Main unit's buttons */ |
43 | #define BUTTON_POWER 0x00000001 | 44 | #define BUTTON_POWER 0x00000001 |
44 | #define BUTTON_PLAYLIST 0x00000002 | 45 | #define BUTTON_MENU 0x00000002 |
45 | #define BUTTON_MENU 0x00000004 | 46 | #define BUTTON_VIEW 0x00000004 |
46 | #define BUTTON_VIEW 0x00000008 | 47 | #define BUTTON_VOL_UP 0x00000008 |
47 | #define BUTTON_VOL_UP 0x00000010 | 48 | #define BUTTON_VOL_DOWN 0x00000010 |
48 | #define BUTTON_VOL_DOWN 0x00000020 | 49 | #define BUTTON_LEFT 0x00000020 |
49 | #define BUTTON_SELECT 0x00000040 | 50 | #define BUTTON_RIGHT 0x00000040 |
50 | #define BUTTON_LEFT 0x00000080 | 51 | #define BUTTON_UP 0x00000080 |
51 | #define BUTTON_RIGHT 0x00000100 | 52 | #define BUTTON_DOWN 0x00000100 |
52 | #define BUTTON_UP 0x00000200 | 53 | #define BUTTON_NEXT 0x00000200 |
53 | #define BUTTON_DOWN 0x00000400 | 54 | #define BUTTON_PREV 0x00000400 |
54 | 55 | #define BUTTON_PLAY 0x00000800 | |
55 | #define BUTTON_MAIN 0x00000fff | 56 | |
57 | #define BUTTON_SELECT 0x00001000 | ||
58 | #define BUTTON_PLAYLIST 0x00002000 | ||
59 | |||
60 | #define BUTTON_MAIN 0x00003fff | ||
56 | 61 | ||
57 | /* No Remote control */ | 62 | /* No Remote control */ |
58 | #define BUTTON_REMOTE 0 | 63 | #define BUTTON_REMOTE 0 |