-rw-r--r-- | libopie/odevice.cpp | 108 |
1 files changed, 102 insertions, 6 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 9b2a954..8f954b1 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1,1281 +1,1377 @@ | |||
1 | /* This file is part of the OPIE libraries | 1 | /* This file is part of the OPIE libraries |
2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) | 2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | #include <unistd.h> | 21 | #include <unistd.h> |
22 | #include <fcntl.h> | 22 | #include <fcntl.h> |
23 | #include <sys/ioctl.h> | 23 | #include <sys/ioctl.h> |
24 | #include <signal.h> | 24 | #include <signal.h> |
25 | #include <sys/time.h> | 25 | #include <sys/time.h> |
26 | #include <linux/soundcard.h> | 26 | #include <linux/soundcard.h> |
27 | #include <math.h> | 27 | #include <math.h> |
28 | 28 | ||
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | 30 | ||
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qpe/sound.h> | 33 | #include <qpe/sound.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | #include <qpe/qcopenvelope_qws.h> | 36 | #include <qpe/qcopenvelope_qws.h> |
37 | 37 | ||
38 | #include "odevice.h" | 38 | #include "odevice.h" |
39 | 39 | ||
40 | #include <qwindowsystem_qws.h> | 40 | #include <qwindowsystem_qws.h> |
41 | 41 | ||
42 | 42 | ||
43 | // _IO and friends are only defined in kernel headers ... | 43 | // _IO and friends are only defined in kernel headers ... |
44 | 44 | ||
45 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 45 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
46 | 46 | ||
47 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 47 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
48 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 48 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
49 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 49 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
50 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 50 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
51 | 51 | ||
52 | using namespace Opie; | 52 | using namespace Opie; |
53 | 53 | ||
54 | class ODeviceData { | 54 | class ODeviceData { |
55 | public: | 55 | public: |
56 | bool m_qwsserver; | 56 | bool m_qwsserver : 1; |
57 | 57 | ||
58 | QString m_vendorstr; | 58 | QString m_vendorstr; |
59 | OVendor m_vendor; | 59 | OVendor m_vendor; |
60 | 60 | ||
61 | QString m_modelstr; | 61 | QString m_modelstr; |
62 | OModel m_model; | 62 | OModel m_model; |
63 | 63 | ||
64 | QString m_systemstr; | 64 | QString m_systemstr; |
65 | OSystem m_system; | 65 | OSystem m_system; |
66 | 66 | ||
67 | QString m_sysverstr; | 67 | QString m_sysverstr; |
68 | 68 | ||
69 | Transformation m_rotation; | 69 | Transformation m_rotation; |
70 | 70 | ||
71 | QValueList <ODeviceButton> *m_buttons; | 71 | QValueList <ODeviceButton> *m_buttons; |
72 | uint m_holdtime; | 72 | uint m_holdtime; |
73 | }; | 73 | }; |
74 | 74 | ||
75 | 75 | ||
76 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { | 76 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { |
77 | protected: | 77 | protected: |
78 | virtual void init ( ); | 78 | virtual void init ( ); |
79 | virtual void initButtons ( ); | 79 | virtual void initButtons ( ); |
80 | 80 | ||
81 | public: | 81 | public: |
82 | virtual bool setSoftSuspend ( bool soft ); | 82 | virtual bool setSoftSuspend ( bool soft ); |
83 | 83 | ||
84 | virtual bool setDisplayBrightness ( int b ); | 84 | virtual bool setDisplayBrightness ( int b ); |
85 | virtual int displayBrightnessResolution ( ) const; | 85 | virtual int displayBrightnessResolution ( ) const; |
86 | 86 | ||
87 | virtual void alarmSound ( ); | 87 | virtual void alarmSound ( ); |
88 | 88 | ||
89 | virtual QValueList <OLed> ledList ( ) const; | 89 | virtual QValueList <OLed> ledList ( ) const; |
90 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 90 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
91 | virtual OLedState ledState ( OLed led ) const; | 91 | virtual OLedState ledState ( OLed led ) const; |
92 | virtual bool setLedState ( OLed led, OLedState st ); | 92 | virtual bool setLedState ( OLed led, OLedState st ); |
93 | 93 | ||
94 | virtual bool hasLightSensor ( ) const; | 94 | virtual bool hasLightSensor ( ) const; |
95 | virtual int readLightSensor ( ); | 95 | virtual int readLightSensor ( ); |
96 | virtual int lightSensorResolution ( ) const; | 96 | virtual int lightSensorResolution ( ) const; |
97 | 97 | ||
98 | protected: | 98 | protected: |
99 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 99 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
100 | virtual void timerEvent ( QTimerEvent *te ); | 100 | virtual void timerEvent ( QTimerEvent *te ); |
101 | 101 | ||
102 | int m_power_timer; | 102 | int m_power_timer; |
103 | 103 | ||
104 | OLedState m_leds [2]; | 104 | OLedState m_leds [2]; |
105 | }; | 105 | }; |
106 | 106 | ||
107 | class Zaurus : public ODevice { | 107 | class Zaurus : public ODevice { |
108 | protected: | 108 | protected: |
109 | virtual void init ( ); | 109 | virtual void init ( ); |
110 | virtual void initButtons ( ); | 110 | virtual void initButtons ( ); |
111 | 111 | ||
112 | public: | 112 | public: |
113 | virtual bool setSoftSuspend ( bool soft ); | 113 | virtual bool setSoftSuspend ( bool soft ); |
114 | 114 | ||
115 | virtual bool setDisplayBrightness ( int b ); | 115 | virtual bool setDisplayBrightness ( int b ); |
116 | virtual int displayBrightnessResolution ( ) const; | 116 | virtual int displayBrightnessResolution ( ) const; |
117 | 117 | ||
118 | virtual void alarmSound ( ); | 118 | virtual void alarmSound ( ); |
119 | virtual void keySound ( ); | 119 | virtual void keySound ( ); |
120 | virtual void touchSound ( ); | 120 | virtual void touchSound ( ); |
121 | 121 | ||
122 | virtual QValueList <OLed> ledList ( ) const; | 122 | virtual QValueList <OLed> ledList ( ) const; |
123 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 123 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
124 | virtual OLedState ledState ( OLed led ) const; | 124 | virtual OLedState ledState ( OLed led ) const; |
125 | virtual bool setLedState ( OLed led, OLedState st ); | 125 | virtual bool setLedState ( OLed led, OLedState st ); |
126 | 126 | ||
127 | protected: | 127 | protected: |
128 | virtual void buzzer ( int snd ); | 128 | virtual void buzzer ( int snd ); |
129 | 129 | ||
130 | OLedState m_leds [1]; | 130 | OLedState m_leds [1]; |
131 | }; | 131 | }; |
132 | 132 | ||
133 | 133 | ||
134 | struct i_button { | 134 | struct i_button { |
135 | uint model; | 135 | uint model; |
136 | Qt::Key code; | 136 | Qt::Key code; |
137 | char *utext; | 137 | char *utext; |
138 | char *pix; | 138 | char *pix; |
139 | char *fpressedservice; | 139 | char *fpressedservice; |
140 | char *fpressedaction; | 140 | char *fpressedaction; |
141 | char *fheldservice; | 141 | char *fheldservice; |
142 | char *fheldaction; | 142 | char *fheldaction; |
143 | } ipaq_buttons [] = { | 143 | } ipaq_buttons [] = { |
144 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 144 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
145 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 145 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
146 | "devicebuttons/ipaq_calendar", | 146 | "devicebuttons/ipaq_calendar", |
147 | "datebook", "nextView()", | 147 | "datebook", "nextView()", |
148 | "today", "raise()" }, | 148 | "today", "raise()" }, |
149 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 149 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
150 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 150 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
151 | "devicebuttons/ipaq_contact", | 151 | "devicebuttons/ipaq_contact", |
152 | "addressbook", "raise()", | 152 | "addressbook", "raise()", |
153 | "addressbook", "beamBusinessCard()" }, | 153 | "addressbook", "beamBusinessCard()" }, |
154 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, | 154 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, |
155 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 155 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
156 | "devicebuttons/ipaq_menu", | 156 | "devicebuttons/ipaq_menu", |
157 | "QPE/TaskBar", "toggleMenu()", | 157 | "QPE/TaskBar", "toggleMenu()", |
158 | "QPE/TaskBar", "toggleStartMenu()" }, | 158 | "QPE/TaskBar", "toggleStartMenu()" }, |
159 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 159 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
160 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 160 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
161 | "devicebuttons/ipaq_mail", | 161 | "devicebuttons/ipaq_mail", |
162 | "mail", "raise()", | 162 | "mail", "raise()", |
163 | "mail", "newMail()" }, | 163 | "mail", "newMail()" }, |
164 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 164 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
165 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 165 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
166 | "devicebuttons/ipaq_home", | 166 | "devicebuttons/ipaq_home", |
167 | "QPE/Launcher", "home()", | 167 | "QPE/Launcher", "home()", |
168 | "buttonsettings", "raise()" }, | 168 | "buttonsettings", "raise()" }, |
169 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 169 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
170 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), | 170 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), |
171 | "devicebuttons/ipaq_record", | 171 | "devicebuttons/ipaq_record", |
172 | "QPE/VMemo", "toggleRecord()", | 172 | "QPE/VMemo", "toggleRecord()", |
173 | "sound", "raise()" }, | 173 | "sound", "raise()" }, |
174 | }; | 174 | }; |
175 | 175 | ||
176 | struct z_button { | 176 | struct z_button { |
177 | Qt::Key code; | 177 | Qt::Key code; |
178 | char *utext; | 178 | char *utext; |
179 | char *pix; | 179 | char *pix; |
180 | char *fpressedservice; | 180 | char *fpressedservice; |
181 | char *fpressedaction; | 181 | char *fpressedaction; |
182 | char *fheldservice; | 182 | char *fheldservice; |
183 | char *fheldaction; | 183 | char *fheldaction; |
184 | } z_buttons [] = { | 184 | } z_buttons [] = { |
185 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 185 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
186 | "devicebuttons/z_calendar", | 186 | "devicebuttons/z_calendar", |
187 | "datebook", "nextView()", | 187 | "datebook", "nextView()", |
188 | "today", "raise()" }, | 188 | "today", "raise()" }, |
189 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 189 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
190 | "devicebuttons/z_contact", | 190 | "devicebuttons/z_contact", |
191 | "addressbook", "raise()", | 191 | "addressbook", "raise()", |
192 | "addressbook", "beamBusinessCard()" }, | 192 | "addressbook", "beamBusinessCard()" }, |
193 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 193 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
194 | "devicebuttons/z_home", | 194 | "devicebuttons/z_home", |
195 | "QPE/Launcher", "home()", | 195 | "QPE/Launcher", "home()", |
196 | "buttonsettings", "raise()" }, | 196 | "buttonsettings", "raise()" }, |
197 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 197 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
198 | "devicebuttons/z_menu", | 198 | "devicebuttons/z_menu", |
199 | "QPE/TaskBar", "toggleMenu()", | 199 | "QPE/TaskBar", "toggleMenu()", |
200 | "QPE/TaskBar", "toggleStartMenu()" }, | 200 | "QPE/TaskBar", "toggleStartMenu()" }, |
201 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 201 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
202 | "devicebuttons/z_mail", | 202 | "devicebuttons/z_mail", |
203 | "mail", "raise()", | 203 | "mail", "raise()", |
204 | "mail", "newMail()" }, | 204 | "mail", "newMail()" }, |
205 | }; | 205 | }; |
206 | 206 | ||
207 | static QCString makeChannel ( const char *str ) | 207 | static QCString makeChannel ( const char *str ) |
208 | { | 208 | { |
209 | if ( str && !::strchr ( str, '/' )) | 209 | if ( str && !::strchr ( str, '/' )) |
210 | return QCString ( "QPE/Application/" ) + str; | 210 | return QCString ( "QPE/Application/" ) + str; |
211 | else | 211 | else |
212 | return str; | 212 | return str; |
213 | } | 213 | } |
214 | 214 | ||
215 | 215 | ||
216 | 216 | ||
217 | 217 | ||
218 | ODevice *ODevice::inst ( ) | 218 | ODevice *ODevice::inst ( ) |
219 | { | 219 | { |
220 | static ODevice *dev = 0; | 220 | static ODevice *dev = 0; |
221 | 221 | ||
222 | if ( !dev ) { | 222 | if ( !dev ) { |
223 | if ( QFile::exists ( "/proc/hal/model" )) | 223 | if ( QFile::exists ( "/proc/hal/model" )) |
224 | dev = new iPAQ ( ); | 224 | dev = new iPAQ ( ); |
225 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 225 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
226 | dev = new Zaurus ( ); | 226 | dev = new Zaurus ( ); |
227 | else | 227 | else |
228 | dev = new ODevice ( ); | 228 | dev = new ODevice ( ); |
229 | 229 | ||
230 | dev-> init ( ); | 230 | dev-> init ( ); |
231 | } | 231 | } |
232 | return dev; | 232 | return dev; |
233 | } | 233 | } |
234 | 234 | ||
235 | 235 | ||
236 | /************************************************** | 236 | /************************************************** |
237 | * | 237 | * |
238 | * common | 238 | * common |
239 | * | 239 | * |
240 | **************************************************/ | 240 | **************************************************/ |
241 | 241 | ||
242 | 242 | ||
243 | ODevice::ODevice ( ) | 243 | ODevice::ODevice ( ) |
244 | { | 244 | { |
245 | d = new ODeviceData; | 245 | d = new ODeviceData; |
246 | 246 | ||
247 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 247 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
248 | 248 | ||
249 | d-> m_modelstr = "Unknown"; | 249 | d-> m_modelstr = "Unknown"; |
250 | d-> m_model = Model_Unknown; | 250 | d-> m_model = Model_Unknown; |
251 | d-> m_vendorstr = "Unknown"; | 251 | d-> m_vendorstr = "Unknown"; |
252 | d-> m_vendor = Vendor_Unknown; | 252 | d-> m_vendor = Vendor_Unknown; |
253 | d-> m_systemstr = "Unknown"; | 253 | d-> m_systemstr = "Unknown"; |
254 | d-> m_system = System_Unknown; | 254 | d-> m_system = System_Unknown; |
255 | d-> m_sysverstr = "0.0"; | 255 | d-> m_sysverstr = "0.0"; |
256 | d-> m_rotation = Rot0; | 256 | d-> m_rotation = Rot0; |
257 | 257 | ||
258 | d-> m_holdtime = 1000; // 1000ms | 258 | d-> m_holdtime = 1000; // 1000ms |
259 | d-> m_buttons = 0; | 259 | d-> m_buttons = 0; |
260 | } | 260 | } |
261 | 261 | ||
262 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 262 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
263 | { | 263 | { |
264 | if ( msg == "deviceButtonMappingChanged()" ) { | 264 | if ( msg == "deviceButtonMappingChanged()" ) { |
265 | reloadButtonMapping ( ); | 265 | reloadButtonMapping ( ); |
266 | } | 266 | } |
267 | } | 267 | } |
268 | 268 | ||
269 | void ODevice::init ( ) | 269 | void ODevice::init ( ) |
270 | { | 270 | { |
271 | } | 271 | } |
272 | 272 | ||
273 | /** | ||
274 | * This method initialises the button mapping | ||
275 | */ | ||
273 | void ODevice::initButtons ( ) | 276 | void ODevice::initButtons ( ) |
274 | { | 277 | { |
275 | if ( d-> m_buttons ) | 278 | if ( d-> m_buttons ) |
276 | return; | 279 | return; |
277 | 280 | ||
278 | // Simulation uses iPAQ 3660 device buttons | 281 | // Simulation uses iPAQ 3660 device buttons |
279 | 282 | ||
280 | qDebug ( "init Buttons" ); | 283 | qDebug ( "init Buttons" ); |
281 | d-> m_buttons = new QValueList <ODeviceButton>; | 284 | d-> m_buttons = new QValueList <ODeviceButton>; |
282 | 285 | ||
283 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 286 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
284 | i_button *ib = ipaq_buttons + i; | 287 | i_button *ib = ipaq_buttons + i; |
285 | ODeviceButton b; | 288 | ODeviceButton b; |
286 | 289 | ||
287 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 290 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
288 | b. setKeycode ( ib-> code ); | 291 | b. setKeycode ( ib-> code ); |
289 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 292 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
290 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 293 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
291 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 294 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
292 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 295 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
293 | d-> m_buttons-> append ( b ); | 296 | d-> m_buttons-> append ( b ); |
294 | } | 297 | } |
295 | } | 298 | } |
296 | reloadButtonMapping ( ); | 299 | reloadButtonMapping ( ); |
297 | 300 | ||
298 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 301 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
299 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 302 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
300 | } | 303 | } |
301 | 304 | ||
302 | ODevice::~ODevice ( ) | 305 | ODevice::~ODevice ( ) |
303 | { | 306 | { |
304 | delete d; | 307 | delete d; |
305 | } | 308 | } |
306 | 309 | ||
307 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 310 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
308 | { | 311 | { |
309 | return false; | 312 | return false; |
310 | } | 313 | } |
311 | 314 | ||
312 | //#include <linux/apm_bios.h> | 315 | //#include <linux/apm_bios.h> |
313 | 316 | ||
314 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 317 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
315 | 318 | ||
316 | 319 | /** | |
320 | * This method will try to suspend the device | ||
321 | * It only works if the user is the QWS Server and the apm application | ||
322 | * is installed. | ||
323 | * It tries to suspend and then waits some time cause some distributions | ||
324 | * do have asynchronus apm implementations. | ||
325 | * This method will either fail and return false or it'll suspend the | ||
326 | * device and return once the device got woken up | ||
327 | * | ||
328 | * @return if the device got suspended | ||
329 | */ | ||
317 | bool ODevice::suspend ( ) | 330 | bool ODevice::suspend ( ) |
318 | { | 331 | { |
319 | if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend | 332 | if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend |
320 | return false; | 333 | return false; |
321 | 334 | ||
322 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 335 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
323 | return false; | 336 | return false; |
324 | 337 | ||
325 | bool res = false; | 338 | bool res = false; |
326 | 339 | ||
327 | struct timeval tvs, tvn; | 340 | struct timeval tvs, tvn; |
328 | ::gettimeofday ( &tvs, 0 ); | 341 | ::gettimeofday ( &tvs, 0 ); |
329 | 342 | ||
330 | ::sync ( ); // flush fs caches | 343 | ::sync ( ); // flush fs caches |
331 | res = ( ::system ( "apm --suspend" ) == 0 ); | 344 | res = ( ::system ( "apm --suspend" ) == 0 ); |
332 | 345 | ||
333 | // This is needed because the iPAQ apm implementation is asynchronous and we | 346 | // This is needed because the iPAQ apm implementation is asynchronous and we |
334 | // can not be sure when exactly the device is really suspended | 347 | // can not be sure when exactly the device is really suspended |
335 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 348 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
336 | 349 | ||
337 | if ( res ) { | 350 | if ( res ) { |
338 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 351 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
339 | ::usleep ( 200 * 1000 ); | 352 | ::usleep ( 200 * 1000 ); |
340 | ::gettimeofday ( &tvn, 0 ); | 353 | ::gettimeofday ( &tvn, 0 ); |
341 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 354 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
342 | } | 355 | } |
343 | 356 | ||
344 | return res; | 357 | return res; |
345 | } | 358 | } |
346 | 359 | ||
347 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 360 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
348 | 361 | ||
349 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 362 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
350 | 363 | ||
351 | /* VESA Blanking Levels */ | 364 | /* VESA Blanking Levels */ |
352 | #define VESA_NO_BLANKING 0 | 365 | #define VESA_NO_BLANKING 0 |
353 | #define VESA_VSYNC_SUSPEND 1 | 366 | #define VESA_VSYNC_SUSPEND 1 |
354 | #define VESA_HSYNC_SUSPEND 2 | 367 | #define VESA_HSYNC_SUSPEND 2 |
355 | #define VESA_POWERDOWN 3 | 368 | #define VESA_POWERDOWN 3 |
356 | 369 | ||
357 | 370 | /** | |
371 | * This sets the display on or off | ||
372 | */ | ||
358 | bool ODevice::setDisplayStatus ( bool on ) | 373 | bool ODevice::setDisplayStatus ( bool on ) |
359 | { | 374 | { |
360 | if ( d-> m_model == Model_Unknown ) | 375 | if ( d-> m_model == Model_Unknown ) |
361 | return false; | 376 | return false; |
362 | 377 | ||
363 | bool res = false; | 378 | bool res = false; |
364 | int fd; | 379 | int fd; |
365 | 380 | ||
366 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 381 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
367 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 382 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
368 | ::close ( fd ); | 383 | ::close ( fd ); |
369 | } | 384 | } |
370 | return res; | 385 | return res; |
371 | } | 386 | } |
372 | 387 | ||
373 | bool ODevice::setDisplayBrightness ( int ) | 388 | /** |
389 | * This sets the display brightness | ||
390 | * @return success or failure | ||
391 | */ | ||
392 | bool ODevice::setDisplayBrightness ( int p) | ||
374 | { | 393 | { |
394 | Q_UNUSED( p ) | ||
375 | return false; | 395 | return false; |
376 | } | 396 | } |
377 | 397 | ||
378 | int ODevice::displayBrightnessResolution ( ) const | 398 | int ODevice::displayBrightnessResolution ( ) const |
379 | { | 399 | { |
380 | return 16; | 400 | return 16; |
381 | } | 401 | } |
382 | 402 | ||
403 | /** | ||
404 | * This returns the vendor as string | ||
405 | * @return Vendor as QString | ||
406 | */ | ||
383 | QString ODevice::vendorString ( ) const | 407 | QString ODevice::vendorString ( ) const |
384 | { | 408 | { |
385 | return d-> m_vendorstr; | 409 | return d-> m_vendorstr; |
386 | } | 410 | } |
387 | 411 | ||
412 | /** | ||
413 | * This returns the vendor as one of the values of OVendor | ||
414 | * @return OVendor | ||
415 | */ | ||
388 | OVendor ODevice::vendor ( ) const | 416 | OVendor ODevice::vendor ( ) const |
389 | { | 417 | { |
390 | return d-> m_vendor; | 418 | return d-> m_vendor; |
391 | } | 419 | } |
392 | 420 | ||
421 | /** | ||
422 | * This returns the model as a string | ||
423 | * @return A string representing the model | ||
424 | */ | ||
393 | QString ODevice::modelString ( ) const | 425 | QString ODevice::modelString ( ) const |
394 | { | 426 | { |
395 | return d-> m_modelstr; | 427 | return d-> m_modelstr; |
396 | } | 428 | } |
397 | 429 | ||
430 | /** | ||
431 | * This does return the OModel used | ||
432 | */ | ||
398 | OModel ODevice::model ( ) const | 433 | OModel ODevice::model ( ) const |
399 | { | 434 | { |
400 | return d-> m_model; | 435 | return d-> m_model; |
401 | } | 436 | } |
402 | 437 | ||
438 | /** | ||
439 | * This does return the systen name | ||
440 | */ | ||
403 | QString ODevice::systemString ( ) const | 441 | QString ODevice::systemString ( ) const |
404 | { | 442 | { |
405 | return d-> m_systemstr; | 443 | return d-> m_systemstr; |
406 | } | 444 | } |
407 | 445 | ||
446 | /** | ||
447 | * Return System as OSystem value | ||
448 | */ | ||
408 | OSystem ODevice::system ( ) const | 449 | OSystem ODevice::system ( ) const |
409 | { | 450 | { |
410 | return d-> m_system; | 451 | return d-> m_system; |
411 | } | 452 | } |
412 | 453 | ||
454 | /** | ||
455 | * @return the version string of the base system | ||
456 | */ | ||
413 | QString ODevice::systemVersionString ( ) const | 457 | QString ODevice::systemVersionString ( ) const |
414 | { | 458 | { |
415 | return d-> m_sysverstr; | 459 | return d-> m_sysverstr; |
416 | } | 460 | } |
417 | 461 | ||
462 | /** | ||
463 | * @return the current Transformation | ||
464 | */ | ||
418 | Transformation ODevice::rotation ( ) const | 465 | Transformation ODevice::rotation ( ) const |
419 | { | 466 | { |
420 | return d-> m_rotation; | 467 | return d-> m_rotation; |
421 | } | 468 | } |
422 | 469 | ||
470 | /** | ||
471 | * This plays an alarmSound | ||
472 | */ | ||
423 | void ODevice::alarmSound ( ) | 473 | void ODevice::alarmSound ( ) |
424 | { | 474 | { |
425 | #ifndef QT_NO_SOUND | 475 | #ifndef QT_NO_SOUND |
426 | static Sound snd ( "alarm" ); | 476 | static Sound snd ( "alarm" ); |
427 | 477 | ||
428 | if ( snd. isFinished ( )) | 478 | if ( snd. isFinished ( )) |
429 | snd. play ( ); | 479 | snd. play ( ); |
430 | #endif | 480 | #endif |
431 | } | 481 | } |
432 | 482 | ||
483 | /** | ||
484 | * This plays a key sound | ||
485 | */ | ||
433 | void ODevice::keySound ( ) | 486 | void ODevice::keySound ( ) |
434 | { | 487 | { |
435 | #ifndef QT_NO_SOUND | 488 | #ifndef QT_NO_SOUND |
436 | static Sound snd ( "keysound" ); | 489 | static Sound snd ( "keysound" ); |
437 | 490 | ||
438 | if ( snd. isFinished ( )) | 491 | if ( snd. isFinished ( )) |
439 | snd. play ( ); | 492 | snd. play ( ); |
440 | #endif | 493 | #endif |
441 | } | 494 | } |
442 | 495 | ||
496 | /** | ||
497 | * This plays a touch sound | ||
498 | */ | ||
443 | void ODevice::touchSound ( ) | 499 | void ODevice::touchSound ( ) |
444 | { | 500 | { |
445 | 501 | ||
446 | #ifndef QT_NO_SOUND | 502 | #ifndef QT_NO_SOUND |
447 | static Sound snd ( "touchsound" ); | 503 | static Sound snd ( "touchsound" ); |
448 | 504 | ||
449 | if ( snd. isFinished ( )) | 505 | if ( snd. isFinished ( )) |
450 | snd. play ( ); | 506 | snd. play ( ); |
451 | #endif | 507 | #endif |
452 | } | 508 | } |
453 | 509 | ||
454 | 510 | /** | |
511 | * This method will return a list of leds | ||
512 | * available on this device | ||
513 | * @return a list of LEDs. | ||
514 | */ | ||
455 | QValueList <OLed> ODevice::ledList ( ) const | 515 | QValueList <OLed> ODevice::ledList ( ) const |
456 | { | 516 | { |
457 | return QValueList <OLed> ( ); | 517 | return QValueList <OLed> ( ); |
458 | } | 518 | } |
459 | 519 | ||
520 | /** | ||
521 | * This does return the state of the LEDs | ||
522 | */ | ||
460 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 523 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
461 | { | 524 | { |
462 | return QValueList <OLedState> ( ); | 525 | return QValueList <OLedState> ( ); |
463 | } | 526 | } |
464 | 527 | ||
528 | /** | ||
529 | * @return the state for a given OLed | ||
530 | */ | ||
465 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 531 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
466 | { | 532 | { |
467 | return Led_Off; | 533 | return Led_Off; |
468 | } | 534 | } |
469 | 535 | ||
470 | bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) | 536 | /** |
537 | * Set the state for a LED | ||
538 | * @param which Which OLed to use | ||
539 | * @param st The state to set | ||
540 | * @return success or failure | ||
541 | */ | ||
542 | bool ODevice::setLedState ( OLed which, OLedState st ) | ||
471 | { | 543 | { |
544 | Q_UNUSED( which ) | ||
545 | Q_UNUSED( st ) | ||
472 | return false; | 546 | return false; |
473 | } | 547 | } |
474 | 548 | ||
549 | /** | ||
550 | * @return if the device has a light sensor | ||
551 | */ | ||
475 | bool ODevice::hasLightSensor ( ) const | 552 | bool ODevice::hasLightSensor ( ) const |
476 | { | 553 | { |
477 | return false; | 554 | return false; |
478 | } | 555 | } |
479 | 556 | ||
557 | /** | ||
558 | * @return a value from the light senso | ||
559 | */ | ||
480 | int ODevice::readLightSensor ( ) | 560 | int ODevice::readLightSensor ( ) |
481 | { | 561 | { |
482 | return -1; | 562 | return -1; |
483 | } | 563 | } |
484 | 564 | ||
565 | /** | ||
566 | * @return the light sensor resolution whatever that is ;) | ||
567 | */ | ||
485 | int ODevice::lightSensorResolution ( ) const | 568 | int ODevice::lightSensorResolution ( ) const |
486 | { | 569 | { |
487 | return 0; | 570 | return 0; |
488 | } | 571 | } |
489 | 572 | ||
573 | /** | ||
574 | * @return a list of hardware buttons | ||
575 | */ | ||
490 | const QValueList <ODeviceButton> &ODevice::buttons ( ) | 576 | const QValueList <ODeviceButton> &ODevice::buttons ( ) |
491 | { | 577 | { |
492 | initButtons ( ); | 578 | initButtons ( ); |
493 | 579 | ||
494 | return *d-> m_buttons; | 580 | return *d-> m_buttons; |
495 | } | 581 | } |
496 | 582 | ||
583 | /** | ||
584 | * @return The amount of time that would count as a hold | ||
585 | */ | ||
497 | uint ODevice::buttonHoldTime ( ) const | 586 | uint ODevice::buttonHoldTime ( ) const |
498 | { | 587 | { |
499 | return d-> m_holdtime; | 588 | return d-> m_holdtime; |
500 | } | 589 | } |
501 | 590 | ||
591 | /** | ||
592 | * This method return a ODeviceButton for a key code | ||
593 | * or 0 if no special hardware button is available for the device | ||
594 | * | ||
595 | * @return The devicebutton or 0l | ||
596 | * @see ODeviceButton | ||
597 | */ | ||
502 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 598 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
503 | { | 599 | { |
504 | initButtons ( ); | 600 | initButtons ( ); |
505 | 601 | ||
506 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { | 602 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { |
507 | if ( (*it). keycode ( ) == code ) | 603 | if ( (*it). keycode ( ) == code ) |
508 | return &(*it); | 604 | return &(*it); |
509 | } | 605 | } |
510 | return 0; | 606 | return 0; |
511 | } | 607 | } |
512 | 608 | ||
513 | void ODevice::reloadButtonMapping ( ) | 609 | void ODevice::reloadButtonMapping ( ) |
514 | { | 610 | { |
515 | initButtons ( ); | 611 | initButtons ( ); |
516 | 612 | ||
517 | Config cfg ( "ButtonSettings" ); | 613 | Config cfg ( "ButtonSettings" ); |
518 | 614 | ||
519 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { | 615 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { |
520 | ODeviceButton &b = ( *d-> m_buttons ) [i]; | 616 | ODeviceButton &b = ( *d-> m_buttons ) [i]; |
521 | QString group = "Button" + QString::number ( i ); | 617 | QString group = "Button" + QString::number ( i ); |
522 | 618 | ||
523 | QCString pch, hch; | 619 | QCString pch, hch; |
524 | QCString pm, hm; | 620 | QCString pm, hm; |
525 | QByteArray pdata, hdata; | 621 | QByteArray pdata, hdata; |
526 | 622 | ||
527 | if ( cfg. hasGroup ( group )) { | 623 | if ( cfg. hasGroup ( group )) { |
528 | cfg. setGroup ( group ); | 624 | cfg. setGroup ( group ); |
529 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); | 625 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); |
530 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); | 626 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); |
531 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 627 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
532 | 628 | ||
533 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); | 629 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); |
534 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); | 630 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); |
535 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 631 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
536 | } | 632 | } |
537 | 633 | ||
538 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 634 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
539 | 635 | ||
540 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 636 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
541 | } | 637 | } |
542 | } | 638 | } |
543 | 639 | ||
544 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 640 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
545 | { | 641 | { |
546 | initButtons ( ); | 642 | initButtons ( ); |
547 | 643 | ||
548 | QString mb_chan; | 644 | QString mb_chan; |
549 | 645 | ||
550 | if ( button >= (int) d-> m_buttons-> count ( )) | 646 | if ( button >= (int) d-> m_buttons-> count ( )) |
551 | return; | 647 | return; |
552 | 648 | ||
553 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 649 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
554 | b. setPressedAction ( action ); | 650 | b. setPressedAction ( action ); |
555 | 651 | ||
556 | mb_chan=b. pressedAction ( ). channel ( ); | 652 | mb_chan=b. pressedAction ( ). channel ( ); |
557 | 653 | ||
558 | Config buttonFile ( "ButtonSettings" ); | 654 | Config buttonFile ( "ButtonSettings" ); |
559 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 655 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
560 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 656 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
561 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 657 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
562 | 658 | ||
563 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 659 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
564 | 660 | ||
565 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 661 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
566 | } | 662 | } |
567 | 663 | ||
568 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 664 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
569 | { | 665 | { |
570 | initButtons ( ); | 666 | initButtons ( ); |
571 | 667 | ||
572 | if ( button >= (int) d-> m_buttons-> count ( )) | 668 | if ( button >= (int) d-> m_buttons-> count ( )) |
573 | return; | 669 | return; |
574 | 670 | ||
575 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 671 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
576 | b. setHeldAction ( action ); | 672 | b. setHeldAction ( action ); |
577 | 673 | ||
578 | Config buttonFile ( "ButtonSettings" ); | 674 | Config buttonFile ( "ButtonSettings" ); |
579 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 675 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
580 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 676 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
581 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 677 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
582 | 678 | ||
583 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 679 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
584 | 680 | ||
585 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 681 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
586 | } | 682 | } |
587 | 683 | ||
588 | 684 | ||
589 | 685 | ||
590 | 686 | ||
591 | /************************************************** | 687 | /************************************************** |
592 | * | 688 | * |
593 | * iPAQ | 689 | * iPAQ |
594 | * | 690 | * |
595 | **************************************************/ | 691 | **************************************************/ |
596 | 692 | ||
597 | void iPAQ::init ( ) | 693 | void iPAQ::init ( ) |
598 | { | 694 | { |
599 | d-> m_vendorstr = "HP"; | 695 | d-> m_vendorstr = "HP"; |
600 | d-> m_vendor = Vendor_HP; | 696 | d-> m_vendor = Vendor_HP; |
601 | 697 | ||
602 | QFile f ( "/proc/hal/model" ); | 698 | QFile f ( "/proc/hal/model" ); |
603 | 699 | ||
604 | if ( f. open ( IO_ReadOnly )) { | 700 | if ( f. open ( IO_ReadOnly )) { |
605 | QTextStream ts ( &f ); | 701 | QTextStream ts ( &f ); |
606 | 702 | ||
607 | d-> m_modelstr = "H" + ts. readLine ( ); | 703 | d-> m_modelstr = "H" + ts. readLine ( ); |
608 | 704 | ||
609 | if ( d-> m_modelstr == "H3100" ) | 705 | if ( d-> m_modelstr == "H3100" ) |
610 | d-> m_model = Model_iPAQ_H31xx; | 706 | d-> m_model = Model_iPAQ_H31xx; |
611 | else if ( d-> m_modelstr == "H3600" ) | 707 | else if ( d-> m_modelstr == "H3600" ) |
612 | d-> m_model = Model_iPAQ_H36xx; | 708 | d-> m_model = Model_iPAQ_H36xx; |
613 | else if ( d-> m_modelstr == "H3700" ) | 709 | else if ( d-> m_modelstr == "H3700" ) |
614 | d-> m_model = Model_iPAQ_H37xx; | 710 | d-> m_model = Model_iPAQ_H37xx; |
615 | else if ( d-> m_modelstr == "H3800" ) | 711 | else if ( d-> m_modelstr == "H3800" ) |
616 | d-> m_model = Model_iPAQ_H38xx; | 712 | d-> m_model = Model_iPAQ_H38xx; |
617 | else if ( d-> m_modelstr == "H3900" ) | 713 | else if ( d-> m_modelstr == "H3900" ) |
618 | d-> m_model = Model_iPAQ_H39xx; | 714 | d-> m_model = Model_iPAQ_H39xx; |
619 | else | 715 | else |
620 | d-> m_model = Model_Unknown; | 716 | d-> m_model = Model_Unknown; |
621 | 717 | ||
622 | f. close ( ); | 718 | f. close ( ); |
623 | } | 719 | } |
624 | 720 | ||
625 | switch ( d-> m_model ) { | 721 | switch ( d-> m_model ) { |
626 | case Model_iPAQ_H31xx: | 722 | case Model_iPAQ_H31xx: |
627 | case Model_iPAQ_H38xx: | 723 | case Model_iPAQ_H38xx: |
628 | d-> m_rotation = Rot90; | 724 | d-> m_rotation = Rot90; |
629 | break; | 725 | break; |
630 | case Model_iPAQ_H36xx: | 726 | case Model_iPAQ_H36xx: |
631 | case Model_iPAQ_H37xx: | 727 | case Model_iPAQ_H37xx: |
632 | case Model_iPAQ_H39xx: | 728 | case Model_iPAQ_H39xx: |
633 | default: | 729 | default: |
634 | d-> m_rotation = Rot270; | 730 | d-> m_rotation = Rot270; |
635 | break; | 731 | break; |
636 | } | 732 | } |
637 | 733 | ||
638 | f. setName ( "/etc/familiar-version" ); | 734 | f. setName ( "/etc/familiar-version" ); |
639 | if ( f. open ( IO_ReadOnly )) { | 735 | if ( f. open ( IO_ReadOnly )) { |
640 | d-> m_systemstr = "Familiar"; | 736 | d-> m_systemstr = "Familiar"; |
641 | d-> m_system = System_Familiar; | 737 | d-> m_system = System_Familiar; |
642 | 738 | ||
643 | QTextStream ts ( &f ); | 739 | QTextStream ts ( &f ); |
644 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 740 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
645 | 741 | ||
646 | f. close ( ); | 742 | f. close ( ); |
647 | } else { | 743 | } else { |
648 | f. setName ( "/etc/oz_version" ); | 744 | f. setName ( "/etc/oz_version" ); |
649 | 745 | ||
650 | if ( f. open ( IO_ReadOnly )) { | 746 | if ( f. open ( IO_ReadOnly )) { |
651 | d-> m_systemstr = "OpenEmbedded/iPaq"; | 747 | d-> m_systemstr = "OpenEmbedded/iPaq"; |
652 | d-> m_system = System_Familiar; | 748 | d-> m_system = System_Familiar; |
653 | 749 | ||
654 | QTextStream ts ( &f ); | 750 | QTextStream ts ( &f ); |
655 | ts.setDevice ( &f ); | 751 | ts.setDevice ( &f ); |
656 | d-> m_sysverstr = ts. readLine ( ); | 752 | d-> m_sysverstr = ts. readLine ( ); |
657 | f. close ( ); | 753 | f. close ( ); |
658 | } | 754 | } |
659 | } | 755 | } |
660 | 756 | ||
661 | 757 | ||
662 | 758 | ||
663 | 759 | ||
664 | 760 | ||
665 | m_leds [0] = m_leds [1] = Led_Off; | 761 | m_leds [0] = m_leds [1] = Led_Off; |
666 | 762 | ||
667 | m_power_timer = 0; | 763 | m_power_timer = 0; |
668 | 764 | ||
669 | if ( d-> m_qwsserver ) | 765 | if ( d-> m_qwsserver ) |
670 | QWSServer::setKeyboardFilter ( this ); | 766 | QWSServer::setKeyboardFilter ( this ); |
671 | } | 767 | } |
672 | 768 | ||
673 | void iPAQ::initButtons ( ) | 769 | void iPAQ::initButtons ( ) |
674 | { | 770 | { |
675 | if ( d-> m_buttons ) | 771 | if ( d-> m_buttons ) |
676 | return; | 772 | return; |
677 | 773 | ||
678 | d-> m_buttons = new QValueList <ODeviceButton>; | 774 | d-> m_buttons = new QValueList <ODeviceButton>; |
679 | 775 | ||
680 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 776 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
681 | i_button *ib = ipaq_buttons + i; | 777 | i_button *ib = ipaq_buttons + i; |
682 | ODeviceButton b; | 778 | ODeviceButton b; |
683 | 779 | ||
684 | if (( ib-> model & d-> m_model ) == d-> m_model ) { | 780 | if (( ib-> model & d-> m_model ) == d-> m_model ) { |
685 | b. setKeycode ( ib-> code ); | 781 | b. setKeycode ( ib-> code ); |
686 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 782 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
687 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 783 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
688 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 784 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
689 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 785 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
690 | 786 | ||
691 | d-> m_buttons-> append ( b ); | 787 | d-> m_buttons-> append ( b ); |
692 | } | 788 | } |
693 | } | 789 | } |
694 | reloadButtonMapping ( ); | 790 | reloadButtonMapping ( ); |
695 | 791 | ||
696 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 792 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
697 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 793 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
698 | } | 794 | } |
699 | 795 | ||
700 | 796 | ||
701 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 797 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
702 | 798 | ||
703 | typedef struct { | 799 | typedef struct { |
704 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 800 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
705 | unsigned char TotalTime; /* Units of 5 seconds */ | 801 | unsigned char TotalTime; /* Units of 5 seconds */ |
706 | unsigned char OnTime; /* units of 100m/s */ | 802 | unsigned char OnTime; /* units of 100m/s */ |
707 | unsigned char OffTime; /* units of 100m/s */ | 803 | unsigned char OffTime; /* units of 100m/s */ |
708 | } LED_IN; | 804 | } LED_IN; |
709 | 805 | ||
710 | typedef struct { | 806 | typedef struct { |
711 | unsigned char mode; | 807 | unsigned char mode; |
712 | unsigned char pwr; | 808 | unsigned char pwr; |
713 | unsigned char brightness; | 809 | unsigned char brightness; |
714 | } FLITE_IN; | 810 | } FLITE_IN; |
715 | 811 | ||
716 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 812 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
717 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 813 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
718 | 814 | ||
719 | 815 | ||
720 | QValueList <OLed> iPAQ::ledList ( ) const | 816 | QValueList <OLed> iPAQ::ledList ( ) const |
721 | { | 817 | { |
722 | QValueList <OLed> vl; | 818 | QValueList <OLed> vl; |
723 | vl << Led_Power; | 819 | vl << Led_Power; |
724 | 820 | ||
725 | if ( d-> m_model == Model_iPAQ_H38xx ) | 821 | if ( d-> m_model == Model_iPAQ_H38xx ) |
726 | vl << Led_BlueTooth; | 822 | vl << Led_BlueTooth; |
727 | return vl; | 823 | return vl; |
728 | } | 824 | } |
729 | 825 | ||
730 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 826 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
731 | { | 827 | { |
732 | QValueList <OLedState> vl; | 828 | QValueList <OLedState> vl; |
733 | 829 | ||
734 | if ( l == Led_Power ) | 830 | if ( l == Led_Power ) |
735 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 831 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
736 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 832 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
737 | vl << Led_Off; // << Led_On << ??? | 833 | vl << Led_Off; // << Led_On << ??? |
738 | 834 | ||
739 | return vl; | 835 | return vl; |
740 | } | 836 | } |
741 | 837 | ||
742 | OLedState iPAQ::ledState ( OLed l ) const | 838 | OLedState iPAQ::ledState ( OLed l ) const |
743 | { | 839 | { |
744 | switch ( l ) { | 840 | switch ( l ) { |
745 | case Led_Power: | 841 | case Led_Power: |
746 | return m_leds [0]; | 842 | return m_leds [0]; |
747 | case Led_BlueTooth: | 843 | case Led_BlueTooth: |
748 | return m_leds [1]; | 844 | return m_leds [1]; |
749 | default: | 845 | default: |
750 | return Led_Off; | 846 | return Led_Off; |
751 | } | 847 | } |
752 | } | 848 | } |
753 | 849 | ||
754 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 850 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
755 | { | 851 | { |
756 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 852 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
757 | 853 | ||
758 | if ( l == Led_Power ) { | 854 | if ( l == Led_Power ) { |
759 | if ( fd >= 0 ) { | 855 | if ( fd >= 0 ) { |
760 | LED_IN leds; | 856 | LED_IN leds; |
761 | ::memset ( &leds, 0, sizeof( leds )); | 857 | ::memset ( &leds, 0, sizeof( leds )); |
762 | leds. TotalTime = 0; | 858 | leds. TotalTime = 0; |
763 | leds. OnTime = 0; | 859 | leds. OnTime = 0; |
764 | leds. OffTime = 1; | 860 | leds. OffTime = 1; |
765 | leds. OffOnBlink = 2; | 861 | leds. OffOnBlink = 2; |
766 | 862 | ||
767 | switch ( st ) { | 863 | switch ( st ) { |
768 | case Led_Off : leds. OffOnBlink = 0; break; | 864 | case Led_Off : leds. OffOnBlink = 0; break; |
769 | case Led_On : leds. OffOnBlink = 1; break; | 865 | case Led_On : leds. OffOnBlink = 1; break; |
770 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 866 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
771 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 867 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
772 | } | 868 | } |
773 | 869 | ||
774 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 870 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
775 | m_leds [0] = st; | 871 | m_leds [0] = st; |
776 | return true; | 872 | return true; |
777 | } | 873 | } |
778 | } | 874 | } |
779 | } | 875 | } |
780 | return false; | 876 | return false; |
781 | } | 877 | } |
782 | 878 | ||
783 | 879 | ||
784 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 880 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
785 | { | 881 | { |
786 | int newkeycode = keycode; | 882 | int newkeycode = keycode; |
787 | 883 | ||
788 | switch ( keycode ) { | 884 | switch ( keycode ) { |
789 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 885 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
790 | case HardKey_Menu: { | 886 | case HardKey_Menu: { |
791 | if (( d-> m_model == Model_iPAQ_H38xx ) || | 887 | if (( d-> m_model == Model_iPAQ_H38xx ) || |
792 | ( d-> m_model == Model_iPAQ_H39xx )) { | 888 | ( d-> m_model == Model_iPAQ_H39xx )) { |
793 | newkeycode = HardKey_Mail; | 889 | newkeycode = HardKey_Mail; |
794 | } | 890 | } |
795 | break; | 891 | break; |
796 | } | 892 | } |
797 | 893 | ||
798 | // Rotate cursor keys 180° | 894 | // Rotate cursor keys 180° |
799 | case Key_Left : | 895 | case Key_Left : |
800 | case Key_Right: | 896 | case Key_Right: |
801 | case Key_Up : | 897 | case Key_Up : |
802 | case Key_Down : { | 898 | case Key_Down : { |
803 | if (( d-> m_model == Model_iPAQ_H31xx ) || | 899 | if (( d-> m_model == Model_iPAQ_H31xx ) || |
804 | ( d-> m_model == Model_iPAQ_H38xx )) { | 900 | ( d-> m_model == Model_iPAQ_H38xx )) { |
805 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 901 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
806 | } | 902 | } |
807 | break; | 903 | break; |
808 | } | 904 | } |
809 | 905 | ||
810 | // map Power Button short/long press to F34/F35 | 906 | // map Power Button short/long press to F34/F35 |
811 | case Key_SysReq: { | 907 | case Key_SysReq: { |
812 | if ( isPress ) { | 908 | if ( isPress ) { |
813 | if ( m_power_timer ) | 909 | if ( m_power_timer ) |
814 | killTimer ( m_power_timer ); | 910 | killTimer ( m_power_timer ); |
815 | m_power_timer = startTimer ( 500 ); | 911 | m_power_timer = startTimer ( 500 ); |
816 | } | 912 | } |
817 | else if ( m_power_timer ) { | 913 | else if ( m_power_timer ) { |
818 | killTimer ( m_power_timer ); | 914 | killTimer ( m_power_timer ); |
819 | m_power_timer = 0; | 915 | m_power_timer = 0; |
820 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 916 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
821 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 917 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
822 | } | 918 | } |
823 | newkeycode = Key_unknown; | 919 | newkeycode = Key_unknown; |
824 | break; | 920 | break; |
825 | } | 921 | } |
826 | } | 922 | } |
827 | 923 | ||
828 | if ( newkeycode != keycode ) { | 924 | if ( newkeycode != keycode ) { |
829 | if ( newkeycode != Key_unknown ) | 925 | if ( newkeycode != Key_unknown ) |
830 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 926 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
831 | return true; | 927 | return true; |
832 | } | 928 | } |
833 | else | 929 | else |
834 | return false; | 930 | return false; |
835 | } | 931 | } |
836 | 932 | ||
837 | void iPAQ::timerEvent ( QTimerEvent * ) | 933 | void iPAQ::timerEvent ( QTimerEvent * ) |
838 | { | 934 | { |
839 | killTimer ( m_power_timer ); | 935 | killTimer ( m_power_timer ); |
840 | m_power_timer = 0; | 936 | m_power_timer = 0; |
841 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 937 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
842 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 938 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
843 | } | 939 | } |
844 | 940 | ||
845 | 941 | ||
846 | void iPAQ::alarmSound ( ) | 942 | void iPAQ::alarmSound ( ) |
847 | { | 943 | { |
848 | #ifndef QT_NO_SOUND | 944 | #ifndef QT_NO_SOUND |
849 | static Sound snd ( "alarm" ); | 945 | static Sound snd ( "alarm" ); |
850 | int fd; | 946 | int fd; |
851 | int vol; | 947 | int vol; |
852 | bool vol_reset = false; | 948 | bool vol_reset = false; |
853 | 949 | ||
854 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 950 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
855 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 951 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
856 | Config cfg ( "qpe" ); | 952 | Config cfg ( "qpe" ); |
857 | cfg. setGroup ( "Volume" ); | 953 | cfg. setGroup ( "Volume" ); |
858 | 954 | ||
859 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 955 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
860 | if ( volalarm < 0 ) | 956 | if ( volalarm < 0 ) |
861 | volalarm = 0; | 957 | volalarm = 0; |
862 | else if ( volalarm > 100 ) | 958 | else if ( volalarm > 100 ) |
863 | volalarm = 100; | 959 | volalarm = 100; |
864 | volalarm |= ( volalarm << 8 ); | 960 | volalarm |= ( volalarm << 8 ); |
865 | 961 | ||
866 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 962 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
867 | vol_reset = true; | 963 | vol_reset = true; |
868 | } | 964 | } |
869 | } | 965 | } |
870 | 966 | ||
871 | snd. play ( ); | 967 | snd. play ( ); |
872 | while ( !snd. isFinished ( )) | 968 | while ( !snd. isFinished ( )) |
873 | qApp-> processEvents ( ); | 969 | qApp-> processEvents ( ); |
874 | 970 | ||
875 | if ( fd >= 0 ) { | 971 | if ( fd >= 0 ) { |
876 | if ( vol_reset ) | 972 | if ( vol_reset ) |
877 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 973 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
878 | ::close ( fd ); | 974 | ::close ( fd ); |
879 | } | 975 | } |
880 | #endif | 976 | #endif |
881 | } | 977 | } |
882 | 978 | ||
883 | 979 | ||
884 | bool iPAQ::setSoftSuspend ( bool soft ) | 980 | bool iPAQ::setSoftSuspend ( bool soft ) |
885 | { | 981 | { |
886 | bool res = false; | 982 | bool res = false; |
887 | int fd; | 983 | int fd; |
888 | 984 | ||
889 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 985 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
890 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 986 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
891 | res = true; | 987 | res = true; |
892 | else | 988 | else |
893 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 989 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
894 | 990 | ||
895 | ::close ( fd ); | 991 | ::close ( fd ); |
896 | } | 992 | } |
897 | else | 993 | else |
898 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 994 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
899 | 995 | ||
900 | return res; | 996 | return res; |
901 | } | 997 | } |
902 | 998 | ||
903 | 999 | ||
904 | bool iPAQ::setDisplayBrightness ( int bright ) | 1000 | bool iPAQ::setDisplayBrightness ( int bright ) |
905 | { | 1001 | { |
906 | bool res = false; | 1002 | bool res = false; |
907 | int fd; | 1003 | int fd; |
908 | 1004 | ||
909 | if ( bright > 255 ) | 1005 | if ( bright > 255 ) |
910 | bright = 255; | 1006 | bright = 255; |
911 | if ( bright < 0 ) | 1007 | if ( bright < 0 ) |
912 | bright = 0; | 1008 | bright = 0; |
913 | 1009 | ||
914 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 1010 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
915 | FLITE_IN bl; | 1011 | FLITE_IN bl; |
916 | bl. mode = 1; | 1012 | bl. mode = 1; |
917 | bl. pwr = bright ? 1 : 0; | 1013 | bl. pwr = bright ? 1 : 0; |
918 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 1014 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
919 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 1015 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
920 | ::close ( fd ); | 1016 | ::close ( fd ); |
921 | } | 1017 | } |
922 | return res; | 1018 | return res; |
923 | } | 1019 | } |
924 | 1020 | ||
925 | int iPAQ::displayBrightnessResolution ( ) const | 1021 | int iPAQ::displayBrightnessResolution ( ) const |
926 | { | 1022 | { |
927 | switch ( model ( )) { | 1023 | switch ( model ( )) { |
928 | case Model_iPAQ_H31xx: | 1024 | case Model_iPAQ_H31xx: |
929 | case Model_iPAQ_H36xx: | 1025 | case Model_iPAQ_H36xx: |
930 | case Model_iPAQ_H37xx: | 1026 | case Model_iPAQ_H37xx: |
931 | return 128; // really 256, but >128 could damage the LCD | 1027 | return 128; // really 256, but >128 could damage the LCD |
932 | 1028 | ||
933 | case Model_iPAQ_H38xx: | 1029 | case Model_iPAQ_H38xx: |
934 | case Model_iPAQ_H39xx: | 1030 | case Model_iPAQ_H39xx: |
935 | return 64; | 1031 | return 64; |
936 | 1032 | ||
937 | default: | 1033 | default: |
938 | return 2; | 1034 | return 2; |
939 | } | 1035 | } |
940 | } | 1036 | } |
941 | 1037 | ||
942 | 1038 | ||
943 | bool iPAQ::hasLightSensor ( ) const | 1039 | bool iPAQ::hasLightSensor ( ) const |
944 | { | 1040 | { |
945 | return true; | 1041 | return true; |
946 | } | 1042 | } |
947 | 1043 | ||
948 | int iPAQ::readLightSensor ( ) | 1044 | int iPAQ::readLightSensor ( ) |
949 | { | 1045 | { |
950 | int fd; | 1046 | int fd; |
951 | int val = -1; | 1047 | int val = -1; |
952 | 1048 | ||
953 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 1049 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
954 | char buffer [8]; | 1050 | char buffer [8]; |
955 | 1051 | ||
956 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 1052 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
957 | char *endptr; | 1053 | char *endptr; |
958 | 1054 | ||
959 | buffer [4] = 0; | 1055 | buffer [4] = 0; |
960 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 1056 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
961 | 1057 | ||
962 | if ( *endptr != 0 ) | 1058 | if ( *endptr != 0 ) |
963 | val = -1; | 1059 | val = -1; |
964 | } | 1060 | } |
965 | ::close ( fd ); | 1061 | ::close ( fd ); |
966 | } | 1062 | } |
967 | 1063 | ||
968 | return val; | 1064 | return val; |
969 | } | 1065 | } |
970 | 1066 | ||
971 | int iPAQ::lightSensorResolution ( ) const | 1067 | int iPAQ::lightSensorResolution ( ) const |
972 | { | 1068 | { |
973 | return 256; | 1069 | return 256; |
974 | } | 1070 | } |
975 | 1071 | ||
976 | /************************************************** | 1072 | /************************************************** |
977 | * | 1073 | * |
978 | * Zaurus | 1074 | * Zaurus |
979 | * | 1075 | * |
980 | **************************************************/ | 1076 | **************************************************/ |
981 | 1077 | ||
982 | 1078 | ||
983 | 1079 | ||
984 | void Zaurus::init ( ) | 1080 | void Zaurus::init ( ) |
985 | { | 1081 | { |
986 | d-> m_vendorstr = "Sharp"; | 1082 | d-> m_vendorstr = "Sharp"; |
987 | d-> m_vendor = Vendor_Sharp; | 1083 | d-> m_vendor = Vendor_Sharp; |
988 | 1084 | ||
989 | QFile f ( "/proc/filesystems" ); | 1085 | QFile f ( "/proc/filesystems" ); |
990 | 1086 | ||
991 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 1087 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
992 | d-> m_vendorstr = "OpenZaurus Team"; | 1088 | d-> m_vendorstr = "OpenZaurus Team"; |
993 | d-> m_systemstr = "OpenZaurus"; | 1089 | d-> m_systemstr = "OpenZaurus"; |
994 | d-> m_system = System_OpenZaurus; | 1090 | d-> m_system = System_OpenZaurus; |
995 | 1091 | ||
996 | f. close ( ); | 1092 | f. close ( ); |
997 | 1093 | ||
998 | f. setName ( "/etc/oz_version" ); | 1094 | f. setName ( "/etc/oz_version" ); |
999 | if ( f. open ( IO_ReadOnly )) { | 1095 | if ( f. open ( IO_ReadOnly )) { |
1000 | QTextStream ts ( &f ); | 1096 | QTextStream ts ( &f ); |
1001 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 1097 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
1002 | f. close ( ); | 1098 | f. close ( ); |
1003 | } | 1099 | } |
1004 | } | 1100 | } |
1005 | else { | 1101 | else { |
1006 | d-> m_systemstr = "Zaurus"; | 1102 | d-> m_systemstr = "Zaurus"; |
1007 | d-> m_system = System_Zaurus; | 1103 | d-> m_system = System_Zaurus; |
1008 | } | 1104 | } |
1009 | 1105 | ||
1010 | f. setName ( "/proc/deviceinfo/product" ); | 1106 | f. setName ( "/proc/deviceinfo/product" ); |
1011 | if ( f. open ( IO_ReadOnly ) ) { | 1107 | if ( f. open ( IO_ReadOnly ) ) { |
1012 | QTextStream ts ( &f ); | 1108 | QTextStream ts ( &f ); |
1013 | QString model = ts. readLine ( ); | 1109 | QString model = ts. readLine ( ); |
1014 | f. close ( ); | 1110 | f. close ( ); |
1015 | 1111 | ||
1016 | d-> m_modelstr = QString("Zaurus ") + model; | 1112 | d-> m_modelstr = QString("Zaurus ") + model; |
1017 | if ( model == "SL-5500" ) | 1113 | if ( model == "SL-5500" ) |
1018 | d-> m_model = Model_Zaurus_SL5500; | 1114 | d-> m_model = Model_Zaurus_SL5500; |
1019 | else if ( model == "SL-C700" ) | 1115 | else if ( model == "SL-C700" ) |
1020 | d-> m_model = Model_Zaurus_SLC700; | 1116 | d-> m_model = Model_Zaurus_SLC700; |
1021 | else if ( model == "SL-A300" ) | 1117 | else if ( model == "SL-A300" ) |
1022 | d-> m_model = Model_Zaurus_SLA300; | 1118 | d-> m_model = Model_Zaurus_SLA300; |
1023 | else if ( model == "SL-B600" || model == "SL-5600" ) | 1119 | else if ( model == "SL-B600" || model == "SL-5600" ) |
1024 | d-> m_model = Model_Zaurus_SLB600; | 1120 | d-> m_model = Model_Zaurus_SLB600; |
1025 | else | 1121 | else |
1026 | d-> m_model = Model_Zaurus_SL5000; | 1122 | d-> m_model = Model_Zaurus_SL5000; |
1027 | } | 1123 | } |
1028 | else { | 1124 | else { |
1029 | d-> m_model = Model_Zaurus_SL5000; | 1125 | d-> m_model = Model_Zaurus_SL5000; |
1030 | d-> m_modelstr = "Zaurus (model unknown)"; | 1126 | d-> m_modelstr = "Zaurus (model unknown)"; |
1031 | } | 1127 | } |
1032 | 1128 | ||
1033 | switch ( d-> m_model ) { | 1129 | switch ( d-> m_model ) { |
1034 | case Model_Zaurus_SLA300: | 1130 | case Model_Zaurus_SLA300: |
1035 | d-> m_rotation = Rot0; | 1131 | d-> m_rotation = Rot0; |
1036 | break; | 1132 | break; |
1037 | case Model_Zaurus_SLC700: | 1133 | case Model_Zaurus_SLC700: |
1038 | /* note for C700, we must check the display rotation | 1134 | /* note for C700, we must check the display rotation |
1039 | * sensor to set an appropriate value | 1135 | * sensor to set an appropriate value |
1040 | */ | 1136 | */ |
1041 | case Model_Zaurus_SLB600: | 1137 | case Model_Zaurus_SLB600: |
1042 | case Model_Zaurus_SL5500: | 1138 | case Model_Zaurus_SL5500: |
1043 | case Model_Zaurus_SL5000: | 1139 | case Model_Zaurus_SL5000: |
1044 | default: | 1140 | default: |
1045 | d-> m_rotation = Rot270; | 1141 | d-> m_rotation = Rot270; |
1046 | break; | 1142 | break; |
1047 | } | 1143 | } |
1048 | m_leds [0] = Led_Off; | 1144 | m_leds [0] = Led_Off; |
1049 | } | 1145 | } |
1050 | 1146 | ||
1051 | void Zaurus::initButtons ( ) | 1147 | void Zaurus::initButtons ( ) |
1052 | { | 1148 | { |
1053 | if ( d-> m_buttons ) | 1149 | if ( d-> m_buttons ) |
1054 | return; | 1150 | return; |
1055 | 1151 | ||
1056 | d-> m_buttons = new QValueList <ODeviceButton>; | 1152 | d-> m_buttons = new QValueList <ODeviceButton>; |
1057 | 1153 | ||
1058 | for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { | 1154 | for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { |
1059 | z_button *zb = z_buttons + i; | 1155 | z_button *zb = z_buttons + i; |
1060 | ODeviceButton b; | 1156 | ODeviceButton b; |
1061 | 1157 | ||
1062 | b. setKeycode ( zb-> code ); | 1158 | b. setKeycode ( zb-> code ); |
1063 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); | 1159 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); |
1064 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); | 1160 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); |
1065 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); | 1161 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); |
1066 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); | 1162 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); |
1067 | 1163 | ||
1068 | d-> m_buttons-> append ( b ); | 1164 | d-> m_buttons-> append ( b ); |
1069 | } | 1165 | } |
1070 | 1166 | ||
1071 | reloadButtonMapping ( ); | 1167 | reloadButtonMapping ( ); |
1072 | 1168 | ||
1073 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1169 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1074 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1170 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1075 | } | 1171 | } |
1076 | 1172 | ||
1077 | #include <unistd.h> | 1173 | #include <unistd.h> |
1078 | #include <fcntl.h> | 1174 | #include <fcntl.h> |
1079 | #include <sys/ioctl.h> | 1175 | #include <sys/ioctl.h> |
1080 | 1176 | ||
1081 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 1177 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
1082 | 1178 | ||
1083 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 1179 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
1084 | 1180 | ||
1085 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1181 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1086 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1182 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1087 | 1183 | ||
1088 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1184 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1089 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1185 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1090 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1186 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1091 | 1187 | ||
1092 | /* --- for SHARP_BUZZER device --- */ | 1188 | /* --- for SHARP_BUZZER device --- */ |
1093 | 1189 | ||
1094 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1190 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1095 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1191 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1096 | 1192 | ||
1097 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 1193 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
1098 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 1194 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
1099 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 1195 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
1100 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 1196 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
1101 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 1197 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
1102 | 1198 | ||
1103 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1199 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1104 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1200 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1105 | 1201 | ||
1106 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 1202 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
1107 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 1203 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
1108 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 1204 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
1109 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 1205 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
1110 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 1206 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
1111 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 1207 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
1112 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 1208 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
1113 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 1209 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
1114 | 1210 | ||
1115 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1211 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1116 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 1212 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
1117 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 1213 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
1118 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 1214 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
1119 | // | 1215 | // |
1120 | 1216 | ||
1121 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1217 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1122 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 1218 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
1123 | 1219 | ||
1124 | typedef struct sharp_led_status { | 1220 | typedef struct sharp_led_status { |
1125 | int which; /* select which LED status is wanted. */ | 1221 | int which; /* select which LED status is wanted. */ |
1126 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 1222 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
1127 | } sharp_led_status; | 1223 | } sharp_led_status; |
1128 | 1224 | ||
1129 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 1225 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
1130 | 1226 | ||
1131 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 1227 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
1132 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 1228 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
1133 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 1229 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
1134 | 1230 | ||
1135 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 1231 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
1136 | 1232 | ||
1137 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 1233 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
1138 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 1234 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
1139 | #define APM_EVT_POWER_BUTTON (1 << 0) | 1235 | #define APM_EVT_POWER_BUTTON (1 << 0) |
1140 | 1236 | ||
1141 | #define FL_IOCTL_STEP_CONTRAST 100 | 1237 | #define FL_IOCTL_STEP_CONTRAST 100 |
1142 | 1238 | ||
1143 | 1239 | ||
1144 | void Zaurus::buzzer ( int sound ) | 1240 | void Zaurus::buzzer ( int sound ) |
1145 | { | 1241 | { |
1146 | static int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 1242 | static int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
1147 | 1243 | ||
1148 | if ( fd >= 0 ) { | 1244 | if ( fd >= 0 ) { |
1149 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 1245 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
1150 | ::close ( fd ); | 1246 | ::close ( fd ); |
1151 | } | 1247 | } |
1152 | } | 1248 | } |
1153 | 1249 | ||
1154 | 1250 | ||
1155 | void Zaurus::alarmSound ( ) | 1251 | void Zaurus::alarmSound ( ) |
1156 | { | 1252 | { |
1157 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 1253 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
1158 | } | 1254 | } |
1159 | 1255 | ||
1160 | void Zaurus::touchSound ( ) | 1256 | void Zaurus::touchSound ( ) |
1161 | { | 1257 | { |
1162 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 1258 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
1163 | } | 1259 | } |
1164 | 1260 | ||
1165 | void Zaurus::keySound ( ) | 1261 | void Zaurus::keySound ( ) |
1166 | { | 1262 | { |
1167 | buzzer ( SHARP_BUZ_KEYSOUND ); | 1263 | buzzer ( SHARP_BUZ_KEYSOUND ); |
1168 | } | 1264 | } |
1169 | 1265 | ||
1170 | 1266 | ||
1171 | QValueList <OLed> Zaurus::ledList ( ) const | 1267 | QValueList <OLed> Zaurus::ledList ( ) const |
1172 | { | 1268 | { |
1173 | QValueList <OLed> vl; | 1269 | QValueList <OLed> vl; |
1174 | vl << Led_Mail; | 1270 | vl << Led_Mail; |
1175 | return vl; | 1271 | return vl; |
1176 | } | 1272 | } |
1177 | 1273 | ||
1178 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 1274 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
1179 | { | 1275 | { |
1180 | QValueList <OLedState> vl; | 1276 | QValueList <OLedState> vl; |
1181 | 1277 | ||
1182 | if ( l == Led_Mail ) | 1278 | if ( l == Led_Mail ) |
1183 | vl << Led_Off << Led_On << Led_BlinkSlow; | 1279 | vl << Led_Off << Led_On << Led_BlinkSlow; |
1184 | return vl; | 1280 | return vl; |
1185 | } | 1281 | } |
1186 | 1282 | ||
1187 | OLedState Zaurus::ledState ( OLed which ) const | 1283 | OLedState Zaurus::ledState ( OLed which ) const |
1188 | { | 1284 | { |
1189 | if ( which == Led_Mail ) | 1285 | if ( which == Led_Mail ) |
1190 | return m_leds [0]; | 1286 | return m_leds [0]; |
1191 | else | 1287 | else |
1192 | return Led_Off; | 1288 | return Led_Off; |
1193 | } | 1289 | } |
1194 | 1290 | ||
1195 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 1291 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
1196 | { | 1292 | { |
1197 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 1293 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
1198 | 1294 | ||
1199 | if ( which == Led_Mail ) { | 1295 | if ( which == Led_Mail ) { |
1200 | if ( fd >= 0 ) { | 1296 | if ( fd >= 0 ) { |
1201 | struct sharp_led_status leds; | 1297 | struct sharp_led_status leds; |
1202 | ::memset ( &leds, 0, sizeof( leds )); | 1298 | ::memset ( &leds, 0, sizeof( leds )); |
1203 | leds. which = SHARP_LED_MAIL_EXISTS; | 1299 | leds. which = SHARP_LED_MAIL_EXISTS; |
1204 | bool ok = true; | 1300 | bool ok = true; |
1205 | 1301 | ||
1206 | switch ( st ) { | 1302 | switch ( st ) { |
1207 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 1303 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
1208 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 1304 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
1209 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 1305 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
1210 | default : ok = false; | 1306 | default : ok = false; |
1211 | } | 1307 | } |
1212 | 1308 | ||
1213 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 1309 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
1214 | m_leds [0] = st; | 1310 | m_leds [0] = st; |
1215 | return true; | 1311 | return true; |
1216 | } | 1312 | } |
1217 | } | 1313 | } |
1218 | } | 1314 | } |
1219 | return false; | 1315 | return false; |
1220 | } | 1316 | } |
1221 | 1317 | ||
1222 | bool Zaurus::setSoftSuspend ( bool soft ) | 1318 | bool Zaurus::setSoftSuspend ( bool soft ) |
1223 | { | 1319 | { |
1224 | bool res = false; | 1320 | bool res = false; |
1225 | int fd; | 1321 | int fd; |
1226 | 1322 | ||
1227 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 1323 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
1228 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 1324 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
1229 | 1325 | ||
1230 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 1326 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
1231 | 1327 | ||
1232 | if ( sources >= 0 ) { | 1328 | if ( sources >= 0 ) { |
1233 | if ( soft ) | 1329 | if ( soft ) |
1234 | sources &= ~APM_EVT_POWER_BUTTON; | 1330 | sources &= ~APM_EVT_POWER_BUTTON; |
1235 | else | 1331 | else |
1236 | sources |= APM_EVT_POWER_BUTTON; | 1332 | sources |= APM_EVT_POWER_BUTTON; |
1237 | 1333 | ||
1238 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 1334 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
1239 | res = true; | 1335 | res = true; |
1240 | else | 1336 | else |
1241 | perror ( "APM_IOCGEVTSRC" ); | 1337 | perror ( "APM_IOCGEVTSRC" ); |
1242 | } | 1338 | } |
1243 | else | 1339 | else |
1244 | perror ( "APM_IOCGEVTSRC" ); | 1340 | perror ( "APM_IOCGEVTSRC" ); |
1245 | 1341 | ||
1246 | ::close ( fd ); | 1342 | ::close ( fd ); |
1247 | } | 1343 | } |
1248 | else | 1344 | else |
1249 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 1345 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
1250 | 1346 | ||
1251 | return res; | 1347 | return res; |
1252 | } | 1348 | } |
1253 | 1349 | ||
1254 | 1350 | ||
1255 | bool Zaurus::setDisplayBrightness ( int bright ) | 1351 | bool Zaurus::setDisplayBrightness ( int bright ) |
1256 | { | 1352 | { |
1257 | bool res = false; | 1353 | bool res = false; |
1258 | int fd; | 1354 | int fd; |
1259 | 1355 | ||
1260 | if ( bright > 255 ) | 1356 | if ( bright > 255 ) |
1261 | bright = 255; | 1357 | bright = 255; |
1262 | if ( bright < 0 ) | 1358 | if ( bright < 0 ) |
1263 | bright = 0; | 1359 | bright = 0; |
1264 | 1360 | ||
1265 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 1361 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
1266 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 1362 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
1267 | if ( bright && !bl ) | 1363 | if ( bright && !bl ) |
1268 | bl = 1; | 1364 | bl = 1; |
1269 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 1365 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
1270 | ::close ( fd ); | 1366 | ::close ( fd ); |
1271 | } | 1367 | } |
1272 | return res; | 1368 | return res; |
1273 | } | 1369 | } |
1274 | 1370 | ||
1275 | 1371 | ||
1276 | int Zaurus::displayBrightnessResolution ( ) const | 1372 | int Zaurus::displayBrightnessResolution ( ) const |
1277 | { | 1373 | { |
1278 | return 5; | 1374 | return 5; |
1279 | } | 1375 | } |
1280 | 1376 | ||
1281 | 1377 | ||