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