summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-06-27 09:36:13 (UTC)
committer mickeyl <mickeyl>2005-06-27 09:36:13 (UTC)
commit3e1e2a8751a169b553570a585293dd9ea6de41cd (patch) (unidiff)
treef39093719df4bd0f3bc3418006a9e59c1c0e76c9
parent99330785fae22b2b9131cfd9c273f3a59a004bdf (diff)
downloadopie-3e1e2a8751a169b553570a585293dd9ea6de41cd.zip
opie-3e1e2a8751a169b553570a585293dd9ea6de41cd.tar.gz
opie-3e1e2a8751a169b553570a585293dd9ea6de41cd.tar.bz2
simpad: restore file header, zaurus: send returnFromSuspend message
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp45
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp4
2 files changed, 25 insertions, 24 deletions
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index f2805de..3337783 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -1,402 +1,401 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3 =. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
4 Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org>
5 =.
6 .=l. 4 .=l.
7           .>+-= 5           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; version 2 of the License.
13     ._= =}       : or (at your option) any later version. 11     ._= =}       :
14    .%`+i>       _;_. 12    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17 : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 19++=   -.     .`     .: details.
22:     =  ...= . :.=- 20 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27
29*/ 28*/
30 29
31#include "odevice_simpad.h" 30#include "odevice_simpad.h"
32 31
33/* QT */ 32/* QT */
34#include <qapplication.h> 33#include <qapplication.h>
35#include <qfile.h> 34#include <qfile.h>
36#include <qtextstream.h> 35#include <qtextstream.h>
37#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
38#include <qwidgetlist.h> 37#include <qwidgetlist.h>
39 38
40/* OPIE */ 39/* OPIE */
41#include <qpe/config.h> 40#include <qpe/config.h>
42#include <qpe/sound.h> 41#include <qpe/sound.h>
43#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
44 43
45#include <opie2/okeyfilter.h> 44#include <opie2/okeyfilter.h>
46#include <opie2/oresource.h> 45#include <opie2/oresource.h>
47 46
48/* STD */ 47/* STD */
49#include <fcntl.h> 48#include <fcntl.h>
50#include <math.h> 49#include <math.h>
51#include <stdlib.h> 50#include <stdlib.h>
52#include <signal.h> 51#include <signal.h>
53#include <sys/ioctl.h> 52#include <sys/ioctl.h>
54#include <sys/time.h> 53#include <sys/time.h>
55#include <unistd.h> 54#include <unistd.h>
56#ifndef QT_NO_SOUND 55#ifndef QT_NO_SOUND
57#include <linux/soundcard.h> 56#include <linux/soundcard.h>
58#endif 57#endif
59 58
60namespace Opie { 59namespace Opie {
61namespace Core { 60namespace Core {
62namespace Internal { 61namespace Internal {
63namespace { 62namespace {
64struct s_button { 63struct s_button {
65 uint model; 64 uint model;
66 Qt::Key code; 65 Qt::Key code;
67 char *utext; 66 char *utext;
68 char *pix; 67 char *pix;
69 char *fpressedservice; 68 char *fpressedservice;
70 char *fpressedaction; 69 char *fpressedaction;
71 char *fheldservice; 70 char *fheldservice;
72 char *fheldaction; 71 char *fheldaction;
73}; 72};
74 73
75static struct s_button simpad_buttons [] = { 74static struct s_button simpad_buttons [] = {
76 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 75 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
77 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 76 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
78 "devicebuttons/simpad_lower_up", 77 "devicebuttons/simpad_lower_up",
79 "datebook", "nextView()", 78 "datebook", "nextView()",
80 "today", "raise()" }, 79 "today", "raise()" },
81 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 80 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
82 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 81 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
83 "devicebuttons/simpad_lower_down", 82 "devicebuttons/simpad_lower_down",
84 "addressbook", "raise()", 83 "addressbook", "raise()",
85 "addressbook", "beamBusinessCard()" }, 84 "addressbook", "beamBusinessCard()" },
86 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 85 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
87 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 86 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
88 "devicebuttons/simpad_lower_right", 87 "devicebuttons/simpad_lower_right",
89 "QPE/TaskBar", "toggleMenu()", 88 "QPE/TaskBar", "toggleMenu()",
90 "QPE/TaskBar", "toggleStartMenu()" }, 89 "QPE/TaskBar", "toggleStartMenu()" },
91 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 90 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
92 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 91 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
93 "devicebuttons/simpad_lower_left", 92 "devicebuttons/simpad_lower_left",
94 "opiemail", "raise()", 93 "opiemail", "raise()",
95 "opiemail", "newMail()" }, 94 "opiemail", "newMail()" },
96 95
97 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 96 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
98 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 97 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
99 "devicebuttons/simpad_upper_up", 98 "devicebuttons/simpad_upper_up",
100 "QPE/Launcher", "home()", 99 "QPE/Launcher", "home()",
101 "buttonsettings", "raise()" }, 100 "buttonsettings", "raise()" },
102 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 101 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
103 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 102 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
104 "devicebuttons/simpad_upper_down", 103 "devicebuttons/simpad_upper_down",
105 "addressbook", "raise()", 104 "addressbook", "raise()",
106 "addressbook", "beamBusinessCard()" }, 105 "addressbook", "beamBusinessCard()" },
107 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 106 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
108 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 107 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
109 "devicebuttons/simpad_upper_right", 108 "devicebuttons/simpad_upper_right",
110 "QPE/TaskBar", "toggleMenu()", 109 "QPE/TaskBar", "toggleMenu()",
111 "QPE/TaskBar", "toggleStartMenu()" }, 110 "QPE/TaskBar", "toggleStartMenu()" },
112 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 111 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
113 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 112 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
114 "devicebuttons/simpad_upper_left", 113 "devicebuttons/simpad_upper_left",
115 "QPE/Rotation", "flip()", 114 "QPE/Rotation", "flip()",
116 "QPE/Rotation", "flip()" }, 115 "QPE/Rotation", "flip()" },
117 /* 116 /*
118 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 117 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
119 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 118 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
120 "devicebuttons/simpad_lower_upper", 119 "devicebuttons/simpad_lower_upper",
121 "QPE/Launcher", "home()", 120 "QPE/Launcher", "home()",
122 "buttonsettings", "raise()" }, 121 "buttonsettings", "raise()" },
123 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 122 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
124 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 123 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
125 "devicebuttons/simpad_upper_lower", 124 "devicebuttons/simpad_upper_lower",
126 "QPE/Launcher", "home()", 125 "QPE/Launcher", "home()",
127 "buttonsettings", "raise()" }, 126 "buttonsettings", "raise()" },
128 */ 127 */
129}; 128};
130} 129}
131 130
132 131
133void SIMpad::init(const QString&) 132void SIMpad::init(const QString&)
134{ 133{
135 d->m_vendorstr = "SIEMENS"; 134 d->m_vendorstr = "SIEMENS";
136 d->m_vendor = Vendor_SIEMENS; 135 d->m_vendor = Vendor_SIEMENS;
137 136
138 137
139 //TODO Implement model checking 138 //TODO Implement model checking
140 //FIXME For now we assume an SL4 139 //FIXME For now we assume an SL4
141 140
142 d->m_modelstr = "SL4"; 141 d->m_modelstr = "SL4";
143 d->m_model = Model_SIMpad_SL4; 142 d->m_model = Model_SIMpad_SL4;
144 143
145 switch ( d->m_model ) { 144 switch ( d->m_model ) {
146 default: 145 default:
147 d->m_rotation = Rot0; 146 d->m_rotation = Rot0;
148 d->m_direction = CCW; 147 d->m_direction = CCW;
149 d->m_holdtime = 1000; // 1000ms 148 d->m_holdtime = 1000; // 1000ms
150 149
151 break; 150 break;
152 } 151 }
153 152
154 //Distribution detecting code is now in base class 153 //Distribution detecting code is now in base class
155 m_leds [0] = m_leds [1] = Led_Off; 154 m_leds [0] = m_leds [1] = Led_Off;
156 155
157 m_power_timer = 0; 156 m_power_timer = 0;
158 157
159} 158}
160 159
161void SIMpad::initButtons() 160void SIMpad::initButtons()
162{ 161{
163 if ( d->m_buttons ) 162 if ( d->m_buttons )
164 return; 163 return;
165 164
166 d->m_buttons = new QValueList <ODeviceButton>; 165 d->m_buttons = new QValueList <ODeviceButton>;
167 166
168 uint size = sizeof(simpad_buttons)/sizeof(s_button); 167 uint size = sizeof(simpad_buttons)/sizeof(s_button);
169 for ( uint i = 0; i < size; i++ ) { 168 for ( uint i = 0; i < size; i++ ) {
170 s_button *sb = simpad_buttons + i; 169 s_button *sb = simpad_buttons + i;
171 ODeviceButton b; 170 ODeviceButton b;
172 171
173 if (( sb->model & d->m_model ) == d->m_model ) { 172 if (( sb->model & d->m_model ) == d->m_model ) {
174 b. setKeycode ( sb->code ); 173 b. setKeycode ( sb->code );
175 b. setUserText ( QObject::tr ( "Button", sb->utext )); 174 b. setUserText ( QObject::tr ( "Button", sb->utext ));
176 b. setPixmap ( OResource::loadPixmap ( sb->pix )); 175 b. setPixmap ( OResource::loadPixmap ( sb->pix ));
177 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); 176 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction ));
178 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); 177 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction ));
179 178
180 d->m_buttons->append ( b ); 179 d->m_buttons->append ( b );
181 } 180 }
182 } 181 }
183 reloadButtonMapping(); 182 reloadButtonMapping();
184} 183}
185 184
186// SIMpad boardcontrol register CS3 185// SIMpad boardcontrol register CS3
187#define SIMPAD_BOARDCONTROL "/proc/cs3" 186#define SIMPAD_BOARDCONTROL "/proc/cs3"
188#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 187#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
189#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 188#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
190#define SIMPAD_EN1 0x0004 // This is only for EPROM's 189#define SIMPAD_EN1 0x0004 // This is only for EPROM's
191#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 190#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
192#define SIMPAD_DISPLAY_ON 0x0010 191#define SIMPAD_DISPLAY_ON 0x0010
193#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 192#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
194#define SIMPAD_MQ_RESET 0x0040 193#define SIMPAD_MQ_RESET 0x0040
195#define SIMPAD_PCMCIA_RESET 0x0080 194#define SIMPAD_PCMCIA_RESET 0x0080
196#define SIMPAD_DECT_POWER_ON 0x0100 195#define SIMPAD_DECT_POWER_ON 0x0100
197#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 196#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
198#define SIMPAD_RS232_ON 0x0400 197#define SIMPAD_RS232_ON 0x0400
199#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 198#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
200#define SIMPAD_LED2_ON 0x1000 199#define SIMPAD_LED2_ON 0x1000
201#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 200#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
202#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 201#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
203#define SIMPAD_RESET_SIMCARD 0x8000 202#define SIMPAD_RESET_SIMCARD 0x8000
204 203
205//SIMpad touchscreen backlight strength control 204//SIMpad touchscreen backlight strength control
206#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/backlight" 205#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/backlight"
207 206
208 207
209/* 208/*
210 * The SIMpad exposes ChipSelect3 to userspace 209 * The SIMpad exposes ChipSelect3 to userspace
211 * via a proc filesystem file. Using this register 210 * via a proc filesystem file. Using this register
212 * one can toggle power of serial, irda, dect circuits 211 * one can toggle power of serial, irda, dect circuits
213 * change the video driver and display status and 212 * change the video driver and display status and
214 * many more things. 213 * many more things.
215 * To not lose the current setting we read the current 214 * To not lose the current setting we read the current
216 * cs3 setting and toggle the necessary bits and then 215 * cs3 setting and toggle the necessary bits and then
217 * write it. 216 * write it.
218 */ 217 */
219static bool setCS3Bit( bool bitset, int bit ) { 218static bool setCS3Bit( bool bitset, int bit ) {
220 QFile file( SIMPAD_BOARDCONTROL ); 219 QFile file( SIMPAD_BOARDCONTROL );
221 if ( !file.open( IO_ReadOnly ) ) 220 if ( !file.open( IO_ReadOnly ) )
222 return false; 221 return false;
223 222
224 unsigned int val = 0; 223 unsigned int val = 0;
225 bool ok = false; 224 bool ok = false;
226 QTextStream stream( &file ); 225 QTextStream stream( &file );
227 226
228 /* 227 /*
229 * Use QFile and QTextStream for parsing to be more 228 * Use QFile and QTextStream for parsing to be more
230 * robust 229 * robust
231 */ 230 */
232 while ( !stream.atEnd() ) { 231 while ( !stream.atEnd() ) {
233 QString line = stream.readLine(); 232 QString line = stream.readLine();
234 if ( line.startsWith( "Chipselect3 : " ) ) { 233 if ( line.startsWith( "Chipselect3 : " ) ) {
235 val = line.mid( 14 ).toUInt( 0, 16 ); 234 val = line.mid( 14 ).toUInt( 0, 16 );
236 ok = true; 235 ok = true;
237 break; 236 break;
238 } 237 }
239 } 238 }
240 239
241 if ( !ok ) 240 if ( !ok )
242 return false; 241 return false;
243 242
244 file.close(); 243 file.close();
245 244
246 /* 245 /*
247 * change the value 246 * change the value
248 */ 247 */
249 val = bitset ? (val | bit) : (val & ~bit); 248 val = bitset ? (val | bit) : (val & ~bit);
250 249
251 /* 250 /*
252 * write it back 251 * write it back
253 */ 252 */
254 int cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_WRONLY ); 253 int cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_WRONLY );
255 if ( cs3_fd < 0 ) 254 if ( cs3_fd < 0 )
256 return false; 255 return false;
257 256
258 char line[32]; 257 char line[32];
259 ::snprintf(line, sizeof(line), "0x%04x\n", val); 258 ::snprintf(line, sizeof(line), "0x%04x\n", val);
260 ::write(cs3_fd, line, strlen(line)); 259 ::write(cs3_fd, line, strlen(line));
261 ::close(cs3_fd); 260 ::close(cs3_fd);
262 261
263 return true; 262 return true;
264} 263}
265 264
266 265
267QValueList <OLed> SIMpad::ledList() const 266QValueList <OLed> SIMpad::ledList() const
268{ 267{
269 QValueList <OLed> vl; 268 QValueList <OLed> vl;
270 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 269 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
271 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 270 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
272 return vl; 271 return vl;
273} 272}
274 273
275QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 274QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
276{ 275{
277 QValueList <OLedState> vl; 276 QValueList <OLedState> vl;
278 277
279 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 278 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
280 vl << Led_Off << Led_On; 279 vl << Led_Off << Led_On;
281 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 280 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
282 //vl << Led_Off; 281 //vl << Led_Off;
283 return vl; 282 return vl;
284} 283}
285 284
286OLedState SIMpad::ledState ( OLed l ) const 285OLedState SIMpad::ledState ( OLed l ) const
287{ 286{
288 switch ( l ) { 287 switch ( l ) {
289 case Led_Power: 288 case Led_Power:
290 return m_leds [0]; 289 return m_leds [0];
291 //case Led_Mail: 290 //case Led_Mail:
292 // return m_leds [1]; 291 // return m_leds [1];
293 default: 292 default:
294 return Led_Off; 293 return Led_Off;
295 } 294 }
296} 295}
297 296
298bool SIMpad::setLedState ( OLed l, OLedState st ) 297bool SIMpad::setLedState ( OLed l, OLedState st )
299{ 298{
300 if ( l == Led_Power ) { 299 if ( l == Led_Power ) {
301 m_leds [0] = st; 300 m_leds [0] = st;
302 setCS3Bit(st == Led_On, SIMPAD_LED2_ON); 301 setCS3Bit(st == Led_On, SIMPAD_LED2_ON);
303 return true; 302 return true;
304 } 303 }
305 304
306 return false; 305 return false;
307} 306}
308 307
309void SIMpad::timerEvent ( QTimerEvent * ) 308void SIMpad::timerEvent ( QTimerEvent * )
310{ 309{
311 killTimer ( m_power_timer ); 310 killTimer ( m_power_timer );
312 m_power_timer = 0; 311 m_power_timer = 0;
313 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 312 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
314 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 313 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
315} 314}
316 315
317 316
318void SIMpad::playAlarmSound() 317void SIMpad::playAlarmSound()
319{ 318{
320#ifndef QT_NO_SOUND 319#ifndef QT_NO_SOUND
321 static Sound snd ( "alarm" ); 320 static Sound snd ( "alarm" );
322 if(!snd.isFinished()) 321 if(!snd.isFinished())
323 return; 322 return;
324 323
325 /* save as the Sound is static! */ 324 /* save as the Sound is static! */
326 changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); 325 changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd);
327 snd. play(); 326 snd. play();
328#endif 327#endif
329} 328}
330 329
331 330
332bool SIMpad::suspend() // Must override because SIMpad does NOT have apm 331bool SIMpad::suspend() // Must override because SIMpad does NOT have apm
333{ 332{
334 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 333 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
335 return false; 334 return false;
336 335
337 bool res = OAbstractMobileDevice::suspend(); 336 bool res = OAbstractMobileDevice::suspend();
338 337
339 /* 338 /*
340 * restore the screen content if we really 339 * restore the screen content if we really
341 * supended the device 340 * supended the device
342 */ 341 */
343 if ( res ) 342 if ( res )
344 updateAllWidgets(); 343 updateAllWidgets();
345 344
346 return res; 345 return res;
347} 346}
348 347
349bool SIMpad::setDisplayStatus ( bool on ) 348bool SIMpad::setDisplayStatus ( bool on )
350{ 349{
351 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 350 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
352 351
353 return setCS3Bit(on, SIMPAD_DISPLAY_ON); 352 return setCS3Bit(on, SIMPAD_DISPLAY_ON);
354} 353}
355 354
356 355
357bool SIMpad::setDisplayBrightness ( int bright ) 356bool SIMpad::setDisplayBrightness ( int bright )
358{ 357{
359 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 358 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
360 bool res = false; 359 bool res = false;
361 int fd; 360 int fd;
362 361
363 if ( bright > 255 ) 362 if ( bright > 255 )
364 bright = 255; 363 bright = 255;
365 if ( bright < 1 ) 364 if ( bright < 1 )
366 bright = 0; 365 bright = 0;
367 366
368 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 367 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
369 QCString str = QFile::encodeName( QString::number(bright)); 368 QCString str = QFile::encodeName( QString::number(bright));
370 res = ( ::write(fd, str, str.length()) != -1 ); 369 res = ( ::write(fd, str, str.length()) != -1 );
371 ::close ( fd ); 370 ::close ( fd );
372 } 371 }
373 return res; 372 return res;
374} 373}
375 374
376 375
377int SIMpad::displayBrightnessResolution() const 376int SIMpad::displayBrightnessResolution() const
378{ 377{
379 return 255; // All SIMpad models share the same display 378 return 255; // All SIMpad models share the same display
380} 379}
381 380
382 381
383/* 382/*
384 * The MQ200 DRAM content is lost during suspend 383 * The MQ200 DRAM content is lost during suspend
385 * so we will just repaint every widget on resume 384 * so we will just repaint every widget on resume
386 */ 385 */
387void SIMpad::updateAllWidgets() { 386void SIMpad::updateAllWidgets() {
388 QWidgetList *list = QApplication::allWidgets(); 387 QWidgetList *list = QApplication::allWidgets();
389 QWidgetListIt it( *list ); 388 QWidgetListIt it( *list );
390 QWidget *wid; 389 QWidget *wid;
391 390
392 while ((wid=it.current()) != 0 ) { 391 while ((wid=it.current()) != 0 ) {
393 wid->update(); 392 wid->update();
394 ++it; 393 ++it;
395 } 394 }
396 395
397 delete list; 396 delete list;
398} 397}
399 398
400} 399}
401} 400}
402} 401}
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 0c421e3..8369f54 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -275,406 +275,408 @@ void Zaurus::initButtons()
275 buttoncount = ARRAY_SIZE(z_buttons); 275 buttoncount = ARRAY_SIZE(z_buttons);
276 break; 276 break;
277 } 277 }
278 278
279 for ( int i = 0; i < buttoncount; i++ ) { 279 for ( int i = 0; i < buttoncount; i++ ) {
280 struct z_button *zb = pz_buttons + i; 280 struct z_button *zb = pz_buttons + i;
281 ODeviceButton b; 281 ODeviceButton b;
282 282
283 b.setKeycode( zb->code ); 283 b.setKeycode( zb->code );
284 b.setUserText( QObject::tr( "Button", zb->utext )); 284 b.setUserText( QObject::tr( "Button", zb->utext ));
285 b.setPixmap( OResource::loadPixmap( zb->pix )); 285 b.setPixmap( OResource::loadPixmap( zb->pix ));
286 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); 286 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction ));
287 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); 287 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction ));
288 d->m_buttons->append( b ); 288 d->m_buttons->append( b );
289 } 289 }
290 290
291 reloadButtonMapping(); 291 reloadButtonMapping();
292} 292}
293 293
294 294
295 295
296typedef struct sharp_led_status { 296typedef struct sharp_led_status {
297 int which; /* select which LED status is wanted. */ 297 int which; /* select which LED status is wanted. */
298 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 298 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
299} sharp_led_status; 299} sharp_led_status;
300 300
301void Zaurus::buzzer( int sound ) 301void Zaurus::buzzer( int sound )
302{ 302{
303#ifndef QT_NO_SOUND 303#ifndef QT_NO_SOUND
304 Sound *snd = 0; 304 Sound *snd = 0;
305 305
306 // All devices except SL5500 have a DSP device 306 // All devices except SL5500 have a DSP device
307 if ( d->m_model != Model_Zaurus_SL5000 307 if ( d->m_model != Model_Zaurus_SL5000
308 && d->m_model != Model_Zaurus_SL5500 ) { 308 && d->m_model != Model_Zaurus_SL5500 ) {
309 309
310 switch ( sound ){ 310 switch ( sound ){
311 case SHARP_BUZ_TOUCHSOUND: { 311 case SHARP_BUZ_TOUCHSOUND: {
312 static Sound touch_sound("touchsound"); 312 static Sound touch_sound("touchsound");
313 snd = &touch_sound; 313 snd = &touch_sound;
314 } 314 }
315 break; 315 break;
316 case SHARP_BUZ_KEYSOUND: { 316 case SHARP_BUZ_KEYSOUND: {
317 static Sound key_sound( "keysound" ); 317 static Sound key_sound( "keysound" );
318 snd = &key_sound; 318 snd = &key_sound;
319 } 319 }
320 break; 320 break;
321 case SHARP_BUZ_SCHEDULE_ALARM: 321 case SHARP_BUZ_SCHEDULE_ALARM:
322 default: { 322 default: {
323 static Sound alarm_sound("alarm"); 323 static Sound alarm_sound("alarm");
324 snd = &alarm_sound; 324 snd = &alarm_sound;
325 } 325 }
326 break; 326 break;
327 } 327 }
328 } 328 }
329 329
330 // If a soundname is defined, we expect that this device has 330 // If a soundname is defined, we expect that this device has
331 // sound capabilities.. Otherwise we expect to have the buzzer 331 // sound capabilities.. Otherwise we expect to have the buzzer
332 // device.. 332 // device..
333 if ( snd && snd->isFinished() ){ 333 if ( snd && snd->isFinished() ){
334 changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); 334 changeMixerForAlarm( 0, "/dev/sound/mixer", snd );
335 snd->play(); 335 snd->play();
336 } else if( !snd ) { 336 } else if( !snd ) {
337 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 337 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
338 338
339 if ( fd >= 0 ) { 339 if ( fd >= 0 ) {
340 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 340 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
341 ::close ( fd ); 341 ::close ( fd );
342 } 342 }
343 343
344 } 344 }
345#endif 345#endif
346} 346}
347 347
348 348
349void Zaurus::playAlarmSound() 349void Zaurus::playAlarmSound()
350{ 350{
351 buzzer( SHARP_BUZ_SCHEDULE_ALARM ); 351 buzzer( SHARP_BUZ_SCHEDULE_ALARM );
352} 352}
353 353
354void Zaurus::playTouchSound() 354void Zaurus::playTouchSound()
355{ 355{
356 buzzer( SHARP_BUZ_TOUCHSOUND ); 356 buzzer( SHARP_BUZ_TOUCHSOUND );
357} 357}
358 358
359void Zaurus::playKeySound() 359void Zaurus::playKeySound()
360{ 360{
361 buzzer( SHARP_BUZ_KEYSOUND ); 361 buzzer( SHARP_BUZ_KEYSOUND );
362} 362}
363 363
364 364
365QValueList <OLed> Zaurus::ledList() const 365QValueList <OLed> Zaurus::ledList() const
366{ 366{
367 QValueList <OLed> vl; 367 QValueList <OLed> vl;
368 vl << Led_Mail; 368 vl << Led_Mail;
369 return vl; 369 return vl;
370} 370}
371 371
372QValueList <OLedState> Zaurus::ledStateList( OLed l ) const 372QValueList <OLedState> Zaurus::ledStateList( OLed l ) const
373{ 373{
374 QValueList <OLedState> vl; 374 QValueList <OLedState> vl;
375 375
376 if ( l == Led_Mail ) 376 if ( l == Led_Mail )
377 vl << Led_Off << Led_On << Led_BlinkSlow; 377 vl << Led_Off << Led_On << Led_BlinkSlow;
378 return vl; 378 return vl;
379} 379}
380 380
381OLedState Zaurus::ledState( OLed which ) const 381OLedState Zaurus::ledState( OLed which ) const
382{ 382{
383 if ( which == Led_Mail ) 383 if ( which == Led_Mail )
384 return m_leds [0]; 384 return m_leds [0];
385 else 385 else
386 return Led_Off; 386 return Led_Off;
387} 387}
388 388
389bool Zaurus::setLedState( OLed which, OLedState st ) 389bool Zaurus::setLedState( OLed which, OLedState st )
390{ 390{
391 // Currently not supported on non_embedix kernels 391 // Currently not supported on non_embedix kernels
392 if (!m_embedix) 392 if (!m_embedix)
393 { 393 {
394 qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); 394 qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" );
395 return false; 395 return false;
396 } 396 }
397 397
398 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 398 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
399 399
400 if ( which == Led_Mail ) { 400 if ( which == Led_Mail ) {
401 if ( fd >= 0 ) { 401 if ( fd >= 0 ) {
402 struct sharp_led_status leds; 402 struct sharp_led_status leds;
403 ::memset ( &leds, 0, sizeof( leds )); 403 ::memset ( &leds, 0, sizeof( leds ));
404 leds. which = SHARP_LED_MAIL_EXISTS; 404 leds. which = SHARP_LED_MAIL_EXISTS;
405 bool ok = true; 405 bool ok = true;
406 406
407 switch ( st ) { 407 switch ( st ) {
408 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 408 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
409 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 409 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
410 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 410 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
411 default : ok = false; 411 default : ok = false;
412 } 412 }
413 413
414 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 414 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
415 m_leds [0] = st; 415 m_leds [0] = st;
416 return true; 416 return true;
417 } 417 }
418 } 418 }
419 } 419 }
420 return false; 420 return false;
421} 421}
422 422
423int Zaurus::displayBrightnessResolution() const 423int Zaurus::displayBrightnessResolution() const
424{ 424{
425 int res = 1; 425 int res = 1;
426 if (m_embedix) 426 if (m_embedix)
427 { 427 {
428 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); 428 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK );
429 if ( fd ) 429 if ( fd )
430 { 430 {
431 int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); 431 int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 );
432 ::close( fd ); 432 ::close( fd );
433 return value ? value : res; 433 return value ? value : res;
434 } 434 }
435 } 435 }
436 else 436 else
437 { 437 {
438 int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); 438 int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK );
439 if ( fd ) 439 if ( fd )
440 { 440 {
441 char buf[100]; 441 char buf[100];
442 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); 442 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res );
443 ::close( fd ); 443 ::close( fd );
444 } 444 }
445 } 445 }
446 return res; 446 return res;
447} 447}
448 448
449bool Zaurus::setDisplayBrightness( int bright ) 449bool Zaurus::setDisplayBrightness( int bright )
450{ 450{
451 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 451 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
452 bool res = false; 452 bool res = false;
453 453
454 if ( bright > 255 ) bright = 255; 454 if ( bright > 255 ) bright = 255;
455 if ( bright < 0 ) bright = 0; 455 if ( bright < 0 ) bright = 0;
456 456
457 int numberOfSteps = displayBrightnessResolution(); 457 int numberOfSteps = displayBrightnessResolution();
458 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; 458 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255;
459 459
460 if ( m_embedix ) 460 if ( m_embedix )
461 { 461 {
462 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 462 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
463 if ( fd ) 463 if ( fd )
464 { 464 {
465 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); 465 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
466 ::close( fd ); 466 ::close( fd );
467 } 467 }
468 } 468 }
469 else 469 else
470 { 470 {
471 int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); 471 int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK );
472 if ( fd ) 472 if ( fd )
473 { 473 {
474 char buf[100]; 474 char buf[100];
475 int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); 475 int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
476 res = ( ::write( fd, &buf[0], len ) == 0 ); 476 res = ( ::write( fd, &buf[0], len ) == 0 );
477 ::close( fd ); 477 ::close( fd );
478 } 478 }
479 } 479 }
480 return res; 480 return res;
481} 481}
482 482
483bool Zaurus::setDisplayStatus( bool on ) 483bool Zaurus::setDisplayStatus( bool on )
484{ 484{
485 bool res = false; 485 bool res = false;
486 if ( m_embedix ) 486 if ( m_embedix )
487 { 487 {
488 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 488 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
489 if ( fd ) 489 if ( fd )
490 { 490 {
491 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; 491 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF;
492 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); 492 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 );
493 ::close ( fd ); 493 ::close ( fd );
494 } 494 }
495 } 495 }
496 else 496 else
497 { 497 {
498 int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); 498 int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK );
499 if ( fd ) 499 if ( fd )
500 { 500 {
501 char buf[10]; 501 char buf[10];
502 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; 502 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
503 buf[1] = '\0'; 503 buf[1] = '\0';
504 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 504 res = ( ::write( fd, &buf[0], 2 ) == 0 );
505 ::close( fd ); 505 ::close( fd );
506 } 506 }
507 } 507 }
508 return res; 508 return res;
509} 509}
510 510
511Transformation Zaurus::rotation() const 511Transformation Zaurus::rotation() const
512{ 512{
513 qDebug( "Zaurus::rotation()" ); 513 qDebug( "Zaurus::rotation()" );
514 Transformation rot; 514 Transformation rot;
515 515
516 switch ( d->m_model ) { 516 switch ( d->m_model ) {
517 case Model_Zaurus_SLC3000: // fallthrough 517 case Model_Zaurus_SLC3000: // fallthrough
518 case Model_Zaurus_SLC1000: // fallthrough 518 case Model_Zaurus_SLC1000: // fallthrough
519 case Model_Zaurus_SLC7x0: 519 case Model_Zaurus_SLC7x0:
520 { 520 {
521 OHingeStatus hs = readHingeSensor(); 521 OHingeStatus hs = readHingeSensor();
522 qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); 522 qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs );
523 523
524 if ( m_embedix ) 524 if ( m_embedix )
525 { 525 {
526 if ( hs == CASE_PORTRAIT ) rot = Rot0; 526 if ( hs == CASE_PORTRAIT ) rot = Rot0;
527 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 527 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
528 else rot = Rot270; 528 else rot = Rot270;
529 } 529 }
530 else 530 else
531 { 531 {
532 if ( hs == CASE_PORTRAIT ) rot = Rot90; 532 if ( hs == CASE_PORTRAIT ) rot = Rot90;
533 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 533 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
534 else rot = Rot0; 534 else rot = Rot0;
535 } 535 }
536 } 536 }
537 break; 537 break;
538 case Model_Zaurus_SL6000: 538 case Model_Zaurus_SL6000:
539 case Model_Zaurus_SLB600: 539 case Model_Zaurus_SLB600:
540 case Model_Zaurus_SLA300: 540 case Model_Zaurus_SLA300:
541 case Model_Zaurus_SL5500: 541 case Model_Zaurus_SL5500:
542 case Model_Zaurus_SL5000: 542 case Model_Zaurus_SL5000:
543 default: 543 default:
544 rot = d->m_rotation; 544 rot = d->m_rotation;
545 break; 545 break;
546 } 546 }
547 547
548 return rot; 548 return rot;
549} 549}
550ODirection Zaurus::direction() const 550ODirection Zaurus::direction() const
551{ 551{
552 ODirection dir; 552 ODirection dir;
553 553
554 switch ( d->m_model ) { 554 switch ( d->m_model ) {
555 case Model_Zaurus_SLC3000: // fallthrough 555 case Model_Zaurus_SLC3000: // fallthrough
556 case Model_Zaurus_SLC1000: // fallthrough 556 case Model_Zaurus_SLC1000: // fallthrough
557 case Model_Zaurus_SLC7x0: { 557 case Model_Zaurus_SLC7x0: {
558 OHingeStatus hs = readHingeSensor(); 558 OHingeStatus hs = readHingeSensor();
559 if ( hs == CASE_PORTRAIT ) dir = CCW; 559 if ( hs == CASE_PORTRAIT ) dir = CCW;
560 else if ( hs == CASE_UNKNOWN ) dir = CCW; 560 else if ( hs == CASE_UNKNOWN ) dir = CCW;
561 else dir = CW; 561 else dir = CW;
562 } 562 }
563 break; 563 break;
564 case Model_Zaurus_SL6000: 564 case Model_Zaurus_SL6000:
565 case Model_Zaurus_SLA300: 565 case Model_Zaurus_SLA300:
566 case Model_Zaurus_SLB600: 566 case Model_Zaurus_SLB600:
567 case Model_Zaurus_SL5500: 567 case Model_Zaurus_SL5500:
568 case Model_Zaurus_SL5000: 568 case Model_Zaurus_SL5000:
569 default: dir = d->m_direction; 569 default: dir = d->m_direction;
570 break; 570 break;
571 } 571 }
572 return dir; 572 return dir;
573 573
574} 574}
575 575
576bool Zaurus::hasHingeSensor() const 576bool Zaurus::hasHingeSensor() const
577{ 577{
578 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000 || d->m_model == Model_Zaurus_SLC1000; 578 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000 || d->m_model == Model_Zaurus_SLC1000;
579} 579}
580 580
581OHingeStatus Zaurus::readHingeSensor() const 581OHingeStatus Zaurus::readHingeSensor() const
582{ 582{
583 if (m_embedix) 583 if (m_embedix)
584 { 584 {
585 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 585 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
586 if (handle == -1) 586 if (handle == -1)
587 { 587 {
588 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror 588 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
589 return CASE_UNKNOWN; 589 return CASE_UNKNOWN;
590 } 590 }
591 else 591 else
592 { 592 {
593 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 593 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
594 ::close (handle); 594 ::close (handle);
595 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) 595 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
596 { 596 {
597 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 597 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
598 return static_cast<OHingeStatus>( retval ); 598 return static_cast<OHingeStatus>( retval );
599 } 599 }
600 else 600 else
601 { 601 {
602 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 602 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
603 return CASE_UNKNOWN; 603 return CASE_UNKNOWN;
604 } 604 }
605 } 605 }
606 } 606 }
607 else 607 else
608 { 608 {
609 // corgi keyboard is event source 0 in OZ kernel 2.6 609 // corgi keyboard is event source 0 in OZ kernel 2.6
610 OInputDevice* keyboard = OInputSystem::instance()->device( "event0" ); 610 OInputDevice* keyboard = OInputSystem::instance()->device( "event0" );
611 if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP0 ) ) return CASE_LANDSCAPE; 611 if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP0 ) ) return CASE_LANDSCAPE;
612 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP1 ) ) return CASE_PORTRAIT; 612 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP1 ) ) return CASE_PORTRAIT;
613 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP2 ) ) return CASE_CLOSED; 613 else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP2 ) ) return CASE_CLOSED;
614 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 614 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
615 return CASE_UNKNOWN; 615 return CASE_UNKNOWN;
616 } 616 }
617} 617}
618 618
619/* 619/*
620 * Take code from iPAQ device. 620 * Take code from iPAQ device.
621 * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction. 621 * That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction.
622 * I hope that is ok - Alwin 622 * I hope that is ok - Alwin
623 */ 623 */
624bool Zaurus::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 624bool Zaurus::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
625{ 625{
626 int newkeycode = keycode; 626 int newkeycode = keycode;
627 627
628 if (d->m_model != Model_Zaurus_SLC7x0 && d->m_model != Model_Zaurus_SLC3000 && d->m_model != Model_Zaurus_SLC1000) return false; 628 if (d->m_model != Model_Zaurus_SLC7x0 && d->m_model != Model_Zaurus_SLC3000 && d->m_model != Model_Zaurus_SLC1000) return false;
629 629
630 /* map cursor keys depending on the hinge status */ 630 /* map cursor keys depending on the hinge status */
631 switch ( keycode ) { 631 switch ( keycode ) {
632 // Rotate cursor keys 632 // Rotate cursor keys
633 case Key_Left : 633 case Key_Left :
634 case Key_Right: 634 case Key_Right:
635 case Key_Up : 635 case Key_Up :
636 case Key_Down : 636 case Key_Down :
637 { 637 {
638 if (rotation()==Rot90) { 638 if (rotation()==Rot90) {
639 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 639 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
640 } 640 }
641 } 641 }
642 break; 642 break;
643 643
644 } 644 }
645 if (newkeycode!=keycode) { 645 if (newkeycode!=keycode) {
646 if ( newkeycode != Key_unknown ) { 646 if ( newkeycode != Key_unknown ) {
647 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 647 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
648 } 648 }
649 return true; 649 return true;
650 } 650 }
651 return false; 651 return false;
652} 652}
653 653
654bool Zaurus::suspend() { 654bool Zaurus::suspend() {
655 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 655 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
656 return false; 656 return false;
657 657
658 bool res = false; 658 bool res = false;
659 OAbstractMobileDevice::sendSuspendmsg(); 659 QCopEnvelope( "QPE/System", "aboutToSuspend()" );
660 660
661 struct timeval tvs, tvn; 661 struct timeval tvs, tvn;
662 ::gettimeofday ( &tvs, 0 ); 662 ::gettimeofday ( &tvs, 0 );
663 663
664 ::sync(); // flush fs caches 664 ::sync(); // flush fs caches
665 res = ( ::system ( "apm --suspend" ) == 0 ); 665 res = ( ::system ( "apm --suspend" ) == 0 );
666 666
667 // This is needed because some apm implementations are asynchronous and we 667 // This is needed because some apm implementations are asynchronous and we
668 // can not be sure when exactly the device is really suspended 668 // can not be sure when exactly the device is really suspended
669 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 669 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
670 // on non embedix eg. 2.6 kernel line apm is synchronous so we don't need it here. 670 // on non embedix eg. 2.6 kernel line apm is synchronous so we don't need it here.
671 671
672 if ( res && m_embedix) { 672 if ( res && m_embedix) {
673 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 673 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
674 ::usleep ( 200 * 1000 ); 674 ::usleep ( 200 * 1000 );
675 ::gettimeofday ( &tvn, 0 ); 675 ::gettimeofday ( &tvn, 0 );
676 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < m_timeOut ); 676 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < m_timeOut );
677 } 677 }
678 678
679 QCopEnvelope( "QPE/System", "returnFromSuspend()" );
680
679 return res; 681 return res;
680} 682}