-rw-r--r-- | libopie/odevice.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index c5342e1..c0b6efa 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1,2847 +1,2846 @@ | |||
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 | #include <qapplication.h> | ||
32 | 31 | ||
33 | #include <qfile.h> | 32 | #include <qfile.h> |
34 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
35 | #include <qpe/sound.h> | 34 | #include <qpe/sound.h> |
36 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
37 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
38 | #include <qpe/qcopenvelope_qws.h> | 37 | #include <qpe/qcopenvelope_qws.h> |
39 | 38 | ||
40 | #include "odevice.h" | 39 | #include "odevice.h" |
41 | 40 | ||
42 | #include <qwindowsystem_qws.h> | 41 | #include <qwindowsystem_qws.h> |
43 | 42 | ||
44 | #ifndef ARRAY_SIZE | 43 | #ifndef ARRAY_SIZE |
45 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | 44 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
46 | #endif | 45 | #endif |
47 | 46 | ||
48 | // _IO and friends are only defined in kernel headers ... | 47 | // _IO and friends are only defined in kernel headers ... |
49 | 48 | ||
50 | #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 )) |
51 | 50 | ||
52 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 51 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
53 | #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)) |
54 | #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)) |
55 | #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)) |
56 | 55 | ||
57 | using namespace Opie; | 56 | using namespace Opie; |
58 | 57 | ||
59 | class ODeviceData { | 58 | class ODeviceData { |
60 | public: | 59 | public: |
61 | QString m_vendorstr; | 60 | QString m_vendorstr; |
62 | OVendor m_vendor; | 61 | OVendor m_vendor; |
63 | 62 | ||
64 | QString m_modelstr; | 63 | QString m_modelstr; |
65 | OModel m_model; | 64 | OModel m_model; |
66 | 65 | ||
67 | QString m_systemstr; | 66 | QString m_systemstr; |
68 | OSystem m_system; | 67 | OSystem m_system; |
69 | 68 | ||
70 | QString m_sysverstr; | 69 | QString m_sysverstr; |
71 | 70 | ||
72 | Transformation m_rotation; | 71 | Transformation m_rotation; |
73 | ODirection m_direction; | 72 | ODirection m_direction; |
74 | 73 | ||
75 | QValueList <ODeviceButton> *m_buttons; | 74 | QValueList <ODeviceButton> *m_buttons; |
76 | uint m_holdtime; | 75 | uint m_holdtime; |
77 | QStrList *m_cpu_frequencies; | 76 | QStrList *m_cpu_frequencies; |
78 | 77 | ||
79 | }; | 78 | }; |
80 | 79 | ||
81 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { | 80 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { |
82 | protected: | 81 | protected: |
83 | virtual void init ( ); | 82 | virtual void init ( ); |
84 | virtual void initButtons ( ); | 83 | virtual void initButtons ( ); |
85 | 84 | ||
86 | public: | 85 | public: |
87 | virtual bool setSoftSuspend ( bool soft ); | 86 | virtual bool setSoftSuspend ( bool soft ); |
88 | 87 | ||
89 | virtual bool setDisplayBrightness ( int b ); | 88 | virtual bool setDisplayBrightness ( int b ); |
90 | virtual int displayBrightnessResolution ( ) const; | 89 | virtual int displayBrightnessResolution ( ) const; |
91 | 90 | ||
92 | virtual void alarmSound ( ); | 91 | virtual void alarmSound ( ); |
93 | 92 | ||
94 | virtual QValueList <OLed> ledList ( ) const; | 93 | virtual QValueList <OLed> ledList ( ) const; |
95 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 94 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
96 | virtual OLedState ledState ( OLed led ) const; | 95 | virtual OLedState ledState ( OLed led ) const; |
97 | virtual bool setLedState ( OLed led, OLedState st ); | 96 | virtual bool setLedState ( OLed led, OLedState st ); |
98 | 97 | ||
99 | virtual bool hasLightSensor ( ) const; | 98 | virtual bool hasLightSensor ( ) const; |
100 | virtual int readLightSensor ( ); | 99 | virtual int readLightSensor ( ); |
101 | virtual int lightSensorResolution ( ) const; | 100 | virtual int lightSensorResolution ( ) const; |
102 | 101 | ||
103 | protected: | 102 | protected: |
104 | 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 ); |
105 | virtual void timerEvent ( QTimerEvent *te ); | 104 | virtual void timerEvent ( QTimerEvent *te ); |
106 | 105 | ||
107 | int m_power_timer; | 106 | int m_power_timer; |
108 | 107 | ||
109 | OLedState m_leds [2]; | 108 | OLedState m_leds [2]; |
110 | }; | 109 | }; |
111 | 110 | ||
112 | class Jornada : public ODevice { | 111 | class Jornada : public ODevice { |
113 | protected: | 112 | protected: |
114 | virtual void init ( ); | 113 | virtual void init ( ); |
115 | //virtual void initButtons ( ); | 114 | //virtual void initButtons ( ); |
116 | public: | 115 | public: |
117 | virtual bool setSoftSuspend ( bool soft ); | 116 | virtual bool setSoftSuspend ( bool soft ); |
118 | virtual bool setDisplayBrightness ( int b ); | 117 | virtual bool setDisplayBrightness ( int b ); |
119 | virtual int displayBrightnessResolution ( ) const; | 118 | virtual int displayBrightnessResolution ( ) const; |
120 | static bool isJornada(); | 119 | static bool isJornada(); |
121 | 120 | ||
122 | }; | 121 | }; |
123 | 122 | ||
124 | class Zaurus : public ODevice { | 123 | class Zaurus : public ODevice { |
125 | protected: | 124 | protected: |
126 | virtual void init ( ); | 125 | virtual void init ( ); |
127 | virtual void initButtons ( ); | 126 | virtual void initButtons ( ); |
128 | 127 | ||
129 | public: | 128 | public: |
130 | virtual bool setSoftSuspend ( bool soft ); | 129 | virtual bool setSoftSuspend ( bool soft ); |
131 | 130 | ||
132 | virtual bool setDisplayBrightness ( int b ); | 131 | virtual bool setDisplayBrightness ( int b ); |
133 | virtual int displayBrightnessResolution ( ) const; | 132 | virtual int displayBrightnessResolution ( ) const; |
134 | 133 | ||
135 | virtual void alarmSound ( ); | 134 | virtual void alarmSound ( ); |
136 | virtual void keySound ( ); | 135 | virtual void keySound ( ); |
137 | virtual void touchSound ( ); | 136 | virtual void touchSound ( ); |
138 | 137 | ||
139 | virtual QValueList <OLed> ledList ( ) const; | 138 | virtual QValueList <OLed> ledList ( ) const; |
140 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 139 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
141 | virtual OLedState ledState ( OLed led ) const; | 140 | virtual OLedState ledState ( OLed led ) const; |
142 | virtual bool setLedState ( OLed led, OLedState st ); | 141 | virtual bool setLedState ( OLed led, OLedState st ); |
143 | 142 | ||
144 | bool hasHingeSensor() const; | 143 | bool hasHingeSensor() const; |
145 | OHingeStatus readHingeSensor(); | 144 | OHingeStatus readHingeSensor(); |
146 | 145 | ||
147 | static bool isZaurus(); | 146 | static bool isZaurus(); |
148 | 147 | ||
149 | // Does this break BC? | 148 | // Does this break BC? |
150 | virtual bool suspend ( ); | 149 | virtual bool suspend ( ); |
151 | Transformation rotation ( ) const; | 150 | Transformation rotation ( ) const; |
152 | ODirection direction ( ) const; | 151 | ODirection direction ( ) const; |
153 | 152 | ||
154 | protected: | 153 | protected: |
155 | virtual void buzzer ( int snd ); | 154 | virtual void buzzer ( int snd ); |
156 | 155 | ||
157 | OLedState m_leds [1]; | 156 | OLedState m_leds [1]; |
158 | bool m_embedix; | 157 | bool m_embedix; |
159 | void virtual_hook( int id, void *data ); | 158 | void virtual_hook( int id, void *data ); |
160 | }; | 159 | }; |
161 | 160 | ||
162 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter { | 161 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter { |
163 | protected: | 162 | protected: |
164 | virtual void init ( ); | 163 | virtual void init ( ); |
165 | virtual void initButtons ( ); | 164 | virtual void initButtons ( ); |
166 | 165 | ||
167 | public: | 166 | public: |
168 | virtual bool setSoftSuspend ( bool soft ); | 167 | virtual bool setSoftSuspend ( bool soft ); |
169 | virtual bool suspend(); | 168 | virtual bool suspend(); |
170 | 169 | ||
171 | virtual bool setDisplayStatus( bool on ); | 170 | virtual bool setDisplayStatus( bool on ); |
172 | virtual bool setDisplayBrightness ( int b ); | 171 | virtual bool setDisplayBrightness ( int b ); |
173 | virtual int displayBrightnessResolution ( ) const; | 172 | virtual int displayBrightnessResolution ( ) const; |
174 | 173 | ||
175 | virtual void alarmSound ( ); | 174 | virtual void alarmSound ( ); |
176 | 175 | ||
177 | virtual QValueList <OLed> ledList ( ) const; | 176 | virtual QValueList <OLed> ledList ( ) const; |
178 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 177 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
179 | virtual OLedState ledState ( OLed led ) const; | 178 | virtual OLedState ledState ( OLed led ) const; |
180 | virtual bool setLedState ( OLed led, OLedState st ); | 179 | virtual bool setLedState ( OLed led, OLedState st ); |
181 | 180 | ||
182 | protected: | 181 | protected: |
183 | 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 ); |
184 | virtual void timerEvent ( QTimerEvent *te ); | 183 | virtual void timerEvent ( QTimerEvent *te ); |
185 | 184 | ||
186 | int m_power_timer; | 185 | int m_power_timer; |
187 | 186 | ||
188 | OLedState m_leds [1]; //FIXME check if really only one | 187 | OLedState m_leds [1]; //FIXME check if really only one |
189 | }; | 188 | }; |
190 | 189 | ||
191 | class Ramses : public ODevice, public QWSServer::KeyboardFilter { | 190 | class Ramses : public ODevice, public QWSServer::KeyboardFilter { |
192 | protected: | 191 | protected: |
193 | virtual void init ( ); | 192 | virtual void init ( ); |
194 | 193 | ||
195 | public: | 194 | public: |
196 | virtual bool setSoftSuspend ( bool soft ); | 195 | virtual bool setSoftSuspend ( bool soft ); |
197 | virtual bool suspend ( ); | 196 | virtual bool suspend ( ); |
198 | 197 | ||
199 | virtual bool setDisplayStatus( bool on ); | 198 | virtual bool setDisplayStatus( bool on ); |
200 | virtual bool setDisplayBrightness ( int b ); | 199 | virtual bool setDisplayBrightness ( int b ); |
201 | virtual int displayBrightnessResolution ( ) const; | 200 | virtual int displayBrightnessResolution ( ) const; |
202 | virtual bool setDisplayContrast ( int b ); | 201 | virtual bool setDisplayContrast ( int b ); |
203 | virtual int displayContrastResolution ( ) const; | 202 | virtual int displayContrastResolution ( ) const; |
204 | 203 | ||
205 | protected: | 204 | protected: |
206 | 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 ); |
207 | virtual void timerEvent ( QTimerEvent *te ); | 206 | virtual void timerEvent ( QTimerEvent *te ); |
208 | 207 | ||
209 | int m_power_timer; | 208 | int m_power_timer; |
210 | }; | 209 | }; |
211 | 210 | ||
212 | struct i_button { | 211 | struct i_button { |
213 | uint model; | 212 | uint model; |
214 | Qt::Key code; | 213 | Qt::Key code; |
215 | char *utext; | 214 | char *utext; |
216 | char *pix; | 215 | char *pix; |
217 | char *fpressedservice; | 216 | char *fpressedservice; |
218 | char *fpressedaction; | 217 | char *fpressedaction; |
219 | char *fheldservice; | 218 | char *fheldservice; |
220 | char *fheldaction; | 219 | char *fheldaction; |
221 | } ipaq_buttons [] = { | 220 | } ipaq_buttons [] = { |
222 | { 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, |
223 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 222 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
224 | "devicebuttons/ipaq_calendar", | 223 | "devicebuttons/ipaq_calendar", |
225 | "datebook", "nextView()", | 224 | "datebook", "nextView()", |
226 | "today", "raise()" }, | 225 | "today", "raise()" }, |
227 | { 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, |
228 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 227 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
229 | "devicebuttons/ipaq_contact", | 228 | "devicebuttons/ipaq_contact", |
230 | "addressbook", "raise()", | 229 | "addressbook", "raise()", |
231 | "addressbook", "beamBusinessCard()" }, | 230 | "addressbook", "beamBusinessCard()" }, |
232 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, | 231 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, |
233 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 232 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
234 | "devicebuttons/ipaq_menu", | 233 | "devicebuttons/ipaq_menu", |
235 | "QPE/TaskBar", "toggleMenu()", | 234 | "QPE/TaskBar", "toggleMenu()", |
236 | "QPE/TaskBar", "toggleStartMenu()" }, | 235 | "QPE/TaskBar", "toggleStartMenu()" }, |
237 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 236 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
238 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 237 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
239 | "devicebuttons/ipaq_mail", | 238 | "devicebuttons/ipaq_mail", |
240 | "mail", "raise()", | 239 | "mail", "raise()", |
241 | "mail", "newMail()" }, | 240 | "mail", "newMail()" }, |
242 | { 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, |
243 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 242 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
244 | "devicebuttons/ipaq_home", | 243 | "devicebuttons/ipaq_home", |
245 | "QPE/Launcher", "home()", | 244 | "QPE/Launcher", "home()", |
246 | "buttonsettings", "raise()" }, | 245 | "buttonsettings", "raise()" }, |
247 | { 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, |
248 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), | 247 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), |
249 | "devicebuttons/ipaq_record", | 248 | "devicebuttons/ipaq_record", |
250 | "QPE/VMemo", "toggleRecord()", | 249 | "QPE/VMemo", "toggleRecord()", |
251 | "sound", "raise()" }, | 250 | "sound", "raise()" }, |
252 | }; | 251 | }; |
253 | 252 | ||
254 | struct z_button { | 253 | struct z_button { |
255 | Qt::Key code; | 254 | Qt::Key code; |
256 | char *utext; | 255 | char *utext; |
257 | char *pix; | 256 | char *pix; |
258 | char *fpressedservice; | 257 | char *fpressedservice; |
259 | char *fpressedaction; | 258 | char *fpressedaction; |
260 | char *fheldservice; | 259 | char *fheldservice; |
261 | char *fheldaction; | 260 | char *fheldaction; |
262 | } z_buttons [] = { | 261 | } z_buttons [] = { |
263 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 262 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
264 | "devicebuttons/z_calendar", | 263 | "devicebuttons/z_calendar", |
265 | "datebook", "nextView()", | 264 | "datebook", "nextView()", |
266 | "today", "raise()" }, | 265 | "today", "raise()" }, |
267 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 266 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
268 | "devicebuttons/z_contact", | 267 | "devicebuttons/z_contact", |
269 | "addressbook", "raise()", | 268 | "addressbook", "raise()", |
270 | "addressbook", "beamBusinessCard()" }, | 269 | "addressbook", "beamBusinessCard()" }, |
271 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 270 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
272 | "devicebuttons/z_home", | 271 | "devicebuttons/z_home", |
273 | "QPE/Launcher", "home()", | 272 | "QPE/Launcher", "home()", |
274 | "buttonsettings", "raise()" }, | 273 | "buttonsettings", "raise()" }, |
275 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 274 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
276 | "devicebuttons/z_menu", | 275 | "devicebuttons/z_menu", |
277 | "QPE/TaskBar", "toggleMenu()", | 276 | "QPE/TaskBar", "toggleMenu()", |
278 | "QPE/TaskBar", "toggleStartMenu()" }, | 277 | "QPE/TaskBar", "toggleStartMenu()" }, |
279 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 278 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
280 | "devicebuttons/z_mail", | 279 | "devicebuttons/z_mail", |
281 | "mail", "raise()", | 280 | "mail", "raise()", |
282 | "mail", "newMail()" }, | 281 | "mail", "newMail()" }, |
283 | }; | 282 | }; |
284 | 283 | ||
285 | struct z_button z_buttons_c700 [] = { | 284 | struct z_button z_buttons_c700 [] = { |
286 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 285 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
287 | "devicebuttons/z_calendar", | 286 | "devicebuttons/z_calendar", |
288 | "datebook", "nextView()", | 287 | "datebook", "nextView()", |
289 | "today", "raise()" }, | 288 | "today", "raise()" }, |
290 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 289 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
291 | "devicebuttons/z_contact", | 290 | "devicebuttons/z_contact", |
292 | "addressbook", "raise()", | 291 | "addressbook", "raise()", |
293 | "addressbook", "beamBusinessCard()" }, | 292 | "addressbook", "beamBusinessCard()" }, |
294 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 293 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
295 | "devicebuttons/z_home", | 294 | "devicebuttons/z_home", |
296 | "QPE/Launcher", "home()", | 295 | "QPE/Launcher", "home()", |
297 | "buttonsettings", "raise()" }, | 296 | "buttonsettings", "raise()" }, |
298 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 297 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
299 | "devicebuttons/z_menu", | 298 | "devicebuttons/z_menu", |
300 | "QPE/TaskBar", "toggleMenu()", | 299 | "QPE/TaskBar", "toggleMenu()", |
301 | "QPE/TaskBar", "toggleStartMenu()" }, | 300 | "QPE/TaskBar", "toggleStartMenu()" }, |
302 | { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), | 301 | { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), |
303 | "devicebuttons/z_hinge", | 302 | "devicebuttons/z_hinge", |
304 | "QPE/Rotation", "rotateDefault()", | 303 | "QPE/Rotation", "rotateDefault()", |
305 | "QPE/Dummy", "doNothing()" }, | 304 | "QPE/Dummy", "doNothing()" }, |
306 | }; | 305 | }; |
307 | 306 | ||
308 | struct s_button { | 307 | struct s_button { |
309 | uint model; | 308 | uint model; |
310 | Qt::Key code; | 309 | Qt::Key code; |
311 | char *utext; | 310 | char *utext; |
312 | char *pix; | 311 | char *pix; |
313 | char *fpressedservice; | 312 | char *fpressedservice; |
314 | char *fpressedaction; | 313 | char *fpressedaction; |
315 | char *fheldservice; | 314 | char *fheldservice; |
316 | char *fheldaction; | 315 | char *fheldaction; |
317 | } simpad_buttons [] = { | 316 | } simpad_buttons [] = { |
318 | { 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, |
319 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), | 318 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), |
320 | "devicebuttons/simpad_lower_up", | 319 | "devicebuttons/simpad_lower_up", |
321 | "datebook", "nextView()", | 320 | "datebook", "nextView()", |
322 | "today", "raise()" }, | 321 | "today", "raise()" }, |
323 | { 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, |
324 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), | 323 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), |
325 | "devicebuttons/simpad_lower_down", | 324 | "devicebuttons/simpad_lower_down", |
326 | "addressbook", "raise()", | 325 | "addressbook", "raise()", |
327 | "addressbook", "beamBusinessCard()" }, | 326 | "addressbook", "beamBusinessCard()" }, |
328 | { 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, |
329 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), | 328 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), |
330 | "devicebuttons/simpad_lower_right", | 329 | "devicebuttons/simpad_lower_right", |
331 | "QPE/TaskBar", "toggleMenu()", | 330 | "QPE/TaskBar", "toggleMenu()", |
332 | "QPE/TaskBar", "toggleStartMenu()" }, | 331 | "QPE/TaskBar", "toggleStartMenu()" }, |
333 | { 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, |
334 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), | 333 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), |
335 | "devicebuttons/simpad_lower_left", | 334 | "devicebuttons/simpad_lower_left", |
336 | "mail", "raise()", | 335 | "mail", "raise()", |
337 | "mail", "newMail()" }, | 336 | "mail", "newMail()" }, |
338 | 337 | ||
339 | { 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, |
340 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), | 339 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), |
341 | "devicebuttons/simpad_upper_up", | 340 | "devicebuttons/simpad_upper_up", |
342 | "QPE/Launcher", "home()", | 341 | "QPE/Launcher", "home()", |
343 | "buttonsettings", "raise()" }, | 342 | "buttonsettings", "raise()" }, |
344 | { 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, |
345 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), | 344 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), |
346 | "devicebuttons/simpad_upper_down", | 345 | "devicebuttons/simpad_upper_down", |
347 | "addressbook", "raise()", | 346 | "addressbook", "raise()", |
348 | "addressbook", "beamBusinessCard()" }, | 347 | "addressbook", "beamBusinessCard()" }, |
349 | { 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, |
350 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), | 349 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), |
351 | "devicebuttons/simpad_upper_right", | 350 | "devicebuttons/simpad_upper_right", |
352 | "QPE/TaskBar", "toggleMenu()", | 351 | "QPE/TaskBar", "toggleMenu()", |
353 | "QPE/TaskBar", "toggleStartMenu()" }, | 352 | "QPE/TaskBar", "toggleStartMenu()" }, |
354 | { 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, |
355 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), | 354 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), |
356 | "devicebuttons/simpad_upper_left", | 355 | "devicebuttons/simpad_upper_left", |
357 | "QPE/Rotation", "flip()", | 356 | "QPE/Rotation", "flip()", |
358 | "QPE/Rotation", "flip()" }, | 357 | "QPE/Rotation", "flip()" }, |
359 | /* | 358 | /* |
360 | { 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, |
361 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 360 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
362 | "devicebuttons/simpad_lower_upper", | 361 | "devicebuttons/simpad_lower_upper", |
363 | "QPE/Launcher", "home()", | 362 | "QPE/Launcher", "home()", |
364 | "buttonsettings", "raise()" }, | 363 | "buttonsettings", "raise()" }, |
365 | { 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, |
366 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 365 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
367 | "devicebuttons/simpad_upper_lower", | 366 | "devicebuttons/simpad_upper_lower", |
368 | "QPE/Launcher", "home()", | 367 | "QPE/Launcher", "home()", |
369 | "buttonsettings", "raise()" }, | 368 | "buttonsettings", "raise()" }, |
370 | */ | 369 | */ |
371 | }; | 370 | }; |
372 | 371 | ||
373 | struct r_button { | 372 | struct r_button { |
374 | uint model; | 373 | uint model; |
375 | Qt::Key code; | 374 | Qt::Key code; |
376 | char *utext; | 375 | char *utext; |
377 | char *pix; | 376 | char *pix; |
378 | char *fpressedservice; | 377 | char *fpressedservice; |
379 | char *fpressedaction; | 378 | char *fpressedaction; |
380 | char *fheldservice; | 379 | char *fheldservice; |
381 | char *fheldaction; | 380 | char *fheldaction; |
382 | } ramses_buttons [] = { | 381 | } ramses_buttons [] = { |
383 | { Model_Ramses_MNCI, | 382 | { Model_Ramses_MNCI, |
384 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 383 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
385 | "devicebuttons/z_menu", | 384 | "devicebuttons/z_menu", |
386 | "QPE/TaskBar", "toggleMenu()", | 385 | "QPE/TaskBar", "toggleMenu()", |
387 | "QPE/TaskBar", "toggleStartMenu()" }, | 386 | "QPE/TaskBar", "toggleStartMenu()" }, |
388 | { Model_Ramses_MNCI, | 387 | { Model_Ramses_MNCI, |
389 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 388 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
390 | "devicebuttons/ipaq_home", | 389 | "devicebuttons/ipaq_home", |
391 | "QPE/Launcher", "home()", | 390 | "QPE/Launcher", "home()", |
392 | "buttonsettings", "raise()" }, | 391 | "buttonsettings", "raise()" }, |
393 | }; | 392 | }; |
394 | 393 | ||
395 | class Yopy : public ODevice { | 394 | class Yopy : public ODevice { |
396 | protected: | 395 | protected: |
397 | virtual void init ( ); | 396 | virtual void init ( ); |
398 | virtual void initButtons ( ); | 397 | virtual void initButtons ( ); |
399 | 398 | ||
400 | public: | 399 | public: |
401 | virtual bool suspend ( ); | 400 | virtual bool suspend ( ); |
402 | 401 | ||
403 | virtual bool setDisplayBrightness ( int b ); | 402 | virtual bool setDisplayBrightness ( int b ); |
404 | virtual int displayBrightnessResolution ( ) const; | 403 | virtual int displayBrightnessResolution ( ) const; |
405 | 404 | ||
406 | static bool isYopy ( ); | 405 | static bool isYopy ( ); |
407 | }; | 406 | }; |
408 | 407 | ||
409 | struct yopy_button { | 408 | struct yopy_button { |
410 | Qt::Key code; | 409 | Qt::Key code; |
411 | char *utext; | 410 | char *utext; |
412 | char *pix; | 411 | char *pix; |
413 | char *fpressedservice; | 412 | char *fpressedservice; |
414 | char *fpressedaction; | 413 | char *fpressedaction; |
415 | char *fheldservice; | 414 | char *fheldservice; |
416 | char *fheldaction; | 415 | char *fheldaction; |
417 | } yopy_buttons [] = { | 416 | } yopy_buttons [] = { |
418 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), | 417 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), |
419 | "devicebuttons/yopy_action", | 418 | "devicebuttons/yopy_action", |
420 | "datebook", "nextView()", | 419 | "datebook", "nextView()", |
421 | "today", "raise()" }, | 420 | "today", "raise()" }, |
422 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), | 421 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), |
423 | "devicebuttons/yopy_ok", | 422 | "devicebuttons/yopy_ok", |
424 | "addressbook", "raise()", | 423 | "addressbook", "raise()", |
425 | "addressbook", "beamBusinessCard()" }, | 424 | "addressbook", "beamBusinessCard()" }, |
426 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), | 425 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), |
427 | "devicebuttons/yopy_end", | 426 | "devicebuttons/yopy_end", |
428 | "QPE/Launcher", "home()", | 427 | "QPE/Launcher", "home()", |
429 | "buttonsettings", "raise()" }, | 428 | "buttonsettings", "raise()" }, |
430 | }; | 429 | }; |
431 | 430 | ||
432 | static QCString makeChannel ( const char *str ) | 431 | static QCString makeChannel ( const char *str ) |
433 | { | 432 | { |
434 | if ( str && !::strchr ( str, '/' )) | 433 | if ( str && !::strchr ( str, '/' )) |
435 | return QCString ( "QPE/Application/" ) + str; | 434 | return QCString ( "QPE/Application/" ) + str; |
436 | else | 435 | else |
437 | return str; | 436 | return str; |
438 | } | 437 | } |
439 | 438 | ||
440 | static inline bool isQWS() | 439 | static inline bool isQWS() |
441 | { | 440 | { |
442 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 441 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
443 | } | 442 | } |
444 | 443 | ||
445 | ODevice *ODevice::inst ( ) | 444 | ODevice *ODevice::inst ( ) |
446 | { | 445 | { |
447 | static ODevice *dev = 0; | 446 | static ODevice *dev = 0; |
448 | 447 | ||
449 | if ( !dev ) { | 448 | if ( !dev ) { |
450 | if ( QFile::exists ( "/proc/hal/model" )) | 449 | if ( QFile::exists ( "/proc/hal/model" )) |
451 | dev = new iPAQ ( ); | 450 | dev = new iPAQ ( ); |
452 | else if ( Zaurus::isZaurus() ) | 451 | else if ( Zaurus::isZaurus() ) |
453 | dev = new Zaurus ( ); | 452 | dev = new Zaurus ( ); |
454 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) | 453 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) |
455 | dev = new SIMpad ( ); | 454 | dev = new SIMpad ( ); |
456 | else if ( QFile::exists ( "/proc/sys/board/name" )) | 455 | else if ( QFile::exists ( "/proc/sys/board/name" )) |
457 | dev = new Ramses ( ); | 456 | dev = new Ramses ( ); |
458 | else if ( Yopy::isYopy() ) | 457 | else if ( Yopy::isYopy() ) |
459 | dev = new Yopy ( ); | 458 | dev = new Yopy ( ); |
460 | else if ( Jornada::isJornada() ) | 459 | else if ( Jornada::isJornada() ) |
461 | dev = new Jornada ( ); | 460 | dev = new Jornada ( ); |
462 | else | 461 | else |
463 | dev = new ODevice ( ); | 462 | dev = new ODevice ( ); |
464 | dev-> init ( ); | 463 | dev-> init ( ); |
465 | } | 464 | } |
466 | return dev; | 465 | return dev; |
467 | } | 466 | } |
468 | 467 | ||
469 | 468 | ||
470 | /************************************************** | 469 | /************************************************** |
471 | * | 470 | * |
472 | * common | 471 | * common |
473 | * | 472 | * |
474 | **************************************************/ | 473 | **************************************************/ |
475 | 474 | ||
476 | 475 | ||
477 | ODevice::ODevice ( ) | 476 | ODevice::ODevice ( ) |
478 | { | 477 | { |
479 | d = new ODeviceData; | 478 | d = new ODeviceData; |
480 | 479 | ||
481 | d-> m_modelstr = "Unknown"; | 480 | d-> m_modelstr = "Unknown"; |
482 | d-> m_model = Model_Unknown; | 481 | d-> m_model = Model_Unknown; |
483 | d-> m_vendorstr = "Unknown"; | 482 | d-> m_vendorstr = "Unknown"; |
484 | d-> m_vendor = Vendor_Unknown; | 483 | d-> m_vendor = Vendor_Unknown; |
485 | d-> m_systemstr = "Unknown"; | 484 | d-> m_systemstr = "Unknown"; |
486 | d-> m_system = System_Unknown; | 485 | d-> m_system = System_Unknown; |
487 | d-> m_sysverstr = "0.0"; | 486 | d-> m_sysverstr = "0.0"; |
488 | d-> m_rotation = Rot0; | 487 | d-> m_rotation = Rot0; |
489 | d-> m_direction = CW; | 488 | d-> m_direction = CW; |
490 | 489 | ||
491 | d-> m_holdtime = 1000; // 1000ms | 490 | d-> m_holdtime = 1000; // 1000ms |
492 | d-> m_buttons = 0; | 491 | d-> m_buttons = 0; |
493 | d-> m_cpu_frequencies = new QStrList; | 492 | d-> m_cpu_frequencies = new QStrList; |
494 | } | 493 | } |
495 | 494 | ||
496 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 495 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
497 | { | 496 | { |
498 | if ( msg == "deviceButtonMappingChanged()" ) { | 497 | if ( msg == "deviceButtonMappingChanged()" ) { |
499 | reloadButtonMapping ( ); | 498 | reloadButtonMapping ( ); |
500 | } | 499 | } |
501 | } | 500 | } |
502 | 501 | ||
503 | void ODevice::init ( ) | 502 | void ODevice::init ( ) |
504 | { | 503 | { |
505 | } | 504 | } |
506 | 505 | ||
507 | /** | 506 | /** |
508 | * This method initialises the button mapping | 507 | * This method initialises the button mapping |
509 | */ | 508 | */ |
510 | void ODevice::initButtons ( ) | 509 | void ODevice::initButtons ( ) |
511 | { | 510 | { |
512 | if ( d-> m_buttons ) | 511 | if ( d-> m_buttons ) |
513 | return; | 512 | return; |
514 | 513 | ||
515 | // Simulation uses iPAQ 3660 device buttons | 514 | // Simulation uses iPAQ 3660 device buttons |
516 | 515 | ||
517 | qDebug ( "init Buttons" ); | 516 | qDebug ( "init Buttons" ); |
518 | d-> m_buttons = new QValueList <ODeviceButton>; | 517 | d-> m_buttons = new QValueList <ODeviceButton>; |
519 | 518 | ||
520 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 519 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
521 | i_button *ib = ipaq_buttons + i; | 520 | i_button *ib = ipaq_buttons + i; |
522 | ODeviceButton b; | 521 | ODeviceButton b; |
523 | 522 | ||
524 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 523 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
525 | b. setKeycode ( ib-> code ); | 524 | b. setKeycode ( ib-> code ); |
526 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 525 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
527 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 526 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
528 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 527 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
529 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 528 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
530 | d-> m_buttons-> append ( b ); | 529 | d-> m_buttons-> append ( b ); |
531 | } | 530 | } |
532 | } | 531 | } |
533 | reloadButtonMapping ( ); | 532 | reloadButtonMapping ( ); |
534 | 533 | ||
535 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 534 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
536 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 535 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
537 | } | 536 | } |
538 | 537 | ||
539 | ODevice::~ODevice ( ) | 538 | ODevice::~ODevice ( ) |
540 | { | 539 | { |
541 | // we leak m_devicebuttons and m_cpu_frequency | 540 | // we leak m_devicebuttons and m_cpu_frequency |
542 | // but it's a singleton and it is not so importantant | 541 | // but it's a singleton and it is not so importantant |
543 | // -zecke | 542 | // -zecke |
544 | delete d; | 543 | delete d; |
545 | } | 544 | } |
546 | 545 | ||
547 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 546 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
548 | { | 547 | { |
549 | return false; | 548 | return false; |
550 | } | 549 | } |
551 | 550 | ||
552 | //#include <linux/apm_bios.h> | 551 | //#include <linux/apm_bios.h> |
553 | 552 | ||
554 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 553 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
555 | 554 | ||
556 | /** | 555 | /** |
557 | * This method will try to suspend the device | 556 | * This method will try to suspend the device |
558 | * It only works if the user is the QWS Server and the apm application | 557 | * It only works if the user is the QWS Server and the apm application |
559 | * is installed. | 558 | * is installed. |
560 | * It tries to suspend and then waits some time cause some distributions | 559 | * It tries to suspend and then waits some time cause some distributions |
561 | * do have asynchronus apm implementations. | 560 | * do have asynchronus apm implementations. |
562 | * This method will either fail and return false or it'll suspend the | 561 | * This method will either fail and return false or it'll suspend the |
563 | * device and return once the device got woken up | 562 | * device and return once the device got woken up |
564 | * | 563 | * |
565 | * @return if the device got suspended | 564 | * @return if the device got suspended |
566 | */ | 565 | */ |
567 | bool ODevice::suspend ( ) | 566 | bool ODevice::suspend ( ) |
568 | { | 567 | { |
569 | qDebug("ODevice::suspend"); | 568 | qDebug("ODevice::suspend"); |
570 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 569 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
571 | return false; | 570 | return false; |
572 | 571 | ||
573 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 572 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
574 | return false; | 573 | return false; |
575 | 574 | ||
576 | bool res = false; | 575 | bool res = false; |
577 | 576 | ||
578 | struct timeval tvs, tvn; | 577 | struct timeval tvs, tvn; |
579 | ::gettimeofday ( &tvs, 0 ); | 578 | ::gettimeofday ( &tvs, 0 ); |
580 | 579 | ||
581 | ::sync ( ); // flush fs caches | 580 | ::sync ( ); // flush fs caches |
582 | res = ( ::system ( "apm --suspend" ) == 0 ); | 581 | res = ( ::system ( "apm --suspend" ) == 0 ); |
583 | 582 | ||
584 | // This is needed because the iPAQ apm implementation is asynchronous and we | 583 | // This is needed because the iPAQ apm implementation is asynchronous and we |
585 | // can not be sure when exactly the device is really suspended | 584 | // can not be sure when exactly the device is really suspended |
586 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 585 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
587 | 586 | ||
588 | if ( res ) { | 587 | if ( res ) { |
589 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 588 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
590 | ::usleep ( 200 * 1000 ); | 589 | ::usleep ( 200 * 1000 ); |
591 | ::gettimeofday ( &tvn, 0 ); | 590 | ::gettimeofday ( &tvn, 0 ); |
592 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 591 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
593 | } | 592 | } |
594 | 593 | ||
595 | return res; | 594 | return res; |
596 | } | 595 | } |
597 | 596 | ||
598 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 597 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
599 | 598 | ||
600 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 599 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
601 | 600 | ||
602 | /* VESA Blanking Levels */ | 601 | /* VESA Blanking Levels */ |
603 | #define VESA_NO_BLANKING 0 | 602 | #define VESA_NO_BLANKING 0 |
604 | #define VESA_VSYNC_SUSPEND 1 | 603 | #define VESA_VSYNC_SUSPEND 1 |
605 | #define VESA_HSYNC_SUSPEND 2 | 604 | #define VESA_HSYNC_SUSPEND 2 |
606 | #define VESA_POWERDOWN 3 | 605 | #define VESA_POWERDOWN 3 |
607 | 606 | ||
608 | /** | 607 | /** |
609 | * This sets the display on or off | 608 | * This sets the display on or off |
610 | */ | 609 | */ |
611 | bool ODevice::setDisplayStatus ( bool on ) | 610 | bool ODevice::setDisplayStatus ( bool on ) |
612 | { | 611 | { |
613 | qDebug("ODevice::setDisplayStatus(%d)", on); | 612 | qDebug("ODevice::setDisplayStatus(%d)", on); |
614 | 613 | ||
615 | if ( d-> m_model == Model_Unknown ) | 614 | if ( d-> m_model == Model_Unknown ) |
616 | return false; | 615 | return false; |
617 | 616 | ||
618 | bool res = false; | 617 | bool res = false; |
619 | int fd; | 618 | int fd; |
620 | 619 | ||
621 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 620 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
622 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 621 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
623 | ::close ( fd ); | 622 | ::close ( fd ); |
624 | } | 623 | } |
625 | return res; | 624 | return res; |
626 | } | 625 | } |
627 | 626 | ||
628 | /** | 627 | /** |
629 | * This sets the display brightness | 628 | * This sets the display brightness |
630 | * | 629 | * |
631 | * @param p The brightness to be set on a scale from 0 to 255 | 630 | * @param p The brightness to be set on a scale from 0 to 255 |
632 | * @return success or failure | 631 | * @return success or failure |
633 | */ | 632 | */ |
634 | bool ODevice::setDisplayBrightness ( int p) | 633 | bool ODevice::setDisplayBrightness ( int p) |
635 | { | 634 | { |
636 | Q_UNUSED( p ) | 635 | Q_UNUSED( p ) |
637 | return false; | 636 | return false; |
638 | } | 637 | } |
639 | 638 | ||
640 | /** | 639 | /** |
641 | * @return returns the number of steppings on the brightness slider | 640 | * @return returns the number of steppings on the brightness slider |
642 | * in the Light-'n-Power settings. | 641 | * in the Light-'n-Power settings. |
643 | */ | 642 | */ |
644 | int ODevice::displayBrightnessResolution ( ) const | 643 | int ODevice::displayBrightnessResolution ( ) const |
645 | { | 644 | { |
646 | return 16; | 645 | return 16; |
647 | } | 646 | } |
648 | 647 | ||
649 | /** | 648 | /** |
650 | * This sets the display contrast | 649 | * This sets the display contrast |
651 | * @param p The contrast to be set on a scale from 0 to 255 | 650 | * @param p The contrast to be set on a scale from 0 to 255 |
652 | * @return success or failure | 651 | * @return success or failure |
653 | */ | 652 | */ |
654 | bool ODevice::setDisplayContrast ( int p) | 653 | bool ODevice::setDisplayContrast ( int p) |
655 | { | 654 | { |
656 | Q_UNUSED( p ) | 655 | Q_UNUSED( p ) |
657 | return false; | 656 | return false; |
658 | } | 657 | } |
659 | 658 | ||
660 | /** | 659 | /** |
661 | * @return return the max value for the brightness settings slider | 660 | * @return return the max value for the brightness settings slider |
662 | * or 0 if the device doesn't support setting of a contrast | 661 | * or 0 if the device doesn't support setting of a contrast |
663 | */ | 662 | */ |
664 | int ODevice::displayContrastResolution ( ) const | 663 | int ODevice::displayContrastResolution ( ) const |
665 | { | 664 | { |
666 | return 0; | 665 | return 0; |
667 | } | 666 | } |
668 | 667 | ||
669 | /** | 668 | /** |
670 | * This returns the vendor as string | 669 | * This returns the vendor as string |
671 | * @return Vendor as QString | 670 | * @return Vendor as QString |
672 | */ | 671 | */ |
673 | QString ODevice::vendorString ( ) const | 672 | QString ODevice::vendorString ( ) const |
674 | { | 673 | { |
675 | return d-> m_vendorstr; | 674 | return d-> m_vendorstr; |
676 | } | 675 | } |
677 | 676 | ||
678 | /** | 677 | /** |
679 | * This returns the vendor as one of the values of OVendor | 678 | * This returns the vendor as one of the values of OVendor |
680 | * @return OVendor | 679 | * @return OVendor |
681 | */ | 680 | */ |
682 | OVendor ODevice::vendor ( ) const | 681 | OVendor ODevice::vendor ( ) const |
683 | { | 682 | { |
684 | return d-> m_vendor; | 683 | return d-> m_vendor; |
685 | } | 684 | } |
686 | 685 | ||
687 | /** | 686 | /** |
688 | * This returns the model as a string | 687 | * This returns the model as a string |
689 | * @return A string representing the model | 688 | * @return A string representing the model |
690 | */ | 689 | */ |
691 | QString ODevice::modelString ( ) const | 690 | QString ODevice::modelString ( ) const |
692 | { | 691 | { |
693 | return d-> m_modelstr; | 692 | return d-> m_modelstr; |
694 | } | 693 | } |
695 | 694 | ||
696 | /** | 695 | /** |
697 | * This does return the OModel used | 696 | * This does return the OModel used |
698 | */ | 697 | */ |
699 | OModel ODevice::model ( ) const | 698 | OModel ODevice::model ( ) const |
700 | { | 699 | { |
701 | return d-> m_model; | 700 | return d-> m_model; |
702 | } | 701 | } |
703 | 702 | ||
704 | /** | 703 | /** |
705 | * This does return the systen name | 704 | * This does return the systen name |
706 | */ | 705 | */ |
707 | QString ODevice::systemString ( ) const | 706 | QString ODevice::systemString ( ) const |
708 | { | 707 | { |
709 | return d-> m_systemstr; | 708 | return d-> m_systemstr; |
710 | } | 709 | } |
711 | 710 | ||
712 | /** | 711 | /** |
713 | * Return System as OSystem value | 712 | * Return System as OSystem value |
714 | */ | 713 | */ |
715 | OSystem ODevice::system ( ) const | 714 | OSystem ODevice::system ( ) const |
716 | { | 715 | { |
717 | return d-> m_system; | 716 | return d-> m_system; |
718 | } | 717 | } |
719 | 718 | ||
720 | /** | 719 | /** |
721 | * @return the version string of the base system | 720 | * @return the version string of the base system |
722 | */ | 721 | */ |
723 | QString ODevice::systemVersionString ( ) const | 722 | QString ODevice::systemVersionString ( ) const |
724 | { | 723 | { |
725 | return d-> m_sysverstr; | 724 | return d-> m_sysverstr; |
726 | } | 725 | } |
727 | 726 | ||
728 | /** | 727 | /** |
729 | * @return the current Transformation | 728 | * @return the current Transformation |
730 | */ | 729 | */ |
731 | Transformation ODevice::rotation ( ) const | 730 | Transformation ODevice::rotation ( ) const |
732 | { | 731 | { |
733 | VirtRotation rot; | 732 | VirtRotation rot; |
734 | ODevice* that =(ODevice* )this; | 733 | ODevice* that =(ODevice* )this; |
735 | that->virtual_hook( VIRTUAL_ROTATION, &rot ); | 734 | that->virtual_hook( VIRTUAL_ROTATION, &rot ); |
736 | return rot.trans; | 735 | return rot.trans; |
737 | } | 736 | } |
738 | 737 | ||
739 | /** | 738 | /** |
740 | * @return the current rotation direction | 739 | * @return the current rotation direction |
741 | */ | 740 | */ |
742 | ODirection ODevice::direction ( ) const | 741 | ODirection ODevice::direction ( ) const |
743 | { | 742 | { |
744 | VirtDirection dir; | 743 | VirtDirection dir; |
745 | ODevice* that =(ODevice* )this; | 744 | ODevice* that =(ODevice* )this; |
746 | that->virtual_hook( VIRTUAL_DIRECTION, &dir ); | 745 | that->virtual_hook( VIRTUAL_DIRECTION, &dir ); |
747 | return dir.direct; | 746 | return dir.direct; |
748 | } | 747 | } |
749 | 748 | ||
750 | /** | 749 | /** |
751 | * This plays an alarmSound | 750 | * This plays an alarmSound |
752 | */ | 751 | */ |
753 | void ODevice::alarmSound ( ) | 752 | void ODevice::alarmSound ( ) |
754 | { | 753 | { |
755 | #ifndef QT_NO_SOUND | 754 | #ifndef QT_NO_SOUND |
756 | static Sound snd ( "alarm" ); | 755 | static Sound snd ( "alarm" ); |
757 | 756 | ||
758 | if ( snd. isFinished ( )) | 757 | if ( snd. isFinished ( )) |
759 | snd. play ( ); | 758 | snd. play ( ); |
760 | #endif | 759 | #endif |
761 | } | 760 | } |
762 | 761 | ||
763 | /** | 762 | /** |
764 | * This plays a key sound | 763 | * This plays a key sound |
765 | */ | 764 | */ |
766 | void ODevice::keySound ( ) | 765 | void ODevice::keySound ( ) |
767 | { | 766 | { |
768 | #ifndef QT_NO_SOUND | 767 | #ifndef QT_NO_SOUND |
769 | static Sound snd ( "keysound" ); | 768 | static Sound snd ( "keysound" ); |
770 | 769 | ||
771 | if ( snd. isFinished ( )) | 770 | if ( snd. isFinished ( )) |
772 | snd. play ( ); | 771 | snd. play ( ); |
773 | #endif | 772 | #endif |
774 | } | 773 | } |
775 | 774 | ||
776 | /** | 775 | /** |
777 | * This plays a touch sound | 776 | * This plays a touch sound |
778 | */ | 777 | */ |
779 | void ODevice::touchSound ( ) | 778 | void ODevice::touchSound ( ) |
780 | { | 779 | { |
781 | #ifndef QT_NO_SOUND | 780 | #ifndef QT_NO_SOUND |
782 | static Sound snd ( "touchsound" ); | 781 | static Sound snd ( "touchsound" ); |
783 | 782 | ||
784 | if ( snd. isFinished ( )) | 783 | if ( snd. isFinished ( )) |
785 | snd. play ( ); | 784 | snd. play ( ); |
786 | #endif | 785 | #endif |
787 | } | 786 | } |
788 | 787 | ||
789 | /** | 788 | /** |
790 | * This method will return a list of leds | 789 | * This method will return a list of leds |
791 | * available on this device | 790 | * available on this device |
792 | * @return a list of LEDs. | 791 | * @return a list of LEDs. |
793 | */ | 792 | */ |
794 | QValueList <OLed> ODevice::ledList ( ) const | 793 | QValueList <OLed> ODevice::ledList ( ) const |
795 | { | 794 | { |
796 | return QValueList <OLed> ( ); | 795 | return QValueList <OLed> ( ); |
797 | } | 796 | } |
798 | 797 | ||
799 | /** | 798 | /** |
800 | * This does return the state of the LEDs | 799 | * This does return the state of the LEDs |
801 | */ | 800 | */ |
802 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 801 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
803 | { | 802 | { |
804 | return QValueList <OLedState> ( ); | 803 | return QValueList <OLedState> ( ); |
805 | } | 804 | } |
806 | 805 | ||
807 | /** | 806 | /** |
808 | * @return the state for a given OLed | 807 | * @return the state for a given OLed |
809 | */ | 808 | */ |
810 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 809 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
811 | { | 810 | { |
812 | return Led_Off; | 811 | return Led_Off; |
813 | } | 812 | } |
814 | 813 | ||
815 | /** | 814 | /** |
816 | * Set the state for a LED | 815 | * Set the state for a LED |
817 | * @param which Which OLed to use | 816 | * @param which Which OLed to use |
818 | * @param st The state to set | 817 | * @param st The state to set |
819 | * @return success or failure | 818 | * @return success or failure |
820 | */ | 819 | */ |
821 | bool ODevice::setLedState ( OLed which, OLedState st ) | 820 | bool ODevice::setLedState ( OLed which, OLedState st ) |
822 | { | 821 | { |
823 | Q_UNUSED( which ) | 822 | Q_UNUSED( which ) |
824 | Q_UNUSED( st ) | 823 | Q_UNUSED( st ) |
825 | return false; | 824 | return false; |
826 | } | 825 | } |
827 | 826 | ||
828 | /** | 827 | /** |
829 | * @return if the device has a light sensor | 828 | * @return if the device has a light sensor |
830 | */ | 829 | */ |
831 | bool ODevice::hasLightSensor ( ) const | 830 | bool ODevice::hasLightSensor ( ) const |
832 | { | 831 | { |
833 | return false; | 832 | return false; |
834 | } | 833 | } |
835 | 834 | ||
836 | /** | 835 | /** |
837 | * @return a value from the light sensor | 836 | * @return a value from the light sensor |
838 | */ | 837 | */ |
839 | int ODevice::readLightSensor ( ) | 838 | int ODevice::readLightSensor ( ) |
840 | { | 839 | { |
841 | return -1; | 840 | return -1; |
842 | } | 841 | } |
843 | 842 | ||
844 | /** | 843 | /** |
845 | * @return the light sensor resolution | 844 | * @return the light sensor resolution |
846 | */ | 845 | */ |
847 | int ODevice::lightSensorResolution ( ) const | 846 | int ODevice::lightSensorResolution ( ) const |
848 | { | 847 | { |
849 | return 0; | 848 | return 0; |
850 | } | 849 | } |
851 | 850 | ||
852 | /** | 851 | /** |
853 | * @return if the device has a hinge sensor | 852 | * @return if the device has a hinge sensor |
854 | */ | 853 | */ |
855 | bool ODevice::hasHingeSensor ( ) const | 854 | bool ODevice::hasHingeSensor ( ) const |
856 | { | 855 | { |
857 | VirtHasHinge hing; | 856 | VirtHasHinge hing; |
858 | ODevice* that =(ODevice* )this; | 857 | ODevice* that =(ODevice* )this; |
859 | that->virtual_hook( VIRTUAL_HAS_HINGE, &hing ); | 858 | that->virtual_hook( VIRTUAL_HAS_HINGE, &hing ); |
860 | return hing.hasHinge; | 859 | return hing.hasHinge; |
861 | } | 860 | } |
862 | 861 | ||
863 | /** | 862 | /** |
864 | * @return a value from the hinge sensor | 863 | * @return a value from the hinge sensor |
865 | */ | 864 | */ |
866 | OHingeStatus ODevice::readHingeSensor ( ) | 865 | OHingeStatus ODevice::readHingeSensor ( ) |
867 | { | 866 | { |
868 | VirtHingeStatus hing; | 867 | VirtHingeStatus hing; |
869 | virtual_hook( VIRTUAL_HINGE, &hing ); | 868 | virtual_hook( VIRTUAL_HINGE, &hing ); |
870 | return hing.hingeStat; | 869 | return hing.hingeStat; |
871 | } | 870 | } |
872 | 871 | ||
873 | /** | 872 | /** |
874 | * @return a list with CPU frequencies supported by the hardware | 873 | * @return a list with CPU frequencies supported by the hardware |
875 | */ | 874 | */ |
876 | const QStrList &ODevice::allowedCpuFrequencies ( ) const | 875 | const QStrList &ODevice::allowedCpuFrequencies ( ) const |
877 | { | 876 | { |
878 | return *d->m_cpu_frequencies; | 877 | return *d->m_cpu_frequencies; |
879 | } | 878 | } |
880 | 879 | ||
881 | 880 | ||
882 | /** | 881 | /** |
883 | * Set desired CPU frequency | 882 | * Set desired CPU frequency |
884 | * | 883 | * |
885 | * @param index index into d->m_cpu_frequencies of the frequency to be set | 884 | * @param index index into d->m_cpu_frequencies of the frequency to be set |
886 | */ | 885 | */ |
887 | bool ODevice::setCurrentCpuFrequency(uint index) | 886 | bool ODevice::setCurrentCpuFrequency(uint index) |
888 | { | 887 | { |
889 | if (index >= d->m_cpu_frequencies->count()) | 888 | if (index >= d->m_cpu_frequencies->count()) |
890 | return false; | 889 | return false; |
891 | 890 | ||
892 | char *freq = d->m_cpu_frequencies->at(index); | 891 | char *freq = d->m_cpu_frequencies->at(index); |
893 | qWarning("set freq to %s", freq); | 892 | qWarning("set freq to %s", freq); |
894 | 893 | ||
895 | int fd; | 894 | int fd; |
896 | 895 | ||
897 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { | 896 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { |
898 | char writeCommand[50]; | 897 | char writeCommand[50]; |
899 | const int count = sprintf(writeCommand, "%s\n", freq); | 898 | const int count = sprintf(writeCommand, "%s\n", freq); |
900 | int res = (::write(fd, writeCommand, count) != -1); | 899 | int res = (::write(fd, writeCommand, count) != -1); |
901 | ::close(fd); | 900 | ::close(fd); |
902 | return res; | 901 | return res; |
903 | } | 902 | } |
904 | 903 | ||
905 | return false; | 904 | return false; |
906 | } | 905 | } |
907 | 906 | ||
908 | 907 | ||
909 | /** | 908 | /** |
910 | * @return a list of hardware buttons | 909 | * @return a list of hardware buttons |
911 | */ | 910 | */ |
912 | const QValueList <ODeviceButton> &ODevice::buttons ( ) | 911 | const QValueList <ODeviceButton> &ODevice::buttons ( ) |
913 | { | 912 | { |
914 | initButtons ( ); | 913 | initButtons ( ); |
915 | 914 | ||
916 | return *d-> m_buttons; | 915 | return *d-> m_buttons; |
917 | } | 916 | } |
918 | 917 | ||
919 | /** | 918 | /** |
920 | * @return The amount of time that would count as a hold | 919 | * @return The amount of time that would count as a hold |
921 | */ | 920 | */ |
922 | uint ODevice::buttonHoldTime ( ) const | 921 | uint ODevice::buttonHoldTime ( ) const |
923 | { | 922 | { |
924 | return d-> m_holdtime; | 923 | return d-> m_holdtime; |
925 | } | 924 | } |
926 | 925 | ||
927 | /** | 926 | /** |
928 | * This method return a ODeviceButton for a key code | 927 | * This method return a ODeviceButton for a key code |
929 | * or 0 if no special hardware button is available for the device | 928 | * or 0 if no special hardware button is available for the device |
930 | * | 929 | * |
931 | * @return The devicebutton or 0l | 930 | * @return The devicebutton or 0l |
932 | * @see ODeviceButton | 931 | * @see ODeviceButton |
933 | */ | 932 | */ |
934 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 933 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
935 | { | 934 | { |
936 | initButtons ( ); | 935 | initButtons ( ); |
937 | 936 | ||
938 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { | 937 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { |
939 | if ( (*it). keycode ( ) == code ) | 938 | if ( (*it). keycode ( ) == code ) |
940 | return &(*it); | 939 | return &(*it); |
941 | } | 940 | } |
942 | return 0; | 941 | return 0; |
943 | } | 942 | } |
944 | 943 | ||
945 | void ODevice::reloadButtonMapping ( ) | 944 | void ODevice::reloadButtonMapping ( ) |
946 | { | 945 | { |
947 | initButtons ( ); | 946 | initButtons ( ); |
948 | 947 | ||
949 | Config cfg ( "ButtonSettings" ); | 948 | Config cfg ( "ButtonSettings" ); |
950 | 949 | ||
951 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { | 950 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { |
952 | ODeviceButton &b = ( *d-> m_buttons ) [i]; | 951 | ODeviceButton &b = ( *d-> m_buttons ) [i]; |
953 | QString group = "Button" + QString::number ( i ); | 952 | QString group = "Button" + QString::number ( i ); |
954 | 953 | ||
955 | QCString pch, hch; | 954 | QCString pch, hch; |
956 | QCString pm, hm; | 955 | QCString pm, hm; |
957 | QByteArray pdata, hdata; | 956 | QByteArray pdata, hdata; |
958 | 957 | ||
959 | if ( cfg. hasGroup ( group )) { | 958 | if ( cfg. hasGroup ( group )) { |
960 | cfg. setGroup ( group ); | 959 | cfg. setGroup ( group ); |
961 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); | 960 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); |
962 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); | 961 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); |
963 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 962 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
964 | 963 | ||
965 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); | 964 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); |
966 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); | 965 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); |
967 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 966 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
968 | } | 967 | } |
969 | 968 | ||
970 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 969 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
971 | 970 | ||
972 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 971 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
973 | } | 972 | } |
974 | } | 973 | } |
975 | 974 | ||
976 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 975 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
977 | { | 976 | { |
978 | initButtons ( ); | 977 | initButtons ( ); |
979 | 978 | ||
980 | QString mb_chan; | 979 | QString mb_chan; |
981 | 980 | ||
982 | if ( button >= (int) d-> m_buttons-> count ( )) | 981 | if ( button >= (int) d-> m_buttons-> count ( )) |
983 | return; | 982 | return; |
984 | 983 | ||
985 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 984 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
986 | b. setPressedAction ( action ); | 985 | b. setPressedAction ( action ); |
987 | 986 | ||
988 | mb_chan=b. pressedAction ( ). channel ( ); | 987 | mb_chan=b. pressedAction ( ). channel ( ); |
989 | 988 | ||
990 | Config buttonFile ( "ButtonSettings" ); | 989 | Config buttonFile ( "ButtonSettings" ); |
991 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 990 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
992 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 991 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
993 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 992 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
994 | 993 | ||
995 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 994 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
996 | 995 | ||
997 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 996 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
998 | } | 997 | } |
999 | 998 | ||
1000 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 999 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
1001 | { | 1000 | { |
1002 | initButtons ( ); | 1001 | initButtons ( ); |
1003 | 1002 | ||
1004 | if ( button >= (int) d-> m_buttons-> count ( )) | 1003 | if ( button >= (int) d-> m_buttons-> count ( )) |
1005 | return; | 1004 | return; |
1006 | 1005 | ||
1007 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 1006 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
1008 | b. setHeldAction ( action ); | 1007 | b. setHeldAction ( action ); |
1009 | 1008 | ||
1010 | Config buttonFile ( "ButtonSettings" ); | 1009 | Config buttonFile ( "ButtonSettings" ); |
1011 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 1010 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
1012 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 1011 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
1013 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 1012 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
1014 | 1013 | ||
1015 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 1014 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
1016 | 1015 | ||
1017 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 1016 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
1018 | } | 1017 | } |
1019 | void ODevice::virtual_hook(int id, void* data){ | 1018 | void ODevice::virtual_hook(int id, void* data){ |
1020 | switch( id ) { | 1019 | switch( id ) { |
1021 | case VIRTUAL_ROTATION:{ | 1020 | case VIRTUAL_ROTATION:{ |
1022 | VirtRotation* rot = reinterpret_cast<VirtRotation*>( data ); | 1021 | VirtRotation* rot = reinterpret_cast<VirtRotation*>( data ); |
1023 | rot->trans = d->m_rotation; | 1022 | rot->trans = d->m_rotation; |
1024 | break; | 1023 | break; |
1025 | } | 1024 | } |
1026 | case VIRTUAL_DIRECTION:{ | 1025 | case VIRTUAL_DIRECTION:{ |
1027 | VirtDirection *dir = reinterpret_cast<VirtDirection*>( data ); | 1026 | VirtDirection *dir = reinterpret_cast<VirtDirection*>( data ); |
1028 | dir->direct = d->m_direction; | 1027 | dir->direct = d->m_direction; |
1029 | break; | 1028 | break; |
1030 | } | 1029 | } |
1031 | case VIRTUAL_HAS_HINGE:{ | 1030 | case VIRTUAL_HAS_HINGE:{ |
1032 | VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data ); | 1031 | VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data ); |
1033 | hin->hasHinge = false; | 1032 | hin->hasHinge = false; |
1034 | break; | 1033 | break; |
1035 | } | 1034 | } |
1036 | case VIRTUAL_HINGE:{ | 1035 | case VIRTUAL_HINGE:{ |
1037 | VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data ); | 1036 | VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data ); |
1038 | hin->hingeStat = CASE_UNKNOWN; | 1037 | hin->hingeStat = CASE_UNKNOWN; |
1039 | break; | 1038 | break; |
1040 | } | 1039 | } |
1041 | } | 1040 | } |
1042 | } | 1041 | } |
1043 | 1042 | ||
1044 | /************************************************** | 1043 | /************************************************** |
1045 | * | 1044 | * |
1046 | * Yopy 3500/3700 | 1045 | * Yopy 3500/3700 |
1047 | * | 1046 | * |
1048 | **************************************************/ | 1047 | **************************************************/ |
1049 | 1048 | ||
1050 | bool Yopy::isYopy ( ) | 1049 | bool Yopy::isYopy ( ) |
1051 | { | 1050 | { |
1052 | QFile f( "/proc/cpuinfo" ); | 1051 | QFile f( "/proc/cpuinfo" ); |
1053 | if ( f. open ( IO_ReadOnly ) ) { | 1052 | if ( f. open ( IO_ReadOnly ) ) { |
1054 | QTextStream ts ( &f ); | 1053 | QTextStream ts ( &f ); |
1055 | QString line; | 1054 | QString line; |
1056 | while( line = ts. readLine ( ) ) { | 1055 | while( line = ts. readLine ( ) ) { |
1057 | if ( line. left ( 8 ) == "Hardware" ) { | 1056 | if ( line. left ( 8 ) == "Hardware" ) { |
1058 | int loc = line. find ( ":" ); | 1057 | int loc = line. find ( ":" ); |
1059 | if ( loc != -1 ) { | 1058 | if ( loc != -1 ) { |
1060 | QString model = | 1059 | QString model = |
1061 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1060 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1062 | return ( model == "Yopy" ); | 1061 | return ( model == "Yopy" ); |
1063 | } | 1062 | } |
1064 | } | 1063 | } |
1065 | } | 1064 | } |
1066 | } | 1065 | } |
1067 | return false; | 1066 | return false; |
1068 | } | 1067 | } |
1069 | 1068 | ||
1070 | void Yopy::init ( ) | 1069 | void Yopy::init ( ) |
1071 | { | 1070 | { |
1072 | d-> m_vendorstr = "G.Mate"; | 1071 | d-> m_vendorstr = "G.Mate"; |
1073 | d-> m_vendor = Vendor_GMate; | 1072 | d-> m_vendor = Vendor_GMate; |
1074 | d-> m_modelstr = "Yopy3700"; | 1073 | d-> m_modelstr = "Yopy3700"; |
1075 | d-> m_model = Model_Yopy_3700; | 1074 | d-> m_model = Model_Yopy_3700; |
1076 | d-> m_rotation = Rot0; | 1075 | d-> m_rotation = Rot0; |
1077 | 1076 | ||
1078 | d-> m_systemstr = "Linupy"; | 1077 | d-> m_systemstr = "Linupy"; |
1079 | d-> m_system = System_Linupy; | 1078 | d-> m_system = System_Linupy; |
1080 | 1079 | ||
1081 | QFile f ( "/etc/issue" ); | 1080 | QFile f ( "/etc/issue" ); |
1082 | if ( f. open ( IO_ReadOnly )) { | 1081 | if ( f. open ( IO_ReadOnly )) { |
1083 | QTextStream ts ( &f ); | 1082 | QTextStream ts ( &f ); |
1084 | ts.readLine(); | 1083 | ts.readLine(); |
1085 | d-> m_sysverstr = ts. readLine ( ); | 1084 | d-> m_sysverstr = ts. readLine ( ); |
1086 | f. close ( ); | 1085 | f. close ( ); |
1087 | } | 1086 | } |
1088 | } | 1087 | } |
1089 | 1088 | ||
1090 | void Yopy::initButtons ( ) | 1089 | void Yopy::initButtons ( ) |
1091 | { | 1090 | { |
1092 | if ( d-> m_buttons ) | 1091 | if ( d-> m_buttons ) |
1093 | return; | 1092 | return; |
1094 | 1093 | ||
1095 | d-> m_buttons = new QValueList <ODeviceButton>; | 1094 | d-> m_buttons = new QValueList <ODeviceButton>; |
1096 | 1095 | ||
1097 | for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { | 1096 | for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { |
1098 | 1097 | ||
1099 | yopy_button *ib = yopy_buttons + i; | 1098 | yopy_button *ib = yopy_buttons + i; |
1100 | 1099 | ||
1101 | ODeviceButton b; | 1100 | ODeviceButton b; |
1102 | 1101 | ||
1103 | b. setKeycode ( ib-> code ); | 1102 | b. setKeycode ( ib-> code ); |
1104 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 1103 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
1105 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 1104 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
1106 | b. setFactoryPresetPressedAction | 1105 | b. setFactoryPresetPressedAction |
1107 | (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); | 1106 | (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); |
1108 | b. setFactoryPresetHeldAction | 1107 | b. setFactoryPresetHeldAction |
1109 | (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); | 1108 | (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); |
1110 | 1109 | ||
1111 | d-> m_buttons-> append ( b ); | 1110 | d-> m_buttons-> append ( b ); |
1112 | } | 1111 | } |
1113 | reloadButtonMapping ( ); | 1112 | reloadButtonMapping ( ); |
1114 | 1113 | ||
1115 | QCopChannel *sysch = new QCopChannel("QPE/System", this); | 1114 | QCopChannel *sysch = new QCopChannel("QPE/System", this); |
1116 | connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), | 1115 | connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), |
1117 | this, SLOT(systemMessage(const QCString &, const QByteArray & ))); | 1116 | this, SLOT(systemMessage(const QCString &, const QByteArray & ))); |
1118 | } | 1117 | } |
1119 | 1118 | ||
1120 | bool Yopy::suspend() | 1119 | bool Yopy::suspend() |
1121 | { | 1120 | { |
1122 | /* Opie for Yopy does not implement its own power management at the | 1121 | /* Opie for Yopy does not implement its own power management at the |
1123 | moment. The public version runs parallel to X, and relies on the | 1122 | moment. The public version runs parallel to X, and relies on the |
1124 | existing power management features. */ | 1123 | existing power management features. */ |
1125 | return false; | 1124 | return false; |
1126 | } | 1125 | } |
1127 | 1126 | ||
1128 | bool Yopy::setDisplayBrightness(int bright) | 1127 | bool Yopy::setDisplayBrightness(int bright) |
1129 | { | 1128 | { |
1130 | /* The code here works, but is disabled as the current version runs | 1129 | /* The code here works, but is disabled as the current version runs |
1131 | parallel to X, and relies on the existing backlight demon. */ | 1130 | parallel to X, and relies on the existing backlight demon. */ |
1132 | #if 0 | 1131 | #if 0 |
1133 | if ( QFile::exists("/proc/sys/pm/light") ) { | 1132 | if ( QFile::exists("/proc/sys/pm/light") ) { |
1134 | int fd = ::open("/proc/sys/pm/light", O_WRONLY); | 1133 | int fd = ::open("/proc/sys/pm/light", O_WRONLY); |
1135 | if (fd >= 0 ) { | 1134 | if (fd >= 0 ) { |
1136 | if (bright) | 1135 | if (bright) |
1137 | ::write(fd, "1\n", 2); | 1136 | ::write(fd, "1\n", 2); |
1138 | else | 1137 | else |
1139 | ::write(fd, "0\n", 2); | 1138 | ::write(fd, "0\n", 2); |
1140 | ::close(fd); | 1139 | ::close(fd); |
1141 | return true; | 1140 | return true; |
1142 | } | 1141 | } |
1143 | } | 1142 | } |
1144 | #endif | 1143 | #endif |
1145 | return false; | 1144 | return false; |
1146 | } | 1145 | } |
1147 | 1146 | ||
1148 | int Yopy::displayBrightnessResolution() const | 1147 | int Yopy::displayBrightnessResolution() const |
1149 | { | 1148 | { |
1150 | return 2; | 1149 | return 2; |
1151 | } | 1150 | } |
1152 | 1151 | ||
1153 | /************************************************** | 1152 | /************************************************** |
1154 | * | 1153 | * |
1155 | * iPAQ | 1154 | * iPAQ |
1156 | * | 1155 | * |
1157 | **************************************************/ | 1156 | **************************************************/ |
1158 | 1157 | ||
1159 | void iPAQ::init ( ) | 1158 | void iPAQ::init ( ) |
1160 | { | 1159 | { |
1161 | d-> m_vendorstr = "HP"; | 1160 | d-> m_vendorstr = "HP"; |
1162 | d-> m_vendor = Vendor_HP; | 1161 | d-> m_vendor = Vendor_HP; |
1163 | 1162 | ||
1164 | QFile f ( "/proc/hal/model" ); | 1163 | QFile f ( "/proc/hal/model" ); |
1165 | 1164 | ||
1166 | if ( f. open ( IO_ReadOnly )) { | 1165 | if ( f. open ( IO_ReadOnly )) { |
1167 | QTextStream ts ( &f ); | 1166 | QTextStream ts ( &f ); |
1168 | 1167 | ||
1169 | d-> m_modelstr = "H" + ts. readLine ( ); | 1168 | d-> m_modelstr = "H" + ts. readLine ( ); |
1170 | 1169 | ||
1171 | if ( d-> m_modelstr == "H3100" ) | 1170 | if ( d-> m_modelstr == "H3100" ) |
1172 | d-> m_model = Model_iPAQ_H31xx; | 1171 | d-> m_model = Model_iPAQ_H31xx; |
1173 | else if ( d-> m_modelstr == "H3600" ) | 1172 | else if ( d-> m_modelstr == "H3600" ) |
1174 | d-> m_model = Model_iPAQ_H36xx; | 1173 | d-> m_model = Model_iPAQ_H36xx; |
1175 | else if ( d-> m_modelstr == "H3700" ) | 1174 | else if ( d-> m_modelstr == "H3700" ) |
1176 | d-> m_model = Model_iPAQ_H37xx; | 1175 | d-> m_model = Model_iPAQ_H37xx; |
1177 | else if ( d-> m_modelstr == "H3800" ) | 1176 | else if ( d-> m_modelstr == "H3800" ) |
1178 | d-> m_model = Model_iPAQ_H38xx; | 1177 | d-> m_model = Model_iPAQ_H38xx; |
1179 | else if ( d-> m_modelstr == "H3900" ) | 1178 | else if ( d-> m_modelstr == "H3900" ) |
1180 | d-> m_model = Model_iPAQ_H39xx; | 1179 | d-> m_model = Model_iPAQ_H39xx; |
1181 | else if ( d-> m_modelstr == "H5400" ) | 1180 | else if ( d-> m_modelstr == "H5400" ) |
1182 | d-> m_model = Model_iPAQ_H5xxx; | 1181 | d-> m_model = Model_iPAQ_H5xxx; |
1183 | else | 1182 | else |
1184 | d-> m_model = Model_Unknown; | 1183 | d-> m_model = Model_Unknown; |
1185 | 1184 | ||
1186 | f. close ( ); | 1185 | f. close ( ); |
1187 | } | 1186 | } |
1188 | 1187 | ||
1189 | switch ( d-> m_model ) { | 1188 | switch ( d-> m_model ) { |
1190 | case Model_iPAQ_H31xx: | 1189 | case Model_iPAQ_H31xx: |
1191 | case Model_iPAQ_H38xx: | 1190 | case Model_iPAQ_H38xx: |
1192 | d-> m_rotation = Rot90; | 1191 | d-> m_rotation = Rot90; |
1193 | break; | 1192 | break; |
1194 | case Model_iPAQ_H36xx: | 1193 | case Model_iPAQ_H36xx: |
1195 | case Model_iPAQ_H37xx: | 1194 | case Model_iPAQ_H37xx: |
1196 | case Model_iPAQ_H39xx: | 1195 | case Model_iPAQ_H39xx: |
1197 | 1196 | ||
1198 | default: | 1197 | default: |
1199 | d-> m_rotation = Rot270; | 1198 | d-> m_rotation = Rot270; |
1200 | break; | 1199 | break; |
1201 | case Model_iPAQ_H5xxx: | 1200 | case Model_iPAQ_H5xxx: |
1202 | d-> m_rotation = Rot0; | 1201 | d-> m_rotation = Rot0; |
1203 | } | 1202 | } |
1204 | 1203 | ||
1205 | f. setName ( "/etc/familiar-version" ); | 1204 | f. setName ( "/etc/familiar-version" ); |
1206 | if ( f. open ( IO_ReadOnly )) { | 1205 | if ( f. open ( IO_ReadOnly )) { |
1207 | d-> m_systemstr = "Familiar"; | 1206 | d-> m_systemstr = "Familiar"; |
1208 | d-> m_system = System_Familiar; | 1207 | d-> m_system = System_Familiar; |
1209 | 1208 | ||
1210 | QTextStream ts ( &f ); | 1209 | QTextStream ts ( &f ); |
1211 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 1210 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
1212 | 1211 | ||
1213 | f. close ( ); | 1212 | f. close ( ); |
1214 | } else { | 1213 | } else { |
1215 | f. setName ( "/etc/oz_version" ); | 1214 | f. setName ( "/etc/oz_version" ); |
1216 | 1215 | ||
1217 | if ( f. open ( IO_ReadOnly )) { | 1216 | if ( f. open ( IO_ReadOnly )) { |
1218 | d-> m_systemstr = "OpenEmbedded/iPaq"; | 1217 | d-> m_systemstr = "OpenEmbedded/iPaq"; |
1219 | d-> m_system = System_Familiar; | 1218 | d-> m_system = System_Familiar; |
1220 | 1219 | ||
1221 | QTextStream ts ( &f ); | 1220 | QTextStream ts ( &f ); |
1222 | ts.setDevice ( &f ); | 1221 | ts.setDevice ( &f ); |
1223 | d-> m_sysverstr = ts. readLine ( ); | 1222 | d-> m_sysverstr = ts. readLine ( ); |
1224 | f. close ( ); | 1223 | f. close ( ); |
1225 | } | 1224 | } |
1226 | } | 1225 | } |
1227 | 1226 | ||
1228 | 1227 | ||
1229 | 1228 | ||
1230 | 1229 | ||
1231 | 1230 | ||
1232 | m_leds [0] = m_leds [1] = Led_Off; | 1231 | m_leds [0] = m_leds [1] = Led_Off; |
1233 | 1232 | ||
1234 | m_power_timer = 0; | 1233 | m_power_timer = 0; |
1235 | 1234 | ||
1236 | } | 1235 | } |
1237 | 1236 | ||
1238 | void iPAQ::initButtons ( ) | 1237 | void iPAQ::initButtons ( ) |
1239 | { | 1238 | { |
1240 | if ( d-> m_buttons ) | 1239 | if ( d-> m_buttons ) |
1241 | return; | 1240 | return; |
1242 | 1241 | ||
1243 | if ( isQWS( ) ) | 1242 | if ( isQWS( ) ) |
1244 | QWSServer::setKeyboardFilter ( this ); | 1243 | QWSServer::setKeyboardFilter ( this ); |
1245 | 1244 | ||
1246 | d-> m_buttons = new QValueList <ODeviceButton>; | 1245 | d-> m_buttons = new QValueList <ODeviceButton>; |
1247 | 1246 | ||
1248 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 1247 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
1249 | i_button *ib = ipaq_buttons + i; | 1248 | i_button *ib = ipaq_buttons + i; |
1250 | ODeviceButton b; | 1249 | ODeviceButton b; |
1251 | 1250 | ||
1252 | if (( ib-> model & d-> m_model ) == d-> m_model ) { | 1251 | if (( ib-> model & d-> m_model ) == d-> m_model ) { |
1253 | b. setKeycode ( ib-> code ); | 1252 | b. setKeycode ( ib-> code ); |
1254 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 1253 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
1255 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 1254 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
1256 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 1255 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
1257 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 1256 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
1258 | 1257 | ||
1259 | d-> m_buttons-> append ( b ); | 1258 | d-> m_buttons-> append ( b ); |
1260 | } | 1259 | } |
1261 | } | 1260 | } |
1262 | reloadButtonMapping ( ); | 1261 | reloadButtonMapping ( ); |
1263 | 1262 | ||
1264 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1263 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1265 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1264 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1266 | } | 1265 | } |
1267 | 1266 | ||
1268 | 1267 | ||
1269 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 1268 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
1270 | 1269 | ||
1271 | typedef struct { | 1270 | typedef struct { |
1272 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 1271 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
1273 | unsigned char TotalTime; /* Units of 5 seconds */ | 1272 | unsigned char TotalTime; /* Units of 5 seconds */ |
1274 | unsigned char OnTime; /* units of 100m/s */ | 1273 | unsigned char OnTime; /* units of 100m/s */ |
1275 | unsigned char OffTime; /* units of 100m/s */ | 1274 | unsigned char OffTime; /* units of 100m/s */ |
1276 | } LED_IN; | 1275 | } LED_IN; |
1277 | 1276 | ||
1278 | typedef struct { | 1277 | typedef struct { |
1279 | unsigned char mode; | 1278 | unsigned char mode; |
1280 | unsigned char pwr; | 1279 | unsigned char pwr; |
1281 | unsigned char brightness; | 1280 | unsigned char brightness; |
1282 | } FLITE_IN; | 1281 | } FLITE_IN; |
1283 | 1282 | ||
1284 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 1283 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
1285 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 1284 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
1286 | 1285 | ||
1287 | 1286 | ||
1288 | QValueList <OLed> iPAQ::ledList ( ) const | 1287 | QValueList <OLed> iPAQ::ledList ( ) const |
1289 | { | 1288 | { |
1290 | QValueList <OLed> vl; | 1289 | QValueList <OLed> vl; |
1291 | vl << Led_Power; | 1290 | vl << Led_Power; |
1292 | 1291 | ||
1293 | if ( d-> m_model == Model_iPAQ_H38xx ) | 1292 | if ( d-> m_model == Model_iPAQ_H38xx ) |
1294 | vl << Led_BlueTooth; | 1293 | vl << Led_BlueTooth; |
1295 | return vl; | 1294 | return vl; |
1296 | } | 1295 | } |
1297 | 1296 | ||
1298 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 1297 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
1299 | { | 1298 | { |
1300 | QValueList <OLedState> vl; | 1299 | QValueList <OLedState> vl; |
1301 | 1300 | ||
1302 | if ( l == Led_Power ) | 1301 | if ( l == Led_Power ) |
1303 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 1302 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
1304 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 1303 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
1305 | vl << Led_Off; // << Led_On << ??? | 1304 | vl << Led_Off; // << Led_On << ??? |
1306 | 1305 | ||
1307 | return vl; | 1306 | return vl; |
1308 | } | 1307 | } |
1309 | 1308 | ||
1310 | OLedState iPAQ::ledState ( OLed l ) const | 1309 | OLedState iPAQ::ledState ( OLed l ) const |
1311 | { | 1310 | { |
1312 | switch ( l ) { | 1311 | switch ( l ) { |
1313 | case Led_Power: | 1312 | case Led_Power: |
1314 | return m_leds [0]; | 1313 | return m_leds [0]; |
1315 | case Led_BlueTooth: | 1314 | case Led_BlueTooth: |
1316 | return m_leds [1]; | 1315 | return m_leds [1]; |
1317 | default: | 1316 | default: |
1318 | return Led_Off; | 1317 | return Led_Off; |
1319 | } | 1318 | } |
1320 | } | 1319 | } |
1321 | 1320 | ||
1322 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 1321 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
1323 | { | 1322 | { |
1324 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 1323 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
1325 | 1324 | ||
1326 | if ( l == Led_Power ) { | 1325 | if ( l == Led_Power ) { |
1327 | if ( fd >= 0 ) { | 1326 | if ( fd >= 0 ) { |
1328 | LED_IN leds; | 1327 | LED_IN leds; |
1329 | ::memset ( &leds, 0, sizeof( leds )); | 1328 | ::memset ( &leds, 0, sizeof( leds )); |
1330 | leds. TotalTime = 0; | 1329 | leds. TotalTime = 0; |
1331 | leds. OnTime = 0; | 1330 | leds. OnTime = 0; |
1332 | leds. OffTime = 1; | 1331 | leds. OffTime = 1; |
1333 | leds. OffOnBlink = 2; | 1332 | leds. OffOnBlink = 2; |
1334 | 1333 | ||
1335 | switch ( st ) { | 1334 | switch ( st ) { |
1336 | case Led_Off : leds. OffOnBlink = 0; break; | 1335 | case Led_Off : leds. OffOnBlink = 0; break; |
1337 | case Led_On : leds. OffOnBlink = 1; break; | 1336 | case Led_On : leds. OffOnBlink = 1; break; |
1338 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 1337 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
1339 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 1338 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
1340 | } | 1339 | } |
1341 | 1340 | ||
1342 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 1341 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
1343 | m_leds [0] = st; | 1342 | m_leds [0] = st; |
1344 | return true; | 1343 | return true; |
1345 | } | 1344 | } |
1346 | } | 1345 | } |
1347 | } | 1346 | } |
1348 | return false; | 1347 | return false; |
1349 | } | 1348 | } |
1350 | 1349 | ||
1351 | 1350 | ||
1352 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 1351 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
1353 | { | 1352 | { |
1354 | int newkeycode = keycode; | 1353 | int newkeycode = keycode; |
1355 | 1354 | ||
1356 | switch ( keycode ) { | 1355 | switch ( keycode ) { |
1357 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 1356 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
1358 | case HardKey_Menu: { | 1357 | case HardKey_Menu: { |
1359 | if (( d-> m_model == Model_iPAQ_H38xx ) || | 1358 | if (( d-> m_model == Model_iPAQ_H38xx ) || |
1360 | ( d-> m_model == Model_iPAQ_H39xx ) || | 1359 | ( d-> m_model == Model_iPAQ_H39xx ) || |
1361 | ( d-> m_model == Model_iPAQ_H5xxx)) { | 1360 | ( d-> m_model == Model_iPAQ_H5xxx)) { |
1362 | newkeycode = HardKey_Mail; | 1361 | newkeycode = HardKey_Mail; |
1363 | } | 1362 | } |
1364 | break; | 1363 | break; |
1365 | } | 1364 | } |
1366 | 1365 | ||
1367 | // Rotate cursor keys 180° or 270° | 1366 | // Rotate cursor keys 180° or 270° |
1368 | case Key_Left : | 1367 | case Key_Left : |
1369 | case Key_Right: | 1368 | case Key_Right: |
1370 | case Key_Up : | 1369 | case Key_Up : |
1371 | case Key_Down : { | 1370 | case Key_Down : { |
1372 | 1371 | ||
1373 | if (( d-> m_model == Model_iPAQ_H31xx ) || | 1372 | if (( d-> m_model == Model_iPAQ_H31xx ) || |
1374 | ( d-> m_model == Model_iPAQ_H38xx )) { | 1373 | ( d-> m_model == Model_iPAQ_H38xx )) { |
1375 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 1374 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
1376 | } | 1375 | } |
1377 | // Rotate the cursor keys by 270° | 1376 | // Rotate the cursor keys by 270° |
1378 | // keycode - Key_Left = position of the button starting from left clockwise | 1377 | // keycode - Key_Left = position of the button starting from left clockwise |
1379 | // add the rotation to it and modolo. No we've the original offset | 1378 | // add the rotation to it and modolo. No we've the original offset |
1380 | // add the offset to the Key_Left key | 1379 | // add the offset to the Key_Left key |
1381 | if ( d-> m_model == Model_iPAQ_H5xxx ) | 1380 | if ( d-> m_model == Model_iPAQ_H5xxx ) |
1382 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; | 1381 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; |
1383 | break; | 1382 | break; |
1384 | } | 1383 | } |
1385 | 1384 | ||
1386 | // map Power Button short/long press to F34/F35 | 1385 | // map Power Button short/long press to F34/F35 |
1387 | case Key_SysReq: { | 1386 | case Key_SysReq: { |
1388 | if ( isPress ) { | 1387 | if ( isPress ) { |
1389 | if ( m_power_timer ) | 1388 | if ( m_power_timer ) |
1390 | killTimer ( m_power_timer ); | 1389 | killTimer ( m_power_timer ); |
1391 | m_power_timer = startTimer ( 500 ); | 1390 | m_power_timer = startTimer ( 500 ); |
1392 | } | 1391 | } |
1393 | else if ( m_power_timer ) { | 1392 | else if ( m_power_timer ) { |
1394 | killTimer ( m_power_timer ); | 1393 | killTimer ( m_power_timer ); |
1395 | m_power_timer = 0; | 1394 | m_power_timer = 0; |
1396 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 1395 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
1397 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 1396 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
1398 | } | 1397 | } |
1399 | newkeycode = Key_unknown; | 1398 | newkeycode = Key_unknown; |
1400 | break; | 1399 | break; |
1401 | } | 1400 | } |
1402 | } | 1401 | } |
1403 | 1402 | ||
1404 | if ( newkeycode != keycode ) { | 1403 | if ( newkeycode != keycode ) { |
1405 | if ( newkeycode != Key_unknown ) | 1404 | if ( newkeycode != Key_unknown ) |
1406 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 1405 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
1407 | return true; | 1406 | return true; |
1408 | } | 1407 | } |
1409 | else | 1408 | else |
1410 | return false; | 1409 | return false; |
1411 | } | 1410 | } |
1412 | 1411 | ||
1413 | void iPAQ::timerEvent ( QTimerEvent * ) | 1412 | void iPAQ::timerEvent ( QTimerEvent * ) |
1414 | { | 1413 | { |
1415 | killTimer ( m_power_timer ); | 1414 | killTimer ( m_power_timer ); |
1416 | m_power_timer = 0; | 1415 | m_power_timer = 0; |
1417 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 1416 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
1418 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 1417 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
1419 | } | 1418 | } |
1420 | 1419 | ||
1421 | 1420 | ||
1422 | void iPAQ::alarmSound ( ) | 1421 | void iPAQ::alarmSound ( ) |
1423 | { | 1422 | { |
1424 | #ifndef QT_NO_SOUND | 1423 | #ifndef QT_NO_SOUND |
1425 | static Sound snd ( "alarm" ); | 1424 | static Sound snd ( "alarm" ); |
1426 | int fd; | 1425 | int fd; |
1427 | int vol; | 1426 | int vol; |
1428 | bool vol_reset = false; | 1427 | bool vol_reset = false; |
1429 | 1428 | ||
1430 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 1429 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
1431 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 1430 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
1432 | Config cfg ( "qpe" ); | 1431 | Config cfg ( "qpe" ); |
1433 | cfg. setGroup ( "Volume" ); | 1432 | cfg. setGroup ( "Volume" ); |
1434 | 1433 | ||
1435 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1434 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1436 | if ( volalarm < 0 ) | 1435 | if ( volalarm < 0 ) |
1437 | volalarm = 0; | 1436 | volalarm = 0; |
1438 | else if ( volalarm > 100 ) | 1437 | else if ( volalarm > 100 ) |
1439 | volalarm = 100; | 1438 | volalarm = 100; |
1440 | volalarm |= ( volalarm << 8 ); | 1439 | volalarm |= ( volalarm << 8 ); |
1441 | 1440 | ||
1442 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1441 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1443 | vol_reset = true; | 1442 | vol_reset = true; |
1444 | } | 1443 | } |
1445 | } | 1444 | } |
1446 | 1445 | ||
1447 | snd. play ( ); | 1446 | snd. play ( ); |
1448 | while ( !snd. isFinished ( )) | 1447 | while ( !snd. isFinished ( )) |
1449 | qApp-> processEvents ( ); | 1448 | qApp-> processEvents ( ); |
1450 | 1449 | ||
1451 | if ( fd >= 0 ) { | 1450 | if ( fd >= 0 ) { |
1452 | if ( vol_reset ) | 1451 | if ( vol_reset ) |
1453 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1452 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
1454 | ::close ( fd ); | 1453 | ::close ( fd ); |
1455 | } | 1454 | } |
1456 | #endif | 1455 | #endif |
1457 | } | 1456 | } |
1458 | 1457 | ||
1459 | 1458 | ||
1460 | bool iPAQ::setSoftSuspend ( bool soft ) | 1459 | bool iPAQ::setSoftSuspend ( bool soft ) |
1461 | { | 1460 | { |
1462 | bool res = false; | 1461 | bool res = false; |
1463 | int fd; | 1462 | int fd; |
1464 | 1463 | ||
1465 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 1464 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
1466 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 1465 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
1467 | res = true; | 1466 | res = true; |
1468 | else | 1467 | else |
1469 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 1468 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
1470 | 1469 | ||
1471 | ::close ( fd ); | 1470 | ::close ( fd ); |
1472 | } | 1471 | } |
1473 | else | 1472 | else |
1474 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 1473 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
1475 | 1474 | ||
1476 | return res; | 1475 | return res; |
1477 | } | 1476 | } |
1478 | 1477 | ||
1479 | 1478 | ||
1480 | bool iPAQ::setDisplayBrightness ( int bright ) | 1479 | bool iPAQ::setDisplayBrightness ( int bright ) |
1481 | { | 1480 | { |
1482 | bool res = false; | 1481 | bool res = false; |
1483 | int fd; | 1482 | int fd; |
1484 | 1483 | ||
1485 | if ( bright > 255 ) | 1484 | if ( bright > 255 ) |
1486 | bright = 255; | 1485 | bright = 255; |
1487 | if ( bright < 0 ) | 1486 | if ( bright < 0 ) |
1488 | bright = 0; | 1487 | bright = 0; |
1489 | 1488 | ||
1490 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 1489 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
1491 | FLITE_IN bl; | 1490 | FLITE_IN bl; |
1492 | bl. mode = 1; | 1491 | bl. mode = 1; |
1493 | bl. pwr = bright ? 1 : 0; | 1492 | bl. pwr = bright ? 1 : 0; |
1494 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 1493 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
1495 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 1494 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
1496 | ::close ( fd ); | 1495 | ::close ( fd ); |
1497 | } | 1496 | } |
1498 | return res; | 1497 | return res; |
1499 | } | 1498 | } |
1500 | 1499 | ||
1501 | int iPAQ::displayBrightnessResolution ( ) const | 1500 | int iPAQ::displayBrightnessResolution ( ) const |
1502 | { | 1501 | { |
1503 | switch ( model ( )) { | 1502 | switch ( model ( )) { |
1504 | case Model_iPAQ_H31xx: | 1503 | case Model_iPAQ_H31xx: |
1505 | case Model_iPAQ_H36xx: | 1504 | case Model_iPAQ_H36xx: |
1506 | case Model_iPAQ_H37xx: | 1505 | case Model_iPAQ_H37xx: |
1507 | return 128; // really 256, but >128 could damage the LCD | 1506 | return 128; // really 256, but >128 could damage the LCD |
1508 | 1507 | ||
1509 | case Model_iPAQ_H38xx: | 1508 | case Model_iPAQ_H38xx: |
1510 | case Model_iPAQ_H39xx: | 1509 | case Model_iPAQ_H39xx: |
1511 | return 64; | 1510 | return 64; |
1512 | case Model_iPAQ_H5xxx: | 1511 | case Model_iPAQ_H5xxx: |
1513 | return 255; | 1512 | return 255; |
1514 | 1513 | ||
1515 | default: | 1514 | default: |
1516 | return 2; | 1515 | return 2; |
1517 | } | 1516 | } |
1518 | } | 1517 | } |
1519 | 1518 | ||
1520 | 1519 | ||
1521 | bool iPAQ::hasLightSensor ( ) const | 1520 | bool iPAQ::hasLightSensor ( ) const |
1522 | { | 1521 | { |
1523 | return true; | 1522 | return true; |
1524 | } | 1523 | } |
1525 | 1524 | ||
1526 | int iPAQ::readLightSensor ( ) | 1525 | int iPAQ::readLightSensor ( ) |
1527 | { | 1526 | { |
1528 | int fd; | 1527 | int fd; |
1529 | int val = -1; | 1528 | int val = -1; |
1530 | 1529 | ||
1531 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 1530 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
1532 | char buffer [8]; | 1531 | char buffer [8]; |
1533 | 1532 | ||
1534 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 1533 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
1535 | char *endptr; | 1534 | char *endptr; |
1536 | 1535 | ||
1537 | buffer [4] = 0; | 1536 | buffer [4] = 0; |
1538 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 1537 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
1539 | 1538 | ||
1540 | if ( *endptr != 0 ) | 1539 | if ( *endptr != 0 ) |
1541 | val = -1; | 1540 | val = -1; |
1542 | } | 1541 | } |
1543 | ::close ( fd ); | 1542 | ::close ( fd ); |
1544 | } | 1543 | } |
1545 | 1544 | ||
1546 | return val; | 1545 | return val; |
1547 | } | 1546 | } |
1548 | 1547 | ||
1549 | int iPAQ::lightSensorResolution ( ) const | 1548 | int iPAQ::lightSensorResolution ( ) const |
1550 | { | 1549 | { |
1551 | return 256; | 1550 | return 256; |
1552 | } | 1551 | } |
1553 | 1552 | ||
1554 | /************************************************** | 1553 | /************************************************** |
1555 | * | 1554 | * |
1556 | * Zaurus | 1555 | * Zaurus |
1557 | * | 1556 | * |
1558 | **************************************************/ | 1557 | **************************************************/ |
1559 | 1558 | ||
1560 | // Check whether this device is the sharp zaurus.. | 1559 | // Check whether this device is the sharp zaurus.. |
1561 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus | 1560 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus |
1562 | // class up into individual classes. We need three classes | 1561 | // class up into individual classes. We need three classes |
1563 | // | 1562 | // |
1564 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) | 1563 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) |
1565 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) | 1564 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) |
1566 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) | 1565 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) |
1567 | // | 1566 | // |
1568 | // Only question right now is: Do we really need to do it? Because as soon | 1567 | // Only question right now is: Do we really need to do it? Because as soon |
1569 | // as the OpenZaurus kernel is ready, there will be a unified interface for all | 1568 | // as the OpenZaurus kernel is ready, there will be a unified interface for all |
1570 | // Zaurus models (concerning apm, backlight, buttons, etc.) | 1569 | // Zaurus models (concerning apm, backlight, buttons, etc.) |
1571 | // | 1570 | // |
1572 | // Comments? - mickeyl. | 1571 | // Comments? - mickeyl. |
1573 | 1572 | ||
1574 | bool Zaurus::isZaurus() | 1573 | bool Zaurus::isZaurus() |
1575 | { | 1574 | { |
1576 | 1575 | ||
1577 | // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! | 1576 | // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! |
1578 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ | 1577 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ |
1579 | return true; | 1578 | return true; |
1580 | } | 1579 | } |
1581 | 1580 | ||
1582 | // On non-embedix kernels, we have to look closer. | 1581 | // On non-embedix kernels, we have to look closer. |
1583 | bool is_zaurus = false; | 1582 | bool is_zaurus = false; |
1584 | QFile f ( "/proc/cpuinfo" ); | 1583 | QFile f ( "/proc/cpuinfo" ); |
1585 | if ( f. open ( IO_ReadOnly ) ) { | 1584 | if ( f. open ( IO_ReadOnly ) ) { |
1586 | QString model; | 1585 | QString model; |
1587 | QFile f ( "/proc/cpuinfo" ); | 1586 | QFile f ( "/proc/cpuinfo" ); |
1588 | 1587 | ||
1589 | QTextStream ts ( &f ); | 1588 | QTextStream ts ( &f ); |
1590 | QString line; | 1589 | QString line; |
1591 | while( line = ts. readLine ( ) ) { | 1590 | while( line = ts. readLine ( ) ) { |
1592 | if ( line. left ( 8 ) == "Hardware" ) | 1591 | if ( line. left ( 8 ) == "Hardware" ) |
1593 | break; | 1592 | break; |
1594 | } | 1593 | } |
1595 | int loc = line. find ( ":" ); | 1594 | int loc = line. find ( ":" ); |
1596 | if ( loc != -1 ) | 1595 | if ( loc != -1 ) |
1597 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1596 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1598 | 1597 | ||
1599 | if ( model == "Sharp-Collie" | 1598 | if ( model == "Sharp-Collie" |
1600 | || model == "Collie" | 1599 | || model == "Collie" |
1601 | || model == "SHARP Corgi" | 1600 | || model == "SHARP Corgi" |
1602 | || model == "SHARP Shepherd" | 1601 | || model == "SHARP Shepherd" |
1603 | || model == "SHARP Poodle" | 1602 | || model == "SHARP Poodle" |
1604 | || model == "SHARP Husky" | 1603 | || model == "SHARP Husky" |
1605 | ) | 1604 | ) |
1606 | is_zaurus = true; | 1605 | is_zaurus = true; |
1607 | 1606 | ||
1608 | } | 1607 | } |
1609 | return is_zaurus; | 1608 | return is_zaurus; |
1610 | } | 1609 | } |
1611 | 1610 | ||
1612 | 1611 | ||
1613 | void Zaurus::init ( ) | 1612 | void Zaurus::init ( ) |
1614 | { | 1613 | { |
1615 | d-> m_vendorstr = "Sharp"; | 1614 | d-> m_vendorstr = "Sharp"; |
1616 | d-> m_vendor = Vendor_Sharp; | 1615 | d-> m_vendor = Vendor_Sharp; |
1617 | m_embedix = true; // Not openzaurus means: It has an embedix kernel ! | 1616 | m_embedix = true; // Not openzaurus means: It has an embedix kernel ! |
1618 | 1617 | ||
1619 | // QFile f ( "/proc/filesystems" ); | 1618 | // QFile f ( "/proc/filesystems" ); |
1620 | QString model; | 1619 | QString model; |
1621 | 1620 | ||
1622 | // It isn't a good idea to check the system configuration to | 1621 | // It isn't a good idea to check the system configuration to |
1623 | // detect the distribution ! | 1622 | // detect the distribution ! |
1624 | // Otherwise it may happen that any other distribution is detected as openzaurus, just | 1623 | // Otherwise it may happen that any other distribution is detected as openzaurus, just |
1625 | // because it uses a jffs2 filesystem.. | 1624 | // because it uses a jffs2 filesystem.. |
1626 | // (eilers) | 1625 | // (eilers) |
1627 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 1626 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
1628 | QFile f ("/etc/oz_version"); | 1627 | QFile f ("/etc/oz_version"); |
1629 | if ( f.exists() ){ | 1628 | if ( f.exists() ){ |
1630 | d-> m_vendorstr = "OpenZaurus Team"; | 1629 | d-> m_vendorstr = "OpenZaurus Team"; |
1631 | d-> m_systemstr = "OpenZaurus"; | 1630 | d-> m_systemstr = "OpenZaurus"; |
1632 | d-> m_system = System_OpenZaurus; | 1631 | d-> m_system = System_OpenZaurus; |
1633 | 1632 | ||
1634 | if ( f. open ( IO_ReadOnly )) { | 1633 | if ( f. open ( IO_ReadOnly )) { |
1635 | QTextStream ts ( &f ); | 1634 | QTextStream ts ( &f ); |
1636 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 1635 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
1637 | f. close ( ); | 1636 | f. close ( ); |
1638 | } | 1637 | } |
1639 | 1638 | ||
1640 | // Openzaurus sometimes uses the embedix kernel! | 1639 | // Openzaurus sometimes uses the embedix kernel! |
1641 | // => Check whether this is an embedix kernel | 1640 | // => Check whether this is an embedix kernel |
1642 | FILE *uname = popen("uname -r", "r"); | 1641 | FILE *uname = popen("uname -r", "r"); |
1643 | QString line; | 1642 | QString line; |
1644 | if ( f.open(IO_ReadOnly, uname) ) { | 1643 | if ( f.open(IO_ReadOnly, uname) ) { |
1645 | QTextStream ts ( &f ); | 1644 | QTextStream ts ( &f ); |
1646 | line = ts. readLine ( ); | 1645 | line = ts. readLine ( ); |
1647 | int loc = line. find ( "embedix" ); | 1646 | int loc = line. find ( "embedix" ); |
1648 | if ( loc != -1 ) | 1647 | if ( loc != -1 ) |
1649 | m_embedix = true; | 1648 | m_embedix = true; |
1650 | else | 1649 | else |
1651 | m_embedix = false; | 1650 | m_embedix = false; |
1652 | f. close ( ); | 1651 | f. close ( ); |
1653 | } | 1652 | } |
1654 | pclose(uname); | 1653 | pclose(uname); |
1655 | } | 1654 | } |
1656 | else { | 1655 | else { |
1657 | d-> m_systemstr = "Zaurus"; | 1656 | d-> m_systemstr = "Zaurus"; |
1658 | d-> m_system = System_Zaurus; | 1657 | d-> m_system = System_Zaurus; |
1659 | } | 1658 | } |
1660 | 1659 | ||
1661 | f. setName ( "/proc/cpuinfo" ); | 1660 | f. setName ( "/proc/cpuinfo" ); |
1662 | if ( f. open ( IO_ReadOnly ) ) { | 1661 | if ( f. open ( IO_ReadOnly ) ) { |
1663 | QTextStream ts ( &f ); | 1662 | QTextStream ts ( &f ); |
1664 | QString line; | 1663 | QString line; |
1665 | while( line = ts. readLine ( ) ) { | 1664 | while( line = ts. readLine ( ) ) { |
1666 | if ( line. left ( 8 ) == "Hardware" ) | 1665 | if ( line. left ( 8 ) == "Hardware" ) |
1667 | break; | 1666 | break; |
1668 | } | 1667 | } |
1669 | int loc = line. find ( ":" ); | 1668 | int loc = line. find ( ":" ); |
1670 | if ( loc != -1 ) | 1669 | if ( loc != -1 ) |
1671 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1670 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1672 | } | 1671 | } |
1673 | 1672 | ||
1674 | if ( model == "SHARP Corgi" ) { | 1673 | if ( model == "SHARP Corgi" ) { |
1675 | d-> m_model = Model_Zaurus_SLC7x0; | 1674 | d-> m_model = Model_Zaurus_SLC7x0; |
1676 | d-> m_modelstr = "Zaurus SL-C700"; | 1675 | d-> m_modelstr = "Zaurus SL-C700"; |
1677 | } else if ( model == "SHARP Shepherd" ) { | 1676 | } else if ( model == "SHARP Shepherd" ) { |
1678 | d-> m_model = Model_Zaurus_SLC7x0; | 1677 | d-> m_model = Model_Zaurus_SLC7x0; |
1679 | d-> m_modelstr = "Zaurus SL-C750"; | 1678 | d-> m_modelstr = "Zaurus SL-C750"; |
1680 | } else if ( model == "SHARP Husky" ) { | 1679 | } else if ( model == "SHARP Husky" ) { |
1681 | d-> m_model = Model_Zaurus_SLC7x0; | 1680 | d-> m_model = Model_Zaurus_SLC7x0; |
1682 | d-> m_modelstr = "Zaurus SL-C760"; | 1681 | d-> m_modelstr = "Zaurus SL-C760"; |
1683 | } else if ( model == "SHARP Poodle" ) { | 1682 | } else if ( model == "SHARP Poodle" ) { |
1684 | d-> m_model = Model_Zaurus_SLB600; | 1683 | d-> m_model = Model_Zaurus_SLB600; |
1685 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; | 1684 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; |
1686 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 1685 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
1687 | d-> m_model = Model_Zaurus_SL5500; | 1686 | d-> m_model = Model_Zaurus_SL5500; |
1688 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 1687 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
1689 | } else { | 1688 | } else { |
1690 | d-> m_model = Model_Zaurus_SL5500; | 1689 | d-> m_model = Model_Zaurus_SL5500; |
1691 | d-> m_modelstr = "Zaurus (Model unknown)"; | 1690 | d-> m_modelstr = "Zaurus (Model unknown)"; |
1692 | } | 1691 | } |
1693 | 1692 | ||
1694 | bool flipstate = false; | 1693 | bool flipstate = false; |
1695 | switch ( d-> m_model ) { | 1694 | switch ( d-> m_model ) { |
1696 | case Model_Zaurus_SLA300: | 1695 | case Model_Zaurus_SLA300: |
1697 | d-> m_rotation = Rot0; | 1696 | d-> m_rotation = Rot0; |
1698 | break; | 1697 | break; |
1699 | case Model_Zaurus_SLC7x0: | 1698 | case Model_Zaurus_SLC7x0: |
1700 | d-> m_rotation = rotation(); | 1699 | d-> m_rotation = rotation(); |
1701 | d-> m_direction = direction(); | 1700 | d-> m_direction = direction(); |
1702 | break; | 1701 | break; |
1703 | case Model_Zaurus_SLB600: | 1702 | case Model_Zaurus_SLB600: |
1704 | case Model_Zaurus_SL5500: | 1703 | case Model_Zaurus_SL5500: |
1705 | case Model_Zaurus_SL5000: | 1704 | case Model_Zaurus_SL5000: |
1706 | default: | 1705 | default: |
1707 | d-> m_rotation = Rot270; | 1706 | d-> m_rotation = Rot270; |
1708 | break; | 1707 | break; |
1709 | } | 1708 | } |
1710 | m_leds [0] = Led_Off; | 1709 | m_leds [0] = Led_Off; |
1711 | } | 1710 | } |
1712 | 1711 | ||
1713 | void Zaurus::initButtons ( ) | 1712 | void Zaurus::initButtons ( ) |
1714 | { | 1713 | { |
1715 | if ( d-> m_buttons ) | 1714 | if ( d-> m_buttons ) |
1716 | return; | 1715 | return; |
1717 | 1716 | ||
1718 | d-> m_buttons = new QValueList <ODeviceButton>; | 1717 | d-> m_buttons = new QValueList <ODeviceButton>; |
1719 | 1718 | ||
1720 | struct z_button * pz_buttons; | 1719 | struct z_button * pz_buttons; |
1721 | int buttoncount; | 1720 | int buttoncount; |
1722 | switch ( d-> m_model ) { | 1721 | switch ( d-> m_model ) { |
1723 | case Model_Zaurus_SLC7x0: | 1722 | case Model_Zaurus_SLC7x0: |
1724 | pz_buttons = z_buttons_c700; | 1723 | pz_buttons = z_buttons_c700; |
1725 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 1724 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
1726 | break; | 1725 | break; |
1727 | default: | 1726 | default: |
1728 | pz_buttons = z_buttons; | 1727 | pz_buttons = z_buttons; |
1729 | buttoncount = ARRAY_SIZE(z_buttons); | 1728 | buttoncount = ARRAY_SIZE(z_buttons); |
1730 | break; | 1729 | break; |
1731 | } | 1730 | } |
1732 | 1731 | ||
1733 | for ( int i = 0; i < buttoncount; i++ ) { | 1732 | for ( int i = 0; i < buttoncount; i++ ) { |
1734 | struct z_button *zb = pz_buttons + i; | 1733 | struct z_button *zb = pz_buttons + i; |
1735 | ODeviceButton b; | 1734 | ODeviceButton b; |
1736 | 1735 | ||
1737 | b. setKeycode ( zb-> code ); | 1736 | b. setKeycode ( zb-> code ); |
1738 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); | 1737 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); |
1739 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); | 1738 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); |
1740 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), | 1739 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), |
1741 | zb-> fpressedaction )); | 1740 | zb-> fpressedaction )); |
1742 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), | 1741 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), |
1743 | zb-> fheldaction )); | 1742 | zb-> fheldaction )); |
1744 | 1743 | ||
1745 | d-> m_buttons-> append ( b ); | 1744 | d-> m_buttons-> append ( b ); |
1746 | } | 1745 | } |
1747 | 1746 | ||
1748 | reloadButtonMapping ( ); | 1747 | reloadButtonMapping ( ); |
1749 | 1748 | ||
1750 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1749 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1751 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), | 1750 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), |
1752 | this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1751 | this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1753 | } | 1752 | } |
1754 | 1753 | ||
1755 | #include <unistd.h> | 1754 | #include <unistd.h> |
1756 | #include <fcntl.h> | 1755 | #include <fcntl.h> |
1757 | #include <sys/ioctl.h> | 1756 | #include <sys/ioctl.h> |
1758 | 1757 | ||
1759 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 1758 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
1760 | 1759 | ||
1761 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 1760 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
1762 | 1761 | ||
1763 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1762 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1764 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1763 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1765 | 1764 | ||
1766 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1765 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1767 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1766 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1768 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1767 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1769 | 1768 | ||
1770 | /* --- for SHARP_BUZZER device --- */ | 1769 | /* --- for SHARP_BUZZER device --- */ |
1771 | 1770 | ||
1772 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1771 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1773 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1772 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1774 | 1773 | ||
1775 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 1774 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
1776 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 1775 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
1777 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 1776 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
1778 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 1777 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
1779 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 1778 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
1780 | 1779 | ||
1781 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1780 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1782 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1781 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1783 | 1782 | ||
1784 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 1783 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
1785 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 1784 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
1786 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 1785 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
1787 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 1786 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
1788 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 1787 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
1789 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 1788 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
1790 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 1789 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
1791 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 1790 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
1792 | 1791 | ||
1793 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1792 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1794 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 1793 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
1795 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 1794 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
1796 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 1795 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
1797 | // | 1796 | // |
1798 | 1797 | ||
1799 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1798 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1800 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 1799 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
1801 | 1800 | ||
1802 | #define SHARP_IOCTL_GET_ROTATION 0x413c | 1801 | #define SHARP_IOCTL_GET_ROTATION 0x413c |
1803 | 1802 | ||
1804 | typedef struct sharp_led_status { | 1803 | typedef struct sharp_led_status { |
1805 | int which; /* select which LED status is wanted. */ | 1804 | int which; /* select which LED status is wanted. */ |
1806 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 1805 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
1807 | } sharp_led_status; | 1806 | } sharp_led_status; |
1808 | 1807 | ||
1809 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 1808 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
1810 | 1809 | ||
1811 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 1810 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
1812 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 1811 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
1813 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 1812 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
1814 | 1813 | ||
1815 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 1814 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
1816 | 1815 | ||
1817 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 1816 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
1818 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 1817 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
1819 | #define APM_EVT_POWER_BUTTON (1 << 0) | 1818 | #define APM_EVT_POWER_BUTTON (1 << 0) |
1820 | 1819 | ||
1821 | #define FL_IOCTL_STEP_CONTRAST 100 | 1820 | #define FL_IOCTL_STEP_CONTRAST 100 |
1822 | 1821 | ||
1823 | 1822 | ||
1824 | void Zaurus::buzzer ( int sound ) | 1823 | void Zaurus::buzzer ( int sound ) |
1825 | { | 1824 | { |
1826 | #ifndef QT_NO_SOUND | 1825 | #ifndef QT_NO_SOUND |
1827 | QString soundname; | 1826 | QString soundname; |
1828 | 1827 | ||
1829 | // Not all devices have real sound | 1828 | // Not all devices have real sound |
1830 | if ( d->m_model == Model_Zaurus_SLC7x0 | 1829 | if ( d->m_model == Model_Zaurus_SLC7x0 |
1831 | || d->m_model == Model_Zaurus_SLB600 ){ | 1830 | || d->m_model == Model_Zaurus_SLB600 ){ |
1832 | 1831 | ||
1833 | switch ( sound ){ | 1832 | switch ( sound ){ |
1834 | case SHARP_BUZ_SCHEDULE_ALARM: | 1833 | case SHARP_BUZ_SCHEDULE_ALARM: |
1835 | soundname = "alarm"; | 1834 | soundname = "alarm"; |
1836 | break; | 1835 | break; |
1837 | case SHARP_BUZ_TOUCHSOUND: | 1836 | case SHARP_BUZ_TOUCHSOUND: |
1838 | soundname = "touchsound"; | 1837 | soundname = "touchsound"; |
1839 | break; | 1838 | break; |
1840 | case SHARP_BUZ_KEYSOUND: | 1839 | case SHARP_BUZ_KEYSOUND: |
1841 | soundname = "keysound"; | 1840 | soundname = "keysound"; |
1842 | break; | 1841 | break; |
1843 | default: | 1842 | default: |
1844 | soundname = "alarm"; | 1843 | soundname = "alarm"; |
1845 | 1844 | ||
1846 | } | 1845 | } |
1847 | } | 1846 | } |
1848 | 1847 | ||
1849 | // If a soundname is defined, we expect that this device has | 1848 | // If a soundname is defined, we expect that this device has |
1850 | // sound capabilities.. Otherwise we expect to have the buzzer | 1849 | // sound capabilities.. Otherwise we expect to have the buzzer |
1851 | // device.. | 1850 | // device.. |
1852 | if ( !soundname.isEmpty() ){ | 1851 | if ( !soundname.isEmpty() ){ |
1853 | int fd; | 1852 | int fd; |
1854 | int vol; | 1853 | int vol; |
1855 | bool vol_reset = false; | 1854 | bool vol_reset = false; |
1856 | 1855 | ||
1857 | Sound snd ( soundname ); | 1856 | Sound snd ( soundname ); |
1858 | 1857 | ||
1859 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 1858 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
1860 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 1859 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
1861 | Config cfg ( "qpe" ); | 1860 | Config cfg ( "qpe" ); |
1862 | cfg. setGroup ( "Volume" ); | 1861 | cfg. setGroup ( "Volume" ); |
1863 | 1862 | ||
1864 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1863 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1865 | if ( volalarm < 0 ) | 1864 | if ( volalarm < 0 ) |
1866 | volalarm = 0; | 1865 | volalarm = 0; |
1867 | else if ( volalarm > 100 ) | 1866 | else if ( volalarm > 100 ) |
1868 | volalarm = 100; | 1867 | volalarm = 100; |
1869 | volalarm |= ( volalarm << 8 ); | 1868 | volalarm |= ( volalarm << 8 ); |
1870 | 1869 | ||
1871 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1870 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1872 | vol_reset = true; | 1871 | vol_reset = true; |
1873 | } | 1872 | } |
1874 | } | 1873 | } |
1875 | 1874 | ||
1876 | snd. play ( ); | 1875 | snd. play ( ); |
1877 | while ( !snd. isFinished ( )) | 1876 | while ( !snd. isFinished ( )) |
1878 | qApp-> processEvents ( ); | 1877 | qApp-> processEvents ( ); |
1879 | 1878 | ||
1880 | if ( fd >= 0 ) { | 1879 | if ( fd >= 0 ) { |
1881 | if ( vol_reset ) | 1880 | if ( vol_reset ) |
1882 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1881 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
1883 | ::close ( fd ); | 1882 | ::close ( fd ); |
1884 | } | 1883 | } |
1885 | } else { | 1884 | } else { |
1886 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 1885 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
1887 | 1886 | ||
1888 | if ( fd >= 0 ) { | 1887 | if ( fd >= 0 ) { |
1889 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 1888 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
1890 | ::close ( fd ); | 1889 | ::close ( fd ); |
1891 | } | 1890 | } |
1892 | 1891 | ||
1893 | } | 1892 | } |
1894 | #endif | 1893 | #endif |
1895 | } | 1894 | } |
1896 | 1895 | ||
1897 | 1896 | ||
1898 | void Zaurus::alarmSound ( ) | 1897 | void Zaurus::alarmSound ( ) |
1899 | { | 1898 | { |
1900 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 1899 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
1901 | } | 1900 | } |
1902 | 1901 | ||
1903 | void Zaurus::touchSound ( ) | 1902 | void Zaurus::touchSound ( ) |
1904 | { | 1903 | { |
1905 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 1904 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
1906 | } | 1905 | } |
1907 | 1906 | ||
1908 | void Zaurus::keySound ( ) | 1907 | void Zaurus::keySound ( ) |
1909 | { | 1908 | { |
1910 | buzzer ( SHARP_BUZ_KEYSOUND ); | 1909 | buzzer ( SHARP_BUZ_KEYSOUND ); |
1911 | } | 1910 | } |
1912 | 1911 | ||
1913 | 1912 | ||
1914 | QValueList <OLed> Zaurus::ledList ( ) const | 1913 | QValueList <OLed> Zaurus::ledList ( ) const |
1915 | { | 1914 | { |
1916 | QValueList <OLed> vl; | 1915 | QValueList <OLed> vl; |
1917 | vl << Led_Mail; | 1916 | vl << Led_Mail; |
1918 | return vl; | 1917 | return vl; |
1919 | } | 1918 | } |
1920 | 1919 | ||
1921 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 1920 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
1922 | { | 1921 | { |
1923 | QValueList <OLedState> vl; | 1922 | QValueList <OLedState> vl; |
1924 | 1923 | ||
1925 | if ( l == Led_Mail ) | 1924 | if ( l == Led_Mail ) |
1926 | vl << Led_Off << Led_On << Led_BlinkSlow; | 1925 | vl << Led_Off << Led_On << Led_BlinkSlow; |
1927 | return vl; | 1926 | return vl; |
1928 | } | 1927 | } |
1929 | 1928 | ||
1930 | OLedState Zaurus::ledState ( OLed which ) const | 1929 | OLedState Zaurus::ledState ( OLed which ) const |
1931 | { | 1930 | { |
1932 | if ( which == Led_Mail ) | 1931 | if ( which == Led_Mail ) |
1933 | return m_leds [0]; | 1932 | return m_leds [0]; |
1934 | else | 1933 | else |
1935 | return Led_Off; | 1934 | return Led_Off; |
1936 | } | 1935 | } |
1937 | 1936 | ||
1938 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 1937 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
1939 | { | 1938 | { |
1940 | if (!m_embedix) // Currently not supported on non_embedix kernels | 1939 | if (!m_embedix) // Currently not supported on non_embedix kernels |
1941 | return false; | 1940 | return false; |
1942 | 1941 | ||
1943 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 1942 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
1944 | 1943 | ||
1945 | if ( which == Led_Mail ) { | 1944 | if ( which == Led_Mail ) { |
1946 | if ( fd >= 0 ) { | 1945 | if ( fd >= 0 ) { |
1947 | struct sharp_led_status leds; | 1946 | struct sharp_led_status leds; |
1948 | ::memset ( &leds, 0, sizeof( leds )); | 1947 | ::memset ( &leds, 0, sizeof( leds )); |
1949 | leds. which = SHARP_LED_MAIL_EXISTS; | 1948 | leds. which = SHARP_LED_MAIL_EXISTS; |
1950 | bool ok = true; | 1949 | bool ok = true; |
1951 | 1950 | ||
1952 | switch ( st ) { | 1951 | switch ( st ) { |
1953 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 1952 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
1954 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 1953 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
1955 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 1954 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
1956 | default : ok = false; | 1955 | default : ok = false; |
1957 | } | 1956 | } |
1958 | 1957 | ||
1959 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 1958 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
1960 | m_leds [0] = st; | 1959 | m_leds [0] = st; |
1961 | return true; | 1960 | return true; |
1962 | } | 1961 | } |
1963 | } | 1962 | } |
1964 | } | 1963 | } |
1965 | return false; | 1964 | return false; |
1966 | } | 1965 | } |
1967 | 1966 | ||
1968 | bool Zaurus::setSoftSuspend ( bool soft ) | 1967 | bool Zaurus::setSoftSuspend ( bool soft ) |
1969 | { | 1968 | { |
1970 | if (!m_embedix) { | 1969 | if (!m_embedix) { |
1971 | /* non-Embedix kernels dont have kernel autosuspend */ | 1970 | /* non-Embedix kernels dont have kernel autosuspend */ |
1972 | return ODevice::setSoftSuspend( soft ); | 1971 | return ODevice::setSoftSuspend( soft ); |
1973 | } | 1972 | } |
1974 | 1973 | ||
1975 | bool res = false; | 1974 | bool res = false; |
1976 | int fd; | 1975 | int fd; |
1977 | 1976 | ||
1978 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 1977 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
1979 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 1978 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
1980 | 1979 | ||
1981 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 1980 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
1982 | 1981 | ||
1983 | if ( sources >= 0 ) { | 1982 | if ( sources >= 0 ) { |
1984 | if ( soft ) | 1983 | if ( soft ) |
1985 | sources &= ~APM_EVT_POWER_BUTTON; | 1984 | sources &= ~APM_EVT_POWER_BUTTON; |
1986 | else | 1985 | else |
1987 | sources |= APM_EVT_POWER_BUTTON; | 1986 | sources |= APM_EVT_POWER_BUTTON; |
1988 | 1987 | ||
1989 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 1988 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
1990 | res = true; | 1989 | res = true; |
1991 | else | 1990 | else |
1992 | perror ( "APM_IOCGEVTSRC" ); | 1991 | perror ( "APM_IOCGEVTSRC" ); |
1993 | } | 1992 | } |
1994 | else | 1993 | else |
1995 | perror ( "APM_IOCGEVTSRC" ); | 1994 | perror ( "APM_IOCGEVTSRC" ); |
1996 | 1995 | ||
1997 | ::close ( fd ); | 1996 | ::close ( fd ); |
1998 | } | 1997 | } |
1999 | else | 1998 | else |
2000 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 1999 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
2001 | 2000 | ||
2002 | return res; | 2001 | return res; |
2003 | } | 2002 | } |
2004 | 2003 | ||
2005 | 2004 | ||
2006 | bool Zaurus::setDisplayBrightness ( int bright ) | 2005 | bool Zaurus::setDisplayBrightness ( int bright ) |
2007 | { | 2006 | { |
2008 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); | 2007 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); |
2009 | bool res = false; | 2008 | bool res = false; |
2010 | int fd; | 2009 | int fd; |
2011 | 2010 | ||
2012 | if ( bright > 255 ) bright = 255; | 2011 | if ( bright > 255 ) bright = 255; |
2013 | if ( bright < 0 ) bright = 0; | 2012 | if ( bright < 0 ) bright = 0; |
2014 | 2013 | ||
2015 | if ( m_embedix ) | 2014 | if ( m_embedix ) |
2016 | { | 2015 | { |
2017 | if ( d->m_model == Model_Zaurus_SLC7x0 ) | 2016 | if ( d->m_model == Model_Zaurus_SLC7x0 ) |
2018 | { | 2017 | { |
2019 | //qDebug( "using special treatment for devices with the corgi backlight interface" ); | 2018 | //qDebug( "using special treatment for devices with the corgi backlight interface" ); |
2020 | // special treatment for devices with the corgi backlight interface | 2019 | // special treatment for devices with the corgi backlight interface |
2021 | if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) | 2020 | if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) |
2022 | { | 2021 | { |
2023 | int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 ); | 2022 | int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 ); |
2024 | char writeCommand[100]; | 2023 | char writeCommand[100]; |
2025 | const int count = sprintf( writeCommand, "0x%x\n", value ); | 2024 | const int count = sprintf( writeCommand, "0x%x\n", value ); |
2026 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 2025 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
2027 | ::close ( fd ); | 2026 | ::close ( fd ); |
2028 | } | 2027 | } |
2029 | return res; | 2028 | return res; |
2030 | } | 2029 | } |
2031 | else | 2030 | else |
2032 | { | 2031 | { |
2033 | // standard treatment for devices with the dumb embedix frontlight interface | 2032 | // standard treatment for devices with the dumb embedix frontlight interface |
2034 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 2033 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
2035 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 2034 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
2036 | if ( bright && !bl ) | 2035 | if ( bright && !bl ) |
2037 | bl = 1; | 2036 | bl = 1; |
2038 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 2037 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
2039 | ::close ( fd ); | 2038 | ::close ( fd ); |
2040 | } | 2039 | } |
2041 | } | 2040 | } |
2042 | } | 2041 | } |
2043 | else | 2042 | else |
2044 | { | 2043 | { |
2045 | // special treatment for the OpenZaurus unified interface | 2044 | // special treatment for the OpenZaurus unified interface |
2046 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ | 2045 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ |
2047 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { | 2046 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { |
2048 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); | 2047 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); |
2049 | ::close ( fd ); | 2048 | ::close ( fd ); |
2050 | } | 2049 | } |
2051 | } | 2050 | } |
2052 | return res; | 2051 | return res; |
2053 | } | 2052 | } |
2054 | 2053 | ||
2055 | bool Zaurus::suspend ( ) | 2054 | bool Zaurus::suspend ( ) |
2056 | { | 2055 | { |
2057 | qDebug("ODevice::suspend"); | 2056 | qDebug("ODevice::suspend"); |
2058 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 2057 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
2059 | return false; | 2058 | return false; |
2060 | 2059 | ||
2061 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 2060 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
2062 | return false; | 2061 | return false; |
2063 | 2062 | ||
2064 | bool res = false; | 2063 | bool res = false; |
2065 | 2064 | ||
2066 | struct timeval tvs, tvn; | 2065 | struct timeval tvs, tvn; |
2067 | ::gettimeofday ( &tvs, 0 ); | 2066 | ::gettimeofday ( &tvs, 0 ); |
2068 | 2067 | ||
2069 | ::sync ( ); // flush fs caches | 2068 | ::sync ( ); // flush fs caches |
2070 | res = ( ::system ( "apm --suspend" ) == 0 ); | 2069 | res = ( ::system ( "apm --suspend" ) == 0 ); |
2071 | 2070 | ||
2072 | // This is needed because the iPAQ apm implementation is asynchronous and we | 2071 | // This is needed because the iPAQ apm implementation is asynchronous and we |
2073 | // can not be sure when exactly the device is really suspended | 2072 | // can not be sure when exactly the device is really suspended |
2074 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 2073 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
2075 | 2074 | ||
2076 | if ( res ) { | 2075 | if ( res ) { |
2077 | do { // Yes, wait 15 seconds. This APM bug sucks big time. | 2076 | do { // Yes, wait 15 seconds. This APM bug sucks big time. |
2078 | ::usleep ( 200 * 1000 ); | 2077 | ::usleep ( 200 * 1000 ); |
2079 | ::gettimeofday ( &tvn, 0 ); | 2078 | ::gettimeofday ( &tvn, 0 ); |
2080 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); | 2079 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); |
2081 | } | 2080 | } |
2082 | 2081 | ||
2083 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); | 2082 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); |
2084 | return res; | 2083 | return res; |
2085 | } | 2084 | } |
2086 | 2085 | ||
2087 | 2086 | ||
2088 | Transformation Zaurus::rotation ( ) const | 2087 | Transformation Zaurus::rotation ( ) const |
2089 | { | 2088 | { |
2090 | Transformation rot; | 2089 | Transformation rot; |
2091 | int handle = 0; | 2090 | int handle = 0; |
2092 | int retval = 0; | 2091 | int retval = 0; |
2093 | 2092 | ||
2094 | switch ( d-> m_model ) { | 2093 | switch ( d-> m_model ) { |
2095 | case Model_Zaurus_SLC7x0: | 2094 | case Model_Zaurus_SLC7x0: |
2096 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 2095 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
2097 | if (handle == -1) { | 2096 | if (handle == -1) { |
2098 | return Rot270; | 2097 | return Rot270; |
2099 | } else { | 2098 | } else { |
2100 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 2099 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
2101 | ::close (handle); | 2100 | ::close (handle); |
2102 | 2101 | ||
2103 | if (retval == 2 ) | 2102 | if (retval == 2 ) |
2104 | rot = Rot0; | 2103 | rot = Rot0; |
2105 | else | 2104 | else |
2106 | rot = Rot270; | 2105 | rot = Rot270; |
2107 | } | 2106 | } |
2108 | break; | 2107 | break; |
2109 | case Model_Zaurus_SLA300: | 2108 | case Model_Zaurus_SLA300: |
2110 | case Model_Zaurus_SLB600: | 2109 | case Model_Zaurus_SLB600: |
2111 | case Model_Zaurus_SL5500: | 2110 | case Model_Zaurus_SL5500: |
2112 | case Model_Zaurus_SL5000: | 2111 | case Model_Zaurus_SL5000: |
2113 | default: | 2112 | default: |
2114 | rot = d-> m_rotation; | 2113 | rot = d-> m_rotation; |
2115 | break; | 2114 | break; |
2116 | } | 2115 | } |
2117 | 2116 | ||
2118 | return rot; | 2117 | return rot; |
2119 | } | 2118 | } |
2120 | ODirection Zaurus::direction ( ) const | 2119 | ODirection Zaurus::direction ( ) const |
2121 | { | 2120 | { |
2122 | ODirection dir; | 2121 | ODirection dir; |
2123 | int handle = 0; | 2122 | int handle = 0; |
2124 | int retval = 0; | 2123 | int retval = 0; |
2125 | switch ( d-> m_model ) { | 2124 | switch ( d-> m_model ) { |
2126 | case Model_Zaurus_SLC7x0: | 2125 | case Model_Zaurus_SLC7x0: |
2127 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 2126 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
2128 | if (handle == -1) { | 2127 | if (handle == -1) { |
2129 | dir = CW; | 2128 | dir = CW; |
2130 | } else { | 2129 | } else { |
2131 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 2130 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
2132 | ::close (handle); | 2131 | ::close (handle); |
2133 | if (retval == 2 ) | 2132 | if (retval == 2 ) |
2134 | dir = CCW; | 2133 | dir = CCW; |
2135 | else | 2134 | else |
2136 | dir = CW; | 2135 | dir = CW; |
2137 | } | 2136 | } |
2138 | break; | 2137 | break; |
2139 | case Model_Zaurus_SLA300: | 2138 | case Model_Zaurus_SLA300: |
2140 | case Model_Zaurus_SLB600: | 2139 | case Model_Zaurus_SLB600: |
2141 | case Model_Zaurus_SL5500: | 2140 | case Model_Zaurus_SL5500: |
2142 | case Model_Zaurus_SL5000: | 2141 | case Model_Zaurus_SL5000: |
2143 | default: | 2142 | default: |
2144 | dir = d-> m_direction; | 2143 | dir = d-> m_direction; |
2145 | break; | 2144 | break; |
2146 | } | 2145 | } |
2147 | return dir; | 2146 | return dir; |
2148 | 2147 | ||
2149 | } | 2148 | } |
2150 | 2149 | ||
2151 | int Zaurus::displayBrightnessResolution ( ) const | 2150 | int Zaurus::displayBrightnessResolution ( ) const |
2152 | { | 2151 | { |
2153 | if (m_embedix) | 2152 | if (m_embedix) |
2154 | return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5; | 2153 | return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5; |
2155 | else | 2154 | else |
2156 | return 256; | 2155 | return 256; |
2157 | } | 2156 | } |
2158 | 2157 | ||
2159 | bool Zaurus::hasHingeSensor() const | 2158 | bool Zaurus::hasHingeSensor() const |
2160 | { | 2159 | { |
2161 | return d->m_model == Model_Zaurus_SLC7x0; | 2160 | return d->m_model == Model_Zaurus_SLC7x0; |
2162 | } | 2161 | } |
2163 | 2162 | ||
2164 | OHingeStatus Zaurus::readHingeSensor() | 2163 | OHingeStatus Zaurus::readHingeSensor() |
2165 | { | 2164 | { |
2166 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 2165 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
2167 | if (handle == -1) | 2166 | if (handle == -1) |
2168 | { | 2167 | { |
2169 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror | 2168 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror |
2170 | return CASE_UNKNOWN; | 2169 | return CASE_UNKNOWN; |
2171 | } | 2170 | } |
2172 | else | 2171 | else |
2173 | { | 2172 | { |
2174 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 2173 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
2175 | ::close (handle); | 2174 | ::close (handle); |
2176 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | 2175 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) |
2177 | { | 2176 | { |
2178 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | 2177 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); |
2179 | return static_cast<OHingeStatus>( retval ); | 2178 | return static_cast<OHingeStatus>( retval ); |
2180 | } | 2179 | } |
2181 | else | 2180 | else |
2182 | { | 2181 | { |
2183 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 2182 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
2184 | return CASE_UNKNOWN; | 2183 | return CASE_UNKNOWN; |
2185 | } | 2184 | } |
2186 | } | 2185 | } |
2187 | } | 2186 | } |
2188 | 2187 | ||
2189 | 2188 | ||
2190 | void Zaurus::virtual_hook( int id, void *data ) { | 2189 | void Zaurus::virtual_hook( int id, void *data ) { |
2191 | switch( id ) { | 2190 | switch( id ) { |
2192 | case VIRTUAL_ROTATION:{ | 2191 | case VIRTUAL_ROTATION:{ |
2193 | VirtRotation* rot = reinterpret_cast<VirtRotation*>( data ); | 2192 | VirtRotation* rot = reinterpret_cast<VirtRotation*>( data ); |
2194 | rot->trans = rotation(); | 2193 | rot->trans = rotation(); |
2195 | break; | 2194 | break; |
2196 | } | 2195 | } |
2197 | case VIRTUAL_DIRECTION:{ | 2196 | case VIRTUAL_DIRECTION:{ |
2198 | VirtDirection *dir = reinterpret_cast<VirtDirection*>( data ); | 2197 | VirtDirection *dir = reinterpret_cast<VirtDirection*>( data ); |
2199 | dir->direct = direction(); | 2198 | dir->direct = direction(); |
2200 | break; | 2199 | break; |
2201 | } | 2200 | } |
2202 | case VIRTUAL_HAS_HINGE:{ | 2201 | case VIRTUAL_HAS_HINGE:{ |
2203 | VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data ); | 2202 | VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data ); |
2204 | hin->hasHinge = hasHingeSensor(); | 2203 | hin->hasHinge = hasHingeSensor(); |
2205 | break; | 2204 | break; |
2206 | } | 2205 | } |
2207 | case VIRTUAL_HINGE:{ | 2206 | case VIRTUAL_HINGE:{ |
2208 | VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data ); | 2207 | VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data ); |
2209 | hin->hingeStat = readHingeSensor(); | 2208 | hin->hingeStat = readHingeSensor(); |
2210 | break; | 2209 | break; |
2211 | } | 2210 | } |
2212 | default: | 2211 | default: |
2213 | ODevice::virtual_hook( id, data ); | 2212 | ODevice::virtual_hook( id, data ); |
2214 | break; | 2213 | break; |
2215 | } | 2214 | } |
2216 | } | 2215 | } |
2217 | 2216 | ||
2218 | /************************************************** | 2217 | /************************************************** |
2219 | * | 2218 | * |
2220 | * SIMpad | 2219 | * SIMpad |
2221 | * | 2220 | * |
2222 | **************************************************/ | 2221 | **************************************************/ |
2223 | 2222 | ||
2224 | void SIMpad::init ( ) | 2223 | void SIMpad::init ( ) |
2225 | { | 2224 | { |
2226 | d-> m_vendorstr = "SIEMENS"; | 2225 | d-> m_vendorstr = "SIEMENS"; |
2227 | d-> m_vendor = Vendor_SIEMENS; | 2226 | d-> m_vendor = Vendor_SIEMENS; |
2228 | 2227 | ||
2229 | QFile f ( "/proc/hal/model" ); | 2228 | QFile f ( "/proc/hal/model" ); |
2230 | 2229 | ||
2231 | //TODO Implement model checking | 2230 | //TODO Implement model checking |
2232 | //FIXME For now we assume an SL4 | 2231 | //FIXME For now we assume an SL4 |
2233 | 2232 | ||
2234 | d-> m_modelstr = "SL4"; | 2233 | d-> m_modelstr = "SL4"; |
2235 | d-> m_model = Model_SIMpad_SL4; | 2234 | d-> m_model = Model_SIMpad_SL4; |
2236 | 2235 | ||
2237 | switch ( d-> m_model ) { | 2236 | switch ( d-> m_model ) { |
2238 | default: | 2237 | default: |
2239 | d-> m_rotation = Rot0; | 2238 | d-> m_rotation = Rot0; |
2240 | d-> m_direction = CCW; | 2239 | d-> m_direction = CCW; |
2241 | d-> m_holdtime = 1000; // 1000ms | 2240 | d-> m_holdtime = 1000; // 1000ms |
2242 | 2241 | ||
2243 | break; | 2242 | break; |
2244 | } | 2243 | } |
2245 | 2244 | ||
2246 | f. setName ( "/etc/familiar-version" ); | 2245 | f. setName ( "/etc/familiar-version" ); |
2247 | if ( f. open ( IO_ReadOnly )) { | 2246 | if ( f. open ( IO_ReadOnly )) { |
2248 | d-> m_systemstr = "Familiar"; | 2247 | d-> m_systemstr = "Familiar"; |
2249 | d-> m_system = System_Familiar; | 2248 | d-> m_system = System_Familiar; |
2250 | 2249 | ||
2251 | QTextStream ts ( &f ); | 2250 | QTextStream ts ( &f ); |
2252 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 2251 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
2253 | 2252 | ||
2254 | f. close ( ); | 2253 | f. close ( ); |
2255 | } else { | 2254 | } else { |
2256 | f. setName ( "/etc/oz_version" ); | 2255 | f. setName ( "/etc/oz_version" ); |
2257 | 2256 | ||
2258 | if ( f. open ( IO_ReadOnly )) { | 2257 | if ( f. open ( IO_ReadOnly )) { |
2259 | d-> m_systemstr = "OpenEmbedded/SIMpad"; | 2258 | d-> m_systemstr = "OpenEmbedded/SIMpad"; |
2260 | d-> m_system = System_OpenZaurus; | 2259 | d-> m_system = System_OpenZaurus; |
2261 | 2260 | ||
2262 | QTextStream ts ( &f ); | 2261 | QTextStream ts ( &f ); |
2263 | ts.setDevice ( &f ); | 2262 | ts.setDevice ( &f ); |
2264 | d-> m_sysverstr = ts. readLine ( ); | 2263 | d-> m_sysverstr = ts. readLine ( ); |
2265 | f. close ( ); | 2264 | f. close ( ); |
2266 | } | 2265 | } |
2267 | } | 2266 | } |
2268 | 2267 | ||
2269 | m_leds [0] = m_leds [1] = Led_Off; | 2268 | m_leds [0] = m_leds [1] = Led_Off; |
2270 | 2269 | ||
2271 | m_power_timer = 0; | 2270 | m_power_timer = 0; |
2272 | 2271 | ||
2273 | } | 2272 | } |
2274 | 2273 | ||
2275 | void SIMpad::initButtons ( ) | 2274 | void SIMpad::initButtons ( ) |
2276 | { | 2275 | { |
2277 | if ( d-> m_buttons ) | 2276 | if ( d-> m_buttons ) |
2278 | return; | 2277 | return; |
2279 | 2278 | ||
2280 | if ( isQWS( ) ) | 2279 | if ( isQWS( ) ) |
2281 | QWSServer::setKeyboardFilter ( this ); | 2280 | QWSServer::setKeyboardFilter ( this ); |
2282 | 2281 | ||
2283 | d-> m_buttons = new QValueList <ODeviceButton>; | 2282 | d-> m_buttons = new QValueList <ODeviceButton>; |
2284 | 2283 | ||
2285 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { | 2284 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { |
2286 | s_button *sb = simpad_buttons + i; | 2285 | s_button *sb = simpad_buttons + i; |
2287 | ODeviceButton b; | 2286 | ODeviceButton b; |
2288 | 2287 | ||
2289 | if (( sb-> model & d-> m_model ) == d-> m_model ) { | 2288 | if (( sb-> model & d-> m_model ) == d-> m_model ) { |
2290 | b. setKeycode ( sb-> code ); | 2289 | b. setKeycode ( sb-> code ); |
2291 | b. setUserText ( QObject::tr ( "Button", sb-> utext )); | 2290 | b. setUserText ( QObject::tr ( "Button", sb-> utext )); |
2292 | b. setPixmap ( Resource::loadPixmap ( sb-> pix )); | 2291 | b. setPixmap ( Resource::loadPixmap ( sb-> pix )); |
2293 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); | 2292 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); |
2294 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); | 2293 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); |
2295 | 2294 | ||
2296 | d-> m_buttons-> append ( b ); | 2295 | d-> m_buttons-> append ( b ); |
2297 | } | 2296 | } |
2298 | } | 2297 | } |
2299 | reloadButtonMapping ( ); | 2298 | reloadButtonMapping ( ); |
2300 | 2299 | ||
2301 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 2300 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
2302 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 2301 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
2303 | } | 2302 | } |
2304 | 2303 | ||
2305 | // SIMpad boardcontrol register CS3 | 2304 | // SIMpad boardcontrol register CS3 |
2306 | #define SIMPAD_BOARDCONTROL "/proc/cs3" | 2305 | #define SIMPAD_BOARDCONTROL "/proc/cs3" |
2307 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA | 2306 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA |
2308 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA | 2307 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA |
2309 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's | 2308 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's |
2310 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V | 2309 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V |
2311 | #define SIMPAD_DISPLAY_ON 0x0010 | 2310 | #define SIMPAD_DISPLAY_ON 0x0010 |
2312 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 | 2311 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 |
2313 | #define SIMPAD_MQ_RESET 0x0040 | 2312 | #define SIMPAD_MQ_RESET 0x0040 |
2314 | #define SIMPAD_PCMCIA_RESET 0x0080 | 2313 | #define SIMPAD_PCMCIA_RESET 0x0080 |
2315 | #define SIMPAD_DECT_POWER_ON 0x0100 | 2314 | #define SIMPAD_DECT_POWER_ON 0x0100 |
2316 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave | 2315 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave |
2317 | #define SIMPAD_RS232_ON 0x0400 | 2316 | #define SIMPAD_RS232_ON 0x0400 |
2318 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave | 2317 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave |
2319 | #define SIMPAD_LED2_ON 0x1000 | 2318 | #define SIMPAD_LED2_ON 0x1000 |
2320 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode | 2319 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode |
2321 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit | 2320 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit |
2322 | #define SIMPAD_RESET_SIMCARD 0x8000 | 2321 | #define SIMPAD_RESET_SIMCARD 0x8000 |
2323 | 2322 | ||
2324 | //SIMpad touchscreen backlight strength control | 2323 | //SIMpad touchscreen backlight strength control |
2325 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" | 2324 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" |
2326 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 | 2325 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 |
2327 | 2326 | ||
2328 | QValueList <OLed> SIMpad::ledList ( ) const | 2327 | QValueList <OLed> SIMpad::ledList ( ) const |
2329 | { | 2328 | { |
2330 | QValueList <OLed> vl; | 2329 | QValueList <OLed> vl; |
2331 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? | 2330 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? |
2332 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway | 2331 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway |
2333 | return vl; | 2332 | return vl; |
2334 | } | 2333 | } |
2335 | 2334 | ||
2336 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const | 2335 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const |
2337 | { | 2336 | { |
2338 | QValueList <OLedState> vl; | 2337 | QValueList <OLedState> vl; |
2339 | 2338 | ||
2340 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? | 2339 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? |
2341 | vl << Led_Off << Led_On; | 2340 | vl << Led_Off << Led_On; |
2342 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway | 2341 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway |
2343 | //vl << Led_Off; | 2342 | //vl << Led_Off; |
2344 | return vl; | 2343 | return vl; |
2345 | } | 2344 | } |
2346 | 2345 | ||
2347 | OLedState SIMpad::ledState ( OLed l ) const | 2346 | OLedState SIMpad::ledState ( OLed l ) const |
2348 | { | 2347 | { |
2349 | switch ( l ) { | 2348 | switch ( l ) { |
2350 | case Led_Power: | 2349 | case Led_Power: |
2351 | return m_leds [0]; | 2350 | return m_leds [0]; |
2352 | //case Led_Mail: | 2351 | //case Led_Mail: |
2353 | //return m_leds [1]; | 2352 | //return m_leds [1]; |
2354 | default: | 2353 | default: |
2355 | return Led_Off; | 2354 | return Led_Off; |
2356 | } | 2355 | } |
2357 | } | 2356 | } |
2358 | 2357 | ||
2359 | bool SIMpad::setLedState ( OLed l, OLedState st ) | 2358 | bool SIMpad::setLedState ( OLed l, OLedState st ) |
2360 | { | 2359 | { |
2361 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); | 2360 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); |
2362 | 2361 | ||
2363 | if ( l == Led_Power ) { | 2362 | if ( l == Led_Power ) { |
2364 | if ( fd >= 0 ) { | 2363 | if ( fd >= 0 ) { |
2365 | LED_IN leds; | 2364 | LED_IN leds; |
2366 | ::memset ( &leds, 0, sizeof( leds )); | 2365 | ::memset ( &leds, 0, sizeof( leds )); |
2367 | leds. TotalTime = 0; | 2366 | leds. TotalTime = 0; |
2368 | leds. OnTime = 0; | 2367 | leds. OnTime = 0; |
2369 | leds. OffTime = 1; | 2368 | leds. OffTime = 1; |
2370 | leds. OffOnBlink = 2; | 2369 | leds. OffOnBlink = 2; |
2371 | 2370 | ||
2372 | switch ( st ) { | 2371 | switch ( st ) { |
2373 | case Led_Off : leds. OffOnBlink = 0; break; | 2372 | case Led_Off : leds. OffOnBlink = 0; break; |
2374 | case Led_On : leds. OffOnBlink = 1; break; | 2373 | case Led_On : leds. OffOnBlink = 1; break; |
2375 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 2374 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
2376 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 2375 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
2377 | } | 2376 | } |
2378 | 2377 | ||
2379 | { | 2378 | { |
2380 | /*TODO Implement this like that: | 2379 | /*TODO Implement this like that: |
2381 | read from cs3 | 2380 | read from cs3 |
2382 | && with SIMPAD_LED2_ON | 2381 | && with SIMPAD_LED2_ON |
2383 | write to cs3 */ | 2382 | write to cs3 */ |
2384 | m_leds [0] = st; | 2383 | m_leds [0] = st; |
2385 | return true; | 2384 | return true; |
2386 | } | 2385 | } |
2387 | } | 2386 | } |
2388 | } | 2387 | } |
2389 | return false; | 2388 | return false; |
2390 | } | 2389 | } |
2391 | 2390 | ||
2392 | 2391 | ||
2393 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 2392 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
2394 | { | 2393 | { |
2395 | //TODO | 2394 | //TODO |
2396 | return false; | 2395 | return false; |
2397 | } | 2396 | } |
2398 | 2397 | ||
2399 | void SIMpad::timerEvent ( QTimerEvent * ) | 2398 | void SIMpad::timerEvent ( QTimerEvent * ) |
2400 | { | 2399 | { |
2401 | killTimer ( m_power_timer ); | 2400 | killTimer ( m_power_timer ); |
2402 | m_power_timer = 0; | 2401 | m_power_timer = 0; |
2403 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 2402 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
2404 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 2403 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
2405 | } | 2404 | } |
2406 | 2405 | ||
2407 | 2406 | ||
2408 | void SIMpad::alarmSound ( ) | 2407 | void SIMpad::alarmSound ( ) |
2409 | { | 2408 | { |
2410 | #ifndef QT_NO_SOUND | 2409 | #ifndef QT_NO_SOUND |
2411 | static Sound snd ( "alarm" ); | 2410 | static Sound snd ( "alarm" ); |
2412 | int fd; | 2411 | int fd; |
2413 | int vol; | 2412 | int vol; |
2414 | bool vol_reset = false; | 2413 | bool vol_reset = false; |
2415 | 2414 | ||
2416 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 2415 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
2417 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 2416 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
2418 | Config cfg ( "qpe" ); | 2417 | Config cfg ( "qpe" ); |
2419 | cfg. setGroup ( "Volume" ); | 2418 | cfg. setGroup ( "Volume" ); |
2420 | 2419 | ||
2421 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 2420 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
2422 | if ( volalarm < 0 ) | 2421 | if ( volalarm < 0 ) |
2423 | volalarm = 0; | 2422 | volalarm = 0; |
2424 | else if ( volalarm > 100 ) | 2423 | else if ( volalarm > 100 ) |
2425 | volalarm = 100; | 2424 | volalarm = 100; |
2426 | volalarm |= ( volalarm << 8 ); | 2425 | volalarm |= ( volalarm << 8 ); |
2427 | 2426 | ||
2428 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 2427 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
2429 | vol_reset = true; | 2428 | vol_reset = true; |
2430 | } | 2429 | } |
2431 | } | 2430 | } |
2432 | 2431 | ||
2433 | snd. play ( ); | 2432 | snd. play ( ); |
2434 | while ( !snd. isFinished ( )) | 2433 | while ( !snd. isFinished ( )) |
2435 | qApp-> processEvents ( ); | 2434 | qApp-> processEvents ( ); |
2436 | 2435 | ||
2437 | if ( fd >= 0 ) { | 2436 | if ( fd >= 0 ) { |
2438 | if ( vol_reset ) | 2437 | if ( vol_reset ) |
2439 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 2438 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
2440 | ::close ( fd ); | 2439 | ::close ( fd ); |
2441 | } | 2440 | } |
2442 | #endif | 2441 | #endif |
2443 | } | 2442 | } |
2444 | 2443 | ||
2445 | 2444 | ||
2446 | bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm | 2445 | bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm |
2447 | { | 2446 | { |
2448 | qDebug( "ODevice for SIMpad: suspend()" ); | 2447 | qDebug( "ODevice for SIMpad: suspend()" ); |
2449 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 2448 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
2450 | return false; | 2449 | return false; |
2451 | 2450 | ||
2452 | bool res = false; | 2451 | bool res = false; |
2453 | 2452 | ||
2454 | struct timeval tvs, tvn; | 2453 | struct timeval tvs, tvn; |
2455 | ::gettimeofday ( &tvs, 0 ); | 2454 | ::gettimeofday ( &tvs, 0 ); |
2456 | 2455 | ||
2457 | ::sync ( ); // flush fs caches | 2456 | ::sync ( ); // flush fs caches |
2458 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) | 2457 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) |
2459 | 2458 | ||
2460 | return res; | 2459 | return res; |
2461 | } | 2460 | } |
2462 | 2461 | ||
2463 | 2462 | ||
2464 | bool SIMpad::setSoftSuspend ( bool soft ) | 2463 | bool SIMpad::setSoftSuspend ( bool soft ) |
2465 | { | 2464 | { |
2466 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); | 2465 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); |
2467 | return false; | 2466 | return false; |
2468 | } | 2467 | } |
2469 | 2468 | ||
2470 | 2469 | ||
2471 | bool SIMpad::setDisplayStatus ( bool on ) | 2470 | bool SIMpad::setDisplayStatus ( bool on ) |
2472 | { | 2471 | { |
2473 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 2472 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
2474 | 2473 | ||
2475 | bool res = false; | 2474 | bool res = false; |
2476 | int fd; | 2475 | int fd; |
2477 | 2476 | ||
2478 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) | 2477 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) |
2479 | 2478 | ||
2480 | res = ( ::system( (const char*) cmdline ) == 0 ); | 2479 | res = ( ::system( (const char*) cmdline ) == 0 ); |
2481 | 2480 | ||
2482 | return res; | 2481 | return res; |
2483 | } | 2482 | } |
2484 | 2483 | ||
2485 | 2484 | ||
2486 | bool SIMpad::setDisplayBrightness ( int bright ) | 2485 | bool SIMpad::setDisplayBrightness ( int bright ) |
2487 | { | 2486 | { |
2488 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); | 2487 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); |
2489 | bool res = false; | 2488 | bool res = false; |
2490 | int fd; | 2489 | int fd; |
2491 | 2490 | ||
2492 | if ( bright > 255 ) | 2491 | if ( bright > 255 ) |
2493 | bright = 255; | 2492 | bright = 255; |
2494 | if ( bright < 1 ) | 2493 | if ( bright < 1 ) |
2495 | bright = 0; | 2494 | bright = 0; |
2496 | 2495 | ||
2497 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 2496 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
2498 | int value = 255 - bright; | 2497 | int value = 255 - bright; |
2499 | const int mask = SIMPAD_BACKLIGHT_MASK; | 2498 | const int mask = SIMPAD_BACKLIGHT_MASK; |
2500 | value = value << 8; | 2499 | value = value << 8; |
2501 | value += mask; | 2500 | value += mask; |
2502 | char writeCommand[100]; | 2501 | char writeCommand[100]; |
2503 | const int count = sprintf( writeCommand, "0x%x\n", value ); | 2502 | const int count = sprintf( writeCommand, "0x%x\n", value ); |
2504 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 2503 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
2505 | ::close ( fd ); | 2504 | ::close ( fd ); |
2506 | } | 2505 | } |
2507 | return res; | 2506 | return res; |
2508 | } | 2507 | } |
2509 | 2508 | ||
2510 | 2509 | ||
2511 | int SIMpad::displayBrightnessResolution ( ) const | 2510 | int SIMpad::displayBrightnessResolution ( ) const |
2512 | { | 2511 | { |
2513 | return 255; // All SIMpad models share the same display | 2512 | return 255; // All SIMpad models share the same display |
2514 | } | 2513 | } |
2515 | 2514 | ||
2516 | /************************************************** | 2515 | /************************************************** |
2517 | * | 2516 | * |
2518 | * Ramses | 2517 | * Ramses |
2519 | * | 2518 | * |
2520 | **************************************************/ | 2519 | **************************************************/ |
2521 | 2520 | ||
2522 | void Ramses::init() | 2521 | void Ramses::init() |
2523 | { | 2522 | { |
2524 | d->m_vendorstr = "M und N"; | 2523 | d->m_vendorstr = "M und N"; |
2525 | d->m_vendor = Vendor_MundN; | 2524 | d->m_vendor = Vendor_MundN; |
2526 | 2525 | ||
2527 | QFile f("/proc/sys/board/ramses"); | 2526 | QFile f("/proc/sys/board/ramses"); |
2528 | 2527 | ||
2529 | d->m_modelstr = "Ramses"; | 2528 | d->m_modelstr = "Ramses"; |
2530 | d->m_model = Model_Ramses_MNCI; | 2529 | d->m_model = Model_Ramses_MNCI; |
2531 | 2530 | ||
2532 | d->m_rotation = Rot0; | 2531 | d->m_rotation = Rot0; |
2533 | d->m_holdtime = 1000; | 2532 | d->m_holdtime = 1000; |
2534 | 2533 | ||
2535 | f.setName("/etc/oz_version"); | 2534 | f.setName("/etc/oz_version"); |
2536 | 2535 | ||
2537 | if (f.open(IO_ReadOnly)) { | 2536 | if (f.open(IO_ReadOnly)) { |
2538 | d->m_systemstr = "OpenEmbedded/Ramses"; | 2537 | d->m_systemstr = "OpenEmbedded/Ramses"; |
2539 | d->m_system = System_OpenZaurus; | 2538 | d->m_system = System_OpenZaurus; |
2540 | 2539 | ||
2541 | QTextStream ts(&f); | 2540 | QTextStream ts(&f); |
2542 | ts.setDevice(&f); | 2541 | ts.setDevice(&f); |
2543 | d->m_sysverstr = ts.readLine(); | 2542 | d->m_sysverstr = ts.readLine(); |
2544 | f.close(); | 2543 | f.close(); |
2545 | } | 2544 | } |
2546 | 2545 | ||
2547 | m_power_timer = 0; | 2546 | m_power_timer = 0; |
2548 | 2547 | ||
2549 | #ifdef QT_QWS_ALLOW_OVERCLOCK | 2548 | #ifdef QT_QWS_ALLOW_OVERCLOCK |
2550 | #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** | 2549 | #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** |
2551 | #define OC(x...) x | 2550 | #define OC(x...) x |
2552 | #else | 2551 | #else |
2553 | #define OC(x...) | 2552 | #define OC(x...) |
2554 | #endif | 2553 | #endif |
2555 | 2554 | ||
2556 | 2555 | ||
2557 | // This table is true for a Intel XScale PXA 255 | 2556 | // This table is true for a Intel XScale PXA 255 |
2558 | 2557 | ||
2559 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 | 2558 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 |
2560 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem | 2559 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem |
2561 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 | 2560 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 |
2562 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem | 2561 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem |
2563 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 | 2562 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 |
2564 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem | 2563 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem |
2565 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 | 2564 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 |
2566 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 | 2565 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 |
2567 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus | 2566 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus |
2568 | 2567 | ||
2569 | } | 2568 | } |
2570 | 2569 | ||
2571 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) | 2570 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) |
2572 | { | 2571 | { |
2573 | Q_UNUSED( keycode ); | 2572 | Q_UNUSED( keycode ); |
2574 | Q_UNUSED( modifiers ); | 2573 | Q_UNUSED( modifiers ); |
2575 | Q_UNUSED( isPress ); | 2574 | Q_UNUSED( isPress ); |
2576 | Q_UNUSED( autoRepeat ); | 2575 | Q_UNUSED( autoRepeat ); |
2577 | return false; | 2576 | return false; |
2578 | } | 2577 | } |
2579 | 2578 | ||
2580 | void Ramses::timerEvent(QTimerEvent *) | 2579 | void Ramses::timerEvent(QTimerEvent *) |
2581 | { | 2580 | { |
2582 | killTimer(m_power_timer); | 2581 | killTimer(m_power_timer); |
2583 | m_power_timer = 0; | 2582 | m_power_timer = 0; |
2584 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); | 2583 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); |
2585 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); | 2584 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); |
2586 | } | 2585 | } |
2587 | 2586 | ||
2588 | 2587 | ||
2589 | bool Ramses::setSoftSuspend(bool soft) | 2588 | bool Ramses::setSoftSuspend(bool soft) |
2590 | { | 2589 | { |
2591 | qDebug("Ramses::setSoftSuspend(%d)", soft); | 2590 | qDebug("Ramses::setSoftSuspend(%d)", soft); |
2592 | #if 0 | 2591 | #if 0 |
2593 | bool res = false; | 2592 | bool res = false; |
2594 | int fd; | 2593 | int fd; |
2595 | 2594 | ||
2596 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || | 2595 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || |
2597 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { | 2596 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { |
2598 | 2597 | ||
2599 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources | 2598 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources |
2600 | 2599 | ||
2601 | if (sources >= 0) { | 2600 | if (sources >= 0) { |
2602 | if (soft) | 2601 | if (soft) |
2603 | sources &= ~APM_EVT_POWER_BUTTON; | 2602 | sources &= ~APM_EVT_POWER_BUTTON; |
2604 | else | 2603 | else |
2605 | sources |= APM_EVT_POWER_BUTTON; | 2604 | sources |= APM_EVT_POWER_BUTTON; |
2606 | 2605 | ||
2607 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources | 2606 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources |
2608 | res = true; | 2607 | res = true; |
2609 | else | 2608 | else |
2610 | perror("APM_IOCGEVTSRC"); | 2609 | perror("APM_IOCGEVTSRC"); |
2611 | } | 2610 | } |
2612 | else | 2611 | else |
2613 | perror("APM_IOCGEVTSRC"); | 2612 | perror("APM_IOCGEVTSRC"); |
2614 | 2613 | ||
2615 | ::close(fd); | 2614 | ::close(fd); |
2616 | } | 2615 | } |
2617 | else | 2616 | else |
2618 | perror("/dev/apm_bios or /dev/misc/apm_bios"); | 2617 | perror("/dev/apm_bios or /dev/misc/apm_bios"); |
2619 | 2618 | ||
2620 | return res; | 2619 | return res; |
2621 | #else | 2620 | #else |
2622 | return true; | 2621 | return true; |
2623 | #endif | 2622 | #endif |
2624 | } | 2623 | } |
2625 | 2624 | ||
2626 | bool Ramses::suspend ( ) | 2625 | bool Ramses::suspend ( ) |
2627 | { | 2626 | { |
2628 | qDebug("Ramses::suspend"); | 2627 | qDebug("Ramses::suspend"); |
2629 | return false; | 2628 | return false; |
2630 | } | 2629 | } |
2631 | 2630 | ||
2632 | /** | 2631 | /** |
2633 | * This sets the display on or off | 2632 | * This sets the display on or off |
2634 | */ | 2633 | */ |
2635 | bool Ramses::setDisplayStatus(bool on) | 2634 | bool Ramses::setDisplayStatus(bool on) |
2636 | { | 2635 | { |
2637 | qDebug("Ramses::setDisplayStatus(%d)", on); | 2636 | qDebug("Ramses::setDisplayStatus(%d)", on); |
2638 | #if 0 | 2637 | #if 0 |
2639 | bool res = false; | 2638 | bool res = false; |
2640 | int fd; | 2639 | int fd; |
2641 | 2640 | ||
2642 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { | 2641 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { |
2643 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); | 2642 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); |
2644 | ::close(fd); | 2643 | ::close(fd); |
2645 | } | 2644 | } |
2646 | return res; | 2645 | return res; |
2647 | #else | 2646 | #else |
2648 | return true; | 2647 | return true; |
2649 | #endif | 2648 | #endif |
2650 | } | 2649 | } |
2651 | 2650 | ||
2652 | 2651 | ||
2653 | /* | 2652 | /* |
2654 | * We get something between 0..255 into us | 2653 | * We get something between 0..255 into us |
2655 | */ | 2654 | */ |
2656 | bool Ramses::setDisplayBrightness(int bright) | 2655 | bool Ramses::setDisplayBrightness(int bright) |
2657 | { | 2656 | { |
2658 | qDebug("Ramses::setDisplayBrightness(%d)", bright); | 2657 | qDebug("Ramses::setDisplayBrightness(%d)", bright); |
2659 | bool res = false; | 2658 | bool res = false; |
2660 | int fd; | 2659 | int fd; |
2661 | 2660 | ||
2662 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) | 2661 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) |
2663 | 2662 | ||
2664 | if (bright > 255 ) | 2663 | if (bright > 255 ) |
2665 | bright = 255; | 2664 | bright = 255; |
2666 | if (bright < 0) | 2665 | if (bright < 0) |
2667 | bright = 0; | 2666 | bright = 0; |
2668 | 2667 | ||
2669 | // Turn backlight completely off | 2668 | // Turn backlight completely off |
2670 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { | 2669 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { |
2671 | char writeCommand[10]; | 2670 | char writeCommand[10]; |
2672 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); | 2671 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); |
2673 | res = (::write(fd, writeCommand, count) != -1); | 2672 | res = (::write(fd, writeCommand, count) != -1); |
2674 | ::close(fd); | 2673 | ::close(fd); |
2675 | } | 2674 | } |
2676 | 2675 | ||
2677 | // scale backlight brightness to hardware | 2676 | // scale backlight brightness to hardware |
2678 | bright = 500-(bright * 500 / 255); | 2677 | bright = 500-(bright * 500 / 255); |
2679 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { | 2678 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { |
2680 | qDebug(" %d -> pwm1", bright); | 2679 | qDebug(" %d -> pwm1", bright); |
2681 | char writeCommand[100]; | 2680 | char writeCommand[100]; |
2682 | const int count = sprintf(writeCommand, "%d\n", bright); | 2681 | const int count = sprintf(writeCommand, "%d\n", bright); |
2683 | res = (::write(fd, writeCommand, count) != -1); | 2682 | res = (::write(fd, writeCommand, count) != -1); |
2684 | ::close(fd); | 2683 | ::close(fd); |
2685 | } | 2684 | } |
2686 | return res; | 2685 | return res; |
2687 | } | 2686 | } |
2688 | 2687 | ||
2689 | 2688 | ||
2690 | int Ramses::displayBrightnessResolution() const | 2689 | int Ramses::displayBrightnessResolution() const |
2691 | { | 2690 | { |
2692 | return 32; | 2691 | return 32; |
2693 | } | 2692 | } |
2694 | 2693 | ||
2695 | bool Ramses::setDisplayContrast(int contr) | 2694 | bool Ramses::setDisplayContrast(int contr) |
2696 | { | 2695 | { |
2697 | qDebug("Ramses::setDisplayContrast(%d)", contr); | 2696 | qDebug("Ramses::setDisplayContrast(%d)", contr); |
2698 | bool res = false; | 2697 | bool res = false; |
2699 | int fd; | 2698 | int fd; |
2700 | 2699 | ||
2701 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) | 2700 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) |
2702 | 2701 | ||
2703 | if (contr > 255 ) | 2702 | if (contr > 255 ) |
2704 | contr = 255; | 2703 | contr = 255; |
2705 | if (contr < 0) | 2704 | if (contr < 0) |
2706 | contr = 0; | 2705 | contr = 0; |
2707 | contr = 90 - (contr * 20 / 255); | 2706 | contr = 90 - (contr * 20 / 255); |
2708 | 2707 | ||
2709 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { | 2708 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { |
2710 | qDebug(" %d -> pwm0", contr); | 2709 | qDebug(" %d -> pwm0", contr); |
2711 | char writeCommand[100]; | 2710 | char writeCommand[100]; |
2712 | const int count = sprintf(writeCommand, "%d\n", contr); | 2711 | const int count = sprintf(writeCommand, "%d\n", contr); |
2713 | res = (::write(fd, writeCommand, count) != -1); | 2712 | res = (::write(fd, writeCommand, count) != -1); |
2714 | res = true; | 2713 | res = true; |
2715 | ::close(fd); | 2714 | ::close(fd); |
2716 | } | 2715 | } |
2717 | return res; | 2716 | return res; |
2718 | } | 2717 | } |
2719 | 2718 | ||
2720 | 2719 | ||
2721 | int Ramses::displayContrastResolution() const | 2720 | int Ramses::displayContrastResolution() const |
2722 | { | 2721 | { |
2723 | return 20; | 2722 | return 20; |
2724 | } | 2723 | } |
2725 | 2724 | ||
2726 | 2725 | ||
2727 | /************************************************** | 2726 | /************************************************** |
2728 | * * | 2727 | * * |
2729 | * Jornada * | 2728 | * Jornada * |
2730 | * * | 2729 | * * |
2731 | **************************************************/ | 2730 | **************************************************/ |
2732 | 2731 | ||
2733 | 2732 | ||
2734 | bool Jornada::isJornada ( ) | 2733 | bool Jornada::isJornada ( ) |
2735 | { | 2734 | { |
2736 | QFile f( "/proc/cpuinfo" ); | 2735 | QFile f( "/proc/cpuinfo" ); |
2737 | if ( f. open ( IO_ReadOnly ) ) { | 2736 | if ( f. open ( IO_ReadOnly ) ) { |
2738 | QTextStream ts ( &f ); | 2737 | QTextStream ts ( &f ); |
2739 | QString line; | 2738 | QString line; |
2740 | while( line = ts. readLine ( ) ) { | 2739 | while( line = ts. readLine ( ) ) { |
2741 | if ( line. left ( 8 ) == "Hardware" ) { | 2740 | if ( line. left ( 8 ) == "Hardware" ) { |
2742 | int loc = line. find ( ":" ); | 2741 | int loc = line. find ( ":" ); |
2743 | if ( loc != -1 ) { | 2742 | if ( loc != -1 ) { |
2744 | QString model = | 2743 | QString model = |
2745 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 2744 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
2746 | return ( model == "HP Jornada 56x" ); | 2745 | return ( model == "HP Jornada 56x" ); |
2747 | } | 2746 | } |
2748 | } | 2747 | } |
2749 | } | 2748 | } |
2750 | } | 2749 | } |
2751 | return false; | 2750 | return false; |
2752 | } | 2751 | } |
2753 | 2752 | ||
2754 | void Jornada::init ( ) | 2753 | void Jornada::init ( ) |
2755 | { | 2754 | { |
2756 | d-> m_vendorstr = "HP"; | 2755 | d-> m_vendorstr = "HP"; |
2757 | d-> m_vendor = Vendor_HP; | 2756 | d-> m_vendor = Vendor_HP; |
2758 | d-> m_modelstr = "Jornada 56x"; | 2757 | d-> m_modelstr = "Jornada 56x"; |
2759 | d-> m_model = Model_Jornada_56x; | 2758 | d-> m_model = Model_Jornada_56x; |
2760 | d-> m_systemstr = "Familiar"; | 2759 | d-> m_systemstr = "Familiar"; |
2761 | d-> m_system = System_Familiar; | 2760 | d-> m_system = System_Familiar; |
2762 | d-> m_rotation = Rot0; | 2761 | d-> m_rotation = Rot0; |
2763 | 2762 | ||
2764 | QFile f ( "/etc/familiar-version" ); | 2763 | QFile f ( "/etc/familiar-version" ); |
2765 | f. setName ( "/etc/familiar-version" ); | 2764 | f. setName ( "/etc/familiar-version" ); |
2766 | if ( f. open ( IO_ReadOnly )) { | 2765 | if ( f. open ( IO_ReadOnly )) { |
2767 | 2766 | ||
2768 | QTextStream ts ( &f ); | 2767 | QTextStream ts ( &f ); |
2769 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 2768 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
2770 | 2769 | ||
2771 | f. close ( ); | 2770 | f. close ( ); |
2772 | } | 2771 | } |
2773 | } | 2772 | } |
2774 | 2773 | ||
2775 | #if 0 | 2774 | #if 0 |
2776 | void Jornada::initButtons ( ) | 2775 | void Jornada::initButtons ( ) |
2777 | { | 2776 | { |
2778 | if ( d-> m_buttons ) | 2777 | if ( d-> m_buttons ) |
2779 | return; | 2778 | return; |
2780 | 2779 | ||
2781 | // Simulation uses iPAQ 3660 device buttons | 2780 | // Simulation uses iPAQ 3660 device buttons |
2782 | 2781 | ||
2783 | qDebug ( "init Buttons" ); | 2782 | qDebug ( "init Buttons" ); |
2784 | d-> m_buttons = new QValueList <ODeviceButton>; | 2783 | d-> m_buttons = new QValueList <ODeviceButton>; |
2785 | 2784 | ||
2786 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 2785 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
2787 | i_button *ib = ipaq_buttons + i; | 2786 | i_button *ib = ipaq_buttons + i; |
2788 | ODeviceButton b; | 2787 | ODeviceButton b; |
2789 | 2788 | ||
2790 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 2789 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
2791 | b. setKeycode ( ib-> code ); | 2790 | b. setKeycode ( ib-> code ); |
2792 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 2791 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
2793 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 2792 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
2794 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 2793 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
2795 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 2794 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
2796 | d-> m_buttons-> append ( b ); | 2795 | d-> m_buttons-> append ( b ); |
2797 | } | 2796 | } |
2798 | } | 2797 | } |
2799 | reloadButtonMapping ( ); | 2798 | reloadButtonMapping ( ); |
2800 | 2799 | ||
2801 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 2800 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
2802 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 2801 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
2803 | } | 2802 | } |
2804 | #endif | 2803 | #endif |
2805 | int Jornada::displayBrightnessResolution ( ) const | 2804 | int Jornada::displayBrightnessResolution ( ) const |
2806 | { | 2805 | { |
2807 | } | 2806 | } |
2808 | 2807 | ||
2809 | bool Jornada::setDisplayBrightness ( int bright ) | 2808 | bool Jornada::setDisplayBrightness ( int bright ) |
2810 | { | 2809 | { |
2811 | bool res = false; | 2810 | bool res = false; |
2812 | int fd; | 2811 | int fd; |
2813 | 2812 | ||
2814 | if ( bright > 255 ) | 2813 | if ( bright > 255 ) |
2815 | bright = 255; | 2814 | bright = 255; |
2816 | if ( bright < 0 ) | 2815 | if ( bright < 0 ) |
2817 | bright = 0; | 2816 | bright = 0; |
2818 | 2817 | ||
2819 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 2818 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
2820 | FLITE_IN bl; | 2819 | FLITE_IN bl; |
2821 | bl. mode = 1; | 2820 | bl. mode = 1; |
2822 | bl. pwr = bright ? 1 : 0; | 2821 | bl. pwr = bright ? 1 : 0; |
2823 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 2822 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
2824 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 2823 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
2825 | ::close ( fd ); | 2824 | ::close ( fd ); |
2826 | } | 2825 | } |
2827 | return res; | 2826 | return res; |
2828 | } | 2827 | } |
2829 | 2828 | ||
2830 | bool Jornada::setSoftSuspend ( bool soft ) | 2829 | bool Jornada::setSoftSuspend ( bool soft ) |
2831 | { | 2830 | { |
2832 | bool res = false; | 2831 | bool res = false; |
2833 | int fd; | 2832 | int fd; |
2834 | 2833 | ||
2835 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 2834 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
2836 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 2835 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
2837 | res = true; | 2836 | res = true; |
2838 | else | 2837 | else |
2839 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 2838 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
2840 | 2839 | ||
2841 | ::close ( fd ); | 2840 | ::close ( fd ); |
2842 | } | 2841 | } |
2843 | else | 2842 | else |
2844 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 2843 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
2845 | 2844 | ||
2846 | return res; | 2845 | return res; |
2847 | } | 2846 | } |