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