-rw-r--r-- | libopie2/opiecore/device/odevice_ipaq.cpp | 55 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.cpp | 52 |
2 files changed, 57 insertions, 50 deletions
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp index 16c0538..791e409 100644 --- a/libopie2/opiecore/device/odevice_ipaq.cpp +++ b/libopie2/opiecore/device/odevice_ipaq.cpp | |||
@@ -1,54 +1,55 @@ | |||
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_ipaq.h" | 30 | #include "odevice_ipaq.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 | 44 | ||
44 | /* STD */ | 45 | /* STD */ |
45 | #include <fcntl.h> | 46 | #include <fcntl.h> |
46 | #include <math.h> | 47 | #include <math.h> |
47 | #include <stdlib.h> | 48 | #include <stdlib.h> |
48 | #include <signal.h> | 49 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 50 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 51 | #include <sys/time.h> |
51 | #include <unistd.h> | 52 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 53 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 54 | #include <linux/soundcard.h> |
54 | #endif | 55 | #endif |
@@ -158,26 +159,28 @@ void iPAQ::init(const QString& model) | |||
158 | 159 | ||
159 | m_leds [0] = m_leds [1] = Led_Off; | 160 | m_leds [0] = m_leds [1] = Led_Off; |
160 | 161 | ||
161 | m_power_timer = 0; | 162 | m_power_timer = 0; |
162 | 163 | ||
163 | } | 164 | } |
164 | 165 | ||
165 | void iPAQ::initButtons() | 166 | void iPAQ::initButtons() |
166 | { | 167 | { |
167 | if ( d->m_buttons ) | 168 | if ( d->m_buttons ) |
168 | return; | 169 | return; |
169 | 170 | ||
170 | if ( isQWS( ) ) | 171 | if ( isQWS( ) ) { |
171 | QWSServer::setKeyboardFilter ( this ); | 172 | Opie::Core::OKeyFilter::inst()->addPreHandler(this); |
173 | //QWSServer::setKeyboardFilter ( this ); | ||
174 | } | ||
172 | 175 | ||
173 | d->m_buttons = new QValueList <ODeviceButton>; | 176 | d->m_buttons = new QValueList <ODeviceButton>; |
174 | 177 | ||
175 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 178 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
176 | i_button *ib = ipaq_buttons + i; | 179 | i_button *ib = ipaq_buttons + i; |
177 | ODeviceButton b; | 180 | ODeviceButton b; |
178 | 181 | ||
179 | if (( ib->model & d->m_model ) == d->m_model ) { | 182 | if (( ib->model & d->m_model ) == d->m_model ) { |
180 | b. setKeycode ( ib->code ); | 183 | b. setKeycode ( ib->code ); |
181 | b. setUserText ( QObject::tr ( "Button", ib->utext )); | 184 | b. setUserText ( QObject::tr ( "Button", ib->utext )); |
182 | b. setPixmap ( Resource::loadPixmap ( ib->pix )); | 185 | b. setPixmap ( Resource::loadPixmap ( ib->pix )); |
183 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); | 186 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); |
@@ -262,34 +265,34 @@ bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, b | |||
262 | 265 | ||
263 | switch ( keycode ) { | 266 | switch ( keycode ) { |
264 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 267 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
265 | case HardKey_Menu: { | 268 | case HardKey_Menu: { |
266 | if (( d->m_model == Model_iPAQ_H38xx ) || | 269 | if (( d->m_model == Model_iPAQ_H38xx ) || |
267 | ( d->m_model == Model_iPAQ_H39xx ) || | 270 | ( d->m_model == Model_iPAQ_H39xx ) || |
268 | ( d->m_model == Model_iPAQ_H5xxx)) { | 271 | ( d->m_model == Model_iPAQ_H5xxx)) { |
269 | newkeycode = HardKey_Mail; | 272 | newkeycode = HardKey_Mail; |
270 | } | 273 | } |
271 | break; | 274 | break; |
272 | } | 275 | } |
273 | 276 | ||
274 | // Rotate cursor keys 180° or 270° | 277 | // Rotate cursor keys 180 or 270 |
275 | case Key_Left : | 278 | case Key_Left : |
276 | case Key_Right: | 279 | case Key_Right: |
277 | case Key_Up : | 280 | case Key_Up : |
278 | case Key_Down : { | 281 | case Key_Down : { |
279 | if (( d->m_model == Model_iPAQ_H31xx ) || | 282 | if (( d->m_model == Model_iPAQ_H31xx ) || |
280 | ( d->m_model == Model_iPAQ_H38xx )) { | 283 | ( d->m_model == Model_iPAQ_H38xx )) { |
281 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 284 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
282 | } | 285 | } |
283 | // Rotate the cursor keys by 270° | 286 | // Rotate the cursor keys by 270 |
284 | // keycode - Key_Left = position of the button starting from left clockwise | 287 | // keycode - Key_Left = position of the button starting from left clockwise |
285 | // add the rotation to it and modolo. No we've the original offset | 288 | // add the rotation to it and modolo. No we've the original offset |
286 | // add the offset to the Key_Left key | 289 | // add the offset to the Key_Left key |
287 | if ( d-> m_model == Model_iPAQ_H5xxx ) | 290 | if ( d-> m_model == Model_iPAQ_H5xxx ) |
288 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; | 291 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; |
289 | break; | 292 | break; |
290 | } | 293 | } |
291 | 294 | ||
292 | // map Power Button short/long press to F34/F35 | 295 | // map Power Button short/long press to F34/F35 |
293 | case Key_SysReq: { | 296 | case Key_SysReq: { |
294 | if ( isPress ) { | 297 | if ( isPress ) { |
295 | if ( m_power_timer ) | 298 | if ( m_power_timer ) |
@@ -401,25 +404,25 @@ bool iPAQ::setDisplayBrightness ( int bright ) | |||
401 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 404 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
402 | ::close ( fd ); | 405 | ::close ( fd ); |
403 | } | 406 | } |
404 | return res; | 407 | return res; |
405 | } | 408 | } |
406 | 409 | ||
407 | int iPAQ::displayBrightnessResolution() const | 410 | int iPAQ::displayBrightnessResolution() const |
408 | { | 411 | { |
409 | switch ( model()) { | 412 | switch ( model()) { |
410 | case Model_iPAQ_H31xx: | 413 | case Model_iPAQ_H31xx: |
411 | case Model_iPAQ_H36xx: | 414 | case Model_iPAQ_H36xx: |
412 | case Model_iPAQ_H37xx: | 415 | case Model_iPAQ_H37xx: |
413 | return 128; // really 256, but >128 could damage the LCD | 416 | return 128; // really 256, but >128 could damage the LCD |
414 | 417 | ||
415 | case Model_iPAQ_H38xx: | 418 | case Model_iPAQ_H38xx: |
416 | case Model_iPAQ_H39xx: | 419 | case Model_iPAQ_H39xx: |
417 | return 64; | 420 | return 64; |
418 | case Model_iPAQ_H5xxx: | 421 | case Model_iPAQ_H5xxx: |
419 | return 255; | 422 | return 255; |
420 | 423 | ||
421 | default: | 424 | default: |
422 | return 2; | 425 | return 2; |
423 | } | 426 | } |
424 | } | 427 | } |
425 | 428 | ||
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp index e62ea18..6c3253c 100644 --- a/libopie2/opiecore/device/odevice_simpad.cpp +++ b/libopie2/opiecore/device/odevice_simpad.cpp | |||
@@ -1,54 +1,55 @@ | |||
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 | 44 | ||
44 | /* STD */ | 45 | /* STD */ |
45 | #include <fcntl.h> | 46 | #include <fcntl.h> |
46 | #include <math.h> | 47 | #include <math.h> |
47 | #include <stdlib.h> | 48 | #include <stdlib.h> |
48 | #include <signal.h> | 49 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 50 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 51 | #include <sys/time.h> |
51 | #include <unistd.h> | 52 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 53 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 54 | #include <linux/soundcard.h> |
54 | #endif | 55 | #endif |
@@ -136,26 +137,29 @@ void SIMpad::init(const QString&) | |||
136 | //Distribution detecting code is now in base class | 137 | //Distribution detecting code is now in base class |
137 | m_leds [0] = m_leds [1] = Led_Off; | 138 | m_leds [0] = m_leds [1] = Led_Off; |
138 | 139 | ||
139 | m_power_timer = 0; | 140 | m_power_timer = 0; |
140 | 141 | ||
141 | } | 142 | } |
142 | 143 | ||
143 | void SIMpad::initButtons() | 144 | void SIMpad::initButtons() |
144 | { | 145 | { |
145 | if ( d->m_buttons ) | 146 | if ( d->m_buttons ) |
146 | return; | 147 | return; |
147 | 148 | ||
148 | if ( isQWS( ) ) | 149 | if ( isQWS( ) ) { |
149 | QWSServer::setKeyboardFilter ( this ); | 150 | Opie::Core::OKeyFilter::inst()->addPreHandler(this); |
151 | // QWSServer::setKeyboardFilter ( this ); | ||
152 | } | ||
153 | |||
150 | 154 | ||
151 | d->m_buttons = new QValueList <ODeviceButton>; | 155 | d->m_buttons = new QValueList <ODeviceButton>; |
152 | 156 | ||
153 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { | 157 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { |
154 | s_button *sb = simpad_buttons + i; | 158 | s_button *sb = simpad_buttons + i; |
155 | ODeviceButton b; | 159 | ODeviceButton b; |
156 | 160 | ||
157 | if (( sb->model & d->m_model ) == d->m_model ) { | 161 | if (( sb->model & d->m_model ) == d->m_model ) { |
158 | b. setKeycode ( sb->code ); | 162 | b. setKeycode ( sb->code ); |
159 | b. setUserText ( QObject::tr ( "Button", sb->utext )); | 163 | b. setUserText ( QObject::tr ( "Button", sb->utext )); |
160 | b. setPixmap ( Resource::loadPixmap ( sb->pix )); | 164 | b. setPixmap ( Resource::loadPixmap ( sb->pix )); |
161 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); | 165 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); |
@@ -209,25 +213,25 @@ QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const | |||
209 | vl << Led_Off << Led_On; | 213 | vl << Led_Off << Led_On; |
210 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway | 214 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway |
211 | //vl << Led_Off; | 215 | //vl << Led_Off; |
212 | return vl; | 216 | return vl; |
213 | } | 217 | } |
214 | 218 | ||
215 | OLedState SIMpad::ledState ( OLed l ) const | 219 | OLedState SIMpad::ledState ( OLed l ) const |
216 | { | 220 | { |
217 | switch ( l ) { | 221 | switch ( l ) { |
218 | case Led_Power: | 222 | case Led_Power: |
219 | return m_leds [0]; | 223 | return m_leds [0]; |
220 | //case Led_Mail: | 224 | //case Led_Mail: |
221 | //return m_leds [1]; | 225 | // return m_leds [1]; |
222 | default: | 226 | default: |
223 | return Led_Off; | 227 | return Led_Off; |
224 | } | 228 | } |
225 | } | 229 | } |
226 | 230 | ||
227 | bool SIMpad::setLedState ( OLed l, OLedState st ) | 231 | bool SIMpad::setLedState ( OLed l, OLedState st ) |
228 | { | 232 | { |
229 | #if 0 | 233 | #if 0 |
230 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); | 234 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); |
231 | 235 | ||
232 | /*TODO Implement this like that: | 236 | /*TODO Implement this like that: |
233 | read from cs3 | 237 | read from cs3 |