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