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