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