author | zecke <zecke> | 2005-10-07 18:21:10 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-10-07 18:21:10 (UTC) |
commit | d5beae7038e36633480cc3e17134a85b6d68fbc7 (patch) (unidiff) | |
tree | 632f5ae52296438e1ff6b4a6c669395da912a3bb | |
parent | 0bad2116a1ceed19956b94889cb034781f35146d (diff) | |
download | opie-d5beae7038e36633480cc3e17134a85b6d68fbc7.zip opie-d5beae7038e36633480cc3e17134a85b6d68fbc7.tar.gz opie-d5beae7038e36633480cc3e17134a85b6d68fbc7.tar.bz2 |
libopie2/opiecore/device/odevice_ipaq.cpp:
-make it compile. This line should have been H1940 in the
patch. Now I even compiled libopiecore before comitting ;)
-rw-r--r-- | libopie2/opiecore/device/odevice_ipaq.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp index 52da2d9..2d734a4 100644 --- a/libopie2/opiecore/device/odevice_ipaq.cpp +++ b/libopie2/opiecore/device/odevice_ipaq.cpp | |||
@@ -25,440 +25,440 @@ | |||
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
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/sound.h> | 40 | #include <qpe/sound.h> |
41 | #include <qpe/qcopenvelope_qws.h> | 41 | #include <qpe/qcopenvelope_qws.h> |
42 | 42 | ||
43 | #include <opie2/okeyfilter.h> | 43 | #include <opie2/okeyfilter.h> |
44 | #include <opie2/oresource.h> | 44 | #include <opie2/oresource.h> |
45 | 45 | ||
46 | /* STD */ | 46 | /* STD */ |
47 | #include <fcntl.h> | 47 | #include <fcntl.h> |
48 | #include <math.h> | 48 | #include <math.h> |
49 | #include <stdlib.h> | 49 | #include <stdlib.h> |
50 | #include <signal.h> | 50 | #include <signal.h> |
51 | #include <sys/ioctl.h> | 51 | #include <sys/ioctl.h> |
52 | #include <sys/time.h> | 52 | #include <sys/time.h> |
53 | #include <unistd.h> | 53 | #include <unistd.h> |
54 | #ifndef QT_NO_SOUND | 54 | #ifndef QT_NO_SOUND |
55 | #include <linux/soundcard.h> | 55 | #include <linux/soundcard.h> |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | 58 | ||
59 | using namespace Opie::Core; | 59 | using namespace Opie::Core; |
60 | using namespace Opie::Core::Internal; | 60 | using namespace Opie::Core::Internal; |
61 | 61 | ||
62 | /* KERNEL */ | 62 | /* KERNEL */ |
63 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 63 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
64 | 64 | ||
65 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 65 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
66 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 66 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
67 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 67 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
68 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 68 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
69 | 69 | ||
70 | typedef struct { | 70 | typedef struct { |
71 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 71 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
72 | unsigned char TotalTime; /* Units of 5 seconds */ | 72 | unsigned char TotalTime; /* Units of 5 seconds */ |
73 | unsigned char OnTime; /* units of 100m/s */ | 73 | unsigned char OnTime; /* units of 100m/s */ |
74 | unsigned char OffTime; /* units of 100m/s */ | 74 | unsigned char OffTime; /* units of 100m/s */ |
75 | } LED_IN; | 75 | } LED_IN; |
76 | 76 | ||
77 | typedef struct { | 77 | typedef struct { |
78 | unsigned char mode; | 78 | unsigned char mode; |
79 | unsigned char pwr; | 79 | unsigned char pwr; |
80 | unsigned char brightness; | 80 | unsigned char brightness; |
81 | } FLITE_IN; | 81 | } FLITE_IN; |
82 | 82 | ||
83 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 83 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
84 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 84 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
85 | 85 | ||
86 | struct i_button ipaq_buttons [] = { | 86 | struct i_button ipaq_buttons [] = { |
87 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x, | 87 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x, |
88 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 88 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
89 | "devicebuttons/ipaq_calendar", | 89 | "devicebuttons/ipaq_calendar", |
90 | "datebook", "nextView()", | 90 | "datebook", "nextView()", |
91 | "today", "raise()" }, | 91 | "today", "raise()" }, |
92 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x, | 92 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x, |
93 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 93 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
94 | "devicebuttons/ipaq_contact", | 94 | "devicebuttons/ipaq_contact", |
95 | "addressbook", "raise()", | 95 | "addressbook", "raise()", |
96 | "addressbook", "beamBusinessCard()" }, | 96 | "addressbook", "beamBusinessCard()" }, |
97 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, | 97 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, |
98 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 98 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
99 | "devicebuttons/ipaq_menu", | 99 | "devicebuttons/ipaq_menu", |
100 | "QPE/TaskBar", "toggleMenu()", | 100 | "QPE/TaskBar", "toggleMenu()", |
101 | "QPE/TaskBar", "toggleStartMenu()" }, | 101 | "QPE/TaskBar", "toggleStartMenu()" }, |
102 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 102 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
103 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 103 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
104 | "devicebuttons/ipaq_mail", | 104 | "devicebuttons/ipaq_mail", |
105 | "opiemail", "raise()", | 105 | "opiemail", "raise()", |
106 | "opiemail", "newMail()" }, | 106 | "opiemail", "newMail()" }, |
107 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x, | 107 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx | Model_iPAQ_H191x, |
108 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 108 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
109 | "devicebuttons/ipaq_home", | 109 | "devicebuttons/ipaq_home", |
110 | "QPE/Launcher", "home()", | 110 | "QPE/Launcher", "home()", |
111 | "buttonsettings", "raise()" }, | 111 | "buttonsettings", "raise()" }, |
112 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 112 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
113 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), | 113 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), |
114 | "devicebuttons/ipaq_record", | 114 | "devicebuttons/ipaq_record", |
115 | "QPE/VMemo", "toggleRecord()", | 115 | "QPE/VMemo", "toggleRecord()", |
116 | "sound", "raise()" }, | 116 | "sound", "raise()" }, |
117 | 117 | ||
118 | { Model_iPAQ_H191x, | 118 | { Model_iPAQ_H191x, |
119 | Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 119 | Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
120 | "devicebuttons/ipaq_mail", | 120 | "devicebuttons/ipaq_mail", |
121 | "opiemail", "raise()", | 121 | "opiemail", "raise()", |
122 | "opiemail", "newMail()" }, | 122 | "opiemail", "newMail()" }, |
123 | { Model_iPAQ_H191x, | 123 | { Model_iPAQ_H191x, |
124 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Record Button"), | 124 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Record Button"), |
125 | "devicebuttons/ipaq_record", | 125 | "devicebuttons/ipaq_record", |
126 | "QPE/VMemo", "toggleRecord()", | 126 | "QPE/VMemo", "toggleRecord()", |
127 | "sound", "raise()" }, | 127 | "sound", "raise()" }, |
128 | 128 | ||
129 | }; | 129 | }; |
130 | 130 | ||
131 | void iPAQ::init(const QString& model) | 131 | void iPAQ::init(const QString& model) |
132 | { | 132 | { |
133 | d->m_vendorstr = "HP"; | 133 | d->m_vendorstr = "HP"; |
134 | d->m_vendor = Vendor_HP; | 134 | d->m_vendor = Vendor_HP; |
135 | 135 | ||
136 | d->m_modelstr = model.mid(model.findRev('H')); | 136 | d->m_modelstr = model.mid(model.findRev('H')); |
137 | 137 | ||
138 | if ( d->m_modelstr == "H3100" ) | 138 | if ( d->m_modelstr == "H3100" ) |
139 | d->m_model = Model_iPAQ_H31xx; | 139 | d->m_model = Model_iPAQ_H31xx; |
140 | else if ( d->m_modelstr == "H3600" ) | 140 | else if ( d->m_modelstr == "H3600" ) |
141 | d->m_model = Model_iPAQ_H36xx; | 141 | d->m_model = Model_iPAQ_H36xx; |
142 | else if ( d->m_modelstr == "H3700" ) | 142 | else if ( d->m_modelstr == "H3700" ) |
143 | d->m_model = Model_iPAQ_H37xx; | 143 | d->m_model = Model_iPAQ_H37xx; |
144 | else if ( d->m_modelstr == "H3800" ) | 144 | else if ( d->m_modelstr == "H3800" ) |
145 | d->m_model = Model_iPAQ_H38xx; | 145 | d->m_model = Model_iPAQ_H38xx; |
146 | else if ( d->m_modelstr == "H3900" ) | 146 | else if ( d->m_modelstr == "H3900" ) |
147 | d->m_model = Model_iPAQ_H39xx; | 147 | d->m_model = Model_iPAQ_H39xx; |
148 | else if ( d->m_modelstr == "H5400" ) | 148 | else if ( d->m_modelstr == "H5400" ) |
149 | d->m_model = Model_iPAQ_H5xxx; | 149 | d->m_model = Model_iPAQ_H5xxx; |
150 | else if ( d->m_modelstr == "H2200" ) | 150 | else if ( d->m_modelstr == "H2200" ) |
151 | d->m_model = Model_iPAQ_H22xx; | 151 | d->m_model = Model_iPAQ_H22xx; |
152 | else if ( d->m_modelstr == "H1910" ) | 152 | else if ( d->m_modelstr == "H1910" ) |
153 | d->m_model = Model_iPAQ_H191x; | 153 | d->m_model = Model_iPAQ_H191x; |
154 | else if ( d->m_modelstr == "H1940" ) | 154 | else if ( d->m_modelstr == "H1940" ) |
155 | d->m_model = Model_iPAQ_H1940; | 155 | d->m_model = Model_iPAQ_H1940; |
156 | else | 156 | else |
157 | d->m_model = Model_Unknown; | 157 | d->m_model = Model_Unknown; |
158 | 158 | ||
159 | switch ( d->m_model ) { | 159 | switch ( d->m_model ) { |
160 | case Model_iPAQ_H31xx: | 160 | case Model_iPAQ_H31xx: |
161 | case Model_iPAQ_H38xx: | 161 | case Model_iPAQ_H38xx: |
162 | d->m_rotation = Rot90; | 162 | d->m_rotation = Rot90; |
163 | break; | 163 | break; |
164 | case Model_iPAQ_H5xxx: | 164 | case Model_iPAQ_H5xxx: |
165 | case Model_iPAQ_H22xx: | 165 | case Model_iPAQ_H22xx: |
166 | case Model_iPAQ_H191x: | 166 | case Model_iPAQ_H191x: |
167 | case Model_iPAQ_H1940: | 167 | case Model_iPAQ_H1940: |
168 | d->m_rotation = Rot0; | 168 | d->m_rotation = Rot0; |
169 | break; | 169 | break; |
170 | case Model_iPAQ_H36xx: | 170 | case Model_iPAQ_H36xx: |
171 | case Model_iPAQ_H37xx: | 171 | case Model_iPAQ_H37xx: |
172 | case Model_iPAQ_H39xx: | 172 | case Model_iPAQ_H39xx: |
173 | default: | 173 | default: |
174 | d->m_rotation = Rot270; | 174 | d->m_rotation = Rot270; |
175 | break; | 175 | break; |
176 | 176 | ||
177 | } | 177 | } |
178 | 178 | ||
179 | m_leds [0] = m_leds [1] = Led_Off; | 179 | m_leds [0] = m_leds [1] = Led_Off; |
180 | 180 | ||
181 | m_power_timer = 0; | 181 | m_power_timer = 0; |
182 | 182 | ||
183 | } | 183 | } |
184 | 184 | ||
185 | void iPAQ::initButtons() | 185 | void iPAQ::initButtons() |
186 | { | 186 | { |
187 | if ( d->m_buttons ) | 187 | if ( d->m_buttons ) |
188 | return; | 188 | return; |
189 | 189 | ||
190 | if ( isQWS( ) ) { | 190 | if ( isQWS( ) ) { |
191 | addPreHandler(this); | 191 | addPreHandler(this); |
192 | } | 192 | } |
193 | 193 | ||
194 | d->m_buttons = new QValueList <ODeviceButton>; | 194 | d->m_buttons = new QValueList <ODeviceButton>; |
195 | 195 | ||
196 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 196 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
197 | i_button *ib = ipaq_buttons + i; | 197 | i_button *ib = ipaq_buttons + i; |
198 | ODeviceButton b; | 198 | ODeviceButton b; |
199 | 199 | ||
200 | if (( ib->model & d->m_model ) == d->m_model ) { | 200 | if (( ib->model & d->m_model ) == d->m_model ) { |
201 | b. setKeycode ( ib->code ); | 201 | b. setKeycode ( ib->code ); |
202 | b. setUserText ( QObject::tr ( "Button", ib->utext )); | 202 | b. setUserText ( QObject::tr ( "Button", ib->utext )); |
203 | b. setPixmap ( OResource::loadPixmap ( ib->pix )); | 203 | b. setPixmap ( OResource::loadPixmap ( ib->pix )); |
204 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); | 204 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); |
205 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); | 205 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); |
206 | 206 | ||
207 | d->m_buttons->append ( b ); | 207 | d->m_buttons->append ( b ); |
208 | } | 208 | } |
209 | } | 209 | } |
210 | reloadButtonMapping(); | 210 | reloadButtonMapping(); |
211 | } | 211 | } |
212 | 212 | ||
213 | QValueList <OLed> iPAQ::ledList() const | 213 | QValueList <OLed> iPAQ::ledList() const |
214 | { | 214 | { |
215 | QValueList <OLed> vl; | 215 | QValueList <OLed> vl; |
216 | vl << Led_Power; | 216 | vl << Led_Power; |
217 | 217 | ||
218 | if ( d->m_model == Model_iPAQ_H38xx ) | 218 | if ( d->m_model == Model_iPAQ_H38xx ) |
219 | vl << Led_BlueTooth; | 219 | vl << Led_BlueTooth; |
220 | return vl; | 220 | return vl; |
221 | } | 221 | } |
222 | 222 | ||
223 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 223 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
224 | { | 224 | { |
225 | QValueList <OLedState> vl; | 225 | QValueList <OLedState> vl; |
226 | 226 | ||
227 | if ( l == Led_Power ) | 227 | if ( l == Led_Power ) |
228 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 228 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
229 | else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) | 229 | else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) |
230 | vl << Led_Off; // << Led_On << ??? | 230 | vl << Led_Off; // << Led_On << ??? |
231 | 231 | ||
232 | return vl; | 232 | return vl; |
233 | } | 233 | } |
234 | 234 | ||
235 | OLedState iPAQ::ledState ( OLed l ) const | 235 | OLedState iPAQ::ledState ( OLed l ) const |
236 | { | 236 | { |
237 | switch ( l ) { | 237 | switch ( l ) { |
238 | case Led_Power: | 238 | case Led_Power: |
239 | return m_leds [0]; | 239 | return m_leds [0]; |
240 | case Led_BlueTooth: | 240 | case Led_BlueTooth: |
241 | return m_leds [1]; | 241 | return m_leds [1]; |
242 | default: | 242 | default: |
243 | return Led_Off; | 243 | return Led_Off; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 247 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
248 | { | 248 | { |
249 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 249 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
250 | 250 | ||
251 | if ( l == Led_Power ) { | 251 | if ( l == Led_Power ) { |
252 | if ( fd >= 0 ) { | 252 | if ( fd >= 0 ) { |
253 | LED_IN leds; | 253 | LED_IN leds; |
254 | ::memset ( &leds, 0, sizeof( leds )); | 254 | ::memset ( &leds, 0, sizeof( leds )); |
255 | leds. TotalTime = 0; | 255 | leds. TotalTime = 0; |
256 | leds. OnTime = 0; | 256 | leds. OnTime = 0; |
257 | leds. OffTime = 1; | 257 | leds. OffTime = 1; |
258 | leds. OffOnBlink = 2; | 258 | leds. OffOnBlink = 2; |
259 | 259 | ||
260 | switch ( st ) { | 260 | switch ( st ) { |
261 | case Led_Off : leds. OffOnBlink = 0; break; | 261 | case Led_Off : leds. OffOnBlink = 0; break; |
262 | case Led_On : leds. OffOnBlink = 1; break; | 262 | case Led_On : leds. OffOnBlink = 1; break; |
263 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 263 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
264 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 264 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
265 | } | 265 | } |
266 | 266 | ||
267 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 267 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
268 | m_leds [0] = st; | 268 | m_leds [0] = st; |
269 | return true; | 269 | return true; |
270 | } | 270 | } |
271 | } | 271 | } |
272 | } | 272 | } |
273 | return false; | 273 | return false; |
274 | } | 274 | } |
275 | 275 | ||
276 | 276 | ||
277 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 277 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
278 | { | 278 | { |
279 | int newkeycode = keycode; | 279 | int newkeycode = keycode; |
280 | 280 | ||
281 | switch ( keycode ) { | 281 | switch ( keycode ) { |
282 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 282 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
283 | case HardKey_Menu: { | 283 | case HardKey_Menu: { |
284 | if (( d->m_model == Model_iPAQ_H38xx ) || | 284 | if (( d->m_model == Model_iPAQ_H38xx ) || |
285 | ( d->m_model == Model_iPAQ_H39xx ) || | 285 | ( d->m_model == Model_iPAQ_H39xx ) || |
286 | ( d->m_model == Model_iPAQ_H5xxx)) { | 286 | ( d->m_model == Model_iPAQ_H5xxx)) { |
287 | newkeycode = HardKey_Mail; | 287 | newkeycode = HardKey_Mail; |
288 | } | 288 | } |
289 | break; | 289 | break; |
290 | } | 290 | } |
291 | 291 | ||
292 | // Rotate cursor keys 180 or 270 | 292 | // Rotate cursor keys 180 or 270 |
293 | case Key_Left : | 293 | case Key_Left : |
294 | case Key_Right: | 294 | case Key_Right: |
295 | case Key_Up : | 295 | case Key_Up : |
296 | case Key_Down : { | 296 | case Key_Down : { |
297 | if (( d->m_model == Model_iPAQ_H31xx ) || | 297 | if (( d->m_model == Model_iPAQ_H31xx ) || |
298 | ( d->m_model == Model_iPAQ_H38xx )) { | 298 | ( d->m_model == Model_iPAQ_H38xx )) { |
299 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 299 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
300 | } | 300 | } |
301 | // Rotate the cursor keys by 270 | 301 | // Rotate the cursor keys by 270 |
302 | // keycode - Key_Left = position of the button starting from left clockwise | 302 | // keycode - Key_Left = position of the button starting from left clockwise |
303 | // add the rotation to it and modolo. No we've the original offset | 303 | // add the rotation to it and modolo. No we've the original offset |
304 | // add the offset to the Key_Left key | 304 | // add the offset to the Key_Left key |
305 | if (( d->m_model == Model_iPAQ_H5xxx ) || | 305 | if (( d->m_model == Model_iPAQ_H5xxx ) || |
306 | ( d->m_model == Model_iPAQ_H191x ) || | 306 | ( d->m_model == Model_iPAQ_H191x ) || |
307 | ( d->m_model == Model_iPAQ_H1940 )) | 307 | ( d->m_model == Model_iPAQ_H1940 )) |
308 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; | 308 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; |
309 | break; | 309 | break; |
310 | } | 310 | } |
311 | 311 | ||
312 | // map Power Button short/long press to F34/F35 | 312 | // map Power Button short/long press to F34/F35 |
313 | case Key_SysReq: { | 313 | case Key_SysReq: { |
314 | if ( isPress ) { | 314 | if ( isPress ) { |
315 | if ( m_power_timer ) | 315 | if ( m_power_timer ) |
316 | killTimer ( m_power_timer ); | 316 | killTimer ( m_power_timer ); |
317 | m_power_timer = startTimer ( 500 ); | 317 | m_power_timer = startTimer ( 500 ); |
318 | } | 318 | } |
319 | else if ( m_power_timer ) { | 319 | else if ( m_power_timer ) { |
320 | killTimer ( m_power_timer ); | 320 | killTimer ( m_power_timer ); |
321 | m_power_timer = 0; | 321 | m_power_timer = 0; |
322 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 322 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
323 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 323 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
324 | } | 324 | } |
325 | newkeycode = Key_unknown; | 325 | newkeycode = Key_unknown; |
326 | break; | 326 | break; |
327 | } | 327 | } |
328 | } | 328 | } |
329 | 329 | ||
330 | if ( newkeycode != keycode ) { | 330 | if ( newkeycode != keycode ) { |
331 | if ( newkeycode != Key_unknown ) | 331 | if ( newkeycode != Key_unknown ) |
332 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 332 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
333 | return true; | 333 | return true; |
334 | } | 334 | } |
335 | else | 335 | else |
336 | return false; | 336 | return false; |
337 | } | 337 | } |
338 | 338 | ||
339 | void iPAQ::timerEvent ( QTimerEvent * ) | 339 | void iPAQ::timerEvent ( QTimerEvent * ) |
340 | { | 340 | { |
341 | killTimer ( m_power_timer ); | 341 | killTimer ( m_power_timer ); |
342 | m_power_timer = 0; | 342 | m_power_timer = 0; |
343 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 343 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
344 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 344 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
345 | } | 345 | } |
346 | 346 | ||
347 | 347 | ||
348 | void iPAQ::playAlarmSound() | 348 | void iPAQ::playAlarmSound() |
349 | { | 349 | { |
350 | #ifndef QT_NO_SOUND | 350 | #ifndef QT_NO_SOUND |
351 | static Sound snd ( "alarm" ); | 351 | static Sound snd ( "alarm" ); |
352 | if(!snd.isFinished()) | 352 | if(!snd.isFinished()) |
353 | return; | 353 | return; |
354 | 354 | ||
355 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); | 355 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); |
356 | snd. play(); | 356 | snd. play(); |
357 | #endif | 357 | #endif |
358 | } | 358 | } |
359 | 359 | ||
360 | bool iPAQ::setDisplayBrightness ( int bright ) | 360 | bool iPAQ::setDisplayBrightness ( int bright ) |
361 | { | 361 | { |
362 | bool res = false; | 362 | bool res = false; |
363 | int fd; | 363 | int fd; |
364 | 364 | ||
365 | if ( bright > 255 ) | 365 | if ( bright > 255 ) |
366 | bright = 255; | 366 | bright = 255; |
367 | if ( bright < 0 ) | 367 | if ( bright < 0 ) |
368 | bright = 0; | 368 | bright = 0; |
369 | 369 | ||
370 | QString cmdline; | 370 | QString cmdline; |
371 | 371 | ||
372 | switch ( model()) { | 372 | switch ( model()) { |
373 | case Model_iPAQ_H191x: | 373 | case Model_iPAQ_H191x: |
374 | if ( !bright ) | 374 | if ( !bright ) |
375 | cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/pxafb/power"); | 375 | cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/pxafb/power"); |
376 | else | 376 | else |
377 | cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/pxafb/power; echo %1 > /sys/class/backlight/pxafb/brightness" ).arg( bright ); | 377 | cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/pxafb/power; echo %1 > /sys/class/backlight/pxafb/brightness" ).arg( bright ); |
378 | // No Global::shellQuote as we gurantee it to be sane | 378 | // No Global::shellQuote as we gurantee it to be sane |
379 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); | 379 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); |
380 | break; | 380 | break; |
381 | default: | 381 | default: |
382 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 382 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
383 | FLITE_IN bl; | 383 | FLITE_IN bl; |
384 | bl. mode = 1; | 384 | bl. mode = 1; |
385 | bl. pwr = bright ? 1 : 0; | 385 | bl. pwr = bright ? 1 : 0; |
386 | bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; | 386 | bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; |
387 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 387 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
388 | ::close ( fd ); | 388 | ::close ( fd ); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | return res; | 391 | return res; |
392 | } | 392 | } |
393 | 393 | ||
394 | int iPAQ::displayBrightnessResolution() const | 394 | int iPAQ::displayBrightnessResolution() const |
395 | { | 395 | { |
396 | switch ( model()) { | 396 | switch ( model()) { |
397 | case Model_iPAQ_H31xx: | 397 | case Model_iPAQ_H31xx: |
398 | case Model_iPAQ_H36xx: | 398 | case Model_iPAQ_H36xx: |
399 | case Model_iPAQ_H37xx: | 399 | case Model_iPAQ_H37xx: |
400 | return 128; // really 256, but >128 could damage the LCD | 400 | return 128; // really 256, but >128 could damage the LCD |
401 | 401 | ||
402 | case Model_iPAQ_H38xx: | 402 | case Model_iPAQ_H38xx: |
403 | case Model_iPAQ_H39xx: | 403 | case Model_iPAQ_H39xx: |
404 | return 64; | 404 | return 64; |
405 | case Model_iPAQ_H5xxx: | 405 | case Model_iPAQ_H5xxx: |
406 | return 255; | 406 | return 255; |
407 | case Model_iPAQ_H191x: | 407 | case Model_iPAQ_H191x: |
408 | return 183; | 408 | return 183; |
409 | case Model_iPAQ_H191x: | 409 | case Model_iPAQ_H1940: |
410 | return 44; | 410 | return 44; |
411 | default: | 411 | default: |
412 | return 2; | 412 | return 2; |
413 | } | 413 | } |
414 | } | 414 | } |
415 | 415 | ||
416 | bool iPAQ::setDisplayStatus ( bool on ) | 416 | bool iPAQ::setDisplayStatus ( bool on ) |
417 | { | 417 | { |
418 | bool res = false; | 418 | bool res = false; |
419 | 419 | ||
420 | QString cmdline; | 420 | QString cmdline; |
421 | 421 | ||
422 | if ( model() == Model_iPAQ_H191x ) { | 422 | if ( model() == Model_iPAQ_H191x ) { |
423 | cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/pxafb/power; echo %2 > /sys/class/backlight/pxafb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); | 423 | cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/pxafb/power; echo %2 > /sys/class/backlight/pxafb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); |
424 | } else { | 424 | } else { |
425 | return OAbstractMobileDevice::setDisplayStatus(on); | 425 | return OAbstractMobileDevice::setDisplayStatus(on); |
426 | } | 426 | } |
427 | 427 | ||
428 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); | 428 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); |
429 | 429 | ||
430 | return res; | 430 | return res; |
431 | } | 431 | } |
432 | 432 | ||
433 | bool iPAQ::hasLightSensor() const | 433 | bool iPAQ::hasLightSensor() const |
434 | { | 434 | { |
435 | return true; | 435 | return true; |
436 | } | 436 | } |
437 | 437 | ||
438 | int iPAQ::readLightSensor() | 438 | int iPAQ::readLightSensor() |
439 | { | 439 | { |
440 | int fd; | 440 | int fd; |
441 | int val = -1; | 441 | int val = -1; |
442 | 442 | ||
443 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 443 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
444 | char buffer [8]; | 444 | char buffer [8]; |
445 | 445 | ||
446 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 446 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
447 | char *endptr; | 447 | char *endptr; |
448 | 448 | ||
449 | buffer [4] = 0; | 449 | buffer [4] = 0; |
450 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 450 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
451 | 451 | ||
452 | if ( *endptr != 0 ) | 452 | if ( *endptr != 0 ) |
453 | val = -1; | 453 | val = -1; |
454 | } | 454 | } |
455 | ::close ( fd ); | 455 | ::close ( fd ); |
456 | } | 456 | } |
457 | 457 | ||
458 | return val; | 458 | return val; |
459 | } | 459 | } |
460 | 460 | ||
461 | int iPAQ::lightSensorResolution() const | 461 | int iPAQ::lightSensorResolution() const |
462 | { | 462 | { |
463 | return 256; | 463 | return 256; |
464 | } | 464 | } |