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