author | zecke <zecke> | 2004-07-13 13:20:17 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-07-13 13:20:17 (UTC) |
commit | 4a31bc0d4c9a30583200e866f21340448d41d1c2 (patch) (unidiff) | |
tree | 2123d65d18b6ca57227bdb8b3254e82d9ba31759 | |
parent | 37e0e077b51841971c3d4c25b287f4d39e750e2d (diff) | |
download | opie-4a31bc0d4c9a30583200e866f21340448d41d1c2.zip opie-4a31bc0d4c9a30583200e866f21340448d41d1c2.tar.gz opie-4a31bc0d4c9a30583200e866f21340448d41d1c2.tar.bz2 |
-Small clean up, we do not need to use the file anymore as all
model checking is done in the ODevice base class
-m_led[0] = m_led[1] = LedOff which size does m_led need? yeah two
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.h | 4 |
2 files changed, 2 insertions, 4 deletions
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp index 6d4624b..76f03a0 100644 --- a/libopie2/opiecore/device/odevice_simpad.cpp +++ b/libopie2/opiecore/device/odevice_simpad.cpp | |||
@@ -1,330 +1,328 @@ | |||
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 | ||
56 | using namespace Opie::Core; | 56 | using namespace Opie::Core; |
57 | using namespace Opie::Core::Internal; | 57 | using namespace Opie::Core::Internal; |
58 | 58 | ||
59 | struct s_button simpad_buttons [] = { | 59 | struct s_button simpad_buttons [] = { |
60 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 60 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
61 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), | 61 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), |
62 | "devicebuttons/simpad_lower_up", | 62 | "devicebuttons/simpad_lower_up", |
63 | "datebook", "nextView()", | 63 | "datebook", "nextView()", |
64 | "today", "raise()" }, | 64 | "today", "raise()" }, |
65 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 65 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
66 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), | 66 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), |
67 | "devicebuttons/simpad_lower_down", | 67 | "devicebuttons/simpad_lower_down", |
68 | "addressbook", "raise()", | 68 | "addressbook", "raise()", |
69 | "addressbook", "beamBusinessCard()" }, | 69 | "addressbook", "beamBusinessCard()" }, |
70 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 70 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
71 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), | 71 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), |
72 | "devicebuttons/simpad_lower_right", | 72 | "devicebuttons/simpad_lower_right", |
73 | "QPE/TaskBar", "toggleMenu()", | 73 | "QPE/TaskBar", "toggleMenu()", |
74 | "QPE/TaskBar", "toggleStartMenu()" }, | 74 | "QPE/TaskBar", "toggleStartMenu()" }, |
75 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 75 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
76 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), | 76 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), |
77 | "devicebuttons/simpad_lower_left", | 77 | "devicebuttons/simpad_lower_left", |
78 | "opiemail", "raise()", | 78 | "opiemail", "raise()", |
79 | "opiemail", "newMail()" }, | 79 | "opiemail", "newMail()" }, |
80 | 80 | ||
81 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 81 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
82 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), | 82 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), |
83 | "devicebuttons/simpad_upper_up", | 83 | "devicebuttons/simpad_upper_up", |
84 | "QPE/Launcher", "home()", | 84 | "QPE/Launcher", "home()", |
85 | "buttonsettings", "raise()" }, | 85 | "buttonsettings", "raise()" }, |
86 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 86 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
87 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), | 87 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), |
88 | "devicebuttons/simpad_upper_down", | 88 | "devicebuttons/simpad_upper_down", |
89 | "addressbook", "raise()", | 89 | "addressbook", "raise()", |
90 | "addressbook", "beamBusinessCard()" }, | 90 | "addressbook", "beamBusinessCard()" }, |
91 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 91 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
92 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), | 92 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), |
93 | "devicebuttons/simpad_upper_right", | 93 | "devicebuttons/simpad_upper_right", |
94 | "QPE/TaskBar", "toggleMenu()", | 94 | "QPE/TaskBar", "toggleMenu()", |
95 | "QPE/TaskBar", "toggleStartMenu()" }, | 95 | "QPE/TaskBar", "toggleStartMenu()" }, |
96 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 96 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
97 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), | 97 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), |
98 | "devicebuttons/simpad_upper_left", | 98 | "devicebuttons/simpad_upper_left", |
99 | "QPE/Rotation", "flip()", | 99 | "QPE/Rotation", "flip()", |
100 | "QPE/Rotation", "flip()" }, | 100 | "QPE/Rotation", "flip()" }, |
101 | /* | 101 | /* |
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 | QFile f ( "/proc/hal/model" ); | ||
121 | 120 | ||
122 | //TODO Implement model checking | 121 | //TODO Implement model checking |
123 | //FIXME For now we assume an SL4 | 122 | //FIXME For now we assume an SL4 |
124 | 123 | ||
125 | d->m_modelstr = "SL4"; | 124 | d->m_modelstr = "SL4"; |
126 | d->m_model = Model_SIMpad_SL4; | 125 | d->m_model = Model_SIMpad_SL4; |
127 | 126 | ||
128 | switch ( d->m_model ) { | 127 | switch ( d->m_model ) { |
129 | default: | 128 | default: |
130 | d->m_rotation = Rot0; | 129 | d->m_rotation = Rot0; |
131 | d->m_direction = CCW; | 130 | d->m_direction = CCW; |
132 | d->m_holdtime = 1000; // 1000ms | 131 | d->m_holdtime = 1000; // 1000ms |
133 | 132 | ||
134 | break; | 133 | break; |
135 | } | 134 | } |
136 | 135 | ||
137 | //Distribution detecting code is now in base class | 136 | //Distribution detecting code is now in base class |
138 | |||
139 | m_leds [0] = m_leds [1] = Led_Off; | 137 | m_leds [0] = m_leds [1] = Led_Off; |
140 | 138 | ||
141 | m_power_timer = 0; | 139 | m_power_timer = 0; |
142 | 140 | ||
143 | } | 141 | } |
144 | 142 | ||
145 | void SIMpad::initButtons() | 143 | void SIMpad::initButtons() |
146 | { | 144 | { |
147 | if ( d->m_buttons ) | 145 | if ( d->m_buttons ) |
148 | return; | 146 | return; |
149 | 147 | ||
150 | if ( isQWS( ) ) | 148 | if ( isQWS( ) ) |
151 | QWSServer::setKeyboardFilter ( this ); | 149 | QWSServer::setKeyboardFilter ( this ); |
152 | 150 | ||
153 | d->m_buttons = new QValueList <ODeviceButton>; | 151 | d->m_buttons = new QValueList <ODeviceButton>; |
154 | 152 | ||
155 | 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++ ) { |
156 | s_button *sb = simpad_buttons + i; | 154 | s_button *sb = simpad_buttons + i; |
157 | ODeviceButton b; | 155 | ODeviceButton b; |
158 | 156 | ||
159 | if (( sb->model & d->m_model ) == d->m_model ) { | 157 | if (( sb->model & d->m_model ) == d->m_model ) { |
160 | b. setKeycode ( sb->code ); | 158 | b. setKeycode ( sb->code ); |
161 | b. setUserText ( QObject::tr ( "Button", sb->utext )); | 159 | b. setUserText ( QObject::tr ( "Button", sb->utext )); |
162 | b. setPixmap ( Resource::loadPixmap ( sb->pix )); | 160 | b. setPixmap ( Resource::loadPixmap ( sb->pix )); |
163 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); | 161 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); |
164 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); | 162 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); |
165 | 163 | ||
166 | d->m_buttons->append ( b ); | 164 | d->m_buttons->append ( b ); |
167 | } | 165 | } |
168 | } | 166 | } |
169 | reloadButtonMapping(); | 167 | reloadButtonMapping(); |
170 | 168 | ||
171 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 169 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
172 | 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&))); |
173 | } | 171 | } |
174 | 172 | ||
175 | // SIMpad boardcontrol register CS3 | 173 | // SIMpad boardcontrol register CS3 |
176 | #define SIMPAD_BOARDCONTROL "/proc/cs3" | 174 | #define SIMPAD_BOARDCONTROL "/proc/cs3" |
177 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA | 175 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA |
178 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA | 176 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA |
179 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's | 177 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's |
180 | #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 |
181 | #define SIMPAD_DISPLAY_ON 0x0010 | 179 | #define SIMPAD_DISPLAY_ON 0x0010 |
182 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 | 180 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 |
183 | #define SIMPAD_MQ_RESET 0x0040 | 181 | #define SIMPAD_MQ_RESET 0x0040 |
184 | #define SIMPAD_PCMCIA_RESET 0x0080 | 182 | #define SIMPAD_PCMCIA_RESET 0x0080 |
185 | #define SIMPAD_DECT_POWER_ON 0x0100 | 183 | #define SIMPAD_DECT_POWER_ON 0x0100 |
186 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave | 184 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave |
187 | #define SIMPAD_RS232_ON 0x0400 | 185 | #define SIMPAD_RS232_ON 0x0400 |
188 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave | 186 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave |
189 | #define SIMPAD_LED2_ON 0x1000 | 187 | #define SIMPAD_LED2_ON 0x1000 |
190 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode | 188 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode |
191 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit | 189 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit |
192 | #define SIMPAD_RESET_SIMCARD 0x8000 | 190 | #define SIMPAD_RESET_SIMCARD 0x8000 |
193 | 191 | ||
194 | //SIMpad touchscreen backlight strength control | 192 | //SIMpad touchscreen backlight strength control |
195 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" | 193 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" |
196 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 | 194 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 |
197 | 195 | ||
198 | QValueList <OLed> SIMpad::ledList() const | 196 | QValueList <OLed> SIMpad::ledList() const |
199 | { | 197 | { |
200 | QValueList <OLed> vl; | 198 | QValueList <OLed> vl; |
201 | 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? |
202 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway | 200 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway |
203 | return vl; | 201 | return vl; |
204 | } | 202 | } |
205 | 203 | ||
206 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const | 204 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const |
207 | { | 205 | { |
208 | QValueList <OLedState> vl; | 206 | QValueList <OLedState> vl; |
209 | 207 | ||
210 | 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? |
211 | vl << Led_Off << Led_On; | 209 | vl << Led_Off << Led_On; |
212 | //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 |
213 | //vl << Led_Off; | 211 | //vl << Led_Off; |
214 | return vl; | 212 | return vl; |
215 | } | 213 | } |
216 | 214 | ||
217 | OLedState SIMpad::ledState ( OLed l ) const | 215 | OLedState SIMpad::ledState ( OLed l ) const |
218 | { | 216 | { |
219 | switch ( l ) { | 217 | switch ( l ) { |
220 | case Led_Power: | 218 | case Led_Power: |
221 | return m_leds [0]; | 219 | return m_leds [0]; |
222 | //case Led_Mail: | 220 | //case Led_Mail: |
223 | //return m_leds [1]; | 221 | //return m_leds [1]; |
224 | default: | 222 | default: |
225 | return Led_Off; | 223 | return Led_Off; |
226 | } | 224 | } |
227 | } | 225 | } |
228 | 226 | ||
229 | bool SIMpad::setLedState ( OLed l, OLedState st ) | 227 | bool SIMpad::setLedState ( OLed l, OLedState st ) |
230 | { | 228 | { |
231 | #if 0 | 229 | #if 0 |
232 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); | 230 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); |
233 | 231 | ||
234 | /*TODO Implement this like that: | 232 | /*TODO Implement this like that: |
235 | read from cs3 | 233 | read from cs3 |
236 | && with SIMPAD_LED2_ON | 234 | && with SIMPAD_LED2_ON |
237 | write to cs3 */ | 235 | write to cs3 */ |
238 | m_leds [0] = st; | 236 | m_leds [0] = st; |
239 | return true; | 237 | return true; |
240 | } | 238 | } |
241 | } | 239 | } |
242 | } | 240 | } |
243 | 241 | ||
244 | #endif | 242 | #endif |
245 | return false; | 243 | return false; |
246 | } | 244 | } |
247 | 245 | ||
248 | 246 | ||
249 | 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 ) |
250 | { | 248 | { |
251 | //TODO | 249 | //TODO |
252 | return false; | 250 | return false; |
253 | } | 251 | } |
254 | 252 | ||
255 | void SIMpad::timerEvent ( QTimerEvent * ) | 253 | void SIMpad::timerEvent ( QTimerEvent * ) |
256 | { | 254 | { |
257 | killTimer ( m_power_timer ); | 255 | killTimer ( m_power_timer ); |
258 | m_power_timer = 0; | 256 | m_power_timer = 0; |
259 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 257 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
260 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 258 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
261 | } | 259 | } |
262 | 260 | ||
263 | 261 | ||
264 | void SIMpad::playAlarmSound() | 262 | void SIMpad::playAlarmSound() |
265 | { | 263 | { |
266 | #ifndef QT_NO_SOUND | 264 | #ifndef QT_NO_SOUND |
267 | static Sound snd ( "alarm" ); | 265 | static Sound snd ( "alarm" ); |
268 | int fd; | 266 | int fd; |
269 | int vol; | 267 | int vol; |
270 | bool vol_reset = false; | 268 | bool vol_reset = false; |
271 | 269 | ||
272 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 270 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
273 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 271 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
274 | Config cfg ( "qpe" ); | 272 | Config cfg ( "qpe" ); |
275 | cfg. setGroup ( "Volume" ); | 273 | cfg. setGroup ( "Volume" ); |
276 | 274 | ||
277 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 275 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
278 | if ( volalarm < 0 ) | 276 | if ( volalarm < 0 ) |
279 | volalarm = 0; | 277 | volalarm = 0; |
280 | else if ( volalarm > 100 ) | 278 | else if ( volalarm > 100 ) |
281 | volalarm = 100; | 279 | volalarm = 100; |
282 | volalarm |= ( volalarm << 8 ); | 280 | volalarm |= ( volalarm << 8 ); |
283 | 281 | ||
284 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 282 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
285 | vol_reset = true; | 283 | vol_reset = true; |
286 | } | 284 | } |
287 | } | 285 | } |
288 | 286 | ||
289 | snd. play(); | 287 | snd. play(); |
290 | while ( !snd. isFinished()) | 288 | while ( !snd. isFinished()) |
291 | qApp->processEvents(); | 289 | qApp->processEvents(); |
292 | 290 | ||
293 | if ( fd >= 0 ) { | 291 | if ( fd >= 0 ) { |
294 | if ( vol_reset ) | 292 | if ( vol_reset ) |
295 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 293 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
296 | ::close ( fd ); | 294 | ::close ( fd ); |
297 | } | 295 | } |
298 | #endif | 296 | #endif |
299 | } | 297 | } |
300 | 298 | ||
301 | 299 | ||
302 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm | 300 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm |
303 | { | 301 | { |
304 | qDebug( "ODevice for SIMpad: suspend()" ); | 302 | qDebug( "ODevice for SIMpad: suspend()" ); |
305 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 303 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
306 | return false; | 304 | return false; |
307 | 305 | ||
308 | bool res = false; | 306 | bool res = false; |
309 | ODevice::sendSuspendmsg(); | 307 | ODevice::sendSuspendmsg(); |
310 | 308 | ||
311 | struct timeval tvs, tvn; | 309 | struct timeval tvs, tvn; |
312 | ::gettimeofday ( &tvs, 0 ); | 310 | ::gettimeofday ( &tvs, 0 ); |
313 | 311 | ||
314 | ::sync(); // flush fs caches | 312 | ::sync(); // flush fs caches |
315 | 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 :) |
316 | 314 | ||
317 | return res; | 315 | return res; |
318 | } | 316 | } |
319 | 317 | ||
320 | 318 | ||
321 | bool SIMpad::setSoftSuspend ( bool soft ) | 319 | bool SIMpad::setSoftSuspend ( bool soft ) |
322 | { | 320 | { |
323 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); | 321 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); |
324 | return false; | 322 | return false; |
325 | } | 323 | } |
326 | 324 | ||
327 | 325 | ||
328 | bool SIMpad::setDisplayStatus ( bool on ) | 326 | bool SIMpad::setDisplayStatus ( bool on ) |
329 | { | 327 | { |
330 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 328 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
diff --git a/libopie2/opiecore/device/odevice_simpad.h b/libopie2/opiecore/device/odevice_simpad.h index 0f4e66f..d9ae5a5 100644 --- a/libopie2/opiecore/device/odevice_simpad.h +++ b/libopie2/opiecore/device/odevice_simpad.h | |||
@@ -1,87 +1,87 @@ | |||
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 | #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 | ||
38 | namespace Opie { | 38 | namespace Opie { |
39 | namespace Core { | 39 | namespace Core { |
40 | namespace Internal { | 40 | namespace Internal { |
41 | 41 | ||
42 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter | 42 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter |
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 setSoftSuspend( bool soft ); | 49 | virtual bool setSoftSuspend( bool soft ); |
50 | virtual bool suspend(); | 50 | virtual bool suspend(); |
51 | 51 | ||
52 | virtual bool setDisplayStatus( bool on ); | 52 | virtual bool setDisplayStatus( bool on ); |
53 | virtual bool setDisplayBrightness( int b ); | 53 | virtual bool setDisplayBrightness( int b ); |
54 | virtual int displayBrightnessResolution() const; | 54 | virtual int displayBrightnessResolution() const; |
55 | 55 | ||
56 | virtual void playAlarmSound(); | 56 | virtual void playAlarmSound(); |
57 | 57 | ||
58 | virtual QValueList <OLed> ledList() const; | 58 | virtual QValueList <OLed> ledList() const; |
59 | virtual QValueList <OLedState> ledStateList( OLed led ) const; | 59 | virtual QValueList <OLedState> ledStateList( OLed led ) const; |
60 | virtual OLedState ledState( OLed led ) const; | 60 | virtual OLedState ledState( OLed led ) const; |
61 | virtual bool setLedState( OLed led, OLedState st ); | 61 | virtual bool setLedState( OLed led, OLedState st ); |
62 | 62 | ||
63 | protected: | 63 | protected: |
64 | virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 64 | virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
65 | virtual void timerEvent( QTimerEvent *te ); | 65 | virtual void timerEvent( QTimerEvent *te ); |
66 | 66 | ||
67 | int m_power_timer; | 67 | int m_power_timer; |
68 | 68 | ||
69 | OLedState m_leds [1]; | 69 | OLedState m_leds [2]; |
70 | }; | 70 | }; |
71 | 71 | ||
72 | struct s_button { | 72 | struct s_button { |
73 | uint model; | 73 | uint model; |
74 | Qt::Key code; | 74 | Qt::Key code; |
75 | char *utext; | 75 | char *utext; |
76 | char *pix; | 76 | char *pix; |
77 | char *fpressedservice; | 77 | char *fpressedservice; |
78 | char *fpressedaction; | 78 | char *fpressedaction; |
79 | char *fheldservice; | 79 | char *fheldservice; |
80 | char *fheldaction; | 80 | char *fheldaction; |
81 | }; | 81 | }; |
82 | 82 | ||
83 | } | 83 | } |
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
87 | #endif | 87 | #endif |