summaryrefslogtreecommitdiff
authorzecke <zecke>2004-09-21 00:40:38 (UTC)
committer zecke <zecke>2004-09-21 00:40:38 (UTC)
commit97e20b7cc746d5e2822385fc815739853a9c6e2f (patch) (unidiff)
tree8c72e5148518cd7b11be4ccce3d9e9f9c4c541d5
parentee21a12cded5c53f196a5183f39e8069a22ef835 (diff)
downloadopie-97e20b7cc746d5e2822385fc815739853a9c6e2f.zip
opie-97e20b7cc746d5e2822385fc815739853a9c6e2f.tar.gz
opie-97e20b7cc746d5e2822385fc815739853a9c6e2f.tar.bz2
If sound is not yet finished return and do not try to play
it again. if(!snd.isFinished()) return;
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_ramses.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp4
4 files changed, 8 insertions, 2 deletions
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 7f5aa7b..6193ddc 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -1,433 +1,435 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2002,2003,2004 The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) 2002,2003,2004 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_ipaq.h" 30#include "odevice_ipaq.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#include <opie2/okeyfilter.h> 43#include <opie2/okeyfilter.h>
44 44
45/* STD */ 45/* STD */
46#include <fcntl.h> 46#include <fcntl.h>
47#include <math.h> 47#include <math.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <signal.h> 49#include <signal.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/time.h> 51#include <sys/time.h>
52#include <unistd.h> 52#include <unistd.h>
53#ifndef QT_NO_SOUND 53#ifndef QT_NO_SOUND
54#include <linux/soundcard.h> 54#include <linux/soundcard.h>
55#endif 55#endif
56 56
57 57
58using namespace Opie::Core; 58using namespace Opie::Core;
59using namespace Opie::Core::Internal; 59using namespace Opie::Core::Internal;
60 60
61/* KERNEL */ 61/* KERNEL */
62#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 62#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
63 63
64#define OD_IO(type,number) OD_IOC(0,type,number,0) 64#define OD_IO(type,number) OD_IOC(0,type,number,0)
65#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 65#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
66#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 66#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
67#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 67#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
68 68
69typedef struct { 69typedef struct {
70 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 70 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
71 unsigned char TotalTime; /* Units of 5 seconds */ 71 unsigned char TotalTime; /* Units of 5 seconds */
72 unsigned char OnTime; /* units of 100m/s */ 72 unsigned char OnTime; /* units of 100m/s */
73 unsigned char OffTime; /* units of 100m/s */ 73 unsigned char OffTime; /* units of 100m/s */
74} LED_IN; 74} LED_IN;
75 75
76typedef struct { 76typedef struct {
77 unsigned char mode; 77 unsigned char mode;
78 unsigned char pwr; 78 unsigned char pwr;
79 unsigned char brightness; 79 unsigned char brightness;
80} FLITE_IN; 80} FLITE_IN;
81 81
82#define LED_ON OD_IOW( 'f', 5, LED_IN ) 82#define LED_ON OD_IOW( 'f', 5, LED_IN )
83#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 83#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
84 84
85struct i_button ipaq_buttons [] = { 85struct i_button ipaq_buttons [] = {
86 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 86 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
87 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 87 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
88 "devicebuttons/ipaq_calendar", 88 "devicebuttons/ipaq_calendar",
89 "datebook", "nextView()", 89 "datebook", "nextView()",
90 "today", "raise()" }, 90 "today", "raise()" },
91 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 91 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
92 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 92 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
93 "devicebuttons/ipaq_contact", 93 "devicebuttons/ipaq_contact",
94 "addressbook", "raise()", 94 "addressbook", "raise()",
95 "addressbook", "beamBusinessCard()" }, 95 "addressbook", "beamBusinessCard()" },
96 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 96 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
97 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 97 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
98 "devicebuttons/ipaq_menu", 98 "devicebuttons/ipaq_menu",
99 "QPE/TaskBar", "toggleMenu()", 99 "QPE/TaskBar", "toggleMenu()",
100 "QPE/TaskBar", "toggleStartMenu()" }, 100 "QPE/TaskBar", "toggleStartMenu()" },
101 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 101 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
102 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 102 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
103 "devicebuttons/ipaq_mail", 103 "devicebuttons/ipaq_mail",
104 "opiemail", "raise()", 104 "opiemail", "raise()",
105 "opiemail", "newMail()" }, 105 "opiemail", "newMail()" },
106 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 106 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
107 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 107 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
108 "devicebuttons/ipaq_home", 108 "devicebuttons/ipaq_home",
109 "QPE/Launcher", "home()", 109 "QPE/Launcher", "home()",
110 "buttonsettings", "raise()" }, 110 "buttonsettings", "raise()" },
111 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 111 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
112 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 112 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
113 "devicebuttons/ipaq_record", 113 "devicebuttons/ipaq_record",
114 "QPE/VMemo", "toggleRecord()", 114 "QPE/VMemo", "toggleRecord()",
115 "sound", "raise()" }, 115 "sound", "raise()" },
116}; 116};
117 117
118void iPAQ::init(const QString& model) 118void iPAQ::init(const QString& model)
119{ 119{
120 d->m_vendorstr = "HP"; 120 d->m_vendorstr = "HP";
121 d->m_vendor = Vendor_HP; 121 d->m_vendor = Vendor_HP;
122 122
123 d->m_modelstr = model.mid(model.findRev('H')); 123 d->m_modelstr = model.mid(model.findRev('H'));
124 124
125 if ( d->m_modelstr == "H3100" ) 125 if ( d->m_modelstr == "H3100" )
126 d->m_model = Model_iPAQ_H31xx; 126 d->m_model = Model_iPAQ_H31xx;
127 else if ( d->m_modelstr == "H3600" ) 127 else if ( d->m_modelstr == "H3600" )
128 d->m_model = Model_iPAQ_H36xx; 128 d->m_model = Model_iPAQ_H36xx;
129 else if ( d->m_modelstr == "H3700" ) 129 else if ( d->m_modelstr == "H3700" )
130 d->m_model = Model_iPAQ_H37xx; 130 d->m_model = Model_iPAQ_H37xx;
131 else if ( d->m_modelstr == "H3800" ) 131 else if ( d->m_modelstr == "H3800" )
132 d->m_model = Model_iPAQ_H38xx; 132 d->m_model = Model_iPAQ_H38xx;
133 else if ( d->m_modelstr == "H3900" ) 133 else if ( d->m_modelstr == "H3900" )
134 d->m_model = Model_iPAQ_H39xx; 134 d->m_model = Model_iPAQ_H39xx;
135 else if ( d->m_modelstr == "H5400" ) 135 else if ( d->m_modelstr == "H5400" )
136 d->m_model = Model_iPAQ_H5xxx; 136 d->m_model = Model_iPAQ_H5xxx;
137 else if ( d->m_modelstr == "H2200" ) 137 else if ( d->m_modelstr == "H2200" )
138 d->m_model = Model_iPAQ_H22xx; 138 d->m_model = Model_iPAQ_H22xx;
139 else 139 else
140 d->m_model = Model_Unknown; 140 d->m_model = Model_Unknown;
141 141
142 switch ( d->m_model ) { 142 switch ( d->m_model ) {
143 case Model_iPAQ_H31xx: 143 case Model_iPAQ_H31xx:
144 case Model_iPAQ_H38xx: 144 case Model_iPAQ_H38xx:
145 d->m_rotation = Rot90; 145 d->m_rotation = Rot90;
146 break; 146 break;
147 case Model_iPAQ_H5xxx: 147 case Model_iPAQ_H5xxx:
148 case Model_iPAQ_H22xx: 148 case Model_iPAQ_H22xx:
149 d->m_rotation = Rot0; 149 d->m_rotation = Rot0;
150 break; 150 break;
151 case Model_iPAQ_H36xx: 151 case Model_iPAQ_H36xx:
152 case Model_iPAQ_H37xx: 152 case Model_iPAQ_H37xx:
153 case Model_iPAQ_H39xx: 153 case Model_iPAQ_H39xx:
154 default: 154 default:
155 d->m_rotation = Rot270; 155 d->m_rotation = Rot270;
156 break; 156 break;
157 157
158 } 158 }
159 159
160 m_leds [0] = m_leds [1] = Led_Off; 160 m_leds [0] = m_leds [1] = Led_Off;
161 161
162 m_power_timer = 0; 162 m_power_timer = 0;
163 163
164} 164}
165 165
166void iPAQ::initButtons() 166void iPAQ::initButtons()
167{ 167{
168 if ( d->m_buttons ) 168 if ( d->m_buttons )
169 return; 169 return;
170 170
171 if ( isQWS( ) ) { 171 if ( isQWS( ) ) {
172 addPreHandler(this); 172 addPreHandler(this);
173 } 173 }
174 174
175 d->m_buttons = new QValueList <ODeviceButton>; 175 d->m_buttons = new QValueList <ODeviceButton>;
176 176
177 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 177 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
178 i_button *ib = ipaq_buttons + i; 178 i_button *ib = ipaq_buttons + i;
179 ODeviceButton b; 179 ODeviceButton b;
180 180
181 if (( ib->model & d->m_model ) == d->m_model ) { 181 if (( ib->model & d->m_model ) == d->m_model ) {
182 b. setKeycode ( ib->code ); 182 b. setKeycode ( ib->code );
183 b. setUserText ( QObject::tr ( "Button", ib->utext )); 183 b. setUserText ( QObject::tr ( "Button", ib->utext ));
184 b. setPixmap ( Resource::loadPixmap ( ib->pix )); 184 b. setPixmap ( Resource::loadPixmap ( ib->pix ));
185 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); 185 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
186 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); 186 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
187 187
188 d->m_buttons->append ( b ); 188 d->m_buttons->append ( b );
189 } 189 }
190 } 190 }
191 reloadButtonMapping(); 191 reloadButtonMapping();
192 192
193 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 193 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
194 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 194 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
195} 195}
196 196
197QValueList <OLed> iPAQ::ledList() const 197QValueList <OLed> iPAQ::ledList() const
198{ 198{
199 QValueList <OLed> vl; 199 QValueList <OLed> vl;
200 vl << Led_Power; 200 vl << Led_Power;
201 201
202 if ( d->m_model == Model_iPAQ_H38xx ) 202 if ( d->m_model == Model_iPAQ_H38xx )
203 vl << Led_BlueTooth; 203 vl << Led_BlueTooth;
204 return vl; 204 return vl;
205} 205}
206 206
207QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 207QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
208{ 208{
209 QValueList <OLedState> vl; 209 QValueList <OLedState> vl;
210 210
211 if ( l == Led_Power ) 211 if ( l == Led_Power )
212 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 212 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
213 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) 213 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx )
214 vl << Led_Off; // << Led_On << ??? 214 vl << Led_Off; // << Led_On << ???
215 215
216 return vl; 216 return vl;
217} 217}
218 218
219OLedState iPAQ::ledState ( OLed l ) const 219OLedState iPAQ::ledState ( OLed l ) const
220{ 220{
221 switch ( l ) { 221 switch ( l ) {
222 case Led_Power: 222 case Led_Power:
223 return m_leds [0]; 223 return m_leds [0];
224 case Led_BlueTooth: 224 case Led_BlueTooth:
225 return m_leds [1]; 225 return m_leds [1];
226 default: 226 default:
227 return Led_Off; 227 return Led_Off;
228 } 228 }
229} 229}
230 230
231bool iPAQ::setLedState ( OLed l, OLedState st ) 231bool iPAQ::setLedState ( OLed l, OLedState st )
232{ 232{
233 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 233 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
234 234
235 if ( l == Led_Power ) { 235 if ( l == Led_Power ) {
236 if ( fd >= 0 ) { 236 if ( fd >= 0 ) {
237 LED_IN leds; 237 LED_IN leds;
238 ::memset ( &leds, 0, sizeof( leds )); 238 ::memset ( &leds, 0, sizeof( leds ));
239 leds. TotalTime = 0; 239 leds. TotalTime = 0;
240 leds. OnTime = 0; 240 leds. OnTime = 0;
241 leds. OffTime = 1; 241 leds. OffTime = 1;
242 leds. OffOnBlink = 2; 242 leds. OffOnBlink = 2;
243 243
244 switch ( st ) { 244 switch ( st ) {
245 case Led_Off : leds. OffOnBlink = 0; break; 245 case Led_Off : leds. OffOnBlink = 0; break;
246 case Led_On : leds. OffOnBlink = 1; break; 246 case Led_On : leds. OffOnBlink = 1; break;
247 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 247 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
248 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 248 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
249 } 249 }
250 250
251 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 251 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
252 m_leds [0] = st; 252 m_leds [0] = st;
253 return true; 253 return true;
254 } 254 }
255 } 255 }
256 } 256 }
257 return false; 257 return false;
258} 258}
259 259
260 260
261bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 261bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
262{ 262{
263 int newkeycode = keycode; 263 int newkeycode = keycode;
264 264
265 switch ( keycode ) { 265 switch ( keycode ) {
266 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 266 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
267 case HardKey_Menu: { 267 case HardKey_Menu: {
268 if (( d->m_model == Model_iPAQ_H38xx ) || 268 if (( d->m_model == Model_iPAQ_H38xx ) ||
269 ( d->m_model == Model_iPAQ_H39xx ) || 269 ( d->m_model == Model_iPAQ_H39xx ) ||
270 ( d->m_model == Model_iPAQ_H5xxx)) { 270 ( d->m_model == Model_iPAQ_H5xxx)) {
271 newkeycode = HardKey_Mail; 271 newkeycode = HardKey_Mail;
272 } 272 }
273 break; 273 break;
274 } 274 }
275 275
276 // Rotate cursor keys 180 or 270 276 // Rotate cursor keys 180 or 270
277 case Key_Left : 277 case Key_Left :
278 case Key_Right: 278 case Key_Right:
279 case Key_Up : 279 case Key_Up :
280 case Key_Down : { 280 case Key_Down : {
281 if (( d->m_model == Model_iPAQ_H31xx ) || 281 if (( d->m_model == Model_iPAQ_H31xx ) ||
282 ( d->m_model == Model_iPAQ_H38xx )) { 282 ( d->m_model == Model_iPAQ_H38xx )) {
283 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 283 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
284 } 284 }
285 // Rotate the cursor keys by 270 285 // Rotate the cursor keys by 270
286 // keycode - Key_Left = position of the button starting from left clockwise 286 // keycode - Key_Left = position of the button starting from left clockwise
287 // add the rotation to it and modolo. No we've the original offset 287 // add the rotation to it and modolo. No we've the original offset
288 // add the offset to the Key_Left key 288 // add the offset to the Key_Left key
289 if ( d-> m_model == Model_iPAQ_H5xxx ) 289 if ( d-> m_model == Model_iPAQ_H5xxx )
290 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 290 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
291 break; 291 break;
292 } 292 }
293 293
294 // map Power Button short/long press to F34/F35 294 // map Power Button short/long press to F34/F35
295 case Key_SysReq: { 295 case Key_SysReq: {
296 if ( isPress ) { 296 if ( isPress ) {
297 if ( m_power_timer ) 297 if ( m_power_timer )
298 killTimer ( m_power_timer ); 298 killTimer ( m_power_timer );
299 m_power_timer = startTimer ( 500 ); 299 m_power_timer = startTimer ( 500 );
300 } 300 }
301 else if ( m_power_timer ) { 301 else if ( m_power_timer ) {
302 killTimer ( m_power_timer ); 302 killTimer ( m_power_timer );
303 m_power_timer = 0; 303 m_power_timer = 0;
304 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 304 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
305 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 305 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
306 } 306 }
307 newkeycode = Key_unknown; 307 newkeycode = Key_unknown;
308 break; 308 break;
309 } 309 }
310 } 310 }
311 311
312 if ( newkeycode != keycode ) { 312 if ( newkeycode != keycode ) {
313 if ( newkeycode != Key_unknown ) 313 if ( newkeycode != Key_unknown )
314 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 314 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
315 return true; 315 return true;
316 } 316 }
317 else 317 else
318 return false; 318 return false;
319} 319}
320 320
321void iPAQ::timerEvent ( QTimerEvent * ) 321void iPAQ::timerEvent ( QTimerEvent * )
322{ 322{
323 killTimer ( m_power_timer ); 323 killTimer ( m_power_timer );
324 m_power_timer = 0; 324 m_power_timer = 0;
325 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 325 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
326 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 326 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
327} 327}
328 328
329 329
330void iPAQ::playAlarmSound() 330void iPAQ::playAlarmSound()
331{ 331{
332#ifndef QT_NO_SOUND 332#ifndef QT_NO_SOUND
333 static Sound snd ( "alarm" ); 333 static Sound snd ( "alarm" );
334 if(!snd.isFinished())
335 return;
334 336
335 changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); 337 changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
336 snd. play(); 338 snd. play();
337#endif 339#endif
338} 340}
339 341
340 342
341bool iPAQ::setSoftSuspend ( bool soft ) 343bool iPAQ::setSoftSuspend ( bool soft )
342{ 344{
343 bool res = false; 345 bool res = false;
344 int fd; 346 int fd;
345 347
346 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 348 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
347 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 349 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
348 res = true; 350 res = true;
349 else 351 else
350 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 352 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
351 353
352 ::close ( fd ); 354 ::close ( fd );
353 } 355 }
354 else 356 else
355 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 357 ::perror ( "/proc/sys/ts/suspend_button_mode" );
356 358
357 return res; 359 return res;
358} 360}
359 361
360 362
361bool iPAQ::setDisplayBrightness ( int bright ) 363bool iPAQ::setDisplayBrightness ( int bright )
362{ 364{
363 bool res = false; 365 bool res = false;
364 int fd; 366 int fd;
365 367
366 if ( bright > 255 ) 368 if ( bright > 255 )
367 bright = 255; 369 bright = 255;
368 if ( bright < 0 ) 370 if ( bright < 0 )
369 bright = 0; 371 bright = 0;
370 372
371 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 373 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
372 FLITE_IN bl; 374 FLITE_IN bl;
373 bl. mode = 1; 375 bl. mode = 1;
374 bl. pwr = bright ? 1 : 0; 376 bl. pwr = bright ? 1 : 0;
375 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; 377 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
376 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 378 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
377 ::close ( fd ); 379 ::close ( fd );
378 } 380 }
379 return res; 381 return res;
380} 382}
381 383
382int iPAQ::displayBrightnessResolution() const 384int iPAQ::displayBrightnessResolution() const
383{ 385{
384 switch ( model()) { 386 switch ( model()) {
385 case Model_iPAQ_H31xx: 387 case Model_iPAQ_H31xx:
386 case Model_iPAQ_H36xx: 388 case Model_iPAQ_H36xx:
387 case Model_iPAQ_H37xx: 389 case Model_iPAQ_H37xx:
388 return 128; // really 256, but >128 could damage the LCD 390 return 128; // really 256, but >128 could damage the LCD
389 391
390 case Model_iPAQ_H38xx: 392 case Model_iPAQ_H38xx:
391 case Model_iPAQ_H39xx: 393 case Model_iPAQ_H39xx:
392 return 64; 394 return 64;
393 case Model_iPAQ_H5xxx: 395 case Model_iPAQ_H5xxx:
394 return 255; 396 return 255;
395 397
396 default: 398 default:
397 return 2; 399 return 2;
398 } 400 }
399} 401}
400 402
401 403
402bool iPAQ::hasLightSensor() const 404bool iPAQ::hasLightSensor() const
403{ 405{
404 return true; 406 return true;
405} 407}
406 408
407int iPAQ::readLightSensor() 409int iPAQ::readLightSensor()
408{ 410{
409 int fd; 411 int fd;
410 int val = -1; 412 int val = -1;
411 413
412 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 414 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
413 char buffer [8]; 415 char buffer [8];
414 416
415 if ( ::read ( fd, buffer, 5 ) == 5 ) { 417 if ( ::read ( fd, buffer, 5 ) == 5 ) {
416 char *endptr; 418 char *endptr;
417 419
418 buffer [4] = 0; 420 buffer [4] = 0;
419 val = ::strtol ( buffer + 2, &endptr, 16 ); 421 val = ::strtol ( buffer + 2, &endptr, 16 );
420 422
421 if ( *endptr != 0 ) 423 if ( *endptr != 0 )
422 val = -1; 424 val = -1;
423 } 425 }
424 ::close ( fd ); 426 ::close ( fd );
425 } 427 }
426 428
427 return val; 429 return val;
428} 430}
429 431
430int iPAQ::lightSensorResolution() const 432int iPAQ::lightSensorResolution() const
431{ 433{
432 return 256; 434 return 256;
433} 435}
diff --git a/libopie2/opiecore/device/odevice_ramses.cpp b/libopie2/opiecore/device/odevice_ramses.cpp
index 0cddf85..c75ea3a 100644
--- a/libopie2/opiecore/device/odevice_ramses.cpp
+++ b/libopie2/opiecore/device/odevice_ramses.cpp
@@ -1,168 +1,170 @@
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_ramses.h" 30#include "odevice_ramses.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
59 59
60void Ramses::init(const QString&) 60void Ramses::init(const QString&)
61{ 61{
62 d->m_vendorstr = "M und N"; 62 d->m_vendorstr = "M und N";
63 d->m_vendor = Vendor_MundN; 63 d->m_vendor = Vendor_MundN;
64 64
65 // with old Prototype-LCD, /proc/sys/board/lcd_type = 1 65 // with old Prototype-LCD, /proc/sys/board/lcd_type = 1
66 //d->m_modelstr = "Ramses"; 66 //d->m_modelstr = "Ramses";
67 //d->m_model = Model_Ramses_MNCI; 67 //d->m_model = Model_Ramses_MNCI;
68 //d->m_rotation = Rot0; 68 //d->m_rotation = Rot0;
69 69
70 // all current Hardware, with /proc/sys/board/lcd_type = 2 70 // all current Hardware, with /proc/sys/board/lcd_type = 2
71 d->m_modelstr = "MNCIRX"; 71 d->m_modelstr = "MNCIRX";
72 d->m_model = Model_Ramses_MNCIRX; 72 d->m_model = Model_Ramses_MNCIRX;
73 d->m_rotation = Rot90; 73 d->m_rotation = Rot90;
74 74
75 d->m_holdtime = 500; 75 d->m_holdtime = 500;
76 76
77 77
78 // This table is true for a Intel XScale PXA 255 78 // This table is true for a Intel XScale PXA 255
79 79
80#ifdef QT_QWS_ALLOW_OVERCLOCK 80#ifdef QT_QWS_ALLOW_OVERCLOCK
81#define OC(x...) x 81#define OC(x...) x
82#else 82#else
83#define OC(x...) 83#define OC(x...)
84#endif 84#endif
85 85
86 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 86 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50
87 OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem 87 OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem
88 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 88 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99
89 OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem 89 OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem
90 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 90 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99
91 OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem 91 OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem
92 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 92 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99
93 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 93 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196
94 OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus 94 OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus
95} 95}
96 96
97 97
98void Ramses::playAlarmSound() 98void Ramses::playAlarmSound()
99{ 99{
100#ifndef QT_NO_SOUND 100#ifndef QT_NO_SOUND
101 static Sound snd ( "alarm" ); 101 static Sound snd ( "alarm" );
102 if(!snd.isFinished())
103 return;
102 104
103 changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); 105 changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd);
104 snd.play(); 106 snd.play();
105#else 107#else
106#error QT_NO_SOUND defined 108#error QT_NO_SOUND defined
107#endif 109#endif
108} 110}
109 111
110 112
111bool Ramses::suspend() 113bool Ramses::suspend()
112{ 114{
113 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 115 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
114 return false; 116 return false;
115 117
116 sendSuspendmsg(); 118 sendSuspendmsg();
117 ::sync(); 119 ::sync();
118 120
119 int fd; 121 int fd;
120 if ((fd = ::open("/proc/sys/pm/suspend", O_WRONLY)) >= 0) { 122 if ((fd = ::open("/proc/sys/pm/suspend", O_WRONLY)) >= 0) {
121 char writeCommand[] = "1\n"; 123 char writeCommand[] = "1\n";
122 ::write(fd, writeCommand, sizeof(writeCommand) ); 124 ::write(fd, writeCommand, sizeof(writeCommand) );
123 ::close(fd); 125 ::close(fd);
124 } 126 }
125 127
126 ::usleep ( 200 * 1000 ); 128 ::usleep ( 200 * 1000 );
127 return true; 129 return true;
128} 130}
129 131
130 132
131bool Ramses::setDisplayBrightness(int bright) 133bool Ramses::setDisplayBrightness(int bright)
132{ 134{
133 //qDebug("Ramses::setDisplayBrightness(%d)", bright); 135 //qDebug("Ramses::setDisplayBrightness(%d)", bright);
134 bool res = false; 136 bool res = false;
135 int fd; 137 int fd;
136 138
137 // pwm1 brighness: 20 steps 500..0 (dunkel->hell) 139 // pwm1 brighness: 20 steps 500..0 (dunkel->hell)
138 140
139 if (bright > 255 ) 141 if (bright > 255 )
140 bright = 255; 142 bright = 255;
141 if (bright < 0) 143 if (bright < 0)
142 bright = 0; 144 bright = 0;
143 145
144 // Turn backlight completely off if brightness=0 146 // Turn backlight completely off if brightness=0
145 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { 147 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) {
146 char writeCommand[10]; 148 char writeCommand[10];
147 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); 149 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0);
148 res = (::write(fd, writeCommand, count) != -1); 150 res = (::write(fd, writeCommand, count) != -1);
149 ::close(fd); 151 ::close(fd);
150 } 152 }
151 153
152 if ((fd = ::open("/proc/sys/board/lcd_brightness", O_WRONLY)) >= 0) { 154 if ((fd = ::open("/proc/sys/board/lcd_brightness", O_WRONLY)) >= 0) {
153 char writeCommand[10]; 155 char writeCommand[10];
154 const int count = sprintf(writeCommand, "%d\n", bright); 156 const int count = sprintf(writeCommand, "%d\n", bright);
155 res = (::write(fd, writeCommand, count) != -1); 157 res = (::write(fd, writeCommand, count) != -1);
156 ::close(fd); 158 ::close(fd);
157 } 159 }
158 return res; 160 return res;
159} 161}
160 162
161 163
162int Ramses::displayBrightnessResolution() const 164int Ramses::displayBrightnessResolution() const
163{ 165{
164 return 32; 166 return 32;
165} 167}
166 168
167 169
168// TODO: add displayContrast for old MNCI 170// TODO: add displayContrast for old MNCI
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index fd46b95..34876da 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -1,398 +1,400 @@
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_simpad.h" 30#include "odevice_simpad.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#include <opie2/okeyfilter.h> 43#include <opie2/okeyfilter.h>
44 44
45/* STD */ 45/* STD */
46#include <fcntl.h> 46#include <fcntl.h>
47#include <math.h> 47#include <math.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <signal.h> 49#include <signal.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/time.h> 51#include <sys/time.h>
52#include <unistd.h> 52#include <unistd.h>
53#ifndef QT_NO_SOUND 53#ifndef QT_NO_SOUND
54#include <linux/soundcard.h> 54#include <linux/soundcard.h>
55#endif 55#endif
56 56
57using namespace Opie::Core; 57using namespace Opie::Core;
58using namespace Opie::Core::Internal; 58using namespace Opie::Core::Internal;
59 59
60struct s_button simpad_buttons [] = { 60struct s_button simpad_buttons [] = {
61 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 61 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
62 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 62 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
63 "devicebuttons/simpad_lower_up", 63 "devicebuttons/simpad_lower_up",
64 "datebook", "nextView()", 64 "datebook", "nextView()",
65 "today", "raise()" }, 65 "today", "raise()" },
66 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 66 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
67 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 67 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
68 "devicebuttons/simpad_lower_down", 68 "devicebuttons/simpad_lower_down",
69 "addressbook", "raise()", 69 "addressbook", "raise()",
70 "addressbook", "beamBusinessCard()" }, 70 "addressbook", "beamBusinessCard()" },
71 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 71 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
72 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 72 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
73 "devicebuttons/simpad_lower_right", 73 "devicebuttons/simpad_lower_right",
74 "QPE/TaskBar", "toggleMenu()", 74 "QPE/TaskBar", "toggleMenu()",
75 "QPE/TaskBar", "toggleStartMenu()" }, 75 "QPE/TaskBar", "toggleStartMenu()" },
76 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 76 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
77 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 77 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
78 "devicebuttons/simpad_lower_left", 78 "devicebuttons/simpad_lower_left",
79 "opiemail", "raise()", 79 "opiemail", "raise()",
80 "opiemail", "newMail()" }, 80 "opiemail", "newMail()" },
81 81
82 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 82 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
83 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 83 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
84 "devicebuttons/simpad_upper_up", 84 "devicebuttons/simpad_upper_up",
85 "QPE/Launcher", "home()", 85 "QPE/Launcher", "home()",
86 "buttonsettings", "raise()" }, 86 "buttonsettings", "raise()" },
87 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 87 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
88 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 88 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
89 "devicebuttons/simpad_upper_down", 89 "devicebuttons/simpad_upper_down",
90 "addressbook", "raise()", 90 "addressbook", "raise()",
91 "addressbook", "beamBusinessCard()" }, 91 "addressbook", "beamBusinessCard()" },
92 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 92 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
93 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 93 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
94 "devicebuttons/simpad_upper_right", 94 "devicebuttons/simpad_upper_right",
95 "QPE/TaskBar", "toggleMenu()", 95 "QPE/TaskBar", "toggleMenu()",
96 "QPE/TaskBar", "toggleStartMenu()" }, 96 "QPE/TaskBar", "toggleStartMenu()" },
97 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 97 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
98 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 98 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
99 "devicebuttons/simpad_upper_left", 99 "devicebuttons/simpad_upper_left",
100 "QPE/Rotation", "flip()", 100 "QPE/Rotation", "flip()",
101 "QPE/Rotation", "flip()" }, 101 "QPE/Rotation", "flip()" },
102 /* 102 /*
103 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 103 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
104 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 104 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
105 "devicebuttons/simpad_lower_upper", 105 "devicebuttons/simpad_lower_upper",
106 "QPE/Launcher", "home()", 106 "QPE/Launcher", "home()",
107 "buttonsettings", "raise()" }, 107 "buttonsettings", "raise()" },
108 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 108 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
109 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 109 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
110 "devicebuttons/simpad_upper_lower", 110 "devicebuttons/simpad_upper_lower",
111 "QPE/Launcher", "home()", 111 "QPE/Launcher", "home()",
112 "buttonsettings", "raise()" }, 112 "buttonsettings", "raise()" },
113 */ 113 */
114}; 114};
115 115
116void SIMpad::init(const QString&) 116void SIMpad::init(const QString&)
117{ 117{
118 d->m_vendorstr = "SIEMENS"; 118 d->m_vendorstr = "SIEMENS";
119 d->m_vendor = Vendor_SIEMENS; 119 d->m_vendor = Vendor_SIEMENS;
120 120
121 121
122 //TODO Implement model checking 122 //TODO Implement model checking
123 //FIXME For now we assume an SL4 123 //FIXME For now we assume an SL4
124 124
125 d->m_modelstr = "SL4"; 125 d->m_modelstr = "SL4";
126 d->m_model = Model_SIMpad_SL4; 126 d->m_model = Model_SIMpad_SL4;
127 127
128 switch ( d->m_model ) { 128 switch ( d->m_model ) {
129 default: 129 default:
130 d->m_rotation = Rot0; 130 d->m_rotation = Rot0;
131 d->m_direction = CCW; 131 d->m_direction = CCW;
132 d->m_holdtime = 1000; // 1000ms 132 d->m_holdtime = 1000; // 1000ms
133 133
134 break; 134 break;
135 } 135 }
136 136
137 //Distribution detecting code is now in base class 137 //Distribution detecting code is now in base class
138 m_leds [0] = m_leds [1] = Led_Off; 138 m_leds [0] = m_leds [1] = Led_Off;
139 139
140 m_power_timer = 0; 140 m_power_timer = 0;
141 141
142} 142}
143 143
144void SIMpad::initButtons() 144void SIMpad::initButtons()
145{ 145{
146 if ( d->m_buttons ) 146 if ( d->m_buttons )
147 return; 147 return;
148 148
149 if ( isQWS( ) ) { 149 if ( isQWS( ) ) {
150 addPreHandler(this); 150 addPreHandler(this);
151 } 151 }
152 152
153 153
154 d->m_buttons = new QValueList <ODeviceButton>; 154 d->m_buttons = new QValueList <ODeviceButton>;
155 155
156 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 156 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
157 s_button *sb = simpad_buttons + i; 157 s_button *sb = simpad_buttons + i;
158 ODeviceButton b; 158 ODeviceButton b;
159 159
160 if (( sb->model & d->m_model ) == d->m_model ) { 160 if (( sb->model & d->m_model ) == d->m_model ) {
161 b. setKeycode ( sb->code ); 161 b. setKeycode ( sb->code );
162 b. setUserText ( QObject::tr ( "Button", sb->utext )); 162 b. setUserText ( QObject::tr ( "Button", sb->utext ));
163 b. setPixmap ( Resource::loadPixmap ( sb->pix )); 163 b. setPixmap ( Resource::loadPixmap ( sb->pix ));
164 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); 164 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction ));
165 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); 165 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction ));
166 166
167 d->m_buttons->append ( b ); 167 d->m_buttons->append ( b );
168 } 168 }
169 } 169 }
170 reloadButtonMapping(); 170 reloadButtonMapping();
171 171
172 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 172 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
173 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 173 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
174} 174}
175 175
176// SIMpad boardcontrol register CS3 176// SIMpad boardcontrol register CS3
177#define SIMPAD_BOARDCONTROL "/proc/cs3" 177#define SIMPAD_BOARDCONTROL "/proc/cs3"
178#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 178#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
179#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 179#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
180#define SIMPAD_EN1 0x0004 // This is only for EPROM's 180#define SIMPAD_EN1 0x0004 // This is only for EPROM's
181#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 181#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
182#define SIMPAD_DISPLAY_ON 0x0010 182#define SIMPAD_DISPLAY_ON 0x0010
183#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 183#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
184#define SIMPAD_MQ_RESET 0x0040 184#define SIMPAD_MQ_RESET 0x0040
185#define SIMPAD_PCMCIA_RESET 0x0080 185#define SIMPAD_PCMCIA_RESET 0x0080
186#define SIMPAD_DECT_POWER_ON 0x0100 186#define SIMPAD_DECT_POWER_ON 0x0100
187#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 187#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
188#define SIMPAD_RS232_ON 0x0400 188#define SIMPAD_RS232_ON 0x0400
189#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 189#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
190#define SIMPAD_LED2_ON 0x1000 190#define SIMPAD_LED2_ON 0x1000
191#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 191#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
192#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 192#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
193#define SIMPAD_RESET_SIMCARD 0x8000 193#define SIMPAD_RESET_SIMCARD 0x8000
194 194
195//SIMpad touchscreen backlight strength control 195//SIMpad touchscreen backlight strength control
196#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" 196#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
197#define SIMPAD_BACKLIGHT_MASK 0x00a10044 197#define SIMPAD_BACKLIGHT_MASK 0x00a10044
198 198
199 199
200/* 200/*
201 * The SIMpad exposes ChipSelect3 to userspace 201 * The SIMpad exposes ChipSelect3 to userspace
202 * via a proc filesystem file. Using this register 202 * via a proc filesystem file. Using this register
203 * one can toggle power of serial, irda, dect circuits 203 * one can toggle power of serial, irda, dect circuits
204 * change the video driver and display status and 204 * change the video driver and display status and
205 * many more things. 205 * many more things.
206 * To not lose the current setting we read the current 206 * To not lose the current setting we read the current
207 * cs3 setting and toggle the necessary bits and then 207 * cs3 setting and toggle the necessary bits and then
208 * write it. 208 * write it.
209 */ 209 */
210static bool setCS3Bit( bool bitset, int bit ) { 210static bool setCS3Bit( bool bitset, int bit ) {
211 int cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_RDONLY ); 211 int cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_RDONLY );
212 212
213 if ( cs3_fd < 0 ) 213 if ( cs3_fd < 0 )
214 return false; 214 return false;
215 215
216 static char line[32]; 216 static char line[32];
217 int val = 0; 217 int val = 0;
218 bool ok = false; 218 bool ok = false;
219 219
220 /* 220 /*
221 * try to read and parse the Chipselect3 status 221 * try to read and parse the Chipselect3 status
222 * be paranoid and make sure line[31] is null 222 * be paranoid and make sure line[31] is null
223 * terminated 223 * terminated
224 */ 224 */
225 while( !ok && ::read(cs3_fd, &line, sizeof(line)) > 0 ) { 225 while( !ok && ::read(cs3_fd, &line, sizeof(line)) > 0 ) {
226 line[31] = '\0'; 226 line[31] = '\0';
227 if (::sscanf(line, "Chipselect3 : %x", &val )) 227 if (::sscanf(line, "Chipselect3 : %x", &val ))
228 ok = true; 228 ok = true;
229 } 229 }
230 230
231 ::close(cs3_fd); 231 ::close(cs3_fd);
232 232
233 /* 233 /*
234 * we were not able to find the current value 234 * we were not able to find the current value
235 * and as a result we won't set it 235 * and as a result we won't set it
236 */ 236 */
237 if ( !ok ) 237 if ( !ok )
238 return false; 238 return false;
239 239
240 /* 240 /*
241 * change the value 241 * change the value
242 */ 242 */
243 val = bitset ? (val | bit) : (val & ~bit); 243 val = bitset ? (val | bit) : (val & ~bit);
244 244
245 /* 245 /*
246 * write it back 246 * write it back
247 */ 247 */
248 cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_WRONLY ); 248 cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_WRONLY );
249 if ( cs3_fd < 0 ) 249 if ( cs3_fd < 0 )
250 return false; 250 return false;
251 251
252 ::snprintf(line, sizeof(line), "0x%04x\n", val); 252 ::snprintf(line, sizeof(line), "0x%04x\n", val);
253 ::write(cs3_fd, line, strlen(line)); 253 ::write(cs3_fd, line, strlen(line));
254 ::close(cs3_fd); 254 ::close(cs3_fd);
255 255
256 return true; 256 return true;
257} 257}
258 258
259 259
260QValueList <OLed> SIMpad::ledList() const 260QValueList <OLed> SIMpad::ledList() const
261{ 261{
262 QValueList <OLed> vl; 262 QValueList <OLed> vl;
263 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 263 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
264 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 264 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
265 return vl; 265 return vl;
266} 266}
267 267
268QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 268QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
269{ 269{
270 QValueList <OLedState> vl; 270 QValueList <OLedState> vl;
271 271
272 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 272 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
273 vl << Led_Off << Led_On; 273 vl << Led_Off << Led_On;
274 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 274 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
275 //vl << Led_Off; 275 //vl << Led_Off;
276 return vl; 276 return vl;
277} 277}
278 278
279OLedState SIMpad::ledState ( OLed l ) const 279OLedState SIMpad::ledState ( OLed l ) const
280{ 280{
281 switch ( l ) { 281 switch ( l ) {
282 case Led_Power: 282 case Led_Power:
283 return m_leds [0]; 283 return m_leds [0];
284 //case Led_Mail: 284 //case Led_Mail:
285 // return m_leds [1]; 285 // return m_leds [1];
286 default: 286 default:
287 return Led_Off; 287 return Led_Off;
288 } 288 }
289} 289}
290 290
291bool SIMpad::setLedState ( OLed l, OLedState st ) 291bool SIMpad::setLedState ( OLed l, OLedState st )
292{ 292{
293 if ( l == Led_Power ) { 293 if ( l == Led_Power ) {
294 m_leds [0] = st; 294 m_leds [0] = st;
295 setCS3Bit(st == Led_On, SIMPAD_LED2_ON); 295 setCS3Bit(st == Led_On, SIMPAD_LED2_ON);
296 return true; 296 return true;
297 } 297 }
298 298
299 return false; 299 return false;
300} 300}
301 301
302 302
303bool SIMpad::filter ( int /*unicode*/, int /*keycode*/, int /*modifiers*/, bool /*isPress*/, bool /*autoRepeat*/ ) 303bool SIMpad::filter ( int /*unicode*/, int /*keycode*/, int /*modifiers*/, bool /*isPress*/, bool /*autoRepeat*/ )
304{ 304{
305 //TODO 305 //TODO
306 return false; 306 return false;
307} 307}
308 308
309void SIMpad::timerEvent ( QTimerEvent * ) 309void SIMpad::timerEvent ( QTimerEvent * )
310{ 310{
311 killTimer ( m_power_timer ); 311 killTimer ( m_power_timer );
312 m_power_timer = 0; 312 m_power_timer = 0;
313 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 313 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
314 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 314 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
315} 315}
316 316
317 317
318void SIMpad::playAlarmSound() 318void SIMpad::playAlarmSound()
319{ 319{
320#ifndef QT_NO_SOUND 320#ifndef QT_NO_SOUND
321 static Sound snd ( "alarm" ); 321 static Sound snd ( "alarm" );
322 if(!snd.isFinished())
323 return;
322 324
323 /* save as the Sound is static! */ 325 /* save as the Sound is static! */
324 changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); 326 changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd);
325 snd. play(); 327 snd. play();
326#endif 328#endif
327} 329}
328 330
329 331
330bool SIMpad::suspend() // Must override because SIMpad does NOT have apm 332bool SIMpad::suspend() // Must override because SIMpad does NOT have apm
331{ 333{
332 qDebug( "ODevice for SIMpad: suspend()" ); 334 qDebug( "ODevice for SIMpad: suspend()" );
333 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 335 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
334 return false; 336 return false;
335 337
336 /* 338 /*
337 * we need to save the screen content 339 * we need to save the screen content
338 * then go to suspend using ODevice::suspend 340 * then go to suspend using ODevice::suspend
339 * and finally restore the screen content 341 * and finally restore the screen content
340 */ 342 */
341 (void)::system( "cat /dev/fb/0 > /tmp/.buffer" ); 343 (void)::system( "cat /dev/fb/0 > /tmp/.buffer" );
342 bool res = ODevice::suspend(); 344 bool res = ODevice::suspend();
343 345
344 /* 346 /*
345 * restore 347 * restore
346 */ 348 */
347 if ( res ) 349 if ( res )
348 ::system( "cat /tmp/.buffer > /dev/fb/0" ); 350 ::system( "cat /tmp/.buffer > /dev/fb/0" );
349 351
350 return res; 352 return res;
351} 353}
352 354
353 355
354bool SIMpad::setSoftSuspend ( bool soft ) 356bool SIMpad::setSoftSuspend ( bool soft )
355{ 357{
356 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 358 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
357 return false; 359 return false;
358} 360}
359 361
360 362
361bool SIMpad::setDisplayStatus ( bool on ) 363bool SIMpad::setDisplayStatus ( bool on )
362{ 364{
363 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 365 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
364 366
365 return setCS3Bit(on, SIMPAD_DISPLAY_ON); 367 return setCS3Bit(on, SIMPAD_DISPLAY_ON);
366} 368}
367 369
368 370
369bool SIMpad::setDisplayBrightness ( int bright ) 371bool SIMpad::setDisplayBrightness ( int bright )
370{ 372{
371 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 373 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
372 bool res = false; 374 bool res = false;
373 int fd; 375 int fd;
374 376
375 if ( bright > 255 ) 377 if ( bright > 255 )
376 bright = 255; 378 bright = 255;
377 if ( bright < 1 ) 379 if ( bright < 1 )
378 bright = 0; 380 bright = 0;
379 381
380 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 382 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
381 int value = 255 - bright; 383 int value = 255 - bright;
382 const int mask = SIMPAD_BACKLIGHT_MASK; 384 const int mask = SIMPAD_BACKLIGHT_MASK;
383 value = value << 8; 385 value = value << 8;
384 value += mask; 386 value += mask;
385 char writeCommand[100]; 387 char writeCommand[100];
386 const int count = snprintf( writeCommand, sizeof(writeCommand), "0x%x\n", value ); 388 const int count = snprintf( writeCommand, sizeof(writeCommand), "0x%x\n", value );
387 res = ( ::write ( fd, writeCommand, count ) != -1 ); 389 res = ( ::write ( fd, writeCommand, count ) != -1 );
388 ::close ( fd ); 390 ::close ( fd );
389 } 391 }
390 return res; 392 return res;
391} 393}
392 394
393 395
394int SIMpad::displayBrightnessResolution() const 396int SIMpad::displayBrightnessResolution() const
395{ 397{
396 return 255; // All SIMpad models share the same display 398 return 255; // All SIMpad models share the same display
397} 399}
398 400
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 64fa199..733479e 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -1,654 +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 }
330 break; 330 break;
331 case SHARP_BUZ_KEYSOUND: { 331 case SHARP_BUZ_KEYSOUND: {
332 static Sound key_sound( "keysound" ); 332 static Sound key_sound( "keysound" );
333 snd = &key_sound; 333 snd = &key_sound;
334 } 334 }
335 break; 335 break;
336 case SHARP_BUZ_SCHEDULE_ALARM: 336 case SHARP_BUZ_SCHEDULE_ALARM:
337 default: { 337 default: {
338 static Sound alarm_sound("alarm"); 338 static Sound alarm_sound("alarm");
339 snd = &alarm_sound; 339 snd = &alarm_sound;
340 } 340 }
341 break; 341 break;
342 } 342 }
343 } 343 }
344 344
345 // If a soundname is defined, we expect that this device has 345 // If a soundname is defined, we expect that this device has
346 // sound capabilities.. Otherwise we expect to have the buzzer 346 // sound capabilities.. Otherwise we expect to have the buzzer
347 // device.. 347 // device..
348 if ( snd ){ 348 if ( snd && snd->isFinished() ){
349 changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); 349 changeMixerForAlarm( 0, "/dev/sound/mixer", snd );
350 snd-> play(); 350 snd-> play();
351 } else { 351 } else if( !snd ) {
352 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 352 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
353 353
354 if ( fd >= 0 ) { 354 if ( fd >= 0 ) {
355 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 355 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
356 ::close ( fd ); 356 ::close ( fd );
357 } 357 }
358 358
359 } 359 }
360#endif 360#endif
361} 361}
362 362
363 363
364void Zaurus::playAlarmSound() 364void Zaurus::playAlarmSound()
365{ 365{
366 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 366 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
367} 367}
368 368
369void Zaurus::playTouchSound() 369void Zaurus::playTouchSound()
370{ 370{
371 buzzer ( SHARP_BUZ_TOUCHSOUND ); 371 buzzer ( SHARP_BUZ_TOUCHSOUND );
372} 372}
373 373
374void Zaurus::playKeySound() 374void Zaurus::playKeySound()
375{ 375{
376 buzzer ( SHARP_BUZ_KEYSOUND ); 376 buzzer ( SHARP_BUZ_KEYSOUND );
377} 377}
378 378
379 379
380QValueList <OLed> Zaurus::ledList() const 380QValueList <OLed> Zaurus::ledList() const
381{ 381{
382 QValueList <OLed> vl; 382 QValueList <OLed> vl;
383 vl << Led_Mail; 383 vl << Led_Mail;
384 return vl; 384 return vl;
385} 385}
386 386
387QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 387QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
388{ 388{
389 QValueList <OLedState> vl; 389 QValueList <OLedState> vl;
390 390
391 if ( l == Led_Mail ) 391 if ( l == Led_Mail )
392 vl << Led_Off << Led_On << Led_BlinkSlow; 392 vl << Led_Off << Led_On << Led_BlinkSlow;
393 return vl; 393 return vl;
394} 394}
395 395
396OLedState Zaurus::ledState ( OLed which ) const 396OLedState Zaurus::ledState ( OLed which ) const
397{ 397{
398 if ( which == Led_Mail ) 398 if ( which == Led_Mail )
399 return m_leds [0]; 399 return m_leds [0];
400 else 400 else
401 return Led_Off; 401 return Led_Off;
402} 402}
403 403
404bool Zaurus::setLedState ( OLed which, OLedState st ) 404bool Zaurus::setLedState ( OLed which, OLedState st )
405{ 405{
406 if (!m_embedix) // Currently not supported on non_embedix kernels 406 if (!m_embedix) // Currently not supported on non_embedix kernels
407 return false; 407 return false;
408 408
409 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 409 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
410 410
411 if ( which == Led_Mail ) { 411 if ( which == Led_Mail ) {
412 if ( fd >= 0 ) { 412 if ( fd >= 0 ) {
413 struct sharp_led_status leds; 413 struct sharp_led_status leds;
414 ::memset ( &leds, 0, sizeof( leds )); 414 ::memset ( &leds, 0, sizeof( leds ));
415 leds. which = SHARP_LED_MAIL_EXISTS; 415 leds. which = SHARP_LED_MAIL_EXISTS;
416 bool ok = true; 416 bool ok = true;
417 417
418 switch ( st ) { 418 switch ( st ) {
419 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 419 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
420 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 420 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
421 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 421 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
422 default : ok = false; 422 default : ok = false;
423 } 423 }
424 424
425 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 425 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
426 m_leds [0] = st; 426 m_leds [0] = st;
427 return true; 427 return true;
428 } 428 }
429 } 429 }
430 } 430 }
431 return false; 431 return false;
432} 432}
433 433
434bool Zaurus::setSoftSuspend ( bool soft ) 434bool Zaurus::setSoftSuspend ( bool soft )
435{ 435{
436 if (!m_embedix) { 436 if (!m_embedix) {
437 /* non-Embedix kernels dont have kernel autosuspend */ 437 /* non-Embedix kernels dont have kernel autosuspend */
438 return ODevice::setSoftSuspend( soft ); 438 return ODevice::setSoftSuspend( soft );
439 } 439 }
440 440
441 bool res = false; 441 bool res = false;
442 int fd; 442 int fd;
443 443
444 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 444 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
445 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 445 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
446 446
447 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 447 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
448 448
449 if ( sources >= 0 ) { 449 if ( sources >= 0 ) {
450 if ( soft ) 450 if ( soft )
451 sources &= ~APM_EVT_POWER_BUTTON; 451 sources &= ~APM_EVT_POWER_BUTTON;
452 else 452 else
453 sources |= APM_EVT_POWER_BUTTON; 453 sources |= APM_EVT_POWER_BUTTON;
454 454
455 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 455 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
456 res = true; 456 res = true;
457 else 457 else
458 perror ( "APM_IOCGEVTSRC" ); 458 perror ( "APM_IOCGEVTSRC" );
459 } 459 }
460 else 460 else
461 perror ( "APM_IOCGEVTSRC" ); 461 perror ( "APM_IOCGEVTSRC" );
462 462
463 ::close ( fd ); 463 ::close ( fd );
464 } 464 }
465 else 465 else
466 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 466 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
467 467
468 return res; 468 return res;
469} 469}
470 470
471 471
472bool Zaurus::setDisplayBrightness ( int bright ) 472bool Zaurus::setDisplayBrightness ( int bright )
473{ 473{
474 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 474 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
475 bool res = false; 475 bool res = false;
476 int fd; 476 int fd;
477 477
478 if ( bright > 255 ) bright = 255; 478 if ( bright > 255 ) bright = 255;
479 if ( bright < 0 ) bright = 0; 479 if ( bright < 0 ) bright = 0;
480 480
481 if ( m_embedix ) 481 if ( m_embedix )
482 { 482 {
483 if ( d->m_model == Model_Zaurus_SLC7x0 ) 483 if ( d->m_model == Model_Zaurus_SLC7x0 )
484 { 484 {
485 //qDebug( "using special treatment for devices with the corgi backlight interface" ); 485 //qDebug( "using special treatment for devices with the corgi backlight interface" );
486 // special treatment for devices with the corgi backlight interface 486 // special treatment for devices with the corgi backlight interface
487 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) 487 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 )
488 { 488 {
489 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 ) );
490 char writeCommand[100]; 490 char writeCommand[100];
491 const int count = sprintf( writeCommand, "0x%x\n", value ); 491 const int count = sprintf( writeCommand, "0x%x\n", value );
492 res = ( ::write ( fd, writeCommand, count ) != -1 ); 492 res = ( ::write ( fd, writeCommand, count ) != -1 );
493 ::close ( fd ); 493 ::close ( fd );
494 } 494 }
495 return res; 495 return res;
496 } 496 }
497 else 497 else
498 { 498 {
499 // standard treatment for devices with the dumb embedix frontlight interface 499 // standard treatment for devices with the dumb embedix frontlight interface
500 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 500 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
501 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 501 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
502 if ( bright && !bl ) 502 if ( bright && !bl )
503 bl = 1; 503 bl = 1;
504 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 504 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
505 ::close ( fd ); 505 ::close ( fd );
506 } 506 }
507 } 507 }
508 } 508 }
509 else 509 else
510 { 510 {
511 // special treatment for the OpenZaurus unified interface 511 // special treatment for the OpenZaurus unified interface
512 #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 */
513 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { 513 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) {
514 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); 514 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 );
515 ::close ( fd ); 515 ::close ( fd );
516 } 516 }
517 } 517 }
518 return res; 518 return res;
519} 519}
520 520
521bool Zaurus::suspend() 521bool Zaurus::suspend()
522{ 522{
523 qDebug("ODevice::suspend"); 523 qDebug("ODevice::suspend");
524 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 524 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
525 return false; 525 return false;
526 526
527 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
528 return false; 528 return false;
529 529
530 bool res = false; 530 bool res = false;
531 ODevice::sendSuspendmsg(); 531 ODevice::sendSuspendmsg();
532 532
533 struct timeval tvs, tvn; 533 struct timeval tvs, tvn;
534 ::gettimeofday ( &tvs, 0 ); 534 ::gettimeofday ( &tvs, 0 );
535 535
536 ::sync(); // flush fs caches 536 ::sync(); // flush fs caches
537 res = ( ::system ( "apm --suspend" ) == 0 ); 537 res = ( ::system ( "apm --suspend" ) == 0 );
538 538
539 // 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
540 // can not be sure when exactly the device is really suspended 540 // can not be sure when exactly the device is really suspended
541 // 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.
542 542
543 if ( res ) { 543 if ( res ) {
544 do { // Yes, wait 15 seconds. This APM bug sucks big time. 544 do { // Yes, wait 15 seconds. This APM bug sucks big time.
545 ::usleep ( 200 * 1000 ); 545 ::usleep ( 200 * 1000 );
546 ::gettimeofday ( &tvn, 0 ); 546 ::gettimeofday ( &tvn, 0 );
547 } 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 );
548 } 548 }
549 549
550 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); 550 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
551 return res; 551 return res;
552} 552}
553 553
554 554
555Transformation Zaurus::rotation() const 555Transformation Zaurus::rotation() const
556{ 556{
557 Transformation rot; 557 Transformation rot;
558 int handle = 0; 558 int handle = 0;
559 int retval = 0; 559 int retval = 0;
560 560
561 switch ( d->m_model ) { 561 switch ( d->m_model ) {
562 case Model_Zaurus_SLC7x0: 562 case Model_Zaurus_SLC7x0:
563 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 563 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
564 if (handle == -1) { 564 if (handle == -1) {
565 return Rot270; 565 return Rot270;
566 } else { 566 } else {
567 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 567 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
568 ::close (handle); 568 ::close (handle);
569 569
570 if (retval == 2 ) 570 if (retval == 2 )
571 rot = Rot0; 571 rot = Rot0;
572 else 572 else
573 rot = Rot270; 573 rot = Rot270;
574 } 574 }
575 break; 575 break;
576 case Model_Zaurus_SLA300: 576 case Model_Zaurus_SLA300:
577 case Model_Zaurus_SLB600: 577 case Model_Zaurus_SLB600:
578 case Model_Zaurus_SL5500: 578 case Model_Zaurus_SL5500:
579 case Model_Zaurus_SL5000: 579 case Model_Zaurus_SL5000:
580 default: 580 default:
581 rot = d->m_rotation; 581 rot = d->m_rotation;
582 break; 582 break;
583 } 583 }
584 584
585 return rot; 585 return rot;
586} 586}
587ODirection Zaurus::direction() const 587ODirection Zaurus::direction() const
588{ 588{
589 ODirection dir; 589 ODirection dir;
590 int handle = 0; 590 int handle = 0;
591 int retval = 0; 591 int retval = 0;
592 switch ( d->m_model ) { 592 switch ( d->m_model ) {
593 case Model_Zaurus_SLC7x0: 593 case Model_Zaurus_SLC7x0:
594 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 594 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
595 if (handle == -1) { 595 if (handle == -1) {
596 dir = CW; 596 dir = CW;
597 } else { 597 } else {
598 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 598 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
599 ::close (handle); 599 ::close (handle);
600 if (retval == 2 ) 600 if (retval == 2 )
601 dir = CCW; 601 dir = CCW;
602 else 602 else
603 dir = CW; 603 dir = CW;
604 } 604 }
605 break; 605 break;
606 case Model_Zaurus_SLA300: 606 case Model_Zaurus_SLA300:
607 case Model_Zaurus_SLB600: 607 case Model_Zaurus_SLB600:
608 case Model_Zaurus_SL5500: 608 case Model_Zaurus_SL5500:
609 case Model_Zaurus_SL5000: 609 case Model_Zaurus_SL5000:
610 default: 610 default:
611 dir = d->m_direction; 611 dir = d->m_direction;
612 break; 612 break;
613 } 613 }
614 return dir; 614 return dir;
615 615
616} 616}
617 617
618int Zaurus::displayBrightnessResolution() const 618int Zaurus::displayBrightnessResolution() const
619{ 619{
620 if (m_embedix) 620 if (m_embedix)
621 return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5; 621 return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5;
622 else 622 else
623 return 256; 623 return 256;
624} 624}
625 625
626bool Zaurus::hasHingeSensor() const 626bool Zaurus::hasHingeSensor() const
627{ 627{
628 return d->m_model == Model_Zaurus_SLC7x0; 628 return d->m_model == Model_Zaurus_SLC7x0;
629} 629}
630 630
631OHingeStatus Zaurus::readHingeSensor() 631OHingeStatus Zaurus::readHingeSensor()
632{ 632{
633 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 633 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
634 if (handle == -1) 634 if (handle == -1)
635 { 635 {
636 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror 636 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
637 return CASE_UNKNOWN; 637 return CASE_UNKNOWN;
638 } 638 }
639 else 639 else
640 { 640 {
641 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 641 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
642 ::close (handle); 642 ::close (handle);
643 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) 643 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
644 { 644 {
645 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 645 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
646 return static_cast<OHingeStatus>( retval ); 646 return static_cast<OHingeStatus>( retval );
647 } 647 }
648 else 648 else
649 { 649 {
650 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 650 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
651 return CASE_UNKNOWN; 651 return CASE_UNKNOWN;
652 } 652 }
653 } 653 }
654} 654}