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