-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp index 76f03a0..e62ea18 100644 --- a/libopie2/opiecore/device/odevice_simpad.cpp +++ b/libopie2/opiecore/device/odevice_simpad.cpp | |||
@@ -102,269 +102,269 @@ struct s_button simpad_buttons [] = { | |||
102 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 102 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
103 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 103 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
104 | "devicebuttons/simpad_lower_upper", | 104 | "devicebuttons/simpad_lower_upper", |
105 | "QPE/Launcher", "home()", | 105 | "QPE/Launcher", "home()", |
106 | "buttonsettings", "raise()" }, | 106 | "buttonsettings", "raise()" }, |
107 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 107 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
108 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 108 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
109 | "devicebuttons/simpad_upper_lower", | 109 | "devicebuttons/simpad_upper_lower", |
110 | "QPE/Launcher", "home()", | 110 | "QPE/Launcher", "home()", |
111 | "buttonsettings", "raise()" }, | 111 | "buttonsettings", "raise()" }, |
112 | */ | 112 | */ |
113 | }; | 113 | }; |
114 | 114 | ||
115 | void SIMpad::init(const QString&) | 115 | void SIMpad::init(const QString&) |
116 | { | 116 | { |
117 | d->m_vendorstr = "SIEMENS"; | 117 | d->m_vendorstr = "SIEMENS"; |
118 | d->m_vendor = Vendor_SIEMENS; | 118 | d->m_vendor = Vendor_SIEMENS; |
119 | 119 | ||
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 | //Distribution detecting code is now in base class | 136 | //Distribution detecting code is now in base class |
137 | m_leds [0] = m_leds [1] = Led_Off; | 137 | m_leds [0] = m_leds [1] = Led_Off; |
138 | 138 | ||
139 | m_power_timer = 0; | 139 | m_power_timer = 0; |
140 | 140 | ||
141 | } | 141 | } |
142 | 142 | ||
143 | void SIMpad::initButtons() | 143 | void SIMpad::initButtons() |
144 | { | 144 | { |
145 | if ( d->m_buttons ) | 145 | if ( d->m_buttons ) |
146 | return; | 146 | return; |
147 | 147 | ||
148 | if ( isQWS( ) ) | 148 | if ( isQWS( ) ) |
149 | QWSServer::setKeyboardFilter ( this ); | 149 | QWSServer::setKeyboardFilter ( this ); |
150 | 150 | ||
151 | d->m_buttons = new QValueList <ODeviceButton>; | 151 | d->m_buttons = new QValueList <ODeviceButton>; |
152 | 152 | ||
153 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { | 153 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { |
154 | s_button *sb = simpad_buttons + i; | 154 | s_button *sb = simpad_buttons + i; |
155 | ODeviceButton b; | 155 | ODeviceButton b; |
156 | 156 | ||
157 | if (( sb->model & d->m_model ) == d->m_model ) { | 157 | if (( sb->model & d->m_model ) == d->m_model ) { |
158 | b. setKeycode ( sb->code ); | 158 | b. setKeycode ( sb->code ); |
159 | b. setUserText ( QObject::tr ( "Button", sb->utext )); | 159 | b. setUserText ( QObject::tr ( "Button", sb->utext )); |
160 | b. setPixmap ( Resource::loadPixmap ( sb->pix )); | 160 | b. setPixmap ( Resource::loadPixmap ( sb->pix )); |
161 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); | 161 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); |
162 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); | 162 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); |
163 | 163 | ||
164 | d->m_buttons->append ( b ); | 164 | d->m_buttons->append ( b ); |
165 | } | 165 | } |
166 | } | 166 | } |
167 | reloadButtonMapping(); | 167 | reloadButtonMapping(); |
168 | 168 | ||
169 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 169 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
170 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 170 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
171 | } | 171 | } |
172 | 172 | ||
173 | // SIMpad boardcontrol register CS3 | 173 | // SIMpad boardcontrol register CS3 |
174 | #define SIMPAD_BOARDCONTROL "/proc/cs3" | 174 | #define SIMPAD_BOARDCONTROL "/proc/cs3" |
175 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA | 175 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA |
176 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA | 176 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA |
177 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's | 177 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's |
178 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V | 178 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V |
179 | #define SIMPAD_DISPLAY_ON 0x0010 | 179 | #define SIMPAD_DISPLAY_ON 0x0010 |
180 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 | 180 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 |
181 | #define SIMPAD_MQ_RESET 0x0040 | 181 | #define SIMPAD_MQ_RESET 0x0040 |
182 | #define SIMPAD_PCMCIA_RESET 0x0080 | 182 | #define SIMPAD_PCMCIA_RESET 0x0080 |
183 | #define SIMPAD_DECT_POWER_ON 0x0100 | 183 | #define SIMPAD_DECT_POWER_ON 0x0100 |
184 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave | 184 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave |
185 | #define SIMPAD_RS232_ON 0x0400 | 185 | #define SIMPAD_RS232_ON 0x0400 |
186 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave | 186 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave |
187 | #define SIMPAD_LED2_ON 0x1000 | 187 | #define SIMPAD_LED2_ON 0x1000 |
188 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode | 188 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode |
189 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit | 189 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit |
190 | #define SIMPAD_RESET_SIMCARD 0x8000 | 190 | #define SIMPAD_RESET_SIMCARD 0x8000 |
191 | 191 | ||
192 | //SIMpad touchscreen backlight strength control | 192 | //SIMpad touchscreen backlight strength control |
193 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" | 193 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" |
194 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 | 194 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 |
195 | 195 | ||
196 | QValueList <OLed> SIMpad::ledList() const | 196 | QValueList <OLed> SIMpad::ledList() const |
197 | { | 197 | { |
198 | QValueList <OLed> vl; | 198 | QValueList <OLed> vl; |
199 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? | 199 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? |
200 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway | 200 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway |
201 | return vl; | 201 | return vl; |
202 | } | 202 | } |
203 | 203 | ||
204 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const | 204 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const |
205 | { | 205 | { |
206 | QValueList <OLedState> vl; | 206 | QValueList <OLedState> vl; |
207 | 207 | ||
208 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? | 208 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? |
209 | vl << Led_Off << Led_On; | 209 | vl << Led_Off << Led_On; |
210 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway | 210 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway |
211 | //vl << Led_Off; | 211 | //vl << Led_Off; |
212 | return vl; | 212 | return vl; |
213 | } | 213 | } |
214 | 214 | ||
215 | OLedState SIMpad::ledState ( OLed l ) const | 215 | OLedState SIMpad::ledState ( OLed l ) const |
216 | { | 216 | { |
217 | switch ( l ) { | 217 | switch ( l ) { |
218 | case Led_Power: | 218 | case Led_Power: |
219 | return m_leds [0]; | 219 | return m_leds [0]; |
220 | //case Led_Mail: | 220 | //case Led_Mail: |
221 | //return m_leds [1]; | 221 | //return m_leds [1]; |
222 | default: | 222 | default: |
223 | return Led_Off; | 223 | return Led_Off; |
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||
227 | bool SIMpad::setLedState ( OLed l, OLedState st ) | 227 | bool SIMpad::setLedState ( OLed l, OLedState st ) |
228 | { | 228 | { |
229 | #if 0 | 229 | #if 0 |
230 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); | 230 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); |
231 | 231 | ||
232 | /*TODO Implement this like that: | 232 | /*TODO Implement this like that: |
233 | read from cs3 | 233 | read from cs3 |
234 | && with SIMPAD_LED2_ON | 234 | && with SIMPAD_LED2_ON |
235 | write to cs3 */ | 235 | write to cs3 */ |
236 | m_leds [0] = st; | 236 | m_leds [0] = st; |
237 | return true; | 237 | return true; |
238 | } | 238 | } |
239 | } | 239 | } |
240 | } | 240 | } |
241 | 241 | ||
242 | #endif | 242 | #endif |
243 | return false; | 243 | return false; |
244 | } | 244 | } |
245 | 245 | ||
246 | 246 | ||
247 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 247 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
248 | { | 248 | { |
249 | //TODO | 249 | //TODO |
250 | return false; | 250 | return false; |
251 | } | 251 | } |
252 | 252 | ||
253 | void SIMpad::timerEvent ( QTimerEvent * ) | 253 | void SIMpad::timerEvent ( QTimerEvent * ) |
254 | { | 254 | { |
255 | killTimer ( m_power_timer ); | 255 | killTimer ( m_power_timer ); |
256 | m_power_timer = 0; | 256 | m_power_timer = 0; |
257 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 257 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
258 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 258 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
259 | } | 259 | } |
260 | 260 | ||
261 | 261 | ||
262 | void SIMpad::playAlarmSound() | 262 | void SIMpad::playAlarmSound() |
263 | { | 263 | { |
264 | #ifndef QT_NO_SOUND | 264 | #ifndef QT_NO_SOUND |
265 | static Sound snd ( "alarm" ); | 265 | static Sound snd ( "alarm" ); |
266 | int fd; | 266 | int fd; |
267 | int vol; | 267 | int vol; |
268 | bool vol_reset = false; | 268 | bool vol_reset = false; |
269 | 269 | ||
270 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 270 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
271 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 271 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
272 | Config cfg ( "qpe" ); | 272 | Config cfg ( "qpe" ); |
273 | cfg. setGroup ( "Volume" ); | 273 | cfg. setGroup ( "Volume" ); |
274 | 274 | ||
275 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 275 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
276 | if ( volalarm < 0 ) | 276 | if ( volalarm < 0 ) |
277 | volalarm = 0; | 277 | volalarm = 0; |
278 | else if ( volalarm > 100 ) | 278 | else if ( volalarm > 100 ) |
279 | volalarm = 100; | 279 | volalarm = 100; |
280 | volalarm |= ( volalarm << 8 ); | 280 | volalarm |= ( volalarm << 8 ); |
281 | 281 | ||
282 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 282 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
283 | vol_reset = true; | 283 | vol_reset = true; |
284 | } | 284 | } |
285 | } | 285 | } |
286 | 286 | ||
287 | snd. play(); | 287 | snd. play(); |
288 | while ( !snd. isFinished()) | 288 | while ( !snd. isFinished()) |
289 | qApp->processEvents(); | 289 | qApp->processEvents(); |
290 | 290 | ||
291 | if ( fd >= 0 ) { | 291 | if ( fd >= 0 ) { |
292 | if ( vol_reset ) | 292 | if ( vol_reset ) |
293 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 293 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
294 | ::close ( fd ); | 294 | ::close ( fd ); |
295 | } | 295 | } |
296 | #endif | 296 | #endif |
297 | } | 297 | } |
298 | 298 | ||
299 | 299 | ||
300 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm | 300 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm |
301 | { | 301 | { |
302 | qDebug( "ODevice for SIMpad: suspend()" ); | 302 | qDebug( "ODevice for SIMpad: suspend()" ); |
303 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 303 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
304 | return false; | 304 | return false; |
305 | 305 | ||
306 | bool res = false; | 306 | bool res = false; |
307 | ODevice::sendSuspendmsg(); | 307 | ODevice::sendSuspendmsg(); |
308 | 308 | ||
309 | struct timeval tvs, tvn; | 309 | struct timeval tvs, tvn; |
310 | ::gettimeofday ( &tvs, 0 ); | 310 | ::gettimeofday ( &tvs, 0 ); |
311 | 311 | ||
312 | ::sync(); // flush fs caches | 312 | ::sync(); // flush fs caches |
313 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) | 313 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) |
314 | 314 | ||
315 | return res; | 315 | return res; |
316 | } | 316 | } |
317 | 317 | ||
318 | 318 | ||
319 | bool SIMpad::setSoftSuspend ( bool soft ) | 319 | bool SIMpad::setSoftSuspend ( bool soft ) |
320 | { | 320 | { |
321 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); | 321 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); |
322 | return false; | 322 | return false; |
323 | } | 323 | } |
324 | 324 | ||
325 | 325 | ||
326 | bool SIMpad::setDisplayStatus ( bool on ) | 326 | bool SIMpad::setDisplayStatus ( bool on ) |
327 | { | 327 | { |
328 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 328 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
329 | 329 | ||
330 | bool res = false; | 330 | bool res = false; |
331 | int fd; | 331 | int fd; |
332 | 332 | ||
333 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) | 333 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) |
334 | 334 | ||
335 | res = ( ::system( (const char*) cmdline ) == 0 ); | 335 | res = ( ::system( (const char*) cmdline ) == 0 ); |
336 | 336 | ||
337 | return res; | 337 | return res; |
338 | } | 338 | } |
339 | 339 | ||
340 | 340 | ||
341 | bool SIMpad::setDisplayBrightness ( int bright ) | 341 | bool SIMpad::setDisplayBrightness ( int bright ) |
342 | { | 342 | { |
343 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); | 343 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); |
344 | bool res = false; | 344 | bool res = false; |
345 | int fd; | 345 | int fd; |
346 | 346 | ||
347 | if ( bright > 255 ) | 347 | if ( bright > 255 ) |
348 | bright = 255; | 348 | bright = 255; |
349 | if ( bright < 1 ) | 349 | if ( bright < 1 ) |
350 | bright = 0; | 350 | bright = 0; |
351 | 351 | ||
352 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 352 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
353 | int value = 255 - bright; | 353 | int value = 255 - bright; |
354 | const int mask = SIMPAD_BACKLIGHT_MASK; | 354 | const int mask = SIMPAD_BACKLIGHT_MASK; |
355 | value = value << 8; | 355 | value = value << 8; |
356 | value += mask; | 356 | value += mask; |
357 | char writeCommand[100]; | 357 | char writeCommand[100]; |
358 | const int count = sprintf( writeCommand, "0x%x\n", value ); | 358 | const int count = snprintf( writeCommand, sizeof(writeCommand), "0x%x\n", value ); |
359 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 359 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
360 | ::close ( fd ); | 360 | ::close ( fd ); |
361 | } | 361 | } |
362 | return res; | 362 | return res; |
363 | } | 363 | } |
364 | 364 | ||
365 | 365 | ||
366 | int SIMpad::displayBrightnessResolution() const | 366 | int SIMpad::displayBrightnessResolution() const |
367 | { | 367 | { |
368 | return 255; // All SIMpad models share the same display | 368 | return 255; // All SIMpad models share the same display |
369 | } | 369 | } |
370 | 370 | ||