summaryrefslogtreecommitdiff
authorchicken <chicken>2004-11-05 10:34:02 (UTC)
committer chicken <chicken>2004-11-05 10:34:02 (UTC)
commitaea18d994988507f6153552698cbb67054715a92 (patch) (unidiff)
tree704b7ec91f59e432910343a6d3efc73b90fae613
parent586ba5bb2842d80911ea22bf47eaa2f1b39362e1 (diff)
downloadopie-aea18d994988507f6153552698cbb67054715a92.zip
opie-aea18d994988507f6153552698cbb67054715a92.tar.gz
opie-aea18d994988507f6153552698cbb67054715a92.tar.bz2
correct simpad cs3 readout
Diffstat (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 2e54216..d6c2c80 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -137,193 +137,193 @@ void SIMpad::init(const QString&)
137 //TODO Implement model checking 137 //TODO Implement model checking
138 //FIXME For now we assume an SL4 138 //FIXME For now we assume an SL4
139 139
140 d->m_modelstr = "SL4"; 140 d->m_modelstr = "SL4";
141 d->m_model = Model_SIMpad_SL4; 141 d->m_model = Model_SIMpad_SL4;
142 142
143 switch ( d->m_model ) { 143 switch ( d->m_model ) {
144 default: 144 default:
145 d->m_rotation = Rot0; 145 d->m_rotation = Rot0;
146 d->m_direction = CCW; 146 d->m_direction = CCW;
147 d->m_holdtime = 1000; // 1000ms 147 d->m_holdtime = 1000; // 1000ms
148 148
149 break; 149 break;
150 } 150 }
151 151
152 //Distribution detecting code is now in base class 152 //Distribution detecting code is now in base class
153 m_leds [0] = m_leds [1] = Led_Off; 153 m_leds [0] = m_leds [1] = Led_Off;
154 154
155 m_power_timer = 0; 155 m_power_timer = 0;
156 156
157} 157}
158 158
159void SIMpad::initButtons() 159void SIMpad::initButtons()
160{ 160{
161 if ( d->m_buttons ) 161 if ( d->m_buttons )
162 return; 162 return;
163 163
164 d->m_buttons = new QValueList <ODeviceButton>; 164 d->m_buttons = new QValueList <ODeviceButton>;
165 165
166 uint size = sizeof(simpad_buttons)/sizeof(s_button); 166 uint size = sizeof(simpad_buttons)/sizeof(s_button);
167 for ( uint i = 0; i < size; i++ ) { 167 for ( uint i = 0; i < size; i++ ) {
168 s_button *sb = simpad_buttons + i; 168 s_button *sb = simpad_buttons + i;
169 ODeviceButton b; 169 ODeviceButton b;
170 170
171 if (( sb->model & d->m_model ) == d->m_model ) { 171 if (( sb->model & d->m_model ) == d->m_model ) {
172 b. setKeycode ( sb->code ); 172 b. setKeycode ( sb->code );
173 b. setUserText ( QObject::tr ( "Button", sb->utext )); 173 b. setUserText ( QObject::tr ( "Button", sb->utext ));
174 b. setPixmap ( Resource::loadPixmap ( sb->pix )); 174 b. setPixmap ( Resource::loadPixmap ( sb->pix ));
175 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); 175 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction ));
176 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); 176 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction ));
177 177
178 d->m_buttons->append ( b ); 178 d->m_buttons->append ( b );
179 } 179 }
180 } 180 }
181 reloadButtonMapping(); 181 reloadButtonMapping();
182} 182}
183 183
184// SIMpad boardcontrol register CS3 184// SIMpad boardcontrol register CS3
185#define SIMPAD_BOARDCONTROL "/proc/cs3" 185#define SIMPAD_BOARDCONTROL "/proc/cs3"
186#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 186#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
187#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 187#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
188#define SIMPAD_EN1 0x0004 // This is only for EPROM's 188#define SIMPAD_EN1 0x0004 // This is only for EPROM's
189#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
190#define SIMPAD_DISPLAY_ON 0x0010 190#define SIMPAD_DISPLAY_ON 0x0010
191#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 191#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
192#define SIMPAD_MQ_RESET 0x0040 192#define SIMPAD_MQ_RESET 0x0040
193#define SIMPAD_PCMCIA_RESET 0x0080 193#define SIMPAD_PCMCIA_RESET 0x0080
194#define SIMPAD_DECT_POWER_ON 0x0100 194#define SIMPAD_DECT_POWER_ON 0x0100
195#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 195#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
196#define SIMPAD_RS232_ON 0x0400 196#define SIMPAD_RS232_ON 0x0400
197#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 197#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
198#define SIMPAD_LED2_ON 0x1000 198#define SIMPAD_LED2_ON 0x1000
199#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 199#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
200#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 200#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
201#define SIMPAD_RESET_SIMCARD 0x8000 201#define SIMPAD_RESET_SIMCARD 0x8000
202 202
203//SIMpad touchscreen backlight strength control 203//SIMpad touchscreen backlight strength control
204#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/backlight" 204#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/backlight"
205 205
206 206
207/* 207/*
208 * The SIMpad exposes ChipSelect3 to userspace 208 * The SIMpad exposes ChipSelect3 to userspace
209 * via a proc filesystem file. Using this register 209 * via a proc filesystem file. Using this register
210 * one can toggle power of serial, irda, dect circuits 210 * one can toggle power of serial, irda, dect circuits
211 * change the video driver and display status and 211 * change the video driver and display status and
212 * many more things. 212 * many more things.
213 * To not lose the current setting we read the current 213 * To not lose the current setting we read the current
214 * cs3 setting and toggle the necessary bits and then 214 * cs3 setting and toggle the necessary bits and then
215 * write it. 215 * write it.
216 */ 216 */
217static bool setCS3Bit( bool bitset, int bit ) { 217static bool setCS3Bit( bool bitset, int bit ) {
218 QFile file( SIMPAD_BOARDCONTROL ); 218 QFile file( SIMPAD_BOARDCONTROL );
219 if ( !file.open( IO_ReadOnly ) ) 219 if ( !file.open( IO_ReadOnly ) )
220 return false; 220 return false;
221 221
222 unsigned int val = 0; 222 unsigned int val = 0;
223 bool ok = false; 223 bool ok = false;
224 QTextStream stream( &file ); 224 QTextStream stream( &file );
225 225
226 /* 226 /*
227 * Use QFile and QTextStream for parsing to be more 227 * Use QFile and QTextStream for parsing to be more
228 * robust 228 * robust
229 */ 229 */
230 while ( !stream.atEnd() ) { 230 while ( !stream.atEnd() ) {
231 QString line = stream.readLine(); 231 QString line = stream.readLine();
232 if ( line.startsWith( "Chipselect3 : " ) ) { 232 if ( line.startsWith( "Chipselect3 : " ) ) {
233 val = line.mid( 15 ).toUInt( 0, 16 ); 233 val = line.mid( 14 ).toUInt( 0, 16 );
234 ok = true; 234 ok = true;
235 break; 235 break;
236 } 236 }
237 } 237 }
238 238
239 if ( !ok ) 239 if ( !ok )
240 return false; 240 return false;
241 241
242 file.close(); 242 file.close();
243 243
244 /* 244 /*
245 * change the value 245 * change the value
246 */ 246 */
247 val = bitset ? (val | bit) : (val & ~bit); 247 val = bitset ? (val | bit) : (val & ~bit);
248 248
249 /* 249 /*
250 * write it back 250 * write it back
251 */ 251 */
252 int cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_WRONLY ); 252 int cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_WRONLY );
253 if ( cs3_fd < 0 ) 253 if ( cs3_fd < 0 )
254 return false; 254 return false;
255 255
256 char line[32]; 256 char line[32];
257 ::snprintf(line, sizeof(line), "0x%04x\n", val); 257 ::snprintf(line, sizeof(line), "0x%04x\n", val);
258 ::write(cs3_fd, line, strlen(line)); 258 ::write(cs3_fd, line, strlen(line));
259 ::close(cs3_fd); 259 ::close(cs3_fd);
260 260
261 return true; 261 return true;
262} 262}
263 263
264 264
265QValueList <OLed> SIMpad::ledList() const 265QValueList <OLed> SIMpad::ledList() const
266{ 266{
267 QValueList <OLed> vl; 267 QValueList <OLed> vl;
268 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 268 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
269 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 269 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
270 return vl; 270 return vl;
271} 271}
272 272
273QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 273QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
274{ 274{
275 QValueList <OLedState> vl; 275 QValueList <OLedState> vl;
276 276
277 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 277 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
278 vl << Led_Off << Led_On; 278 vl << Led_Off << Led_On;
279 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 279 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
280 //vl << Led_Off; 280 //vl << Led_Off;
281 return vl; 281 return vl;
282} 282}
283 283
284OLedState SIMpad::ledState ( OLed l ) const 284OLedState SIMpad::ledState ( OLed l ) const
285{ 285{
286 switch ( l ) { 286 switch ( l ) {
287 case Led_Power: 287 case Led_Power:
288 return m_leds [0]; 288 return m_leds [0];
289 //case Led_Mail: 289 //case Led_Mail:
290 // return m_leds [1]; 290 // return m_leds [1];
291 default: 291 default:
292 return Led_Off; 292 return Led_Off;
293 } 293 }
294} 294}
295 295
296bool SIMpad::setLedState ( OLed l, OLedState st ) 296bool SIMpad::setLedState ( OLed l, OLedState st )
297{ 297{
298 if ( l == Led_Power ) { 298 if ( l == Led_Power ) {
299 m_leds [0] = st; 299 m_leds [0] = st;
300 setCS3Bit(st == Led_On, SIMPAD_LED2_ON); 300 setCS3Bit(st == Led_On, SIMPAD_LED2_ON);
301 return true; 301 return true;
302 } 302 }
303 303
304 return false; 304 return false;
305} 305}
306 306
307void SIMpad::timerEvent ( QTimerEvent * ) 307void SIMpad::timerEvent ( QTimerEvent * )
308{ 308{
309 killTimer ( m_power_timer ); 309 killTimer ( m_power_timer );
310 m_power_timer = 0; 310 m_power_timer = 0;
311 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 311 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
312 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 312 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
313} 313}
314 314
315 315
316void SIMpad::playAlarmSound() 316void SIMpad::playAlarmSound()
317{ 317{
318#ifndef QT_NO_SOUND 318#ifndef QT_NO_SOUND
319 static Sound snd ( "alarm" ); 319 static Sound snd ( "alarm" );
320 if(!snd.isFinished()) 320 if(!snd.isFinished())
321 return; 321 return;
322 322
323 /* save as the Sound is static! */ 323 /* save as the Sound is static! */
324 changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); 324 changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd);
325 snd. play(); 325 snd. play();
326#endif 326#endif
327} 327}
328 328
329 329