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