Diffstat (limited to 'libopie2/opiecore/device/odevice_htc.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice_htc.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libopie2/opiecore/device/odevice_htc.cpp b/libopie2/opiecore/device/odevice_htc.cpp index 44b33c0..7f82369 100644 --- a/libopie2/opiecore/device/odevice_htc.cpp +++ b/libopie2/opiecore/device/odevice_htc.cpp | |||
@@ -117,385 +117,387 @@ struct htc_button htc_buttons_universal [] = { | |||
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/corgi-bl/"; | 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/corgi-bl/"; | 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/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 | if (::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ) == -1) |
310 | qWarning( "HTC::buzzer() - Couldn't make the buzzer buzz (%s)", | ||
311 | strerror( errno ) ); | ||
310 | ::close ( fd ); | 312 | ::close ( fd ); |
311 | } | 313 | } |
312 | 314 | ||
313 | } | 315 | } |
314 | #endif | 316 | #endif |
315 | } | 317 | } |
316 | 318 | ||
317 | 319 | ||
318 | void HTC::playAlarmSound() | 320 | void HTC::playAlarmSound() |
319 | { | 321 | { |
320 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); | 322 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); |
321 | } | 323 | } |
322 | 324 | ||
323 | void HTC::playTouchSound() | 325 | void HTC::playTouchSound() |
324 | { | 326 | { |
325 | buzzer( SHARP_BUZ_TOUCHSOUND ); | 327 | buzzer( SHARP_BUZ_TOUCHSOUND ); |
326 | } | 328 | } |
327 | 329 | ||
328 | void HTC::playKeySound() | 330 | void HTC::playKeySound() |
329 | { | 331 | { |
330 | buzzer( SHARP_BUZ_KEYSOUND ); | 332 | buzzer( SHARP_BUZ_KEYSOUND ); |
331 | } | 333 | } |
332 | 334 | ||
333 | 335 | ||
334 | QValueList <OLed> HTC::ledList() const | 336 | QValueList <OLed> HTC::ledList() const |
335 | { | 337 | { |
336 | QValueList <OLed> vl; | 338 | QValueList <OLed> vl; |
337 | vl << Led_Mail; | 339 | vl << Led_Mail; |
338 | return vl; | 340 | return vl; |
339 | } | 341 | } |
340 | 342 | ||
341 | QValueList <OLedState> HTC::ledStateList( OLed l ) const | 343 | QValueList <OLedState> HTC::ledStateList( OLed l ) const |
342 | { | 344 | { |
343 | QValueList <OLedState> vl; | 345 | QValueList <OLedState> vl; |
344 | 346 | ||
345 | if ( l == Led_Mail ) | 347 | if ( l == Led_Mail ) |
346 | vl << Led_Off << Led_On << Led_BlinkSlow; | 348 | vl << Led_Off << Led_On << Led_BlinkSlow; |
347 | return vl; | 349 | return vl; |
348 | } | 350 | } |
349 | 351 | ||
350 | OLedState HTC::ledState( OLed which ) const | 352 | OLedState HTC::ledState( OLed which ) const |
351 | { | 353 | { |
352 | if ( which == Led_Mail ) | 354 | if ( which == Led_Mail ) |
353 | return m_leds [0]; | 355 | return m_leds [0]; |
354 | else | 356 | else |
355 | return Led_Off; | 357 | return Led_Off; |
356 | } | 358 | } |
357 | 359 | ||
358 | bool HTC::setLedState( OLed, OLedState ) | 360 | bool HTC::setLedState( OLed, OLedState ) |
359 | { | 361 | { |
360 | qDebug( "HTC::setLedState: ODevice handling not yet implemented" ); | 362 | qDebug( "HTC::setLedState: ODevice handling not yet implemented" ); |
361 | return false; | 363 | return false; |
362 | } | 364 | } |
363 | 365 | ||
364 | int HTC::displayBrightnessResolution() const | 366 | int HTC::displayBrightnessResolution() const |
365 | { | 367 | { |
366 | int res = 1; | 368 | int res = 1; |
367 | 369 | ||
368 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); | 370 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); |
369 | 371 | ||
370 | if ( fd ) | 372 | if ( fd ) |
371 | { | 373 | { |
372 | char buf[100]; | 374 | char buf[100]; |
373 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); | 375 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); |
374 | ::close( fd ); | 376 | ::close( fd ); |
375 | } | 377 | } |
376 | 378 | ||
377 | return res; | 379 | return res; |
378 | } | 380 | } |
379 | 381 | ||
380 | bool HTC::setDisplayBrightness( int bright ) | 382 | bool HTC::setDisplayBrightness( int bright ) |
381 | { | 383 | { |
382 | 384 | ||
383 | //qDebug( "HTC::setDisplayBrightness( %d )", bright ); | 385 | //qDebug( "HTC::setDisplayBrightness( %d )", bright ); |
384 | bool res = false; | 386 | bool res = false; |
385 | 387 | ||
386 | if ( bright > 255 ) bright = 255; | 388 | if ( bright > 255 ) bright = 255; |
387 | if ( bright < 0 ) bright = 0; | 389 | if ( bright < 0 ) bright = 0; |
388 | 390 | ||
389 | int numberOfSteps = displayBrightnessResolution(); | 391 | int numberOfSteps = displayBrightnessResolution(); |
390 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; | 392 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; |
391 | 393 | ||
392 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); | 394 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); |
393 | if ( fd ) | 395 | if ( fd ) |
394 | { | 396 | { |
395 | char buf[100]; | 397 | char buf[100]; |
396 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); | 398 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); |
397 | res = ( ::write( fd, &buf[0], len ) == 0 ); | 399 | res = ( ::write( fd, &buf[0], len ) == 0 ); |
398 | ::close( fd ); | 400 | ::close( fd ); |
399 | } | 401 | } |
400 | return res; | 402 | return res; |
401 | } | 403 | } |
402 | 404 | ||
403 | bool HTC::setDisplayStatus( bool on ) | 405 | bool HTC::setDisplayStatus( bool on ) |
404 | { | 406 | { |
405 | 407 | ||
406 | bool res = false; | 408 | bool res = false; |
407 | 409 | ||
408 | int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); | 410 | int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); |
409 | if ( fd ) | 411 | if ( fd ) |
410 | { | 412 | { |
411 | char buf[10]; | 413 | char buf[10]; |
412 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; | 414 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; |
413 | buf[1] = '\0'; | 415 | buf[1] = '\0'; |
414 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); | 416 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); |
415 | ::close( fd ); | 417 | ::close( fd ); |
416 | } | 418 | } |
417 | return res; | 419 | return res; |
418 | } | 420 | } |
419 | 421 | ||
420 | Transformation HTC::rotation() const | 422 | Transformation HTC::rotation() const |
421 | { | 423 | { |
422 | qDebug( "HTC::rotation()" ); | 424 | qDebug( "HTC::rotation()" ); |
423 | Transformation rot = Rot270; | 425 | Transformation rot = Rot270; |
424 | 426 | ||
425 | switch ( d->m_model ) { | 427 | switch ( d->m_model ) { |
426 | case Model_HTC_Universal: | 428 | case Model_HTC_Universal: |
427 | { | 429 | { |
428 | OHingeStatus hs = readHingeSensor(); | 430 | OHingeStatus hs = readHingeSensor(); |
429 | qDebug( "HTC::rotation() - hinge sensor = %d", (int) hs ); | 431 | qDebug( "HTC::rotation() - hinge sensor = %d", (int) hs ); |
430 | if ( hs == CASE_PORTRAIT ) rot = Rot0; | 432 | if ( hs == CASE_PORTRAIT ) rot = Rot0; |
431 | else if ( hs == CASE_UNKNOWN ) rot = Rot270; | 433 | else if ( hs == CASE_UNKNOWN ) rot = Rot270; |
432 | } | 434 | } |
433 | break; | 435 | break; |
434 | default: | 436 | default: |
435 | break; | 437 | break; |
436 | } | 438 | } |
437 | 439 | ||
438 | qDebug( "HTC::rotation() - returning '%d'", rot ); | 440 | qDebug( "HTC::rotation() - returning '%d'", rot ); |
439 | return rot; | 441 | return rot; |
440 | } | 442 | } |
441 | ODirection HTC::direction() const | 443 | ODirection HTC::direction() const |
442 | { | 444 | { |
443 | ODirection dir; | 445 | ODirection dir; |
444 | 446 | ||
445 | switch ( d->m_model ) { | 447 | switch ( d->m_model ) { |
446 | case Model_HTC_Universal: { | 448 | case Model_HTC_Universal: { |
447 | OHingeStatus hs = readHingeSensor(); | 449 | OHingeStatus hs = readHingeSensor(); |
448 | if ( hs == CASE_PORTRAIT ) dir = CCW; | 450 | if ( hs == CASE_PORTRAIT ) dir = CCW; |
449 | else if ( hs == CASE_UNKNOWN ) dir = CCW; | 451 | else if ( hs == CASE_UNKNOWN ) dir = CCW; |
450 | else dir = CW; | 452 | else dir = CW; |
451 | } | 453 | } |
452 | break; | 454 | break; |
453 | default: dir = d->m_direction; | 455 | default: dir = d->m_direction; |
454 | break; | 456 | break; |
455 | } | 457 | } |
456 | return dir; | 458 | return dir; |
457 | 459 | ||
458 | } | 460 | } |
459 | 461 | ||
460 | bool HTC::hasHingeSensor() const | 462 | bool HTC::hasHingeSensor() const |
461 | { | 463 | { |
462 | return d->m_model == Model_HTC_Universal; | 464 | return d->m_model == Model_HTC_Universal; |
463 | } | 465 | } |
464 | 466 | ||
465 | OHingeStatus HTC::readHingeSensor() const | 467 | OHingeStatus HTC::readHingeSensor() const |
466 | { | 468 | { |
467 | /* | 469 | /* |
468 | * The HTC Universal keyboard is event source 1 in kernel 2.6. | 470 | * The HTC Universal keyboard is event source 1 in kernel 2.6. |
469 | * Hinge status is reported via Input System Switchs 0 and 1 like that: | 471 | * Hinge status is reported via Input System Switchs 0 and 1 like that: |
470 | * | 472 | * |
471 | * ------------------------- | 473 | * ------------------------- |
472 | * | SW0 | SW1 | CASE | | 474 | * | SW0 | SW1 | CASE | |
473 | * |-----|-----|-----------| | 475 | * |-----|-----|-----------| |
474 | * | 0 0 Unknown | | 476 | * | 0 0 Unknown | |
475 | * | 1 0 Portrait | | 477 | * | 1 0 Portrait | |
476 | * | 0 1 Closed | | 478 | * | 0 1 Closed | |
477 | * | 1 1 Landscape | | 479 | * | 1 1 Landscape | |
478 | * ------------------------- | 480 | * ------------------------- |
479 | */ | 481 | */ |
480 | OInputDevice* keyboard = OInputSystem::instance()->device( "event1" ); | 482 | OInputDevice* keyboard = OInputSystem::instance()->device( "event1" ); |
481 | bool switch0 = true; | 483 | bool switch0 = true; |
482 | bool switch1 = false; | 484 | bool switch1 = false; |
483 | if ( keyboard ) | 485 | if ( keyboard ) |
484 | { | 486 | { |
485 | switch0 = keyboard->isHeld( OInputDevice::Switch0 ); | 487 | switch0 = keyboard->isHeld( OInputDevice::Switch0 ); |
486 | switch1 = keyboard->isHeld( OInputDevice::Switch1 ); | 488 | switch1 = keyboard->isHeld( OInputDevice::Switch1 ); |
487 | } | 489 | } |
488 | if ( switch0 ) | 490 | if ( switch0 ) |
489 | { | 491 | { |
490 | return switch1 ? CASE_LANDSCAPE : CASE_PORTRAIT; | 492 | return switch1 ? CASE_LANDSCAPE : CASE_PORTRAIT; |
491 | } | 493 | } |
492 | else | 494 | else |
493 | { | 495 | { |
494 | return switch1 ? CASE_CLOSED : CASE_UNKNOWN; | 496 | return switch1 ? CASE_CLOSED : CASE_UNKNOWN; |
495 | } | 497 | } |
496 | } | 498 | } |
497 | 499 | ||
498 | void HTC::initHingeSensor() | 500 | void HTC::initHingeSensor() |
499 | { | 501 | { |
500 | if ( m_embedix ) return; | 502 | if ( m_embedix ) return; |
501 | 503 | ||