summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp30
-rw-r--r--libopie2/opiecore/device/odevice_simpad.h2
2 files changed, 23 insertions, 9 deletions
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index 4ae3c4f..ebf0cbb 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -1,371 +1,383 @@
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#include <qwidgetlist.h>
37 38
38/* OPIE */ 39/* OPIE */
39#include <qpe/config.h> 40#include <qpe/config.h>
40#include <qpe/resource.h> 41#include <qpe/resource.h>
41#include <qpe/sound.h> 42#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 43#include <qpe/qcopenvelope_qws.h>
43#include <opie2/okeyfilter.h> 44#include <opie2/okeyfilter.h>
44 45
45/* STD */ 46/* STD */
46#include <fcntl.h> 47#include <fcntl.h>
47#include <math.h> 48#include <math.h>
48#include <stdlib.h> 49#include <stdlib.h>
49#include <signal.h> 50#include <signal.h>
50#include <sys/ioctl.h> 51#include <sys/ioctl.h>
51#include <sys/time.h> 52#include <sys/time.h>
52#include <unistd.h> 53#include <unistd.h>
53#ifndef QT_NO_SOUND 54#ifndef QT_NO_SOUND
54#include <linux/soundcard.h> 55#include <linux/soundcard.h>
55#endif 56#endif
56 57
57using namespace Opie::Core; 58using namespace Opie::Core;
58using namespace Opie::Core::Internal; 59using namespace Opie::Core::Internal;
59 60
60struct s_button simpad_buttons [] = { 61struct s_button simpad_buttons [] = {
61 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 62 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
62 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 63 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
63 "devicebuttons/simpad_lower_up", 64 "devicebuttons/simpad_lower_up",
64 "datebook", "nextView()", 65 "datebook", "nextView()",
65 "today", "raise()" }, 66 "today", "raise()" },
66 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 67 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
67 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 68 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
68 "devicebuttons/simpad_lower_down", 69 "devicebuttons/simpad_lower_down",
69 "addressbook", "raise()", 70 "addressbook", "raise()",
70 "addressbook", "beamBusinessCard()" }, 71 "addressbook", "beamBusinessCard()" },
71 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 72 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
72 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 73 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
73 "devicebuttons/simpad_lower_right", 74 "devicebuttons/simpad_lower_right",
74 "QPE/TaskBar", "toggleMenu()", 75 "QPE/TaskBar", "toggleMenu()",
75 "QPE/TaskBar", "toggleStartMenu()" }, 76 "QPE/TaskBar", "toggleStartMenu()" },
76 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 77 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
77 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 78 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
78 "devicebuttons/simpad_lower_left", 79 "devicebuttons/simpad_lower_left",
79 "opiemail", "raise()", 80 "opiemail", "raise()",
80 "opiemail", "newMail()" }, 81 "opiemail", "newMail()" },
81 82
82 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 83 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
83 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 84 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
84 "devicebuttons/simpad_upper_up", 85 "devicebuttons/simpad_upper_up",
85 "QPE/Launcher", "home()", 86 "QPE/Launcher", "home()",
86 "buttonsettings", "raise()" }, 87 "buttonsettings", "raise()" },
87 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 88 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
88 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 89 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
89 "devicebuttons/simpad_upper_down", 90 "devicebuttons/simpad_upper_down",
90 "addressbook", "raise()", 91 "addressbook", "raise()",
91 "addressbook", "beamBusinessCard()" }, 92 "addressbook", "beamBusinessCard()" },
92 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 93 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
93 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 94 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
94 "devicebuttons/simpad_upper_right", 95 "devicebuttons/simpad_upper_right",
95 "QPE/TaskBar", "toggleMenu()", 96 "QPE/TaskBar", "toggleMenu()",
96 "QPE/TaskBar", "toggleStartMenu()" }, 97 "QPE/TaskBar", "toggleStartMenu()" },
97 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 98 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
98 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 99 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
99 "devicebuttons/simpad_upper_left", 100 "devicebuttons/simpad_upper_left",
100 "QPE/Rotation", "flip()", 101 "QPE/Rotation", "flip()",
101 "QPE/Rotation", "flip()" }, 102 "QPE/Rotation", "flip()" },
102 /* 103 /*
103 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 104 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
104 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 105 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
105 "devicebuttons/simpad_lower_upper", 106 "devicebuttons/simpad_lower_upper",
106 "QPE/Launcher", "home()", 107 "QPE/Launcher", "home()",
107 "buttonsettings", "raise()" }, 108 "buttonsettings", "raise()" },
108 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 109 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
109 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 110 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
110 "devicebuttons/simpad_upper_lower", 111 "devicebuttons/simpad_upper_lower",
111 "QPE/Launcher", "home()", 112 "QPE/Launcher", "home()",
112 "buttonsettings", "raise()" }, 113 "buttonsettings", "raise()" },
113 */ 114 */
114}; 115};
115 116
116void SIMpad::init(const QString&) 117void SIMpad::init(const QString&)
117{ 118{
118 d->m_vendorstr = "SIEMENS"; 119 d->m_vendorstr = "SIEMENS";
119 d->m_vendor = Vendor_SIEMENS; 120 d->m_vendor = Vendor_SIEMENS;
120 121
121 122
122 //TODO Implement model checking 123 //TODO Implement model checking
123 //FIXME For now we assume an SL4 124 //FIXME For now we assume an SL4
124 125
125 d->m_modelstr = "SL4"; 126 d->m_modelstr = "SL4";
126 d->m_model = Model_SIMpad_SL4; 127 d->m_model = Model_SIMpad_SL4;
127 128
128 switch ( d->m_model ) { 129 switch ( d->m_model ) {
129 default: 130 default:
130 d->m_rotation = Rot0; 131 d->m_rotation = Rot0;
131 d->m_direction = CCW; 132 d->m_direction = CCW;
132 d->m_holdtime = 1000; // 1000ms 133 d->m_holdtime = 1000; // 1000ms
133 134
134 break; 135 break;
135 } 136 }
136 137
137 //Distribution detecting code is now in base class 138 //Distribution detecting code is now in base class
138 m_leds [0] = m_leds [1] = Led_Off; 139 m_leds [0] = m_leds [1] = Led_Off;
139 140
140 m_power_timer = 0; 141 m_power_timer = 0;
141 142
142} 143}
143 144
144void SIMpad::initButtons() 145void SIMpad::initButtons()
145{ 146{
146 if ( d->m_buttons ) 147 if ( d->m_buttons )
147 return; 148 return;
148 149
149 d->m_buttons = new QValueList <ODeviceButton>; 150 d->m_buttons = new QValueList <ODeviceButton>;
150 151
151 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 152 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
152 s_button *sb = simpad_buttons + i; 153 s_button *sb = simpad_buttons + i;
153 ODeviceButton b; 154 ODeviceButton b;
154 155
155 if (( sb->model & d->m_model ) == d->m_model ) { 156 if (( sb->model & d->m_model ) == d->m_model ) {
156 b. setKeycode ( sb->code ); 157 b. setKeycode ( sb->code );
157 b. setUserText ( QObject::tr ( "Button", sb->utext )); 158 b. setUserText ( QObject::tr ( "Button", sb->utext ));
158 b. setPixmap ( Resource::loadPixmap ( sb->pix )); 159 b. setPixmap ( Resource::loadPixmap ( sb->pix ));
159 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); 160 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction ));
160 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); 161 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction ));
161 162
162 d->m_buttons->append ( b ); 163 d->m_buttons->append ( b );
163 } 164 }
164 } 165 }
165 reloadButtonMapping(); 166 reloadButtonMapping();
166} 167}
167 168
168// SIMpad boardcontrol register CS3 169// SIMpad boardcontrol register CS3
169#define SIMPAD_BOARDCONTROL "/proc/cs3" 170#define SIMPAD_BOARDCONTROL "/proc/cs3"
170#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 171#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
171#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 172#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
172#define SIMPAD_EN1 0x0004 // This is only for EPROM's 173#define SIMPAD_EN1 0x0004 // This is only for EPROM's
173#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 174#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
174#define SIMPAD_DISPLAY_ON 0x0010 175#define SIMPAD_DISPLAY_ON 0x0010
175#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 176#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
176#define SIMPAD_MQ_RESET 0x0040 177#define SIMPAD_MQ_RESET 0x0040
177#define SIMPAD_PCMCIA_RESET 0x0080 178#define SIMPAD_PCMCIA_RESET 0x0080
178#define SIMPAD_DECT_POWER_ON 0x0100 179#define SIMPAD_DECT_POWER_ON 0x0100
179#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 180#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
180#define SIMPAD_RS232_ON 0x0400 181#define SIMPAD_RS232_ON 0x0400
181#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 182#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
182#define SIMPAD_LED2_ON 0x1000 183#define SIMPAD_LED2_ON 0x1000
183#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 184#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
184#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 185#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
185#define SIMPAD_RESET_SIMCARD 0x8000 186#define SIMPAD_RESET_SIMCARD 0x8000
186 187
187//SIMpad touchscreen backlight strength control 188//SIMpad touchscreen backlight strength control
188#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/backlight" 189#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/backlight"
189 190
190 191
191/* 192/*
192 * The SIMpad exposes ChipSelect3 to userspace 193 * The SIMpad exposes ChipSelect3 to userspace
193 * via a proc filesystem file. Using this register 194 * via a proc filesystem file. Using this register
194 * one can toggle power of serial, irda, dect circuits 195 * one can toggle power of serial, irda, dect circuits
195 * change the video driver and display status and 196 * change the video driver and display status and
196 * many more things. 197 * many more things.
197 * To not lose the current setting we read the current 198 * To not lose the current setting we read the current
198 * cs3 setting and toggle the necessary bits and then 199 * cs3 setting and toggle the necessary bits and then
199 * write it. 200 * write it.
200 */ 201 */
201static bool setCS3Bit( bool bitset, int bit ) { 202static bool setCS3Bit( bool bitset, int bit ) {
202 int cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_RDONLY ); 203 int cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_RDONLY );
203 204
204 if ( cs3_fd < 0 ) 205 if ( cs3_fd < 0 )
205 return false; 206 return false;
206 207
207 static char line[32]; 208 static char line[32];
208 int val = 0; 209 int val = 0;
209 bool ok = false; 210 bool ok = false;
210 211
211 /* 212 /*
212 * try to read and parse the Chipselect3 status 213 * try to read and parse the Chipselect3 status
213 * be paranoid and make sure line[31] is null 214 * be paranoid and make sure line[31] is null
214 * terminated 215 * terminated
215 */ 216 */
216 while( !ok && ::read(cs3_fd, &line, sizeof(line)) > 0 ) { 217 while( !ok && ::read(cs3_fd, &line, sizeof(line)) > 0 ) {
217 line[31] = '\0'; 218 line[31] = '\0';
218 if (::sscanf(line, "Chipselect3 : %x", &val )) 219 if (::sscanf(line, "Chipselect3 : %x", &val ))
219 ok = true; 220 ok = true;
220 } 221 }
221 222
222 ::close(cs3_fd); 223 ::close(cs3_fd);
223 224
224 /* 225 /*
225 * we were not able to find the current value 226 * we were not able to find the current value
226 * and as a result we won't set it 227 * and as a result we won't set it
227 */ 228 */
228 if ( !ok ) 229 if ( !ok )
229 return false; 230 return false;
230 231
231 /* 232 /*
232 * change the value 233 * change the value
233 */ 234 */
234 val = bitset ? (val | bit) : (val & ~bit); 235 val = bitset ? (val | bit) : (val & ~bit);
235 236
236 /* 237 /*
237 * write it back 238 * write it back
238 */ 239 */
239 cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_WRONLY ); 240 cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_WRONLY );
240 if ( cs3_fd < 0 ) 241 if ( cs3_fd < 0 )
241 return false; 242 return false;
242 243
243 ::snprintf(line, sizeof(line), "0x%04x\n", val); 244 ::snprintf(line, sizeof(line), "0x%04x\n", val);
244 ::write(cs3_fd, line, strlen(line)); 245 ::write(cs3_fd, line, strlen(line));
245 ::close(cs3_fd); 246 ::close(cs3_fd);
246 247
247 return true; 248 return true;
248} 249}
249 250
250 251
251QValueList <OLed> SIMpad::ledList() const 252QValueList <OLed> SIMpad::ledList() const
252{ 253{
253 QValueList <OLed> vl; 254 QValueList <OLed> vl;
254 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 255 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
255 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 256 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
256 return vl; 257 return vl;
257} 258}
258 259
259QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 260QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
260{ 261{
261 QValueList <OLedState> vl; 262 QValueList <OLedState> vl;
262 263
263 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 264 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
264 vl << Led_Off << Led_On; 265 vl << Led_Off << Led_On;
265 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 266 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
266 //vl << Led_Off; 267 //vl << Led_Off;
267 return vl; 268 return vl;
268} 269}
269 270
270OLedState SIMpad::ledState ( OLed l ) const 271OLedState SIMpad::ledState ( OLed l ) const
271{ 272{
272 switch ( l ) { 273 switch ( l ) {
273 case Led_Power: 274 case Led_Power:
274 return m_leds [0]; 275 return m_leds [0];
275 //case Led_Mail: 276 //case Led_Mail:
276 // return m_leds [1]; 277 // return m_leds [1];
277 default: 278 default:
278 return Led_Off; 279 return Led_Off;
279 } 280 }
280} 281}
281 282
282bool SIMpad::setLedState ( OLed l, OLedState st ) 283bool SIMpad::setLedState ( OLed l, OLedState st )
283{ 284{
284 if ( l == Led_Power ) { 285 if ( l == Led_Power ) {
285 m_leds [0] = st; 286 m_leds [0] = st;
286 setCS3Bit(st == Led_On, SIMPAD_LED2_ON); 287 setCS3Bit(st == Led_On, SIMPAD_LED2_ON);
287 return true; 288 return true;
288 } 289 }
289 290
290 return false; 291 return false;
291} 292}
292 293
293void SIMpad::timerEvent ( QTimerEvent * ) 294void SIMpad::timerEvent ( QTimerEvent * )
294{ 295{
295 killTimer ( m_power_timer ); 296 killTimer ( m_power_timer );
296 m_power_timer = 0; 297 m_power_timer = 0;
297 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 298 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
298 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 299 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
299} 300}
300 301
301 302
302void SIMpad::playAlarmSound() 303void SIMpad::playAlarmSound()
303{ 304{
304#ifndef QT_NO_SOUND 305#ifndef QT_NO_SOUND
305 static Sound snd ( "alarm" ); 306 static Sound snd ( "alarm" );
306 if(!snd.isFinished()) 307 if(!snd.isFinished())
307 return; 308 return;
308 309
309 /* save as the Sound is static! */ 310 /* save as the Sound is static! */
310 changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); 311 changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd);
311 snd. play(); 312 snd. play();
312#endif 313#endif
313} 314}
314 315
315 316
316bool SIMpad::suspend() // Must override because SIMpad does NOT have apm 317bool SIMpad::suspend() // Must override because SIMpad does NOT have apm
317{ 318{
318 qDebug( "ODevice for SIMpad: suspend()" );
319 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 319 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
320 return false; 320 return false;
321 321
322 /*
323 * we need to save the screen content
324 * then go to suspend using ODevice::suspend
325 * and finally restore the screen content
326 */
327 (void)::system( "cat /dev/fb/0 > /tmp/.buffer" );
328 bool res = ODevice::suspend(); 322 bool res = ODevice::suspend();
329 323
330 /* 324 /*
331 * restore 325 * restore the screen content if we really
326 * supended the device
332 */ 327 */
333 if ( res ) 328 if ( res )
334 ::system( "cat /tmp/.buffer > /dev/fb/0" ); 329 updateAllWidgets();
335 330
336 return res; 331 return res;
337} 332}
338 333
339bool SIMpad::setDisplayStatus ( bool on ) 334bool SIMpad::setDisplayStatus ( bool on )
340{ 335{
341 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 336 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
342 337
343 return setCS3Bit(on, SIMPAD_DISPLAY_ON); 338 return setCS3Bit(on, SIMPAD_DISPLAY_ON);
344} 339}
345 340
346 341
347bool SIMpad::setDisplayBrightness ( int bright ) 342bool SIMpad::setDisplayBrightness ( int bright )
348{ 343{
349 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 344 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
350 bool res = false; 345 bool res = false;
351 int fd; 346 int fd;
352 347
353 if ( bright > 255 ) 348 if ( bright > 255 )
354 bright = 255; 349 bright = 255;
355 if ( bright < 1 ) 350 if ( bright < 1 )
356 bright = 0; 351 bright = 0;
357 352
358 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 353 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
359 QCString str = QFile::encodeName( QString::number(bright)); 354 QCString str = QFile::encodeName( QString::number(bright));
360 res = ( ::write(fd, str, str.length()) != -1 ); 355 res = ( ::write(fd, str, str.length()) != -1 );
361 ::close ( fd ); 356 ::close ( fd );
362 } 357 }
363 return res; 358 return res;
364} 359}
365 360
366 361
367int SIMpad::displayBrightnessResolution() const 362int SIMpad::displayBrightnessResolution() const
368{ 363{
369 return 255; // All SIMpad models share the same display 364 return 255; // All SIMpad models share the same display
370} 365}
371 366
367
368/*
369 * The MQ200 DRAM content is lost during suspend
370 * so we will just repaint every widget on resume
371 */
372void SIMpad::updateAllWidgets() {
373 QWidgetList *list = QApplication::allWidgets();
374 QWidgetListIt it( *list );
375 QWidget *wid;
376
377 while ((wid=it.current()) != 0 ) {
378 wid->update();
379 ++it;
380 }
381
382 delete list;
383}
diff --git a/libopie2/opiecore/device/odevice_simpad.h b/libopie2/opiecore/device/odevice_simpad.h
index dbcbbb4..c25b911 100644
--- a/libopie2/opiecore/device/odevice_simpad.h
+++ b/libopie2/opiecore/device/odevice_simpad.h
@@ -1,85 +1,87 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003, 2004 The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) 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#ifndef ODEVICE_SIMPAD 30#ifndef ODEVICE_SIMPAD
31#define ODEVICE_SIMPAD 31#define ODEVICE_SIMPAD
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34 34
35/* QT */ 35/* QT */
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38namespace Opie { 38namespace Opie {
39namespace Core { 39namespace Core {
40namespace Internal { 40namespace Internal {
41 41
42class SIMpad : public ODevice 42class SIMpad : public ODevice
43{ 43{
44 protected: 44 protected:
45 virtual void init(const QString&); 45 virtual void init(const QString&);
46 virtual void initButtons(); 46 virtual void initButtons();
47 47
48 public: 48 public:
49 virtual bool suspend(); 49 virtual bool suspend();
50 50
51 virtual bool setDisplayStatus( bool on ); 51 virtual bool setDisplayStatus( bool on );
52 virtual bool setDisplayBrightness( int b ); 52 virtual bool setDisplayBrightness( int b );
53 virtual int displayBrightnessResolution() const; 53 virtual int displayBrightnessResolution() const;
54 54
55 virtual void playAlarmSound(); 55 virtual void playAlarmSound();
56 56
57 virtual QValueList <OLed> ledList() const; 57 virtual QValueList <OLed> ledList() const;
58 virtual QValueList <OLedState> ledStateList( OLed led ) const; 58 virtual QValueList <OLedState> ledStateList( OLed led ) const;
59 virtual OLedState ledState( OLed led ) const; 59 virtual OLedState ledState( OLed led ) const;
60 virtual bool setLedState( OLed led, OLedState st ); 60 virtual bool setLedState( OLed led, OLedState st );
61 61
62protected: 62protected:
63 virtual void timerEvent( QTimerEvent *te ); 63 virtual void timerEvent( QTimerEvent *te );
64 64
65 int m_power_timer; 65 int m_power_timer;
66 66
67 OLedState m_leds [2]; 67 OLedState m_leds [2];
68private:
69 static void updateAllWidgets();
68}; 70};
69 71
70struct s_button { 72struct s_button {
71 uint model; 73 uint model;
72 Qt::Key code; 74 Qt::Key code;
73 char *utext; 75 char *utext;
74 char *pix; 76 char *pix;
75 char *fpressedservice; 77 char *fpressedservice;
76 char *fpressedaction; 78 char *fpressedaction;
77 char *fheldservice; 79 char *fheldservice;
78 char *fheldaction; 80 char *fheldaction;
79}; 81};
80 82
81} 83}
82} 84}
83} 85}
84 86
85#endif 87#endif