-rw-r--r-- | libopie2/opiecore/device/odevice_htc.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libopie2/opiecore/device/odevice_htc.cpp b/libopie2/opiecore/device/odevice_htc.cpp index 4e5200b..a6ade11 100644 --- a/libopie2/opiecore/device/odevice_htc.cpp +++ b/libopie2/opiecore/device/odevice_htc.cpp | |||
@@ -1,495 +1,495 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> |
4 | =. Copyright (C) 2002-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 4 | =. Copyright (C) 2002-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; version 2 of the License. | 11 | - . .-<_> .<> Foundation; version 2 of the License. |
12 | ._= =} : | 12 | ._= =} : |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "odevice_htc.h" | 30 | #include "odevice_htc.h" |
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <opie2/oinputsystem.h> | 33 | #include <opie2/oinputsystem.h> |
34 | #include <opie2/oresource.h> | 34 | #include <opie2/oresource.h> |
35 | 35 | ||
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/sound.h> | 37 | #include <qpe/sound.h> |
38 | 38 | ||
39 | /* QT */ | 39 | /* QT */ |
40 | #include <qapplication.h> | 40 | #include <qapplication.h> |
41 | #include <qfile.h> | 41 | #include <qfile.h> |
42 | #include <qtextstream.h> | 42 | #include <qtextstream.h> |
43 | #include <qwindowsystem_qws.h> | 43 | #include <qwindowsystem_qws.h> |
44 | #include <qcopchannel_qws.h> | 44 | #include <qcopchannel_qws.h> |
45 | 45 | ||
46 | /* STD */ | 46 | /* STD */ |
47 | #include <string.h> | 47 | #include <string.h> |
48 | #include <errno.h> | 48 | #include <errno.h> |
49 | #include <fcntl.h> | 49 | #include <fcntl.h> |
50 | #include <math.h> | 50 | #include <math.h> |
51 | #include <stdlib.h> | 51 | #include <stdlib.h> |
52 | #include <signal.h> | 52 | #include <signal.h> |
53 | #include <sys/ioctl.h> | 53 | #include <sys/ioctl.h> |
54 | #include <sys/time.h> | 54 | #include <sys/time.h> |
55 | #include <unistd.h> | 55 | #include <unistd.h> |
56 | #ifndef QT_NO_SOUND | 56 | #ifndef QT_NO_SOUND |
57 | #include <linux/soundcard.h> | 57 | #include <linux/soundcard.h> |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | using namespace Opie::Core; | 60 | using namespace Opie::Core; |
61 | using namespace Opie::Core::Internal; | 61 | using namespace Opie::Core::Internal; |
62 | 62 | ||
63 | struct htc_button htc_buttons [] = { | 63 | struct htc_button htc_buttons [] = { |
64 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 64 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
65 | "devicebuttons/z_calendar", | 65 | "devicebuttons/z_calendar", |
66 | "datebook", "nextView()", | 66 | "datebook", "nextView()", |
67 | "today", "raise()" }, | 67 | "today", "raise()" }, |
68 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 68 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
69 | "devicebuttons/z_contact", | 69 | "devicebuttons/z_contact", |
70 | "addressbook", "raise()", | 70 | "addressbook", "raise()", |
71 | "addressbook", "beamBusinessCard()" }, | 71 | "addressbook", "beamBusinessCard()" }, |
72 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 72 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
73 | "devicebuttons/z_home", | 73 | "devicebuttons/z_home", |
74 | "QPE/Launcher", "home()", | 74 | "QPE/Launcher", "home()", |
75 | "buttonsettings", "raise()" }, | 75 | "buttonsettings", "raise()" }, |
76 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 76 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
77 | "devicebuttons/z_menu", | 77 | "devicebuttons/z_menu", |
78 | "QPE/TaskBar", "toggleMenu()", | 78 | "QPE/TaskBar", "toggleMenu()", |
79 | "QPE/TaskBar", "toggleStartMenu()" }, | 79 | "QPE/TaskBar", "toggleStartMenu()" }, |
80 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 80 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
81 | "devicebuttons/z_mail", | 81 | "devicebuttons/z_mail", |
82 | "opiemail", "raise()", | 82 | "opiemail", "raise()", |
83 | "opiemail", "newMail()" }, | 83 | "opiemail", "newMail()" }, |
84 | }; | 84 | }; |
85 | 85 | ||
86 | struct htc_button htc_buttons_universal [] = { | 86 | struct htc_button htc_buttons_universal [] = { |
87 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 87 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
88 | "devicebuttons/z_calendar", | 88 | "devicebuttons/z_calendar", |
89 | "datebook", "nextView()", | 89 | "datebook", "nextView()", |
90 | "today", "raise()" }, | 90 | "today", "raise()" }, |
91 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 91 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
92 | "devicebuttons/z_contact", | 92 | "devicebuttons/z_contact", |
93 | "addressbook", "raise()", | 93 | "addressbook", "raise()", |
94 | "addressbook", "beamBusinessCard()" }, | 94 | "addressbook", "beamBusinessCard()" }, |
95 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 95 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
96 | "devicebuttons/z_home", | 96 | "devicebuttons/z_home", |
97 | "QPE/Launcher", "home()", | 97 | "QPE/Launcher", "home()", |
98 | "buttonsettings", "raise()" }, | 98 | "buttonsettings", "raise()" }, |
99 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 99 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
100 | "devicebuttons/z_menu", | 100 | "devicebuttons/z_menu", |
101 | "QPE/TaskBar", "toggleMenu()", | 101 | "QPE/TaskBar", "toggleMenu()", |
102 | "QPE/TaskBar", "toggleStartMenu()" }, | 102 | "QPE/TaskBar", "toggleStartMenu()" }, |
103 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 103 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
104 | "devicebuttons/z_mail", | 104 | "devicebuttons/z_mail", |
105 | "opiemail", "raise()", | 105 | "opiemail", "raise()", |
106 | "opiemail", "newMail()" }, | 106 | "opiemail", "newMail()" }, |
107 | 107 | ||
108 | { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"), | 108 | { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"), |
109 | "devicebuttons/z_hinge1", | 109 | "devicebuttons/z_hinge1", |
110 | "QPE/Rotation", "rotateDefault()",0}, | 110 | "QPE/Rotation", "rotateDefault()",0}, |
111 | { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), | 111 | { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), |
112 | "devicebuttons/z_hinge2", | 112 | "devicebuttons/z_hinge2", |
113 | "QPE/Rotation", "rotateDefault()",0}, | 113 | "QPE/Rotation", "rotateDefault()",0}, |
114 | { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), | 114 | { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), |
115 | "devicebuttons/z_hinge3", | 115 | "devicebuttons/z_hinge3", |
116 | "QPE/Rotation", "rotateDefault()",0}, | 116 | "QPE/Rotation", "rotateDefault()",0}, |
117 | }; | 117 | }; |
118 | 118 | ||
119 | 119 | ||
120 | // | 120 | // |
121 | // HTC-Universal (PXA-model w/ 480x640 3.6" lcd) | 121 | // HTC-Universal (PXA-model w/ 480x640 3.6" lcd) |
122 | // HTC-Alpine (PXA-model w/ 240x320 3.5" lcd) | 122 | // HTC-Alpine (PXA-model w/ 240x320 3.5" lcd) |
123 | // HTC-Apache (PXA-model w/ 240x320 2.8" lcd) | 123 | // HTC-Apache (PXA-model w/ 240x320 2.8" lcd) |
124 | // HTC-Beetles (PXA-model w/ 240x240 3.0" lcd) | 124 | // HTC-Beetles (PXA-model w/ 240x240 3.0" lcd) |
125 | // HTC-Blueangel (PXA-model w/ 240x320 3.5" lcd) | 125 | // HTC-Blueangel (PXA-model w/ 240x320 3.5" lcd) |
126 | // HTC-Himalaya (PXA-model w/ 240x320 3.5" lcd) | 126 | // HTC-Himalaya (PXA-model w/ 240x320 3.5" lcd) |
127 | // HTC-Magician (PXA-model w/ 240x320 2.8" lcd) | 127 | // HTC-Magician (PXA-model w/ 240x320 2.8" lcd) |
128 | 128 | ||
129 | void HTC::init(const QString& cpu_info) | 129 | void HTC::init(const QString& cpu_info) |
130 | { | 130 | { |
131 | qDebug( "HTC::init()" ); | 131 | qDebug( "HTC::init()" ); |
132 | // Set the time to wait until the system is really suspended | 132 | // Set the time to wait until the system is really suspended |
133 | // the delta between apm --suspend and sleeping | 133 | // the delta between apm --suspend and sleeping |
134 | setAPMTimeOut( 15000 ); | 134 | setAPMTimeOut( 15000 ); |
135 | 135 | ||
136 | d->m_vendorstr = "Xanadux Team"; | 136 | d->m_vendorstr = "Xanadux Team"; |
137 | d->m_systemstr = "Familiar"; | 137 | d->m_systemstr = "Familiar"; |
138 | d->m_system = System_Familiar; | 138 | d->m_system = System_Familiar; |
139 | 139 | ||
140 | // check the HTC model | 140 | // check the HTC model |
141 | QString model; | 141 | QString model; |
142 | int loc = cpu_info.find( ":" ); | 142 | int loc = cpu_info.find( ":" ); |
143 | if ( loc != -1 ) | 143 | if ( loc != -1 ) |
144 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 144 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
145 | else | 145 | else |
146 | model = cpu_info; | 146 | model = cpu_info; |
147 | 147 | ||
148 | d->m_model = Model_HTC_Universal; | 148 | d->m_model = Model_HTC_Universal; |
149 | d->m_modelstr = "Unknown HTC"; | 149 | d->m_modelstr = "Unknown HTC"; |
150 | 150 | ||
151 | if ( model == "HTC Universal" ) { | 151 | if ( model == "HTC Universal" ) { |
152 | d->m_model = Model_HTC_Universal; | 152 | d->m_model = Model_HTC_Universal; |
153 | d->m_modelstr = "HTC Universal"; | 153 | d->m_modelstr = "HTC Universal"; |
154 | } | 154 | } |
155 | if ( model == "HTC Alpine" ) { | 155 | if ( model == "HTC Alpine" ) { |
156 | d->m_model = Model_HTC_Alpine; | 156 | d->m_model = Model_HTC_Alpine; |
157 | d->m_modelstr = "HTC Alpine"; | 157 | d->m_modelstr = "HTC Alpine"; |
158 | } | 158 | } |
159 | if ( model == "HTC Apache" ) { | 159 | if ( model == "HTC Apache" ) { |
160 | d->m_model = Model_HTC_Apache; | 160 | d->m_model = Model_HTC_Apache; |
161 | d->m_modelstr = "HTC Apache"; | 161 | d->m_modelstr = "HTC Apache"; |
162 | } | 162 | } |
163 | if ( model == "HTC Beetles" ) { | 163 | if ( model == "HTC Beetles" ) { |
164 | d->m_model = Model_HTC_Beetles; | 164 | d->m_model = Model_HTC_Beetles; |
165 | d->m_modelstr = "HTC Beetles"; | 165 | d->m_modelstr = "HTC Beetles"; |
166 | } | 166 | } |
167 | if ( model == "HTC Blueangel" ) { | 167 | if ( model == "HTC Blueangel" ) { |
168 | d->m_model = Model_HTC_Blueangel; | 168 | d->m_model = Model_HTC_Blueangel; |
169 | d->m_modelstr = "HTC Blueangel"; | 169 | d->m_modelstr = "HTC Blueangel"; |
170 | } | 170 | } |
171 | if ( model == "HTC Himalaya" ) { | 171 | if ( model == "HTC Himalaya" ) { |
172 | d->m_model = Model_HTC_Himalaya; | 172 | d->m_model = Model_HTC_Himalaya; |
173 | d->m_modelstr = "HTC Himalaya"; | 173 | d->m_modelstr = "HTC Himalaya"; |
174 | } | 174 | } |
175 | if ( model == "HTC Magician" ) { | 175 | if ( model == "HTC Magician" ) { |
176 | d->m_model = Model_HTC_Magician; | 176 | d->m_model = Model_HTC_Magician; |
177 | d->m_modelstr = "HTC Magician"; | 177 | d->m_modelstr = "HTC Magician"; |
178 | } | 178 | } |
179 | 179 | ||
180 | 180 | ||
181 | // set path to backlight device | 181 | // set path to backlight device |
182 | switch ( d->m_model ) | 182 | switch ( d->m_model ) |
183 | { | 183 | { |
184 | case Model_HTC_Universal: | 184 | case Model_HTC_Universal: |
185 | case Model_HTC_Magician: | 185 | case Model_HTC_Magician: |
186 | case Model_HTC_Alpine: | 186 | case Model_HTC_Alpine: |
187 | case Model_HTC_Beetles: | 187 | case Model_HTC_Beetles: |
188 | case Model_HTC_Apache: | 188 | case Model_HTC_Apache: |
189 | m_backlightdev = "/sys/class/backlight/pxa2xx-fb/"; | 189 | m_backlightdev = "/sys/class/backlight/corgi-bl/"; |
190 | break; | 190 | break; |
191 | case Model_HTC_Blueangel: | 191 | case Model_HTC_Blueangel: |
192 | case Model_HTC_Himalaya: | 192 | case Model_HTC_Himalaya: |
193 | m_backlightdev = "/sys/class/backlight/w100fb/"; | 193 | m_backlightdev = "/sys/class/backlight/w100fb/"; |
194 | break; | 194 | break; |
195 | default: | 195 | default: |
196 | m_backlightdev = "/sys/class/backlight/pxafb/"; | 196 | m_backlightdev = "/sys/class/backlight/corgi-bl/"; |
197 | } | 197 | } |
198 | 198 | ||
199 | // set initial rotation | 199 | // set initial rotation |
200 | switch( d->m_model ) | 200 | switch( d->m_model ) |
201 | { | 201 | { |
202 | case Model_HTC_Universal: | 202 | case Model_HTC_Universal: |
203 | initHingeSensor(); | 203 | initHingeSensor(); |
204 | d->m_rotation = rotation(); | 204 | d->m_rotation = rotation(); |
205 | d->m_direction = direction(); | 205 | d->m_direction = direction(); |
206 | break; | 206 | break; |
207 | default: | 207 | default: |
208 | d->m_rotation = Rot270; | 208 | d->m_rotation = Rot270; |
209 | } | 209 | } |
210 | 210 | ||
211 | // set default qte driver | 211 | // set default qte driver |
212 | switch( d->m_model ) | 212 | switch( d->m_model ) |
213 | { | 213 | { |
214 | default: | 214 | default: |
215 | d->m_qteDriver = "Transformed"; | 215 | d->m_qteDriver = "Transformed"; |
216 | } | 216 | } |
217 | 217 | ||
218 | m_leds[0] = Led_Off; | 218 | m_leds[0] = Led_Off; |
219 | 219 | ||
220 | qDebug( "HTC::init() - Using the 2.6 Xanadux on a %s", (const char*) d->m_modelstr ); | 220 | qDebug( "HTC::init() - Using the 2.6 Xanadux on a %s", (const char*) d->m_modelstr ); |
221 | } | 221 | } |
222 | 222 | ||
223 | void HTC::initButtons() | 223 | void HTC::initButtons() |
224 | { | 224 | { |
225 | qDebug( "HTC::initButtons()" ); | 225 | qDebug( "HTC::initButtons()" ); |
226 | if ( d->m_buttons ) | 226 | if ( d->m_buttons ) |
227 | return; | 227 | return; |
228 | 228 | ||
229 | d->m_buttons = new QValueList <ODeviceButton>; | 229 | d->m_buttons = new QValueList <ODeviceButton>; |
230 | 230 | ||
231 | struct htc_button * phtc_buttons; | 231 | struct htc_button * phtc_buttons; |
232 | int buttoncount; | 232 | int buttoncount; |
233 | switch ( d->m_model ) | 233 | switch ( d->m_model ) |
234 | { | 234 | { |
235 | case Model_HTC_Universal: | 235 | case Model_HTC_Universal: |
236 | if ( isQWS( ) ) | 236 | if ( isQWS( ) ) |
237 | { | 237 | { |
238 | addPreHandler(this); | 238 | addPreHandler(this); |
239 | } | 239 | } |
240 | phtc_buttons = htc_buttons_universal; | 240 | phtc_buttons = htc_buttons_universal; |
241 | buttoncount = ARRAY_SIZE(htc_buttons_universal); | 241 | buttoncount = ARRAY_SIZE(htc_buttons_universal); |
242 | break; | 242 | break; |
243 | default: | 243 | default: |
244 | phtc_buttons = htc_buttons; | 244 | phtc_buttons = htc_buttons; |
245 | buttoncount = ARRAY_SIZE(htc_buttons); | 245 | buttoncount = ARRAY_SIZE(htc_buttons); |
246 | break; | 246 | break; |
247 | } | 247 | } |
248 | 248 | ||
249 | for ( int i = 0; i < buttoncount; i++ ) { | 249 | for ( int i = 0; i < buttoncount; i++ ) { |
250 | struct htc_button *zb = phtc_buttons + i; | 250 | struct htc_button *zb = phtc_buttons + i; |
251 | ODeviceButton b; | 251 | ODeviceButton b; |
252 | 252 | ||
253 | b.setKeycode( zb->code ); | 253 | b.setKeycode( zb->code ); |
254 | b.setUserText( QObject::tr( "Button", zb->utext )); | 254 | b.setUserText( QObject::tr( "Button", zb->utext )); |
255 | b.setPixmap( OResource::loadPixmap( zb->pix )); | 255 | b.setPixmap( OResource::loadPixmap( zb->pix )); |
256 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); | 256 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); |
257 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); | 257 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); |
258 | d->m_buttons->append( b ); | 258 | d->m_buttons->append( b ); |
259 | } | 259 | } |
260 | 260 | ||
261 | reloadButtonMapping(); | 261 | reloadButtonMapping(); |
262 | } | 262 | } |
263 | 263 | ||
264 | 264 | ||
265 | 265 | ||
266 | typedef struct sharp_led_status { | 266 | typedef struct sharp_led_status { |
267 | int which; /* select which LED status is wanted. */ | 267 | int which; /* select which LED status is wanted. */ |
268 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 268 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
269 | } sharp_led_status; | 269 | } sharp_led_status; |
270 | 270 | ||
271 | void HTC::buzzer( int sound ) | 271 | void HTC::buzzer( int sound ) |
272 | { | 272 | { |
273 | #ifndef QT_NO_SOUND | 273 | #ifndef QT_NO_SOUND |
274 | Sound *snd = 0; | 274 | Sound *snd = 0; |
275 | 275 | ||
276 | // All devices except SL5500 have a DSP device | 276 | // All devices except SL5500 have a DSP device |
277 | if ( d->m_model == Model_HTC_Universal ) { | 277 | if ( d->m_model == Model_HTC_Universal ) { |
278 | 278 | ||
279 | switch ( sound ){ | 279 | switch ( sound ){ |
280 | case SHARP_BUZ_TOUCHSOUND: { | 280 | case SHARP_BUZ_TOUCHSOUND: { |
281 | static Sound touch_sound("touchsound"); | 281 | static Sound touch_sound("touchsound"); |
282 | snd = &touch_sound; | 282 | snd = &touch_sound; |
283 | } | 283 | } |
284 | break; | 284 | break; |
285 | case SHARP_BUZ_KEYSOUND: { | 285 | case SHARP_BUZ_KEYSOUND: { |
286 | static Sound key_sound( "keysound" ); | 286 | static Sound key_sound( "keysound" ); |
287 | snd = &key_sound; | 287 | snd = &key_sound; |
288 | } | 288 | } |
289 | break; | 289 | break; |
290 | case SHARP_BUZ_SCHEDULE_ALARM: | 290 | case SHARP_BUZ_SCHEDULE_ALARM: |
291 | default: { | 291 | default: { |
292 | static Sound alarm_sound("alarm"); | 292 | static Sound alarm_sound("alarm"); |
293 | snd = &alarm_sound; | 293 | snd = &alarm_sound; |
294 | } | 294 | } |
295 | break; | 295 | break; |
296 | } | 296 | } |
297 | } | 297 | } |
298 | 298 | ||
299 | // If a soundname is defined, we expect that this device has | 299 | // If a soundname is defined, we expect that this device has |
300 | // sound capabilities.. Otherwise we expect to have the buzzer | 300 | // sound capabilities.. Otherwise we expect to have the buzzer |
301 | // device.. | 301 | // device.. |
302 | if ( snd && snd->isFinished() ){ | 302 | if ( snd && snd->isFinished() ){ |
303 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); | 303 | changeMixerForAlarm( 0, "/dev/mixer", snd ); |
304 | snd->play(); | 304 | snd->play(); |
305 | } else if( !snd ) { | 305 | } else if( !snd ) { |
306 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 306 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
307 | 307 | ||
308 | if ( fd >= 0 ) { | 308 | if ( fd >= 0 ) { |
309 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 309 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
310 | ::close ( fd ); | 310 | ::close ( fd ); |
311 | } | 311 | } |
312 | 312 | ||
313 | } | 313 | } |
314 | #endif | 314 | #endif |
315 | } | 315 | } |
316 | 316 | ||
317 | 317 | ||
318 | void HTC::playAlarmSound() | 318 | void HTC::playAlarmSound() |
319 | { | 319 | { |
320 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); | 320 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); |
321 | } | 321 | } |
322 | 322 | ||
323 | void HTC::playTouchSound() | 323 | void HTC::playTouchSound() |
324 | { | 324 | { |
325 | buzzer( SHARP_BUZ_TOUCHSOUND ); | 325 | buzzer( SHARP_BUZ_TOUCHSOUND ); |
326 | } | 326 | } |
327 | 327 | ||
328 | void HTC::playKeySound() | 328 | void HTC::playKeySound() |
329 | { | 329 | { |
330 | buzzer( SHARP_BUZ_KEYSOUND ); | 330 | buzzer( SHARP_BUZ_KEYSOUND ); |
331 | } | 331 | } |
332 | 332 | ||
333 | 333 | ||
334 | QValueList <OLed> HTC::ledList() const | 334 | QValueList <OLed> HTC::ledList() const |
335 | { | 335 | { |
336 | QValueList <OLed> vl; | 336 | QValueList <OLed> vl; |
337 | vl << Led_Mail; | 337 | vl << Led_Mail; |
338 | return vl; | 338 | return vl; |
339 | } | 339 | } |
340 | 340 | ||
341 | QValueList <OLedState> HTC::ledStateList( OLed l ) const | 341 | QValueList <OLedState> HTC::ledStateList( OLed l ) const |
342 | { | 342 | { |
343 | QValueList <OLedState> vl; | 343 | QValueList <OLedState> vl; |
344 | 344 | ||
345 | if ( l == Led_Mail ) | 345 | if ( l == Led_Mail ) |
346 | vl << Led_Off << Led_On << Led_BlinkSlow; | 346 | vl << Led_Off << Led_On << Led_BlinkSlow; |
347 | return vl; | 347 | return vl; |
348 | } | 348 | } |
349 | 349 | ||
350 | OLedState HTC::ledState( OLed which ) const | 350 | OLedState HTC::ledState( OLed which ) const |
351 | { | 351 | { |
352 | if ( which == Led_Mail ) | 352 | if ( which == Led_Mail ) |
353 | return m_leds [0]; | 353 | return m_leds [0]; |
354 | else | 354 | else |
355 | return Led_Off; | 355 | return Led_Off; |
356 | } | 356 | } |
357 | 357 | ||
358 | bool HTC::setLedState( OLed which, OLedState st ) | 358 | bool HTC::setLedState( OLed which, OLedState st ) |
359 | { | 359 | { |
360 | qDebug( "HTC::setLedState: ODevice handling not yet implemented" ); | 360 | qDebug( "HTC::setLedState: ODevice handling not yet implemented" ); |
361 | return false; | 361 | return false; |
362 | } | 362 | } |
363 | 363 | ||
364 | int HTC::displayBrightnessResolution() const | 364 | int HTC::displayBrightnessResolution() const |
365 | { | 365 | { |
366 | int res = 1; | 366 | int res = 1; |
367 | 367 | ||
368 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); | 368 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); |
369 | 369 | ||
370 | if ( fd ) | 370 | if ( fd ) |
371 | { | 371 | { |
372 | char buf[100]; | 372 | char buf[100]; |
373 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); | 373 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); |
374 | ::close( fd ); | 374 | ::close( fd ); |
375 | } | 375 | } |
376 | 376 | ||
377 | return res; | 377 | return res; |
378 | } | 378 | } |
379 | 379 | ||
380 | bool HTC::setDisplayBrightness( int bright ) | 380 | bool HTC::setDisplayBrightness( int bright ) |
381 | { | 381 | { |
382 | 382 | ||
383 | //qDebug( "HTC::setDisplayBrightness( %d )", bright ); | 383 | //qDebug( "HTC::setDisplayBrightness( %d )", bright ); |
384 | bool res = false; | 384 | bool res = false; |
385 | 385 | ||
386 | if ( bright > 255 ) bright = 255; | 386 | if ( bright > 255 ) bright = 255; |
387 | if ( bright < 0 ) bright = 0; | 387 | if ( bright < 0 ) bright = 0; |
388 | 388 | ||
389 | int numberOfSteps = displayBrightnessResolution(); | 389 | int numberOfSteps = displayBrightnessResolution(); |
390 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; | 390 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; |
391 | 391 | ||
392 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); | 392 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); |
393 | if ( fd ) | 393 | if ( fd ) |
394 | { | 394 | { |
395 | char buf[100]; | 395 | char buf[100]; |
396 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); | 396 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); |
397 | res = ( ::write( fd, &buf[0], len ) == 0 ); | 397 | res = ( ::write( fd, &buf[0], len ) == 0 ); |
398 | ::close( fd ); | 398 | ::close( fd ); |
399 | } | 399 | } |
400 | return res; | 400 | return res; |
401 | } | 401 | } |
402 | 402 | ||
403 | bool HTC::setDisplayStatus( bool on ) | 403 | bool HTC::setDisplayStatus( bool on ) |
404 | { | 404 | { |
405 | 405 | ||
406 | bool res = false; | 406 | bool res = false; |
407 | 407 | ||
408 | int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); | 408 | int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); |
409 | if ( fd ) | 409 | if ( fd ) |
410 | { | 410 | { |
411 | char buf[10]; | 411 | char buf[10]; |
412 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; | 412 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; |
413 | buf[1] = '\0'; | 413 | buf[1] = '\0'; |
414 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); | 414 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); |
415 | ::close( fd ); | 415 | ::close( fd ); |
416 | } | 416 | } |
417 | return res; | 417 | return res; |
418 | } | 418 | } |
419 | 419 | ||
420 | Transformation HTC::rotation() const | 420 | Transformation HTC::rotation() const |
421 | { | 421 | { |
422 | qDebug( "HTC::rotation()" ); | 422 | qDebug( "HTC::rotation()" ); |
423 | Transformation rot = Rot270; | 423 | Transformation rot = Rot270; |
424 | 424 | ||
425 | switch ( d->m_model ) { | 425 | switch ( d->m_model ) { |
426 | case Model_HTC_Universal: | 426 | case Model_HTC_Universal: |
427 | { | 427 | { |
428 | OHingeStatus hs = readHingeSensor(); | 428 | OHingeStatus hs = readHingeSensor(); |
429 | qDebug( "HTC::rotation() - hinge sensor = %d", (int) hs ); | 429 | qDebug( "HTC::rotation() - hinge sensor = %d", (int) hs ); |
430 | if ( hs == CASE_PORTRAIT ) rot = Rot0; | 430 | if ( hs == CASE_PORTRAIT ) rot = Rot0; |
431 | else if ( hs == CASE_UNKNOWN ) rot = Rot270; | 431 | else if ( hs == CASE_UNKNOWN ) rot = Rot270; |
432 | } | 432 | } |
433 | break; | 433 | break; |
434 | } | 434 | } |
435 | 435 | ||
436 | qDebug( "HTC::rotation() - returning '%d'", rot ); | 436 | qDebug( "HTC::rotation() - returning '%d'", rot ); |
437 | return rot; | 437 | return rot; |
438 | } | 438 | } |
439 | ODirection HTC::direction() const | 439 | ODirection HTC::direction() const |
440 | { | 440 | { |
441 | ODirection dir; | 441 | ODirection dir; |
442 | 442 | ||
443 | switch ( d->m_model ) { | 443 | switch ( d->m_model ) { |
444 | case Model_HTC_Universal: { | 444 | case Model_HTC_Universal: { |
445 | OHingeStatus hs = readHingeSensor(); | 445 | OHingeStatus hs = readHingeSensor(); |
446 | if ( hs == CASE_PORTRAIT ) dir = CCW; | 446 | if ( hs == CASE_PORTRAIT ) dir = CCW; |
447 | else if ( hs == CASE_UNKNOWN ) dir = CCW; | 447 | else if ( hs == CASE_UNKNOWN ) dir = CCW; |
448 | else dir = CW; | 448 | else dir = CW; |
449 | } | 449 | } |
450 | break; | 450 | break; |
451 | default: dir = d->m_direction; | 451 | default: dir = d->m_direction; |
452 | break; | 452 | break; |
453 | } | 453 | } |
454 | return dir; | 454 | return dir; |
455 | 455 | ||
456 | } | 456 | } |
457 | 457 | ||
458 | bool HTC::hasHingeSensor() const | 458 | bool HTC::hasHingeSensor() const |
459 | { | 459 | { |
460 | return d->m_model == Model_HTC_Universal; | 460 | return d->m_model == Model_HTC_Universal; |
461 | } | 461 | } |
462 | 462 | ||
463 | OHingeStatus HTC::readHingeSensor() const | 463 | OHingeStatus HTC::readHingeSensor() const |
464 | { | 464 | { |
465 | /* | 465 | /* |
466 | * The HTC Universal keyboard is event source 1 in kernel 2.6. | 466 | * The HTC Universal keyboard is event source 1 in kernel 2.6. |
467 | * Hinge status is reported via Input System Switchs 0 and 1 like that: | 467 | * Hinge status is reported via Input System Switchs 0 and 1 like that: |
468 | * | 468 | * |
469 | * ------------------------- | 469 | * ------------------------- |
470 | * | SW0 | SW1 | CASE | | 470 | * | SW0 | SW1 | CASE | |
471 | * |-----|-----|-----------| | 471 | * |-----|-----|-----------| |
472 | * | 0 0 Unknown | | 472 | * | 0 0 Unknown | |
473 | * | 1 0 Portrait | | 473 | * | 1 0 Portrait | |
474 | * | 0 1 Closed | | 474 | * | 0 1 Closed | |
475 | * | 1 1 Landscape | | 475 | * | 1 1 Landscape | |
476 | * ------------------------- | 476 | * ------------------------- |
477 | */ | 477 | */ |
478 | OInputDevice* keyboard = OInputSystem::instance()->device( "event1" ); | 478 | OInputDevice* keyboard = OInputSystem::instance()->device( "event1" ); |
479 | bool switch0 = true; | 479 | bool switch0 = true; |
480 | bool switch1 = false; | 480 | bool switch1 = false; |
481 | if ( keyboard ) | 481 | if ( keyboard ) |
482 | { | 482 | { |
483 | switch0 = keyboard->isHeld( OInputDevice::Switch0 ); | 483 | switch0 = keyboard->isHeld( OInputDevice::Switch0 ); |
484 | switch1 = keyboard->isHeld( OInputDevice::Switch1 ); | 484 | switch1 = keyboard->isHeld( OInputDevice::Switch1 ); |
485 | } | 485 | } |
486 | if ( switch0 ) | 486 | if ( switch0 ) |
487 | { | 487 | { |
488 | return switch1 ? CASE_LANDSCAPE : CASE_PORTRAIT; | 488 | return switch1 ? CASE_LANDSCAPE : CASE_PORTRAIT; |
489 | } | 489 | } |
490 | else | 490 | else |
491 | { | 491 | { |
492 | return switch1 ? CASE_CLOSED : CASE_UNKNOWN; | 492 | return switch1 ? CASE_CLOSED : CASE_UNKNOWN; |
493 | } | 493 | } |
494 | } | 494 | } |
495 | 495 | ||