summaryrefslogtreecommitdiff
path: root/libopie2
authorzecke <zecke>2004-09-06 10:57:48 (UTC)
committer zecke <zecke>2004-09-06 10:57:48 (UTC)
commit8bf99aaa1b31e770b21b7bf50407a650a8f5d646 (patch) (unidiff)
tree4aadf040fb94085f54080c2b2b112ab5ff236b24 /libopie2
parent97a40bb7f35a8323dd99712bf014387add283177 (diff)
downloadopie-8bf99aaa1b31e770b21b7bf50407a650a8f5d646.zip
opie-8bf99aaa1b31e770b21b7bf50407a650a8f5d646.tar.gz
opie-8bf99aaa1b31e770b21b7bf50407a650a8f5d646.tar.bz2
GCC 2.95 compile fix for switch/case statement
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 127fee9..64fa199 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -1,651 +1,654 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
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; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
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_zaurus.h" 30#include "odevice_zaurus.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie::Core; 56using namespace Opie::Core;
57using namespace Opie::Core::Internal; 57using namespace Opie::Core::Internal;
58 58
59struct z_button z_buttons [] = { 59struct z_button z_buttons [] = {
60 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 60 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
61 "devicebuttons/z_calendar", 61 "devicebuttons/z_calendar",
62 "datebook", "nextView()", 62 "datebook", "nextView()",
63 "today", "raise()" }, 63 "today", "raise()" },
64 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 64 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
65 "devicebuttons/z_contact", 65 "devicebuttons/z_contact",
66 "addressbook", "raise()", 66 "addressbook", "raise()",
67 "addressbook", "beamBusinessCard()" }, 67 "addressbook", "beamBusinessCard()" },
68 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 68 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
69 "devicebuttons/z_home", 69 "devicebuttons/z_home",
70 "QPE/Launcher", "home()", 70 "QPE/Launcher", "home()",
71 "buttonsettings", "raise()" }, 71 "buttonsettings", "raise()" },
72 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 72 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
73 "devicebuttons/z_menu", 73 "devicebuttons/z_menu",
74 "QPE/TaskBar", "toggleMenu()", 74 "QPE/TaskBar", "toggleMenu()",
75 "QPE/TaskBar", "toggleStartMenu()" }, 75 "QPE/TaskBar", "toggleStartMenu()" },
76 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 76 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
77 "devicebuttons/z_mail", 77 "devicebuttons/z_mail",
78 "opiemail", "raise()", 78 "opiemail", "raise()",
79 "opiemail", "newMail()" }, 79 "opiemail", "newMail()" },
80}; 80};
81 81
82struct z_button z_buttons_c700 [] = { 82struct z_button z_buttons_c700 [] = {
83 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 83 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
84 "devicebuttons/z_calendar", 84 "devicebuttons/z_calendar",
85 "datebook", "nextView()", 85 "datebook", "nextView()",
86 "today", "raise()" }, 86 "today", "raise()" },
87 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 87 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
88 "devicebuttons/z_contact", 88 "devicebuttons/z_contact",
89 "addressbook", "raise()", 89 "addressbook", "raise()",
90 "addressbook", "beamBusinessCard()" }, 90 "addressbook", "beamBusinessCard()" },
91 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 91 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
92 "devicebuttons/z_home", 92 "devicebuttons/z_home",
93 "QPE/Launcher", "home()", 93 "QPE/Launcher", "home()",
94 "buttonsettings", "raise()" }, 94 "buttonsettings", "raise()" },
95 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 95 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
96 "devicebuttons/z_menu", 96 "devicebuttons/z_menu",
97 "QPE/TaskBar", "toggleMenu()", 97 "QPE/TaskBar", "toggleMenu()",
98 "QPE/TaskBar", "toggleStartMenu()" }, 98 "QPE/TaskBar", "toggleStartMenu()" },
99 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 99 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
100 "devicebuttons/z_hinge", 100 "devicebuttons/z_hinge",
101 "QPE/Rotation", "rotateDefault()", 101 "QPE/Rotation", "rotateDefault()",
102 "QPE/Dummy", "doNothing()" }, 102 "QPE/Dummy", "doNothing()" },
103}; 103};
104 104
105// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 105// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
106// class up into individual classes. We need three classes 106// class up into individual classes. We need three classes
107// 107//
108// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 108// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
109// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 109// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
110// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) 110// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860)
111// 111//
112// Only question right now is: Do we really need to do it? Because as soon 112// Only question right now is: Do we really need to do it? Because as soon
113// as the OpenZaurus kernel is ready, there will be a unified interface for all 113// as the OpenZaurus kernel is ready, there will be a unified interface for all
114// Zaurus models (concerning apm, backlight, buttons, etc.) 114// Zaurus models (concerning apm, backlight, buttons, etc.)
115// 115//
116// Comments? - mickeyl. 116// Comments? - mickeyl.
117 117
118void Zaurus::init(const QString& cpu_info) 118void Zaurus::init(const QString& cpu_info)
119{ 119{
120 // generic distribution code already scanned /etc/issue at that point - 120 // generic distribution code already scanned /etc/issue at that point -
121 // embedix releases contain "Embedix <version> | Linux for Embedded Devices" 121 // embedix releases contain "Embedix <version> | Linux for Embedded Devices"
122 if ( d->m_sysverstr.contains( "embedix", false ) ) 122 if ( d->m_sysverstr.contains( "embedix", false ) )
123 { 123 {
124 d->m_vendorstr = "Sharp"; 124 d->m_vendorstr = "Sharp";
125 d->m_vendor = Vendor_Sharp; 125 d->m_vendor = Vendor_Sharp;
126 d->m_systemstr = "Zaurus"; 126 d->m_systemstr = "Zaurus";
127 d->m_system = System_Zaurus; 127 d->m_system = System_Zaurus;
128 m_embedix = true; 128 m_embedix = true;
129 } 129 }
130 else 130 else
131 { 131 {
132 d->m_vendorstr = "OpenZaurus Team"; 132 d->m_vendorstr = "OpenZaurus Team";
133 d->m_systemstr = "OpenZaurus"; 133 d->m_systemstr = "OpenZaurus";
134 d->m_system = System_OpenZaurus; 134 d->m_system = System_OpenZaurus;
135 // sysver already gathered 135 // sysver already gathered
136 136
137 // Openzaurus sometimes uses the embedix kernel, check if this is one 137 // Openzaurus sometimes uses the embedix kernel, check if this is one
138 FILE *uname = popen("uname -r", "r"); 138 FILE *uname = popen("uname -r", "r");
139 QFile f; 139 QFile f;
140 QString line; 140 QString line;
141 if ( f.open(IO_ReadOnly, uname) ) { 141 if ( f.open(IO_ReadOnly, uname) ) {
142 QTextStream ts ( &f ); 142 QTextStream ts ( &f );
143 line = ts. readLine(); 143 line = ts. readLine();
144 int loc = line. find ( "embedix" ); 144 int loc = line. find ( "embedix" );
145 if ( loc != -1 ) 145 if ( loc != -1 )
146 m_embedix = true; 146 m_embedix = true;
147 else 147 else
148 m_embedix = false; 148 m_embedix = false;
149 f.close(); 149 f.close();
150 } 150 }
151 pclose(uname); 151 pclose(uname);
152 } 152 }
153 153
154 // check the Zaurus model 154 // check the Zaurus model
155 QString model; 155 QString model;
156 int loc = cpu_info.find( ":" ); 156 int loc = cpu_info.find( ":" );
157 if ( loc != -1 ) 157 if ( loc != -1 )
158 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); 158 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
159 else 159 else
160 model = cpu_info; 160 model = cpu_info;
161 161
162 if ( model == "SHARP Corgi" ) { 162 if ( model == "SHARP Corgi" ) {
163 d->m_model = Model_Zaurus_SLC7x0; 163 d->m_model = Model_Zaurus_SLC7x0;
164 d->m_modelstr = "Zaurus SL-C700"; 164 d->m_modelstr = "Zaurus SL-C700";
165 } else if ( model == "SHARP Shepherd" ) { 165 } else if ( model == "SHARP Shepherd" ) {
166 d->m_model = Model_Zaurus_SLC7x0; 166 d->m_model = Model_Zaurus_SLC7x0;
167 d->m_modelstr = "Zaurus SL-C750"; 167 d->m_modelstr = "Zaurus SL-C750";
168 } else if ( model == "SHARP Husky" ) { 168 } else if ( model == "SHARP Husky" ) {
169 d->m_model = Model_Zaurus_SLC7x0; 169 d->m_model = Model_Zaurus_SLC7x0;
170 d->m_modelstr = "Zaurus SL-C760"; 170 d->m_modelstr = "Zaurus SL-C760";
171 } else if ( model == "SHARP Poodle" ) { 171 } else if ( model == "SHARP Poodle" ) {
172 d->m_model = Model_Zaurus_SLB600; 172 d->m_model = Model_Zaurus_SLB600;
173 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 173 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
174 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 174 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
175 d->m_model = Model_Zaurus_SL5500; 175 d->m_model = Model_Zaurus_SL5500;
176 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 176 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
177 } else if ( model == "SHARP Tosa" ) { 177 } else if ( model == "SHARP Tosa" ) {
178 d->m_model = Model_Zaurus_SL6000; 178 d->m_model = Model_Zaurus_SL6000;
179 d->m_modelstr = "Zaurus SL-6000"; 179 d->m_modelstr = "Zaurus SL-6000";
180 } else { 180 } else {
181 d->m_model = Model_Zaurus_SL5500; 181 d->m_model = Model_Zaurus_SL5500;
182 d->m_modelstr = "Unkown Zaurus"; 182 d->m_modelstr = "Unkown Zaurus";
183 } 183 }
184 184
185 // set initial rotation 185 // set initial rotation
186 switch ( d->m_model ) { 186 switch ( d->m_model ) {
187 case Model_Zaurus_SL6000: 187 case Model_Zaurus_SL6000:
188 case Model_Zaurus_SLA300: 188 case Model_Zaurus_SLA300:
189 d->m_rotation = Rot0; 189 d->m_rotation = Rot0;
190 break; 190 break;
191 case Model_Zaurus_SLC7x0: 191 case Model_Zaurus_SLC7x0:
192 d->m_rotation = rotation(); 192 d->m_rotation = rotation();
193 d->m_direction = direction(); 193 d->m_direction = direction();
194 break; 194 break;
195 case Model_Zaurus_SLB600: 195 case Model_Zaurus_SLB600:
196 case Model_Zaurus_SL5500: 196 case Model_Zaurus_SL5500:
197 case Model_Zaurus_SL5000: 197 case Model_Zaurus_SL5000:
198 default: 198 default:
199 d->m_rotation = Rot270; 199 d->m_rotation = Rot270;
200 break; 200 break;
201 } 201 }
202 m_leds [0] = Led_Off; 202 m_leds [0] = Led_Off;
203} 203}
204 204
205void Zaurus::initButtons() 205void Zaurus::initButtons()
206{ 206{
207 if ( d->m_buttons ) 207 if ( d->m_buttons )
208 return; 208 return;
209 209
210 d->m_buttons = new QValueList <ODeviceButton>; 210 d->m_buttons = new QValueList <ODeviceButton>;
211 211
212 struct z_button * pz_buttons; 212 struct z_button * pz_buttons;
213 int buttoncount; 213 int buttoncount;
214 switch ( d->m_model ) { 214 switch ( d->m_model ) {
215 case Model_Zaurus_SLC7x0: 215 case Model_Zaurus_SLC7x0:
216 pz_buttons = z_buttons_c700; 216 pz_buttons = z_buttons_c700;
217 buttoncount = ARRAY_SIZE(z_buttons_c700); 217 buttoncount = ARRAY_SIZE(z_buttons_c700);
218 break; 218 break;
219 default: 219 default:
220 pz_buttons = z_buttons; 220 pz_buttons = z_buttons;
221 buttoncount = ARRAY_SIZE(z_buttons); 221 buttoncount = ARRAY_SIZE(z_buttons);
222 break; 222 break;
223 } 223 }
224 224
225 for ( int i = 0; i < buttoncount; i++ ) { 225 for ( int i = 0; i < buttoncount; i++ ) {
226 struct z_button *zb = pz_buttons + i; 226 struct z_button *zb = pz_buttons + i;
227 ODeviceButton b; 227 ODeviceButton b;
228 228
229 b. setKeycode ( zb->code ); 229 b. setKeycode ( zb->code );
230 b. setUserText ( QObject::tr ( "Button", zb->utext )); 230 b. setUserText ( QObject::tr ( "Button", zb->utext ));
231 b. setPixmap ( Resource::loadPixmap ( zb->pix )); 231 b. setPixmap ( Resource::loadPixmap ( zb->pix ));
232 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ), 232 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ),
233 zb->fpressedaction )); 233 zb->fpressedaction ));
234 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ), 234 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ),
235 zb->fheldaction )); 235 zb->fheldaction ));
236 236
237 d->m_buttons->append ( b ); 237 d->m_buttons->append ( b );
238 } 238 }
239 239
240 reloadButtonMapping(); 240 reloadButtonMapping();
241 241
242 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 242 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
243 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), 243 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)),
244 this, SLOT( systemMessage(const QCString&,const QByteArray&))); 244 this, SLOT( systemMessage(const QCString&,const QByteArray&)));
245} 245}
246 246
247#include <unistd.h> 247#include <unistd.h>
248#include <fcntl.h> 248#include <fcntl.h>
249#include <sys/ioctl.h> 249#include <sys/ioctl.h>
250 250
251//#include <asm/sharp_char.h> // including kernel headers is evil ... 251//#include <asm/sharp_char.h> // including kernel headers is evil ...
252 252
253#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 253#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
254 254
255 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 255 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
256#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 256#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
257 257
258#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 258#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
259#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 259#define SHARP_BUZ_KEYSOUND 2 /* key sound */
260#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 260#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
261 261
262/* --- for SHARP_BUZZER device --- */ 262/* --- for SHARP_BUZZER device --- */
263 263
264 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 264 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
265//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 265//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
266 266
267#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 267#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
268#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 268#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
269#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 269#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
270#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 270#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
271#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 271#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
272 272
273//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 273//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
274//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 274//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
275 275
276//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 276//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
277//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 277//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
278//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 278//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
279//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 279//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
280//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 280//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
281//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 281//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
282//#define SHARP_PDA_APPSTART 9 /* application start */ 282//#define SHARP_PDA_APPSTART 9 /* application start */
283//#define SHARP_PDA_APPQUIT 10 /* application ends */ 283//#define SHARP_PDA_APPQUIT 10 /* application ends */
284 284
285//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 285//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
286//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 286//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
287//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 287//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
288//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 288//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
289// 289//
290 290
291 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 291 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
292#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 292#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
293 293
294#define SHARP_IOCTL_GET_ROTATION 0x413c 294#define SHARP_IOCTL_GET_ROTATION 0x413c
295 295
296typedef struct sharp_led_status { 296typedef struct sharp_led_status {
297int which; /* select which LED status is wanted. */ 297int which; /* select which LED status is wanted. */
298int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 298int status; /* set new led status if you call SHARP_LED_SETSTATUS */
299} sharp_led_status; 299} sharp_led_status;
300 300
301#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 301#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
302 302
303#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 303#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
304#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 304#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
305#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 305#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
306 306
307// #include <asm/sharp_apm.h> // including kernel headers is evil ... 307// #include <asm/sharp_apm.h> // including kernel headers is evil ...
308 308
309#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 309#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
310#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 310#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
311#define APM_EVT_POWER_BUTTON (1 << 0) 311#define APM_EVT_POWER_BUTTON (1 << 0)
312 312
313#define FL_IOCTL_STEP_CONTRAST 100 313#define FL_IOCTL_STEP_CONTRAST 100
314 314
315 315
316void Zaurus::buzzer ( int sound ) 316void Zaurus::buzzer ( int sound )
317{ 317{
318#ifndef QT_NO_SOUND 318#ifndef QT_NO_SOUND
319 Sound *snd = 0; 319 Sound *snd = 0;
320 320
321 // Not all devices have real sound 321 // Not all devices have real sound
322 if ( d->m_model == Model_Zaurus_SLC7x0 322 if ( d->m_model == Model_Zaurus_SLC7x0
323 || d->m_model == Model_Zaurus_SLB600 ){ 323 || d->m_model == Model_Zaurus_SLB600 ){
324 324
325 switch ( sound ){ 325 switch ( sound ){
326 case SHARP_BUZ_TOUCHSOUND: 326 case SHARP_BUZ_TOUCHSOUND: {
327 static Sound touch_sound("touchsound"); 327 static Sound touch_sound("touchsound");
328 snd = &touch_sound; 328 snd = &touch_sound;
329 }
329 break; 330 break;
330 case SHARP_BUZ_KEYSOUND: 331 case SHARP_BUZ_KEYSOUND: {
331 static Sound key_sound( "keysound" ); 332 static Sound key_sound( "keysound" );
332 snd = &key_sound; 333 snd = &key_sound;
334 }
333 break; 335 break;
334 case SHARP_BUZ_SCHEDULE_ALARM: 336 case SHARP_BUZ_SCHEDULE_ALARM:
335 default: 337 default: {
336 static Sound alarm_sound("alarm"); 338 static Sound alarm_sound("alarm");
337 snd = &alarm_sound; 339 snd = &alarm_sound;
340 }
338 break; 341 break;
339 } 342 }
340 } 343 }
341 344
342 // If a soundname is defined, we expect that this device has 345 // If a soundname is defined, we expect that this device has
343 // sound capabilities.. Otherwise we expect to have the buzzer 346 // sound capabilities.. Otherwise we expect to have the buzzer
344 // device.. 347 // device..
345 if ( snd ){ 348 if ( snd ){
346 changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); 349 changeMixerForAlarm( 0, "/dev/sound/mixer", snd );
347 snd-> play(); 350 snd-> play();
348 } else { 351 } else {
349 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 352 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
350 353
351 if ( fd >= 0 ) { 354 if ( fd >= 0 ) {
352 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 355 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
353 ::close ( fd ); 356 ::close ( fd );
354 } 357 }
355 358
356 } 359 }
357#endif 360#endif
358} 361}
359 362
360 363
361void Zaurus::playAlarmSound() 364void Zaurus::playAlarmSound()
362{ 365{
363 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 366 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
364} 367}
365 368
366void Zaurus::playTouchSound() 369void Zaurus::playTouchSound()
367{ 370{
368 buzzer ( SHARP_BUZ_TOUCHSOUND ); 371 buzzer ( SHARP_BUZ_TOUCHSOUND );
369} 372}
370 373
371void Zaurus::playKeySound() 374void Zaurus::playKeySound()
372{ 375{
373 buzzer ( SHARP_BUZ_KEYSOUND ); 376 buzzer ( SHARP_BUZ_KEYSOUND );
374} 377}
375 378
376 379
377QValueList <OLed> Zaurus::ledList() const 380QValueList <OLed> Zaurus::ledList() const
378{ 381{
379 QValueList <OLed> vl; 382 QValueList <OLed> vl;
380 vl << Led_Mail; 383 vl << Led_Mail;
381 return vl; 384 return vl;
382} 385}
383 386
384QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 387QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
385{ 388{
386 QValueList <OLedState> vl; 389 QValueList <OLedState> vl;
387 390
388 if ( l == Led_Mail ) 391 if ( l == Led_Mail )
389 vl << Led_Off << Led_On << Led_BlinkSlow; 392 vl << Led_Off << Led_On << Led_BlinkSlow;
390 return vl; 393 return vl;
391} 394}
392 395
393OLedState Zaurus::ledState ( OLed which ) const 396OLedState Zaurus::ledState ( OLed which ) const
394{ 397{
395 if ( which == Led_Mail ) 398 if ( which == Led_Mail )
396 return m_leds [0]; 399 return m_leds [0];
397 else 400 else
398 return Led_Off; 401 return Led_Off;
399} 402}
400 403
401bool Zaurus::setLedState ( OLed which, OLedState st ) 404bool Zaurus::setLedState ( OLed which, OLedState st )
402{ 405{
403 if (!m_embedix) // Currently not supported on non_embedix kernels 406 if (!m_embedix) // Currently not supported on non_embedix kernels
404 return false; 407 return false;
405 408
406 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 409 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
407 410
408 if ( which == Led_Mail ) { 411 if ( which == Led_Mail ) {
409 if ( fd >= 0 ) { 412 if ( fd >= 0 ) {
410 struct sharp_led_status leds; 413 struct sharp_led_status leds;
411 ::memset ( &leds, 0, sizeof( leds )); 414 ::memset ( &leds, 0, sizeof( leds ));
412 leds. which = SHARP_LED_MAIL_EXISTS; 415 leds. which = SHARP_LED_MAIL_EXISTS;
413 bool ok = true; 416 bool ok = true;
414 417
415 switch ( st ) { 418 switch ( st ) {
416 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 419 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
417 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 420 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
418 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 421 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
419 default : ok = false; 422 default : ok = false;
420 } 423 }
421 424
422 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 425 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
423 m_leds [0] = st; 426 m_leds [0] = st;
424 return true; 427 return true;
425 } 428 }
426 } 429 }
427 } 430 }
428 return false; 431 return false;
429} 432}
430 433
431bool Zaurus::setSoftSuspend ( bool soft ) 434bool Zaurus::setSoftSuspend ( bool soft )
432{ 435{
433 if (!m_embedix) { 436 if (!m_embedix) {
434 /* non-Embedix kernels dont have kernel autosuspend */ 437 /* non-Embedix kernels dont have kernel autosuspend */
435 return ODevice::setSoftSuspend( soft ); 438 return ODevice::setSoftSuspend( soft );
436 } 439 }
437 440
438 bool res = false; 441 bool res = false;
439 int fd; 442 int fd;
440 443
441 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 444 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
442 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 445 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
443 446
444 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 447 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
445 448
446 if ( sources >= 0 ) { 449 if ( sources >= 0 ) {
447 if ( soft ) 450 if ( soft )
448 sources &= ~APM_EVT_POWER_BUTTON; 451 sources &= ~APM_EVT_POWER_BUTTON;
449 else 452 else
450 sources |= APM_EVT_POWER_BUTTON; 453 sources |= APM_EVT_POWER_BUTTON;
451 454
452 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 455 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
453 res = true; 456 res = true;
454 else 457 else
455 perror ( "APM_IOCGEVTSRC" ); 458 perror ( "APM_IOCGEVTSRC" );
456 } 459 }
457 else 460 else
458 perror ( "APM_IOCGEVTSRC" ); 461 perror ( "APM_IOCGEVTSRC" );
459 462
460 ::close ( fd ); 463 ::close ( fd );
461 } 464 }
462 else 465 else
463 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 466 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
464 467
465 return res; 468 return res;
466} 469}
467 470
468 471
469bool Zaurus::setDisplayBrightness ( int bright ) 472bool Zaurus::setDisplayBrightness ( int bright )
470{ 473{
471 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 474 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
472 bool res = false; 475 bool res = false;
473 int fd; 476 int fd;
474 477
475 if ( bright > 255 ) bright = 255; 478 if ( bright > 255 ) bright = 255;
476 if ( bright < 0 ) bright = 0; 479 if ( bright < 0 ) bright = 0;
477 480
478 if ( m_embedix ) 481 if ( m_embedix )
479 { 482 {
480 if ( d->m_model == Model_Zaurus_SLC7x0 ) 483 if ( d->m_model == Model_Zaurus_SLC7x0 )
481 { 484 {
482 //qDebug( "using special treatment for devices with the corgi backlight interface" ); 485 //qDebug( "using special treatment for devices with the corgi backlight interface" );
483 // special treatment for devices with the corgi backlight interface 486 // special treatment for devices with the corgi backlight interface
484 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) 487 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 )
485 { 488 {
486 int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) ); 489 int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) );
487 char writeCommand[100]; 490 char writeCommand[100];
488 const int count = sprintf( writeCommand, "0x%x\n", value ); 491 const int count = sprintf( writeCommand, "0x%x\n", value );
489 res = ( ::write ( fd, writeCommand, count ) != -1 ); 492 res = ( ::write ( fd, writeCommand, count ) != -1 );
490 ::close ( fd ); 493 ::close ( fd );
491 } 494 }
492 return res; 495 return res;
493 } 496 }
494 else 497 else
495 { 498 {
496 // standard treatment for devices with the dumb embedix frontlight interface 499 // standard treatment for devices with the dumb embedix frontlight interface
497 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 500 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
498 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 501 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
499 if ( bright && !bl ) 502 if ( bright && !bl )
500 bl = 1; 503 bl = 1;
501 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 504 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
502 ::close ( fd ); 505 ::close ( fd );
503 } 506 }
504 } 507 }
505 } 508 }
506 else 509 else
507 { 510 {
508 // special treatment for the OpenZaurus unified interface 511 // special treatment for the OpenZaurus unified interface
509 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ 512 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */
510 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { 513 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) {
511 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); 514 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 );
512 ::close ( fd ); 515 ::close ( fd );
513 } 516 }
514 } 517 }
515 return res; 518 return res;
516} 519}
517 520
518bool Zaurus::suspend() 521bool Zaurus::suspend()
519{ 522{
520 qDebug("ODevice::suspend"); 523 qDebug("ODevice::suspend");
521 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 524 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
522 return false; 525 return false;
523 526
524 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 527 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
525 return false; 528 return false;
526 529
527 bool res = false; 530 bool res = false;
528 ODevice::sendSuspendmsg(); 531 ODevice::sendSuspendmsg();
529 532
530 struct timeval tvs, tvn; 533 struct timeval tvs, tvn;
531 ::gettimeofday ( &tvs, 0 ); 534 ::gettimeofday ( &tvs, 0 );
532 535
533 ::sync(); // flush fs caches 536 ::sync(); // flush fs caches
534 res = ( ::system ( "apm --suspend" ) == 0 ); 537 res = ( ::system ( "apm --suspend" ) == 0 );
535 538
536 // This is needed because the iPAQ apm implementation is asynchronous and we 539 // This is needed because the iPAQ apm implementation is asynchronous and we
537 // can not be sure when exactly the device is really suspended 540 // can not be sure when exactly the device is really suspended
538 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 541 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
539 542
540 if ( res ) { 543 if ( res ) {
541 do { // Yes, wait 15 seconds. This APM bug sucks big time. 544 do { // Yes, wait 15 seconds. This APM bug sucks big time.
542 ::usleep ( 200 * 1000 ); 545 ::usleep ( 200 * 1000 );
543 ::gettimeofday ( &tvn, 0 ); 546 ::gettimeofday ( &tvn, 0 );
544 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); 547 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
545 } 548 }
546 549
547 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); 550 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
548 return res; 551 return res;
549} 552}
550 553
551 554
552Transformation Zaurus::rotation() const 555Transformation Zaurus::rotation() const
553{ 556{
554 Transformation rot; 557 Transformation rot;
555 int handle = 0; 558 int handle = 0;
556 int retval = 0; 559 int retval = 0;
557 560
558 switch ( d->m_model ) { 561 switch ( d->m_model ) {
559 case Model_Zaurus_SLC7x0: 562 case Model_Zaurus_SLC7x0:
560 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 563 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
561 if (handle == -1) { 564 if (handle == -1) {
562 return Rot270; 565 return Rot270;
563 } else { 566 } else {
564 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 567 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
565 ::close (handle); 568 ::close (handle);
566 569
567 if (retval == 2 ) 570 if (retval == 2 )
568 rot = Rot0; 571 rot = Rot0;
569 else 572 else
570 rot = Rot270; 573 rot = Rot270;
571 } 574 }
572 break; 575 break;
573 case Model_Zaurus_SLA300: 576 case Model_Zaurus_SLA300:
574 case Model_Zaurus_SLB600: 577 case Model_Zaurus_SLB600:
575 case Model_Zaurus_SL5500: 578 case Model_Zaurus_SL5500:
576 case Model_Zaurus_SL5000: 579 case Model_Zaurus_SL5000:
577 default: 580 default:
578 rot = d->m_rotation; 581 rot = d->m_rotation;
579 break; 582 break;
580 } 583 }
581 584
582 return rot; 585 return rot;
583} 586}
584ODirection Zaurus::direction() const 587ODirection Zaurus::direction() const
585{ 588{
586 ODirection dir; 589 ODirection dir;
587 int handle = 0; 590 int handle = 0;
588 int retval = 0; 591 int retval = 0;
589 switch ( d->m_model ) { 592 switch ( d->m_model ) {
590 case Model_Zaurus_SLC7x0: 593 case Model_Zaurus_SLC7x0:
591 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 594 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
592 if (handle == -1) { 595 if (handle == -1) {
593 dir = CW; 596 dir = CW;
594 } else { 597 } else {
595 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 598 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
596 ::close (handle); 599 ::close (handle);
597 if (retval == 2 ) 600 if (retval == 2 )
598 dir = CCW; 601 dir = CCW;
599 else 602 else
600 dir = CW; 603 dir = CW;
601 } 604 }
602 break; 605 break;
603 case Model_Zaurus_SLA300: 606 case Model_Zaurus_SLA300:
604 case Model_Zaurus_SLB600: 607 case Model_Zaurus_SLB600:
605 case Model_Zaurus_SL5500: 608 case Model_Zaurus_SL5500:
606 case Model_Zaurus_SL5000: 609 case Model_Zaurus_SL5000:
607 default: 610 default:
608 dir = d->m_direction; 611 dir = d->m_direction;
609 break; 612 break;
610 } 613 }
611 return dir; 614 return dir;
612 615
613} 616}
614 617
615int Zaurus::displayBrightnessResolution() const 618int Zaurus::displayBrightnessResolution() const
616{ 619{
617 if (m_embedix) 620 if (m_embedix)
618 return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5; 621 return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5;
619 else 622 else
620 return 256; 623 return 256;
621} 624}
622 625
623bool Zaurus::hasHingeSensor() const 626bool Zaurus::hasHingeSensor() const
624{ 627{
625 return d->m_model == Model_Zaurus_SLC7x0; 628 return d->m_model == Model_Zaurus_SLC7x0;
626} 629}
627 630
628OHingeStatus Zaurus::readHingeSensor() 631OHingeStatus Zaurus::readHingeSensor()
629{ 632{
630 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 633 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
631 if (handle == -1) 634 if (handle == -1)
632 { 635 {
633 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror 636 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
634 return CASE_UNKNOWN; 637 return CASE_UNKNOWN;
635 } 638 }
636 else 639 else
637 { 640 {
638 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 641 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
639 ::close (handle); 642 ::close (handle);
640 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) 643 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
641 { 644 {
642 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 645 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
643 return static_cast<OHingeStatus>( retval ); 646 return static_cast<OHingeStatus>( retval );
644 } 647 }
645 else 648 else
646 { 649 {
647 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 650 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
648 return CASE_UNKNOWN; 651 return CASE_UNKNOWN;
649 } 652 }
650 } 653 }
651} 654}