summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-05-30 16:12:14 (UTC)
committer mickeyl <mickeyl>2003-05-30 16:12:14 (UTC)
commit5c9e869c42ce14ff87a02450da09c2a35ee799e1 (patch) (unidiff)
treeb61b3a02f1a6edeb0ecddf778e8b44fd49bdb757
parentcc06c984e13d5a452da3a5636cac77e001c80ad6 (diff)
downloadopie-5c9e869c42ce14ff87a02450da09c2a35ee799e1.zip
opie-5c9e869c42ce14ff87a02450da09c2a35ee799e1.tar.gz
opie-5c9e869c42ce14ff87a02450da09c2a35ee799e1.tar.bz2
add support for the SIMpad virtual switches
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp59
1 files changed, 50 insertions, 9 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 2873407..01932c9 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -165,211 +165,252 @@ struct i_button {
165 uint model; 165 uint model;
166 Qt::Key code; 166 Qt::Key code;
167 char *utext; 167 char *utext;
168 char *pix; 168 char *pix;
169 char *fpressedservice; 169 char *fpressedservice;
170 char *fpressedaction; 170 char *fpressedaction;
171 char *fheldservice; 171 char *fheldservice;
172 char *fheldaction; 172 char *fheldaction;
173} ipaq_buttons [] = { 173} ipaq_buttons [] = {
174 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 174 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
175 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 175 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
176 "devicebuttons/ipaq_calendar", 176 "devicebuttons/ipaq_calendar",
177 "datebook", "nextView()", 177 "datebook", "nextView()",
178 "today", "raise()" }, 178 "today", "raise()" },
179 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 179 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
180 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 180 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
181 "devicebuttons/ipaq_contact", 181 "devicebuttons/ipaq_contact",
182 "addressbook", "raise()", 182 "addressbook", "raise()",
183 "addressbook", "beamBusinessCard()" }, 183 "addressbook", "beamBusinessCard()" },
184 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 184 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
185 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 185 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
186 "devicebuttons/ipaq_menu", 186 "devicebuttons/ipaq_menu",
187 "QPE/TaskBar", "toggleMenu()", 187 "QPE/TaskBar", "toggleMenu()",
188 "QPE/TaskBar", "toggleStartMenu()" }, 188 "QPE/TaskBar", "toggleStartMenu()" },
189 { Model_iPAQ_H38xx | Model_iPAQ_H39xx, 189 { Model_iPAQ_H38xx | Model_iPAQ_H39xx,
190 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 190 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
191 "devicebuttons/ipaq_mail", 191 "devicebuttons/ipaq_mail",
192 "mail", "raise()", 192 "mail", "raise()",
193 "mail", "newMail()" }, 193 "mail", "newMail()" },
194 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 194 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
195 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 195 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
196 "devicebuttons/ipaq_home", 196 "devicebuttons/ipaq_home",
197 "QPE/Launcher", "home()", 197 "QPE/Launcher", "home()",
198 "buttonsettings", "raise()" }, 198 "buttonsettings", "raise()" },
199 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 199 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
200 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 200 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
201 "devicebuttons/ipaq_record", 201 "devicebuttons/ipaq_record",
202 "QPE/VMemo", "toggleRecord()", 202 "QPE/VMemo", "toggleRecord()",
203 "sound", "raise()" }, 203 "sound", "raise()" },
204}; 204};
205 205
206struct z_button { 206struct z_button {
207 Qt::Key code; 207 Qt::Key code;
208 char *utext; 208 char *utext;
209 char *pix; 209 char *pix;
210 char *fpressedservice; 210 char *fpressedservice;
211 char *fpressedaction; 211 char *fpressedaction;
212 char *fheldservice; 212 char *fheldservice;
213 char *fheldaction; 213 char *fheldaction;
214} z_buttons [] = { 214} z_buttons [] = {
215 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 215 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
216 "devicebuttons/z_calendar", 216 "devicebuttons/z_calendar",
217 "datebook", "nextView()", 217 "datebook", "nextView()",
218 "today", "raise()" }, 218 "today", "raise()" },
219 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 219 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
220 "devicebuttons/z_contact", 220 "devicebuttons/z_contact",
221 "addressbook", "raise()", 221 "addressbook", "raise()",
222 "addressbook", "beamBusinessCard()" }, 222 "addressbook", "beamBusinessCard()" },
223 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 223 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
224 "devicebuttons/z_home", 224 "devicebuttons/z_home",
225 "QPE/Launcher", "home()", 225 "QPE/Launcher", "home()",
226 "buttonsettings", "raise()" }, 226 "buttonsettings", "raise()" },
227 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 227 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
228 "devicebuttons/z_menu", 228 "devicebuttons/z_menu",
229 "QPE/TaskBar", "toggleMenu()", 229 "QPE/TaskBar", "toggleMenu()",
230 "QPE/TaskBar", "toggleStartMenu()" }, 230 "QPE/TaskBar", "toggleStartMenu()" },
231 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 231 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
232 "devicebuttons/z_mail", 232 "devicebuttons/z_mail",
233 "mail", "raise()", 233 "mail", "raise()",
234 "mail", "newMail()" }, 234 "mail", "newMail()" },
235}; 235};
236 236
237struct z_button z_buttons_c700 [] = { 237struct z_button z_buttons_c700 [] = {
238 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 238 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
239 "devicebuttons/z_calendar", 239 "devicebuttons/z_calendar",
240 "datebook", "nextView()", 240 "datebook", "nextView()",
241 "today", "raise()" }, 241 "today", "raise()" },
242 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 242 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
243 "devicebuttons/z_contact", 243 "devicebuttons/z_contact",
244 "addressbook", "raise()", 244 "addressbook", "raise()",
245 "addressbook", "beamBusinessCard()" }, 245 "addressbook", "beamBusinessCard()" },
246 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 246 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
247 "devicebuttons/z_home", 247 "devicebuttons/z_home",
248 "QPE/Launcher", "home()", 248 "QPE/Launcher", "home()",
249 "buttonsettings", "raise()" }, 249 "buttonsettings", "raise()" },
250 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 250 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
251 "devicebuttons/z_menu", 251 "devicebuttons/z_menu",
252 "QPE/TaskBar", "toggleMenu()", 252 "QPE/TaskBar", "toggleMenu()",
253 "QPE/TaskBar", "toggleStartMenu()" }, 253 "QPE/TaskBar", "toggleStartMenu()" },
254 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 254 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
255 "", 255 "",
256 "QPE/Rotation", "flip()", 256 "QPE/Rotation", "flip()",
257 "QPE/Rotation", "flip()" }, 257 "QPE/Rotation", "flip()" },
258}; 258};
259 259
260struct s_button { 260struct s_button {
261 uint model; 261 uint model;
262 Qt::Key code; 262 Qt::Key code;
263 char *utext; 263 char *utext;
264 char *pix; 264 char *pix;
265 char *fpressedservice; 265 char *fpressedservice;
266 char *fpressedaction; 266 char *fpressedaction;
267 char *fheldservice; 267 char *fheldservice;
268 char *fheldaction; 268 char *fheldaction;
269} simpad_buttons [] = { 269} simpad_buttons [] = {
270 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 270 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
271 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 271 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
272 "devicebuttons/simpad_menu", 272 "devicebuttons/simpad_lower_up",
273 "QPE/TaskBar", "toggleMenu()", 273 "datebook", "nextView()",
274 "QPE/TaskBar", "toggleStartMenu()" }, 274 "today", "raise()" },
275 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 275 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
276 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 276 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
277 "devicebuttons/ipaq_home", 277 "devicebuttons/simpad_lower_down",
278 "QPE/Launcher", "home()", 278 "addressbook", "raise()",
279 "buttonsettings", "raise()" }, 279 "addressbook", "beamBusinessCard()" },
280 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
281 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
282 "devicebuttons/simpad_lower_right",
283 "QPE/TaskBar", "toggleMenu()",
284 "QPE/TaskBar", "toggleStartMenu()" },
285 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
286 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
287 "devicebuttons/simpad_lower_upper",
288 "QPE/Launcher", "home()",
289 "buttonsettings", "raise()" },
290 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
291 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
292 "devicebuttons/simpad_lower_left",
293 "mail", "raise()",
294 "mail", "newMail()" },
295
296 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
297 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
298 "devicebuttons/simpad_upper_up",
299 "datebook", "nextView()",
300 "today", "raise()" },
301 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
302 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
303 "devicebuttons/simpad_upper_down",
304 "addressbook", "raise()",
305 "addressbook", "beamBusinessCard()" },
306 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
307 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
308 "devicebuttons/simpad_upper_right",
309 "QPE/TaskBar", "toggleMenu()",
310 "QPE/TaskBar", "toggleStartMenu()" },
311 /*{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
312 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
313 "devicebuttons/simpad_lower_upper",
314 "QPE/Launcher", "home()",
315 "buttonsettings", "raise()" },*/
316 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
317 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
318 "devicebuttons/simpad_upper_left",
319 "mail", "raise()",
320 "mail", "newMail()" },
280}; 321};
281 322
282static QCString makeChannel ( const char *str ) 323static QCString makeChannel ( const char *str )
283{ 324{
284 if ( str && !::strchr ( str, '/' )) 325 if ( str && !::strchr ( str, '/' ))
285 return QCString ( "QPE/Application/" ) + str; 326 return QCString ( "QPE/Application/" ) + str;
286 else 327 else
287 return str; 328 return str;
288} 329}
289 330
290static inline bool isQWS() 331static inline bool isQWS()
291{ 332{
292 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 333 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
293} 334}
294 335
295ODevice *ODevice::inst ( ) 336ODevice *ODevice::inst ( )
296{ 337{
297 static ODevice *dev = 0; 338 static ODevice *dev = 0;
298 339
299 if ( !dev ) { 340 if ( !dev ) {
300 if ( QFile::exists ( "/proc/hal/model" )) 341 if ( QFile::exists ( "/proc/hal/model" ))
301 dev = new iPAQ ( ); 342 dev = new iPAQ ( );
302 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 343 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
303 dev = new Zaurus ( ); 344 dev = new Zaurus ( );
304 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) 345 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" ))
305 dev = new SIMpad ( ); 346 dev = new SIMpad ( );
306 else 347 else
307 dev = new ODevice ( ); 348 dev = new ODevice ( );
308 349
309 dev-> init ( ); 350 dev-> init ( );
310 } 351 }
311 return dev; 352 return dev;
312} 353}
313 354
314 355
315/************************************************** 356/**************************************************
316 * 357 *
317 * common 358 * common
318 * 359 *
319 **************************************************/ 360 **************************************************/
320 361
321 362
322ODevice::ODevice ( ) 363ODevice::ODevice ( )
323{ 364{
324 d = new ODeviceData; 365 d = new ODeviceData;
325 366
326 d-> m_modelstr = "Unknown"; 367 d-> m_modelstr = "Unknown";
327 d-> m_model = Model_Unknown; 368 d-> m_model = Model_Unknown;
328 d-> m_vendorstr = "Unknown"; 369 d-> m_vendorstr = "Unknown";
329 d-> m_vendor = Vendor_Unknown; 370 d-> m_vendor = Vendor_Unknown;
330 d-> m_systemstr = "Unknown"; 371 d-> m_systemstr = "Unknown";
331 d-> m_system = System_Unknown; 372 d-> m_system = System_Unknown;
332 d-> m_sysverstr = "0.0"; 373 d-> m_sysverstr = "0.0";
333 d-> m_rotation = Rot0; 374 d-> m_rotation = Rot0;
334 d-> m_direction = CW; 375 d-> m_direction = CW;
335 376
336 d-> m_holdtime = 1000; // 1000ms 377 d-> m_holdtime = 1000; // 1000ms
337 d-> m_buttons = 0; 378 d-> m_buttons = 0;
338} 379}
339 380
340void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 381void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
341{ 382{
342 if ( msg == "deviceButtonMappingChanged()" ) { 383 if ( msg == "deviceButtonMappingChanged()" ) {
343 reloadButtonMapping ( ); 384 reloadButtonMapping ( );
344 } 385 }
345} 386}
346 387
347void ODevice::init ( ) 388void ODevice::init ( )
348{ 389{
349} 390}
350 391
351/** 392/**
352 * This method initialises the button mapping 393 * This method initialises the button mapping
353 */ 394 */
354void ODevice::initButtons ( ) 395void ODevice::initButtons ( )
355{ 396{
356 if ( d-> m_buttons ) 397 if ( d-> m_buttons )
357 return; 398 return;
358 399
359 // Simulation uses iPAQ 3660 device buttons 400 // Simulation uses iPAQ 3660 device buttons
360 401
361 qDebug ( "init Buttons" ); 402 qDebug ( "init Buttons" );
362 d-> m_buttons = new QValueList <ODeviceButton>; 403 d-> m_buttons = new QValueList <ODeviceButton>;
363 404
364 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 405 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
365 i_button *ib = ipaq_buttons + i; 406 i_button *ib = ipaq_buttons + i;
366 ODeviceButton b; 407 ODeviceButton b;
367 408
368 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 409 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
369 b. setKeycode ( ib-> code ); 410 b. setKeycode ( ib-> code );
370 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 411 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
371 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 412 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
372 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 413 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
373 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 414 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
374 d-> m_buttons-> append ( b ); 415 d-> m_buttons-> append ( b );
375 } 416 }