summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice_simpad.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/device/odevice_simpad.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index 31b9297..90aca2f 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -1,384 +1,384 @@
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 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; 56using namespace Opie;
57 57
58struct s_button simpad_buttons [] = { 58struct s_button simpad_buttons [] = {
59 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 59 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
60 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 60 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
61 "devicebuttons/simpad_lower_up", 61 "devicebuttons/simpad_lower_up",
62 "datebook", "nextView()", 62 "datebook", "nextView()",
63 "today", "raise()" }, 63 "today", "raise()" },
64 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 64 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
65 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 65 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
66 "devicebuttons/simpad_lower_down", 66 "devicebuttons/simpad_lower_down",
67 "addressbook", "raise()", 67 "addressbook", "raise()",
68 "addressbook", "beamBusinessCard()" }, 68 "addressbook", "beamBusinessCard()" },
69 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 69 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
70 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 70 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
71 "devicebuttons/simpad_lower_right", 71 "devicebuttons/simpad_lower_right",
72 "QPE/TaskBar", "toggleMenu()", 72 "QPE/TaskBar", "toggleMenu()",
73 "QPE/TaskBar", "toggleStartMenu()" }, 73 "QPE/TaskBar", "toggleStartMenu()" },
74 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 74 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
75 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 75 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
76 "devicebuttons/simpad_lower_left", 76 "devicebuttons/simpad_lower_left",
77 "mail", "raise()", 77 "mail", "raise()",
78 "mail", "newMail()" }, 78 "mail", "newMail()" },
79 79
80 { 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,
81 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 81 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
82 "devicebuttons/simpad_upper_up", 82 "devicebuttons/simpad_upper_up",
83 "QPE/Launcher", "home()", 83 "QPE/Launcher", "home()",
84 "buttonsettings", "raise()" }, 84 "buttonsettings", "raise()" },
85 { 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,
86 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 86 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
87 "devicebuttons/simpad_upper_down", 87 "devicebuttons/simpad_upper_down",
88 "addressbook", "raise()", 88 "addressbook", "raise()",
89 "addressbook", "beamBusinessCard()" }, 89 "addressbook", "beamBusinessCard()" },
90 { 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,
91 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 91 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
92 "devicebuttons/simpad_upper_right", 92 "devicebuttons/simpad_upper_right",
93 "QPE/TaskBar", "toggleMenu()", 93 "QPE/TaskBar", "toggleMenu()",
94 "QPE/TaskBar", "toggleStartMenu()" }, 94 "QPE/TaskBar", "toggleStartMenu()" },
95 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 95 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
96 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 96 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
97 "devicebuttons/simpad_upper_left", 97 "devicebuttons/simpad_upper_left",
98 "QPE/Rotation", "flip()", 98 "QPE/Rotation", "flip()",
99 "QPE/Rotation", "flip()" }, 99 "QPE/Rotation", "flip()" },
100 /* 100 /*
101 { 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,
102 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 102 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
103 "devicebuttons/simpad_lower_upper", 103 "devicebuttons/simpad_lower_upper",
104 "QPE/Launcher", "home()", 104 "QPE/Launcher", "home()",
105 "buttonsettings", "raise()" }, 105 "buttonsettings", "raise()" },
106 { 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,
107 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 107 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
108 "devicebuttons/simpad_upper_lower", 108 "devicebuttons/simpad_upper_lower",
109 "QPE/Launcher", "home()", 109 "QPE/Launcher", "home()",
110 "buttonsettings", "raise()" }, 110 "buttonsettings", "raise()" },
111 */ 111 */
112}; 112};
113 113
114void SIMpad::init() 114void SIMpad::init()
115{ 115{
116 d->m_vendorstr = "SIEMENS"; 116 d->m_vendorstr = "SIEMENS";
117 d->m_vendor = Vendor_SIEMENS; 117 d->m_vendor = Vendor_SIEMENS;
118 118
119 QFile f ( "/proc/hal/model" ); 119 QFile f ( "/proc/hal/model" );
120 120
121 //TODO Implement model checking 121 //TODO Implement model checking
122 //FIXME For now we assume an SL4 122 //FIXME For now we assume an SL4
123 123
124 d->m_modelstr = "SL4"; 124 d->m_modelstr = "SL4";
125 d->m_model = Model_SIMpad_SL4; 125 d->m_model = Model_SIMpad_SL4;
126 126
127 switch ( d->m_model ) { 127 switch ( d->m_model ) {
128 default: 128 default:
129 d->m_rotation = Rot0; 129 d->m_rotation = Rot0;
130 d->m_direction = CCW; 130 d->m_direction = CCW;
131 d->m_holdtime = 1000; // 1000ms 131 d->m_holdtime = 1000; // 1000ms
132 132
133 break; 133 break;
134 } 134 }
135 135
136 f. setName ( "/etc/familiar-version" ); 136 f. setName ( "/etc/familiar-version" );
137 if ( f. open ( IO_ReadOnly )) { 137 if ( f. open ( IO_ReadOnly )) {
138 d->m_systemstr = "Familiar"; 138 d->m_systemstr = "Familiar";
139 d->m_system = System_Familiar; 139 d->m_system = System_Familiar;
140 140
141 QTextStream ts ( &f ); 141 QTextStream ts ( &f );
142 d->m_sysverstr = ts. readLine(). mid ( 10 ); 142 d->m_sysverstr = ts. readLine(). mid ( 10 );
143 143
144 f. close(); 144 f. close();
145 } else { 145 } else {
146 f. setName ( "/etc/oz_version" ); 146 f. setName ( "/etc/oz_version" );
147 147
148 if ( f. open ( IO_ReadOnly )) { 148 if ( f. open ( IO_ReadOnly )) {
149 d->m_systemstr = "OpenEmbedded/SIMpad"; 149 d->m_systemstr = "OpenEmbedded/SIMpad";
150 d->m_system = System_OpenZaurus; 150 d->m_system = System_OpenZaurus;
151 151
152 QTextStream ts ( &f ); 152 QTextStream ts ( &f );
153 ts.setDevice ( &f ); 153 ts.setDevice ( &f );
154 d->m_sysverstr = ts. readLine(); 154 d->m_sysverstr = ts. readLine();
155 f. close(); 155 f. close();
156 } 156 }
157 } 157 }
158 158
159 m_leds [0] = m_leds [1] = Led_Off; 159 m_leds [0] = m_leds [1] = Led_Off;
160 160
161 m_power_timer = 0; 161 m_power_timer = 0;
162 162
163} 163}
164 164
165void SIMpad::initButtons() 165void SIMpad::initButtons()
166{ 166{
167 if ( d->m_buttons ) 167 if ( d->m_buttons )
168 return; 168 return;
169 169
170 if ( isQWS( ) ) 170 if ( isQWS( ) )
171 QWSServer::setKeyboardFilter ( this ); 171 QWSServer::setKeyboardFilter ( this );
172 172
173 d->m_buttons = new QValueList <ODeviceButton>; 173 d->m_buttons = new QValueList <ODeviceButton>;
174 174
175 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 175 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
176 s_button *sb = simpad_buttons + i; 176 s_button *sb = simpad_buttons + i;
177 ODeviceButton b; 177 ODeviceButton b;
178 178
179 if (( sb->model & d->m_model ) == d->m_model ) { 179 if (( sb->model & d->m_model ) == d->m_model ) {
180 b. setKeycode ( sb->code ); 180 b. setKeycode ( sb->code );
181 b. setUserText ( QObject::tr ( "Button", sb->utext )); 181 b. setUserText ( QObject::tr ( "Button", sb->utext ));
182 b. setPixmap ( Resource::loadPixmap ( sb->pix )); 182 b. setPixmap ( Resource::loadPixmap ( sb->pix ));
183 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); 183 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction ));
184 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); 184 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction ));
185 185
186 d->m_buttons->append ( b ); 186 d->m_buttons->append ( b );
187 } 187 }
188 } 188 }
189 reloadButtonMapping(); 189 reloadButtonMapping();
190 190
191 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 191 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
192 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 192 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
193} 193}
194 194
195// SIMpad boardcontrol register CS3 195// SIMpad boardcontrol register CS3
196#define SIMPAD_BOARDCONTROL "/proc/cs3" 196#define SIMPAD_BOARDCONTROL "/proc/cs3"
197#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 197#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
198#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 198#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
199#define SIMPAD_EN1 0x0004 // This is only for EPROM's 199#define SIMPAD_EN1 0x0004 // This is only for EPROM's
200#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 200#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
201#define SIMPAD_DISPLAY_ON 0x0010 201#define SIMPAD_DISPLAY_ON 0x0010
202#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 202#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
203#define SIMPAD_MQ_RESET 0x0040 203#define SIMPAD_MQ_RESET 0x0040
204#define SIMPAD_PCMCIA_RESET 0x0080 204#define SIMPAD_PCMCIA_RESET 0x0080
205#define SIMPAD_DECT_POWER_ON 0x0100 205#define SIMPAD_DECT_POWER_ON 0x0100
206#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 206#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
207#define SIMPAD_RS232_ON 0x0400 207#define SIMPAD_RS232_ON 0x0400
208#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 208#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
209#define SIMPAD_LED2_ON 0x1000 209#define SIMPAD_LED2_ON 0x1000
210#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 210#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
211#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 211#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
212#define SIMPAD_RESET_SIMCARD 0x8000 212#define SIMPAD_RESET_SIMCARD 0x8000
213 213
214//SIMpad touchscreen backlight strength control 214//SIMpad touchscreen backlight strength control
215#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" 215#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
216#define SIMPAD_BACKLIGHT_MASK 0x00a10044 216#define SIMPAD_BACKLIGHT_MASK 0x00a10044
217 217
218QValueList <OLed> SIMpad::ledList() const 218QValueList <OLed> SIMpad::ledList() const
219{ 219{
220 QValueList <OLed> vl; 220 QValueList <OLed> vl;
221 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 221 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
222 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 222 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
223 return vl; 223 return vl;
224} 224}
225 225
226QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 226QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
227{ 227{
228 QValueList <OLedState> vl; 228 QValueList <OLedState> vl;
229 229
230 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 230 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
231 vl << Led_Off << Led_On; 231 vl << Led_Off << Led_On;
232 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 232 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
233 //vl << Led_Off; 233 //vl << Led_Off;
234 return vl; 234 return vl;
235} 235}
236 236
237OLedState SIMpad::ledState ( OLed l ) const 237OLedState SIMpad::ledState ( OLed l ) const
238{ 238{
239 switch ( l ) { 239 switch ( l ) {
240 case Led_Power: 240 case Led_Power:
241 return m_leds [0]; 241 return m_leds [0];
242 //case Led_Mail: 242 //case Led_Mail:
243 //return m_leds [1]; 243 //return m_leds [1];
244 default: 244 default:
245 return Led_Off; 245 return Led_Off;
246 } 246 }
247} 247}
248 248
249bool SIMpad::setLedState ( OLed l, OLedState st ) 249bool SIMpad::setLedState ( OLed l, OLedState st )
250{ 250{
251#if 0 251#if 0
252 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); 252 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
253 253
254 /*TODO Implement this like that: 254 /*TODO Implement this like that:
255 read from cs3 255 read from cs3
256 && with SIMPAD_LED2_ON 256 && with SIMPAD_LED2_ON
257 write to cs3 */ 257 write to cs3 */
258 m_leds [0] = st; 258 m_leds [0] = st;
259 return true; 259 return true;
260 } 260 }
261 } 261 }
262 } 262 }
263 263
264#endif 264#endif
265 return false; 265 return false;
266} 266}
267 267
268 268
269bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 269bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
270{ 270{
271 //TODO 271 //TODO
272 return false; 272 return false;
273} 273}
274 274
275void SIMpad::timerEvent ( QTimerEvent * ) 275void SIMpad::timerEvent ( QTimerEvent * )
276{ 276{
277 killTimer ( m_power_timer ); 277 killTimer ( m_power_timer );
278 m_power_timer = 0; 278 m_power_timer = 0;
279 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 279 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
280 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 280 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
281} 281}
282 282
283 283
284void SIMpad::playAlarmSound() 284void SIMpad::playAlarmSound()
285{ 285{
286#ifndef QT_NO_SOUND 286#ifndef QT_NO_SOUND
287 static Sound snd ( "alarm" ); 287 static Sound snd ( "alarm" );
288 int fd; 288 int fd;
289 int vol; 289 int vol;
290 bool vol_reset = false; 290 bool vol_reset = false;
291 291
292 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 292 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
293 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 293 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
294 Config cfg ( "qpe" ); 294 Config cfg ( "qpe" );
295 cfg. setGroup ( "Volume" ); 295 cfg. setGroup ( "Volume" );
296 296
297 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 297 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
298 if ( volalarm < 0 ) 298 if ( volalarm < 0 )
299 volalarm = 0; 299 volalarm = 0;
300 else if ( volalarm > 100 ) 300 else if ( volalarm > 100 )
301 volalarm = 100; 301 volalarm = 100;
302 volalarm |= ( volalarm << 8 ); 302 volalarm |= ( volalarm << 8 );
303 303
304 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 304 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
305 vol_reset = true; 305 vol_reset = true;
306 } 306 }
307 } 307 }
308 308
309 snd. play(); 309 snd. play();
310 while ( !snd. isFinished()) 310 while ( !snd. isFinished())
311 qApp->processEvents(); 311 qApp->processEvents();
312 312
313 if ( fd >= 0 ) { 313 if ( fd >= 0 ) {
314 if ( vol_reset ) 314 if ( vol_reset )
315 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 315 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
316 ::close ( fd ); 316 ::close ( fd );
317 } 317 }
318#endif 318#endif
319} 319}
320 320
321 321
322bool SIMpad::suspend() // Must override because SIMpad does NOT have apm 322bool SIMpad::suspend() // Must override because SIMpad does NOT have apm
323{ 323{
324 qDebug( "ODevice for SIMpad: suspend()" ); 324 qDebug( "ODevice for SIMpad: suspend()" );
325 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 325 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
326 return false; 326 return false;
327 327
328 bool res = false; 328 bool res = false;
329 ODevice::sendSuspendmsg(); 329 ODevice::sendSuspendmsg();
330 330
331 struct timeval tvs, tvn; 331 struct timeval tvs, tvn;
332 ::gettimeofday ( &tvs, 0 ); 332 ::gettimeofday ( &tvs, 0 );
333 333
334 ::sync(); // flush fs caches 334 ::sync(); // flush fs caches
335 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) 335 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :)
336 336
337 return res; 337 return res;
338} 338}
339 339
340 340
341bool SIMpad::setSoftSuspend ( bool soft ) 341bool SIMpad::setSoftSuspend ( bool soft )
342{ 342{
343 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 343 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
344 return false; 344 return false;
345} 345}
346 346
347 347
348bool SIMpad::setDisplayStatus ( bool on ) 348bool SIMpad::setDisplayStatus ( bool on )
349{ 349{
350 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 350 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
351 351
352 bool res = false; 352 bool res = false;
353 int fd; 353 int fd;
354 354
355 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 355 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
356 356
357 res = ( ::system( (const char*) cmdline ) == 0 ); 357 res = ( ::system( (const char*) cmdline ) == 0 );
358 358
359 return res; 359 return res;
360} 360}
361 361
362 362
363bool SIMpad::setDisplayBrightness ( int bright ) 363bool SIMpad::setDisplayBrightness ( int bright )
364{ 364{
365 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 365 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
366 bool res = false; 366 bool res = false;
367 int fd; 367 int fd;
368 368
369 if ( bright > 255 ) 369 if ( bright > 255 )
370 bright = 255; 370 bright = 255;
371 if ( bright < 1 ) 371 if ( bright < 1 )
372 bright = 0; 372 bright = 0;
373 373
374 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 374 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
375 int value = 255 - bright; 375 int value = 255 - bright;
376 const int mask = SIMPAD_BACKLIGHT_MASK; 376 const int mask = SIMPAD_BACKLIGHT_MASK;
377 value = value << 8; 377 value = value << 8;
378 value += mask; 378 value += mask;
379 char writeCommand[100]; 379 char writeCommand[100];
380 const int count = sprintf( writeCommand, "0x%x\n", value ); 380 const int count = sprintf( writeCommand, "0x%x\n", value );
381 res = ( ::write ( fd, writeCommand, count ) != -1 ); 381 res = ( ::write ( fd, writeCommand, count ) != -1 );
382 ::close ( fd ); 382 ::close ( fd );
383 } 383 }
384 return res; 384 return res;