author | alwin <alwin> | 2004-08-01 10:32:56 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-08-01 10:32:56 (UTC) |
commit | 142d432ef9f8215636a81c358c828d4b6986a6ad (patch) (unidiff) | |
tree | faf33f40f3e19fdd0362256c61e6774ea949f70c | |
parent | 24c8aff75cbb41ccb2acf3de79675c2f4fd7ecc9 (diff) | |
download | opie-142d432ef9f8215636a81c358c828d4b6986a6ad.zip opie-142d432ef9f8215636a81c358c828d4b6986a6ad.tar.gz opie-142d432ef9f8215636a81c358c828d4b6986a6ad.tar.bz2 |
added a keyfilter singleton. All OPIE apps should use that instead of
the base from qte 'cause there are some stupids in handling pointers.
key handlers from odevice-classes will handled at top of all others
iPAQ and SIMPad are switched to that filter queue.
-rw-r--r-- | libopie2/opiecore/device/odevice_ipaq.cpp | 55 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.cpp | 52 | ||||
-rw-r--r-- | libopie2/opiecore/okeyfilter.cpp | 119 | ||||
-rw-r--r-- | libopie2/opiecore/okeyfilter.h | 77 | ||||
-rw-r--r-- | libopie2/opiecore/opiecore.pro | 2 |
5 files changed, 255 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,458 +1,461 @@ | |||
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 |
55 | 56 | ||
56 | 57 | ||
57 | using namespace Opie::Core; | 58 | using namespace Opie::Core; |
58 | using namespace Opie::Core::Internal; | 59 | using namespace Opie::Core::Internal; |
59 | 60 | ||
60 | /* KERNEL */ | 61 | /* KERNEL */ |
61 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 62 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
62 | 63 | ||
63 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 64 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
64 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 65 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
65 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 66 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
66 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 67 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
67 | 68 | ||
68 | typedef struct { | 69 | typedef struct { |
69 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 70 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
70 | unsigned char TotalTime; /* Units of 5 seconds */ | 71 | unsigned char TotalTime; /* Units of 5 seconds */ |
71 | unsigned char OnTime; /* units of 100m/s */ | 72 | unsigned char OnTime; /* units of 100m/s */ |
72 | unsigned char OffTime; /* units of 100m/s */ | 73 | unsigned char OffTime; /* units of 100m/s */ |
73 | } LED_IN; | 74 | } LED_IN; |
74 | 75 | ||
75 | typedef struct { | 76 | typedef struct { |
76 | unsigned char mode; | 77 | unsigned char mode; |
77 | unsigned char pwr; | 78 | unsigned char pwr; |
78 | unsigned char brightness; | 79 | unsigned char brightness; |
79 | } FLITE_IN; | 80 | } FLITE_IN; |
80 | 81 | ||
81 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 82 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
82 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 83 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
83 | 84 | ||
84 | struct i_button ipaq_buttons [] = { | 85 | struct i_button ipaq_buttons [] = { |
85 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 86 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
86 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 87 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
87 | "devicebuttons/ipaq_calendar", | 88 | "devicebuttons/ipaq_calendar", |
88 | "datebook", "nextView()", | 89 | "datebook", "nextView()", |
89 | "today", "raise()" }, | 90 | "today", "raise()" }, |
90 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 91 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
91 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 92 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
92 | "devicebuttons/ipaq_contact", | 93 | "devicebuttons/ipaq_contact", |
93 | "addressbook", "raise()", | 94 | "addressbook", "raise()", |
94 | "addressbook", "beamBusinessCard()" }, | 95 | "addressbook", "beamBusinessCard()" }, |
95 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, | 96 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, |
96 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 97 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
97 | "devicebuttons/ipaq_menu", | 98 | "devicebuttons/ipaq_menu", |
98 | "QPE/TaskBar", "toggleMenu()", | 99 | "QPE/TaskBar", "toggleMenu()", |
99 | "QPE/TaskBar", "toggleStartMenu()" }, | 100 | "QPE/TaskBar", "toggleStartMenu()" }, |
100 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 101 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
101 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 102 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
102 | "devicebuttons/ipaq_mail", | 103 | "devicebuttons/ipaq_mail", |
103 | "opiemail", "raise()", | 104 | "opiemail", "raise()", |
104 | "opiemail", "newMail()" }, | 105 | "opiemail", "newMail()" }, |
105 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 106 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
106 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 107 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
107 | "devicebuttons/ipaq_home", | 108 | "devicebuttons/ipaq_home", |
108 | "QPE/Launcher", "home()", | 109 | "QPE/Launcher", "home()", |
109 | "buttonsettings", "raise()" }, | 110 | "buttonsettings", "raise()" }, |
110 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 111 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
111 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), | 112 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), |
112 | "devicebuttons/ipaq_record", | 113 | "devicebuttons/ipaq_record", |
113 | "QPE/VMemo", "toggleRecord()", | 114 | "QPE/VMemo", "toggleRecord()", |
114 | "sound", "raise()" }, | 115 | "sound", "raise()" }, |
115 | }; | 116 | }; |
116 | 117 | ||
117 | void iPAQ::init(const QString& model) | 118 | void iPAQ::init(const QString& model) |
118 | { | 119 | { |
119 | d->m_vendorstr = "HP"; | 120 | d->m_vendorstr = "HP"; |
120 | d->m_vendor = Vendor_HP; | 121 | d->m_vendor = Vendor_HP; |
121 | 122 | ||
122 | d->m_modelstr = model.mid(model.findRev('H')); | 123 | d->m_modelstr = model.mid(model.findRev('H')); |
123 | 124 | ||
124 | if ( d->m_modelstr == "H3100" ) | 125 | if ( d->m_modelstr == "H3100" ) |
125 | d->m_model = Model_iPAQ_H31xx; | 126 | d->m_model = Model_iPAQ_H31xx; |
126 | else if ( d->m_modelstr == "H3600" ) | 127 | else if ( d->m_modelstr == "H3600" ) |
127 | d->m_model = Model_iPAQ_H36xx; | 128 | d->m_model = Model_iPAQ_H36xx; |
128 | else if ( d->m_modelstr == "H3700" ) | 129 | else if ( d->m_modelstr == "H3700" ) |
129 | d->m_model = Model_iPAQ_H37xx; | 130 | d->m_model = Model_iPAQ_H37xx; |
130 | else if ( d->m_modelstr == "H3800" ) | 131 | else if ( d->m_modelstr == "H3800" ) |
131 | d->m_model = Model_iPAQ_H38xx; | 132 | d->m_model = Model_iPAQ_H38xx; |
132 | else if ( d->m_modelstr == "H3900" ) | 133 | else if ( d->m_modelstr == "H3900" ) |
133 | d->m_model = Model_iPAQ_H39xx; | 134 | d->m_model = Model_iPAQ_H39xx; |
134 | else if ( d->m_modelstr == "H5400" ) | 135 | else if ( d->m_modelstr == "H5400" ) |
135 | d->m_model = Model_iPAQ_H5xxx; | 136 | d->m_model = Model_iPAQ_H5xxx; |
136 | else if ( d->m_modelstr == "H2200" ) | 137 | else if ( d->m_modelstr == "H2200" ) |
137 | d->m_model = Model_iPAQ_H22xx; | 138 | d->m_model = Model_iPAQ_H22xx; |
138 | else | 139 | else |
139 | d->m_model = Model_Unknown; | 140 | d->m_model = Model_Unknown; |
140 | 141 | ||
141 | switch ( d->m_model ) { | 142 | switch ( d->m_model ) { |
142 | case Model_iPAQ_H31xx: | 143 | case Model_iPAQ_H31xx: |
143 | case Model_iPAQ_H38xx: | 144 | case Model_iPAQ_H38xx: |
144 | d->m_rotation = Rot90; | 145 | d->m_rotation = Rot90; |
145 | break; | 146 | break; |
146 | case Model_iPAQ_H5xxx: | 147 | case Model_iPAQ_H5xxx: |
147 | case Model_iPAQ_H22xx: | 148 | case Model_iPAQ_H22xx: |
148 | d->m_rotation = Rot0; | 149 | d->m_rotation = Rot0; |
149 | break; | 150 | break; |
150 | case Model_iPAQ_H36xx: | 151 | case Model_iPAQ_H36xx: |
151 | case Model_iPAQ_H37xx: | 152 | case Model_iPAQ_H37xx: |
152 | case Model_iPAQ_H39xx: | 153 | case Model_iPAQ_H39xx: |
153 | default: | 154 | default: |
154 | d->m_rotation = Rot270; | 155 | d->m_rotation = Rot270; |
155 | break; | 156 | break; |
156 | 157 | ||
157 | } | 158 | } |
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 )); |
184 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); | 187 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); |
185 | 188 | ||
186 | d->m_buttons->append ( b ); | 189 | d->m_buttons->append ( b ); |
187 | } | 190 | } |
188 | } | 191 | } |
189 | reloadButtonMapping(); | 192 | reloadButtonMapping(); |
190 | 193 | ||
191 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 194 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
192 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 195 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
193 | } | 196 | } |
194 | 197 | ||
195 | QValueList <OLed> iPAQ::ledList() const | 198 | QValueList <OLed> iPAQ::ledList() const |
196 | { | 199 | { |
197 | QValueList <OLed> vl; | 200 | QValueList <OLed> vl; |
198 | vl << Led_Power; | 201 | vl << Led_Power; |
199 | 202 | ||
200 | if ( d->m_model == Model_iPAQ_H38xx ) | 203 | if ( d->m_model == Model_iPAQ_H38xx ) |
201 | vl << Led_BlueTooth; | 204 | vl << Led_BlueTooth; |
202 | return vl; | 205 | return vl; |
203 | } | 206 | } |
204 | 207 | ||
205 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 208 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
206 | { | 209 | { |
207 | QValueList <OLedState> vl; | 210 | QValueList <OLedState> vl; |
208 | 211 | ||
209 | if ( l == Led_Power ) | 212 | if ( l == Led_Power ) |
210 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 213 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
211 | else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) | 214 | else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) |
212 | vl << Led_Off; // << Led_On << ??? | 215 | vl << Led_Off; // << Led_On << ??? |
213 | 216 | ||
214 | return vl; | 217 | return vl; |
215 | } | 218 | } |
216 | 219 | ||
217 | OLedState iPAQ::ledState ( OLed l ) const | 220 | OLedState iPAQ::ledState ( OLed l ) const |
218 | { | 221 | { |
219 | switch ( l ) { | 222 | switch ( l ) { |
220 | case Led_Power: | 223 | case Led_Power: |
221 | return m_leds [0]; | 224 | return m_leds [0]; |
222 | case Led_BlueTooth: | 225 | case Led_BlueTooth: |
223 | return m_leds [1]; | 226 | return m_leds [1]; |
224 | default: | 227 | default: |
225 | return Led_Off; | 228 | return Led_Off; |
226 | } | 229 | } |
227 | } | 230 | } |
228 | 231 | ||
229 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 232 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
230 | { | 233 | { |
231 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 234 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
232 | 235 | ||
233 | if ( l == Led_Power ) { | 236 | if ( l == Led_Power ) { |
234 | if ( fd >= 0 ) { | 237 | if ( fd >= 0 ) { |
235 | LED_IN leds; | 238 | LED_IN leds; |
236 | ::memset ( &leds, 0, sizeof( leds )); | 239 | ::memset ( &leds, 0, sizeof( leds )); |
237 | leds. TotalTime = 0; | 240 | leds. TotalTime = 0; |
238 | leds. OnTime = 0; | 241 | leds. OnTime = 0; |
239 | leds. OffTime = 1; | 242 | leds. OffTime = 1; |
240 | leds. OffOnBlink = 2; | 243 | leds. OffOnBlink = 2; |
241 | 244 | ||
242 | switch ( st ) { | 245 | switch ( st ) { |
243 | case Led_Off : leds. OffOnBlink = 0; break; | 246 | case Led_Off : leds. OffOnBlink = 0; break; |
244 | case Led_On : leds. OffOnBlink = 1; break; | 247 | case Led_On : leds. OffOnBlink = 1; break; |
245 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 248 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
246 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 249 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
247 | } | 250 | } |
248 | 251 | ||
249 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 252 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
250 | m_leds [0] = st; | 253 | m_leds [0] = st; |
251 | return true; | 254 | return true; |
252 | } | 255 | } |
253 | } | 256 | } |
254 | } | 257 | } |
255 | return false; | 258 | return false; |
256 | } | 259 | } |
257 | 260 | ||
258 | 261 | ||
259 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 262 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
260 | { | 263 | { |
261 | int newkeycode = keycode; | 264 | int newkeycode = keycode; |
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 ) |
296 | killTimer ( m_power_timer ); | 299 | killTimer ( m_power_timer ); |
297 | m_power_timer = startTimer ( 500 ); | 300 | m_power_timer = startTimer ( 500 ); |
298 | } | 301 | } |
299 | else if ( m_power_timer ) { | 302 | else if ( m_power_timer ) { |
300 | killTimer ( m_power_timer ); | 303 | killTimer ( m_power_timer ); |
301 | m_power_timer = 0; | 304 | m_power_timer = 0; |
302 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 305 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
303 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 306 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
304 | } | 307 | } |
305 | newkeycode = Key_unknown; | 308 | newkeycode = Key_unknown; |
306 | break; | 309 | break; |
307 | } | 310 | } |
308 | } | 311 | } |
309 | 312 | ||
310 | if ( newkeycode != keycode ) { | 313 | if ( newkeycode != keycode ) { |
311 | if ( newkeycode != Key_unknown ) | 314 | if ( newkeycode != Key_unknown ) |
312 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 315 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
313 | return true; | 316 | return true; |
314 | } | 317 | } |
315 | else | 318 | else |
316 | return false; | 319 | return false; |
317 | } | 320 | } |
318 | 321 | ||
319 | void iPAQ::timerEvent ( QTimerEvent * ) | 322 | void iPAQ::timerEvent ( QTimerEvent * ) |
320 | { | 323 | { |
321 | killTimer ( m_power_timer ); | 324 | killTimer ( m_power_timer ); |
322 | m_power_timer = 0; | 325 | m_power_timer = 0; |
323 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 326 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
324 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 327 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
325 | } | 328 | } |
326 | 329 | ||
327 | 330 | ||
328 | void iPAQ::playAlarmSound() | 331 | void iPAQ::playAlarmSound() |
329 | { | 332 | { |
330 | #ifndef QT_NO_SOUND | 333 | #ifndef QT_NO_SOUND |
331 | static Sound snd ( "alarm" ); | 334 | static Sound snd ( "alarm" ); |
332 | int fd; | 335 | int fd; |
333 | int vol; | 336 | int vol; |
334 | bool vol_reset = false; | 337 | bool vol_reset = false; |
335 | 338 | ||
336 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 339 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
337 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 340 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
338 | Config cfg ( "qpe" ); | 341 | Config cfg ( "qpe" ); |
339 | cfg. setGroup ( "Volume" ); | 342 | cfg. setGroup ( "Volume" ); |
340 | 343 | ||
341 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 344 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
342 | if ( volalarm < 0 ) | 345 | if ( volalarm < 0 ) |
343 | volalarm = 0; | 346 | volalarm = 0; |
344 | else if ( volalarm > 100 ) | 347 | else if ( volalarm > 100 ) |
345 | volalarm = 100; | 348 | volalarm = 100; |
346 | volalarm |= ( volalarm << 8 ); | 349 | volalarm |= ( volalarm << 8 ); |
347 | 350 | ||
348 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 351 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
349 | vol_reset = true; | 352 | vol_reset = true; |
350 | } | 353 | } |
351 | } | 354 | } |
352 | 355 | ||
353 | snd. play(); | 356 | snd. play(); |
354 | while ( !snd. isFinished()) | 357 | while ( !snd. isFinished()) |
355 | qApp->processEvents(); | 358 | qApp->processEvents(); |
356 | 359 | ||
357 | if ( fd >= 0 ) { | 360 | if ( fd >= 0 ) { |
358 | if ( vol_reset ) | 361 | if ( vol_reset ) |
359 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 362 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
360 | ::close ( fd ); | 363 | ::close ( fd ); |
361 | } | 364 | } |
362 | #endif | 365 | #endif |
363 | } | 366 | } |
364 | 367 | ||
365 | 368 | ||
366 | bool iPAQ::setSoftSuspend ( bool soft ) | 369 | bool iPAQ::setSoftSuspend ( bool soft ) |
367 | { | 370 | { |
368 | bool res = false; | 371 | bool res = false; |
369 | int fd; | 372 | int fd; |
370 | 373 | ||
371 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 374 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
372 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 375 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
373 | res = true; | 376 | res = true; |
374 | else | 377 | else |
375 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 378 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
376 | 379 | ||
377 | ::close ( fd ); | 380 | ::close ( fd ); |
378 | } | 381 | } |
379 | else | 382 | else |
380 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 383 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
381 | 384 | ||
382 | return res; | 385 | return res; |
383 | } | 386 | } |
384 | 387 | ||
385 | 388 | ||
386 | bool iPAQ::setDisplayBrightness ( int bright ) | 389 | bool iPAQ::setDisplayBrightness ( int bright ) |
387 | { | 390 | { |
388 | bool res = false; | 391 | bool res = false; |
389 | int fd; | 392 | int fd; |
390 | 393 | ||
391 | if ( bright > 255 ) | 394 | if ( bright > 255 ) |
392 | bright = 255; | 395 | bright = 255; |
393 | if ( bright < 0 ) | 396 | if ( bright < 0 ) |
394 | bright = 0; | 397 | bright = 0; |
395 | 398 | ||
396 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 399 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
397 | FLITE_IN bl; | 400 | FLITE_IN bl; |
398 | bl. mode = 1; | 401 | bl. mode = 1; |
399 | bl. pwr = bright ? 1 : 0; | 402 | bl. pwr = bright ? 1 : 0; |
400 | bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; | 403 | bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; |
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 | ||
426 | 429 | ||
427 | bool iPAQ::hasLightSensor() const | 430 | bool iPAQ::hasLightSensor() const |
428 | { | 431 | { |
429 | return true; | 432 | return true; |
430 | } | 433 | } |
431 | 434 | ||
432 | int iPAQ::readLightSensor() | 435 | int iPAQ::readLightSensor() |
433 | { | 436 | { |
434 | int fd; | 437 | int fd; |
435 | int val = -1; | 438 | int val = -1; |
436 | 439 | ||
437 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 440 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
438 | char buffer [8]; | 441 | char buffer [8]; |
439 | 442 | ||
440 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 443 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
441 | char *endptr; | 444 | char *endptr; |
442 | 445 | ||
443 | buffer [4] = 0; | 446 | buffer [4] = 0; |
444 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 447 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
445 | 448 | ||
446 | if ( *endptr != 0 ) | 449 | if ( *endptr != 0 ) |
447 | val = -1; | 450 | val = -1; |
448 | } | 451 | } |
449 | ::close ( fd ); | 452 | ::close ( fd ); |
450 | } | 453 | } |
451 | 454 | ||
452 | return val; | 455 | return val; |
453 | } | 456 | } |
454 | 457 | ||
455 | int iPAQ::lightSensorResolution() const | 458 | int iPAQ::lightSensorResolution() const |
456 | { | 459 | { |
457 | return 256; | 460 | return 256; |
458 | } | 461 | } |
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,370 +1,374 @@ | |||
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 |
55 | 56 | ||
56 | using namespace Opie::Core; | 57 | using namespace Opie::Core; |
57 | using namespace Opie::Core::Internal; | 58 | using namespace Opie::Core::Internal; |
58 | 59 | ||
59 | struct s_button simpad_buttons [] = { | 60 | struct s_button simpad_buttons [] = { |
60 | { 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, |
61 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), | 62 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), |
62 | "devicebuttons/simpad_lower_up", | 63 | "devicebuttons/simpad_lower_up", |
63 | "datebook", "nextView()", | 64 | "datebook", "nextView()", |
64 | "today", "raise()" }, | 65 | "today", "raise()" }, |
65 | { 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, |
66 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), | 67 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), |
67 | "devicebuttons/simpad_lower_down", | 68 | "devicebuttons/simpad_lower_down", |
68 | "addressbook", "raise()", | 69 | "addressbook", "raise()", |
69 | "addressbook", "beamBusinessCard()" }, | 70 | "addressbook", "beamBusinessCard()" }, |
70 | { 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, |
71 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), | 72 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), |
72 | "devicebuttons/simpad_lower_right", | 73 | "devicebuttons/simpad_lower_right", |
73 | "QPE/TaskBar", "toggleMenu()", | 74 | "QPE/TaskBar", "toggleMenu()", |
74 | "QPE/TaskBar", "toggleStartMenu()" }, | 75 | "QPE/TaskBar", "toggleStartMenu()" }, |
75 | { 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, |
76 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), | 77 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), |
77 | "devicebuttons/simpad_lower_left", | 78 | "devicebuttons/simpad_lower_left", |
78 | "opiemail", "raise()", | 79 | "opiemail", "raise()", |
79 | "opiemail", "newMail()" }, | 80 | "opiemail", "newMail()" }, |
80 | 81 | ||
81 | { 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, |
82 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), | 83 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), |
83 | "devicebuttons/simpad_upper_up", | 84 | "devicebuttons/simpad_upper_up", |
84 | "QPE/Launcher", "home()", | 85 | "QPE/Launcher", "home()", |
85 | "buttonsettings", "raise()" }, | 86 | "buttonsettings", "raise()" }, |
86 | { 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, |
87 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), | 88 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), |
88 | "devicebuttons/simpad_upper_down", | 89 | "devicebuttons/simpad_upper_down", |
89 | "addressbook", "raise()", | 90 | "addressbook", "raise()", |
90 | "addressbook", "beamBusinessCard()" }, | 91 | "addressbook", "beamBusinessCard()" }, |
91 | { 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, |
92 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), | 93 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), |
93 | "devicebuttons/simpad_upper_right", | 94 | "devicebuttons/simpad_upper_right", |
94 | "QPE/TaskBar", "toggleMenu()", | 95 | "QPE/TaskBar", "toggleMenu()", |
95 | "QPE/TaskBar", "toggleStartMenu()" }, | 96 | "QPE/TaskBar", "toggleStartMenu()" }, |
96 | { 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, |
97 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), | 98 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), |
98 | "devicebuttons/simpad_upper_left", | 99 | "devicebuttons/simpad_upper_left", |
99 | "QPE/Rotation", "flip()", | 100 | "QPE/Rotation", "flip()", |
100 | "QPE/Rotation", "flip()" }, | 101 | "QPE/Rotation", "flip()" }, |
101 | /* | 102 | /* |
102 | { 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, |
103 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 104 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
104 | "devicebuttons/simpad_lower_upper", | 105 | "devicebuttons/simpad_lower_upper", |
105 | "QPE/Launcher", "home()", | 106 | "QPE/Launcher", "home()", |
106 | "buttonsettings", "raise()" }, | 107 | "buttonsettings", "raise()" }, |
107 | { 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, |
108 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 109 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
109 | "devicebuttons/simpad_upper_lower", | 110 | "devicebuttons/simpad_upper_lower", |
110 | "QPE/Launcher", "home()", | 111 | "QPE/Launcher", "home()", |
111 | "buttonsettings", "raise()" }, | 112 | "buttonsettings", "raise()" }, |
112 | */ | 113 | */ |
113 | }; | 114 | }; |
114 | 115 | ||
115 | void SIMpad::init(const QString&) | 116 | void SIMpad::init(const QString&) |
116 | { | 117 | { |
117 | d->m_vendorstr = "SIEMENS"; | 118 | d->m_vendorstr = "SIEMENS"; |
118 | d->m_vendor = Vendor_SIEMENS; | 119 | d->m_vendor = Vendor_SIEMENS; |
119 | 120 | ||
120 | 121 | ||
121 | //TODO Implement model checking | 122 | //TODO Implement model checking |
122 | //FIXME For now we assume an SL4 | 123 | //FIXME For now we assume an SL4 |
123 | 124 | ||
124 | d->m_modelstr = "SL4"; | 125 | d->m_modelstr = "SL4"; |
125 | d->m_model = Model_SIMpad_SL4; | 126 | d->m_model = Model_SIMpad_SL4; |
126 | 127 | ||
127 | switch ( d->m_model ) { | 128 | switch ( d->m_model ) { |
128 | default: | 129 | default: |
129 | d->m_rotation = Rot0; | 130 | d->m_rotation = Rot0; |
130 | d->m_direction = CCW; | 131 | d->m_direction = CCW; |
131 | d->m_holdtime = 1000; // 1000ms | 132 | d->m_holdtime = 1000; // 1000ms |
132 | 133 | ||
133 | break; | 134 | break; |
134 | } | 135 | } |
135 | 136 | ||
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 )); |
162 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); | 166 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); |
163 | 167 | ||
164 | d->m_buttons->append ( b ); | 168 | d->m_buttons->append ( b ); |
165 | } | 169 | } |
166 | } | 170 | } |
167 | reloadButtonMapping(); | 171 | reloadButtonMapping(); |
168 | 172 | ||
169 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 173 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
170 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 174 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
171 | } | 175 | } |
172 | 176 | ||
173 | // SIMpad boardcontrol register CS3 | 177 | // SIMpad boardcontrol register CS3 |
174 | #define SIMPAD_BOARDCONTROL "/proc/cs3" | 178 | #define SIMPAD_BOARDCONTROL "/proc/cs3" |
175 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA | 179 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA |
176 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA | 180 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA |
177 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's | 181 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's |
178 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V | 182 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V |
179 | #define SIMPAD_DISPLAY_ON 0x0010 | 183 | #define SIMPAD_DISPLAY_ON 0x0010 |
180 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 | 184 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 |
181 | #define SIMPAD_MQ_RESET 0x0040 | 185 | #define SIMPAD_MQ_RESET 0x0040 |
182 | #define SIMPAD_PCMCIA_RESET 0x0080 | 186 | #define SIMPAD_PCMCIA_RESET 0x0080 |
183 | #define SIMPAD_DECT_POWER_ON 0x0100 | 187 | #define SIMPAD_DECT_POWER_ON 0x0100 |
184 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave | 188 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave |
185 | #define SIMPAD_RS232_ON 0x0400 | 189 | #define SIMPAD_RS232_ON 0x0400 |
186 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave | 190 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave |
187 | #define SIMPAD_LED2_ON 0x1000 | 191 | #define SIMPAD_LED2_ON 0x1000 |
188 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode | 192 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode |
189 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit | 193 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit |
190 | #define SIMPAD_RESET_SIMCARD 0x8000 | 194 | #define SIMPAD_RESET_SIMCARD 0x8000 |
191 | 195 | ||
192 | //SIMpad touchscreen backlight strength control | 196 | //SIMpad touchscreen backlight strength control |
193 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" | 197 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" |
194 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 | 198 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 |
195 | 199 | ||
196 | QValueList <OLed> SIMpad::ledList() const | 200 | QValueList <OLed> SIMpad::ledList() const |
197 | { | 201 | { |
198 | QValueList <OLed> vl; | 202 | QValueList <OLed> vl; |
199 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? | 203 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? |
200 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway | 204 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway |
201 | return vl; | 205 | return vl; |
202 | } | 206 | } |
203 | 207 | ||
204 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const | 208 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const |
205 | { | 209 | { |
206 | QValueList <OLedState> vl; | 210 | QValueList <OLedState> vl; |
207 | 211 | ||
208 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? | 212 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? |
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 |
234 | && with SIMPAD_LED2_ON | 238 | && with SIMPAD_LED2_ON |
235 | write to cs3 */ | 239 | write to cs3 */ |
236 | m_leds [0] = st; | 240 | m_leds [0] = st; |
237 | return true; | 241 | return true; |
238 | } | 242 | } |
239 | } | 243 | } |
240 | } | 244 | } |
241 | 245 | ||
242 | #endif | 246 | #endif |
243 | return false; | 247 | return false; |
244 | } | 248 | } |
245 | 249 | ||
246 | 250 | ||
247 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 251 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
248 | { | 252 | { |
249 | //TODO | 253 | //TODO |
250 | return false; | 254 | return false; |
251 | } | 255 | } |
252 | 256 | ||
253 | void SIMpad::timerEvent ( QTimerEvent * ) | 257 | void SIMpad::timerEvent ( QTimerEvent * ) |
254 | { | 258 | { |
255 | killTimer ( m_power_timer ); | 259 | killTimer ( m_power_timer ); |
256 | m_power_timer = 0; | 260 | m_power_timer = 0; |
257 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 261 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
258 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 262 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
259 | } | 263 | } |
260 | 264 | ||
261 | 265 | ||
262 | void SIMpad::playAlarmSound() | 266 | void SIMpad::playAlarmSound() |
263 | { | 267 | { |
264 | #ifndef QT_NO_SOUND | 268 | #ifndef QT_NO_SOUND |
265 | static Sound snd ( "alarm" ); | 269 | static Sound snd ( "alarm" ); |
266 | int fd; | 270 | int fd; |
267 | int vol; | 271 | int vol; |
268 | bool vol_reset = false; | 272 | bool vol_reset = false; |
269 | 273 | ||
270 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 274 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
271 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 275 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
272 | Config cfg ( "qpe" ); | 276 | Config cfg ( "qpe" ); |
273 | cfg. setGroup ( "Volume" ); | 277 | cfg. setGroup ( "Volume" ); |
274 | 278 | ||
275 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 279 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
276 | if ( volalarm < 0 ) | 280 | if ( volalarm < 0 ) |
277 | volalarm = 0; | 281 | volalarm = 0; |
278 | else if ( volalarm > 100 ) | 282 | else if ( volalarm > 100 ) |
279 | volalarm = 100; | 283 | volalarm = 100; |
280 | volalarm |= ( volalarm << 8 ); | 284 | volalarm |= ( volalarm << 8 ); |
281 | 285 | ||
282 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 286 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
283 | vol_reset = true; | 287 | vol_reset = true; |
284 | } | 288 | } |
285 | } | 289 | } |
286 | 290 | ||
287 | snd. play(); | 291 | snd. play(); |
288 | while ( !snd. isFinished()) | 292 | while ( !snd. isFinished()) |
289 | qApp->processEvents(); | 293 | qApp->processEvents(); |
290 | 294 | ||
291 | if ( fd >= 0 ) { | 295 | if ( fd >= 0 ) { |
292 | if ( vol_reset ) | 296 | if ( vol_reset ) |
293 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 297 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
294 | ::close ( fd ); | 298 | ::close ( fd ); |
295 | } | 299 | } |
296 | #endif | 300 | #endif |
297 | } | 301 | } |
298 | 302 | ||
299 | 303 | ||
300 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm | 304 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm |
301 | { | 305 | { |
302 | qDebug( "ODevice for SIMpad: suspend()" ); | 306 | qDebug( "ODevice for SIMpad: suspend()" ); |
303 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 307 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
304 | return false; | 308 | return false; |
305 | 309 | ||
306 | bool res = false; | 310 | bool res = false; |
307 | ODevice::sendSuspendmsg(); | 311 | ODevice::sendSuspendmsg(); |
308 | 312 | ||
309 | struct timeval tvs, tvn; | 313 | struct timeval tvs, tvn; |
310 | ::gettimeofday ( &tvs, 0 ); | 314 | ::gettimeofday ( &tvs, 0 ); |
311 | 315 | ||
312 | ::sync(); // flush fs caches | 316 | ::sync(); // flush fs caches |
313 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) | 317 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) |
314 | 318 | ||
315 | return res; | 319 | return res; |
316 | } | 320 | } |
317 | 321 | ||
318 | 322 | ||
319 | bool SIMpad::setSoftSuspend ( bool soft ) | 323 | bool SIMpad::setSoftSuspend ( bool soft ) |
320 | { | 324 | { |
321 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); | 325 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); |
322 | return false; | 326 | return false; |
323 | } | 327 | } |
324 | 328 | ||
325 | 329 | ||
326 | bool SIMpad::setDisplayStatus ( bool on ) | 330 | bool SIMpad::setDisplayStatus ( bool on ) |
327 | { | 331 | { |
328 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 332 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
329 | 333 | ||
330 | bool res = false; | 334 | bool res = false; |
331 | int fd; | 335 | int fd; |
332 | 336 | ||
333 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) | 337 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) |
334 | 338 | ||
335 | res = ( ::system( (const char*) cmdline ) == 0 ); | 339 | res = ( ::system( (const char*) cmdline ) == 0 ); |
336 | 340 | ||
337 | return res; | 341 | return res; |
338 | } | 342 | } |
339 | 343 | ||
340 | 344 | ||
341 | bool SIMpad::setDisplayBrightness ( int bright ) | 345 | bool SIMpad::setDisplayBrightness ( int bright ) |
342 | { | 346 | { |
343 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); | 347 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); |
344 | bool res = false; | 348 | bool res = false; |
345 | int fd; | 349 | int fd; |
346 | 350 | ||
347 | if ( bright > 255 ) | 351 | if ( bright > 255 ) |
348 | bright = 255; | 352 | bright = 255; |
349 | if ( bright < 1 ) | 353 | if ( bright < 1 ) |
350 | bright = 0; | 354 | bright = 0; |
351 | 355 | ||
352 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 356 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
353 | int value = 255 - bright; | 357 | int value = 255 - bright; |
354 | const int mask = SIMPAD_BACKLIGHT_MASK; | 358 | const int mask = SIMPAD_BACKLIGHT_MASK; |
355 | value = value << 8; | 359 | value = value << 8; |
356 | value += mask; | 360 | value += mask; |
357 | char writeCommand[100]; | 361 | char writeCommand[100]; |
358 | const int count = snprintf( writeCommand, sizeof(writeCommand), "0x%x\n", value ); | 362 | const int count = snprintf( writeCommand, sizeof(writeCommand), "0x%x\n", value ); |
359 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 363 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
360 | ::close ( fd ); | 364 | ::close ( fd ); |
361 | } | 365 | } |
362 | return res; | 366 | return res; |
363 | } | 367 | } |
364 | 368 | ||
365 | 369 | ||
366 | int SIMpad::displayBrightnessResolution() const | 370 | int SIMpad::displayBrightnessResolution() const |
367 | { | 371 | { |
368 | return 255; // All SIMpad models share the same display | 372 | return 255; // All SIMpad models share the same display |
369 | } | 373 | } |
370 | 374 | ||
diff --git a/libopie2/opiecore/okeyfilter.cpp b/libopie2/opiecore/okeyfilter.cpp new file mode 100644 index 0000000..d806dbd --- a/dev/null +++ b/libopie2/opiecore/okeyfilter.cpp | |||
@@ -0,0 +1,119 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | =. Copyright (C) 2004 Rajko 'Alwin' Albrecht <alwin@handhelds.org> | ||
4 | .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This program is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This program is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
18 | ..}^=.= = ; Library General Public License for more | ||
19 | ++= -. .` .: details. | ||
20 | : = ...= . :.=- | ||
21 | -. .:....=;==+<; You should have received a copy of the GNU | ||
22 | -_. . . )=. = Library General Public License along with | ||
23 | -- :-=` this library; see the file COPYING.LIB. | ||
24 | If not, write to the Free Software Foundation, | ||
25 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | ||
27 | */ | ||
28 | |||
29 | #include "okeyfilter.h" | ||
30 | #include "device/odevice.h" | ||
31 | #include "odebug.h" | ||
32 | |||
33 | namespace Opie { | ||
34 | namespace Core { | ||
35 | |||
36 | QValueList<QWSServer::KeyboardFilter*> OKeyFilter::filterList; | ||
37 | QValueList<QWSServer::KeyboardFilter*> OKeyFilter::preFilterList; | ||
38 | |||
39 | OKeyFilter::OKeyFilter() | ||
40 | :QWSServer::KeyboardFilter() | ||
41 | { | ||
42 | filterList.clear(); | ||
43 | preFilterList.clear(); | ||
44 | if ( isQWS( ) ) { | ||
45 | QWSServer::setKeyboardFilter ( this ); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | OKeyFilter::~OKeyFilter() | ||
50 | { | ||
51 | } | ||
52 | |||
53 | OKeyFilter* OKeyFilter::inst() | ||
54 | { | ||
55 | static OKeyFilter*ofilter = 0; | ||
56 | if (!ofilter) { | ||
57 | ofilter = new OKeyFilter; | ||
58 | } | ||
59 | return ofilter; | ||
60 | } | ||
61 | |||
62 | bool OKeyFilter::filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ) | ||
63 | { | ||
64 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; | ||
65 | for (iter=preFilterList.begin();iter!=preFilterList.end();++iter) { | ||
66 | if ((*iter)->filter(unicode,keycode,modifiers,isPress,autoRepeat)) { | ||
67 | return true; | ||
68 | } | ||
69 | } | ||
70 | for (iter=filterList.begin();iter!=filterList.end();++iter) { | ||
71 | if ((*iter)->filter(unicode,keycode,modifiers,isPress,autoRepeat)) { | ||
72 | return true; | ||
73 | } | ||
74 | } | ||
75 | return false; | ||
76 | } | ||
77 | |||
78 | void OKeyFilter::addHandler(QWSServer::KeyboardFilter*aF) | ||
79 | { | ||
80 | if (filterList.find(aF)!=filterList.end()) { | ||
81 | return; | ||
82 | } | ||
83 | odebug << "adding a keyboard filter handler"<<oendl; | ||
84 | filterList.append(aF); | ||
85 | } | ||
86 | |||
87 | void OKeyFilter::remHandler(QWSServer::KeyboardFilter*aF) | ||
88 | { | ||
89 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; | ||
90 | if ( (iter=filterList.find(aF))==filterList.end() ) { | ||
91 | return; | ||
92 | } | ||
93 | odebug << "removing a keyboard filter handler"<<oendl; | ||
94 | filterList.remove(iter); | ||
95 | } | ||
96 | |||
97 | void OKeyFilter::addPreHandler(QWSServer::KeyboardFilter*aF) | ||
98 | { | ||
99 | if (preFilterList.find(aF)!=preFilterList.end()) { | ||
100 | return; | ||
101 | } | ||
102 | odebug << "adding a preferred keyboard filter handler"<<oendl; | ||
103 | preFilterList.append(aF); | ||
104 | } | ||
105 | |||
106 | void OKeyFilter::remPreHandler(QWSServer::KeyboardFilter*aF) | ||
107 | { | ||
108 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; | ||
109 | if ( (iter=preFilterList.find(aF))==preFilterList.end() ) { | ||
110 | return; | ||
111 | } | ||
112 | odebug << "removing a preferred keyboard filter handler"<<oendl; | ||
113 | preFilterList.remove(iter); | ||
114 | } | ||
115 | |||
116 | /* namespace Core */ | ||
117 | } | ||
118 | /* namespace Opie */ | ||
119 | } | ||
diff --git a/libopie2/opiecore/okeyfilter.h b/libopie2/opiecore/okeyfilter.h new file mode 100644 index 0000000..3f9f744 --- a/dev/null +++ b/libopie2/opiecore/okeyfilter.h | |||
@@ -0,0 +1,77 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | =. Copyright (C) 2004 Rajko 'Alwin' Albrecht <alwin@handhelds.org> | ||
4 | .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This program is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This program is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
18 | ..}^=.= = ; Library General Public License for more | ||
19 | ++= -. .` .: details. | ||
20 | : = ...= . :.=- | ||
21 | -. .:....=;==+<; You should have received a copy of the GNU | ||
22 | -_. . . )=. = Library General Public License along with | ||
23 | -- :-=` this library; see the file COPYING.LIB. | ||
24 | If not, write to the Free Software Foundation, | ||
25 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | ||
27 | */ | ||
28 | |||
29 | /* QT */ | ||
30 | #include <qwindowsystem_qws.h> | ||
31 | #include <qvaluelist.h> | ||
32 | |||
33 | namespace Opie { | ||
34 | namespace Core { | ||
35 | class ODevice; | ||
36 | namespace Internal { | ||
37 | class iPAQ; | ||
38 | class SIMpad; | ||
39 | } | ||
40 | |||
41 | /** | ||
42 | * A singleton which will manage all possible keyboard filters inside opie. | ||
43 | * It makes sure that key handlers of odevice are checked first than the | ||
44 | * keyfilters of software. | ||
45 | * @short a keyfilter proxy | ||
46 | * @see QWSServer::KeyboardFilter | ||
47 | * @author Rajko Albrecht | ||
48 | * @version 1.0 | ||
49 | */ | ||
50 | class OKeyFilter:public QWSServer::KeyboardFilter | ||
51 | { | ||
52 | friend class Opie::Core::ODevice; | ||
53 | friend class Opie::Core::Internal::iPAQ; | ||
54 | friend class Opie::Core::Internal::SIMpad; | ||
55 | |||
56 | static QValueList<QWSServer::KeyboardFilter*> filterList; | ||
57 | static QValueList<QWSServer::KeyboardFilter*> preFilterList; | ||
58 | |||
59 | OKeyFilter(); | ||
60 | OKeyFilter(const OKeyFilter&):QWSServer::KeyboardFilter(){}; | ||
61 | |||
62 | protected: | ||
63 | void addPreHandler(QWSServer::KeyboardFilter*); | ||
64 | void remPreHandler(QWSServer::KeyboardFilter*); | ||
65 | |||
66 | public: | ||
67 | virtual ~OKeyFilter(); | ||
68 | virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | ||
69 | |||
70 | void addHandler(QWSServer::KeyboardFilter*); | ||
71 | void remHandler(QWSServer::KeyboardFilter*); | ||
72 | |||
73 | static OKeyFilter*inst(); | ||
74 | }; | ||
75 | |||
76 | } | ||
77 | } | ||
diff --git a/libopie2/opiecore/opiecore.pro b/libopie2/opiecore/opiecore.pro index 5056d48..8189a7c 100644 --- a/libopie2/opiecore/opiecore.pro +++ b/libopie2/opiecore/opiecore.pro | |||
@@ -1,57 +1,59 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | DESTDIR = $(OPIEDIR)/lib | 3 | DESTDIR = $(OPIEDIR)/lib |
4 | HEADERS = oapplication.h \ | 4 | HEADERS = oapplication.h \ |
5 | oconfig.h \ | 5 | oconfig.h \ |
6 | odebug.h \ | 6 | odebug.h \ |
7 | oglobal.h \ | 7 | oglobal.h \ |
8 | oglobalsettings.h \ | 8 | oglobalsettings.h \ |
9 | okeyconfigmanager.h \ | 9 | okeyconfigmanager.h \ |
10 | okeyfilter.h \ | ||
10 | opluginloader.h \ | 11 | opluginloader.h \ |
11 | oprocess.h \ | 12 | oprocess.h \ |
12 | oprocctrl.h \ | 13 | oprocctrl.h \ |
13 | osmartpointer.h \ | 14 | osmartpointer.h \ |
14 | ostorageinfo.h \ | 15 | ostorageinfo.h \ |
15 | xmltree.h | 16 | xmltree.h |
16 | 17 | ||
17 | SOURCES = oapplication.cpp \ | 18 | SOURCES = oapplication.cpp \ |
18 | oconfig.cpp \ | 19 | oconfig.cpp \ |
19 | odebug.cpp \ | 20 | odebug.cpp \ |
20 | oglobal.cpp \ | 21 | oglobal.cpp \ |
21 | oglobalsettings.cpp \ | 22 | oglobalsettings.cpp \ |
22 | okeyconfigmanager.cpp \ | 23 | okeyconfigmanager.cpp \ |
24 | okeyfilter.cpp \ | ||
23 | opluginloader.cpp \ | 25 | opluginloader.cpp \ |
24 | oprocess.cpp \ | 26 | oprocess.cpp \ |
25 | oprocctrl.cpp \ | 27 | oprocctrl.cpp \ |
26 | ostorageinfo.cpp \ | 28 | ostorageinfo.cpp \ |
27 | xmltree.cpp | 29 | xmltree.cpp |
28 | 30 | ||
29 | 31 | ||
30 | # The following files are currently not compileable on mac ! | 32 | # The following files are currently not compileable on mac ! |
31 | # Therfore I removed them from the build .. (eilers) | 33 | # Therfore I removed them from the build .. (eilers) |
32 | 34 | ||
33 | CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) | 35 | CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) |
34 | !contains( CONFTEST, y ) { | 36 | !contains( CONFTEST, y ) { |
35 | HEADERS += ofilenotify.h | 37 | HEADERS += ofilenotify.h |
36 | SOURCES += ofilenotify.cpp | 38 | SOURCES += ofilenotify.cpp |
37 | } else { | 39 | } else { |
38 | message( "ofilenotify is not available in a mac build !" ) | 40 | message( "ofilenotify is not available in a mac build !" ) |
39 | } | 41 | } |
40 | 42 | ||
41 | include ( device/device.pro ) | 43 | include ( device/device.pro ) |
42 | 44 | ||
43 | INTERFACES = | 45 | INTERFACES = |
44 | TARGET = opiecore2 | 46 | TARGET = opiecore2 |
45 | VERSION = 1.9.1 | 47 | VERSION = 1.9.1 |
46 | INCLUDEPATH += $(OPIEDIR)/include | 48 | INCLUDEPATH += $(OPIEDIR)/include |
47 | DEPENDPATH += $(OPIEDIR)/include | 49 | DEPENDPATH += $(OPIEDIR)/include |
48 | 50 | ||
49 | !contains( platform, x11 ) { | 51 | !contains( platform, x11 ) { |
50 | LIBS = -lqpe | 52 | LIBS = -lqpe |
51 | include ( $(OPIEDIR)/include.pro ) | 53 | include ( $(OPIEDIR)/include.pro ) |
52 | } | 54 | } |
53 | 55 | ||
54 | contains( platform, x11 ) { | 56 | contains( platform, x11 ) { |
55 | LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib | 57 | LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib |
56 | } | 58 | } |
57 | 59 | ||