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