author | mickeyl <mickeyl> | 2003-05-15 22:42:11 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-15 22:42:11 (UTC) |
commit | a098d190fed94b731c9f91538147ad0f9873758a (patch) (unidiff) | |
tree | bc7bcb7ccc36465ddccaed78b528bbf235e929f9 | |
parent | 80e9fd1b08a3a7173ecf443b2830df4ca6e83ce6 (diff) | |
download | opie-a098d190fed94b731c9f91538147ad0f9873758a.zip opie-a098d190fed94b731c9f91538147ad0f9873758a.tar.gz opie-a098d190fed94b731c9f91538147ad0f9873758a.tar.bz2 |
first shot at integrating SIMpad device specifica
-rw-r--r-- | libopie/odevice.cpp | 320 | ||||
-rw-r--r-- | libopie/odevice.h | 11 |
2 files changed, 330 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 7d862cd..921a94e 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1,637 +1,687 @@ | |||
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 | #include <linux/soundcard.h> | 26 | #include <linux/soundcard.h> |
27 | #include <math.h> | 27 | #include <math.h> |
28 | 28 | ||
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | 30 | ||
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qpe/sound.h> | 33 | #include <qpe/sound.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | #include <qpe/qcopenvelope_qws.h> | 36 | #include <qpe/qcopenvelope_qws.h> |
37 | 37 | ||
38 | #include "odevice.h" | 38 | #include "odevice.h" |
39 | 39 | ||
40 | #include <qwindowsystem_qws.h> | 40 | #include <qwindowsystem_qws.h> |
41 | 41 | ||
42 | #ifndef ARRAY_SIZE | 42 | #ifndef ARRAY_SIZE |
43 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | 43 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | // _IO and friends are only defined in kernel headers ... | 46 | // _IO and friends are only defined in kernel headers ... |
47 | 47 | ||
48 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 48 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
49 | 49 | ||
50 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 50 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
51 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 51 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
52 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 52 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
53 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 53 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
54 | 54 | ||
55 | using namespace Opie; | 55 | using namespace Opie; |
56 | 56 | ||
57 | class ODeviceData { | 57 | class ODeviceData { |
58 | public: | 58 | public: |
59 | QString m_vendorstr; | 59 | QString m_vendorstr; |
60 | OVendor m_vendor; | 60 | OVendor m_vendor; |
61 | 61 | ||
62 | QString m_modelstr; | 62 | QString m_modelstr; |
63 | OModel m_model; | 63 | OModel m_model; |
64 | 64 | ||
65 | QString m_systemstr; | 65 | QString m_systemstr; |
66 | OSystem m_system; | 66 | OSystem m_system; |
67 | 67 | ||
68 | QString m_sysverstr; | 68 | QString m_sysverstr; |
69 | 69 | ||
70 | Transformation m_rotation; | 70 | Transformation m_rotation; |
71 | ODirection m_direction; | 71 | ODirection m_direction; |
72 | 72 | ||
73 | QValueList <ODeviceButton> *m_buttons; | 73 | QValueList <ODeviceButton> *m_buttons; |
74 | uint m_holdtime; | 74 | uint m_holdtime; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | 77 | ||
78 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { | 78 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { |
79 | protected: | 79 | protected: |
80 | virtual void init ( ); | 80 | virtual void init ( ); |
81 | virtual void initButtons ( ); | 81 | virtual void initButtons ( ); |
82 | 82 | ||
83 | public: | 83 | public: |
84 | virtual bool setSoftSuspend ( bool soft ); | 84 | virtual bool setSoftSuspend ( bool soft ); |
85 | 85 | ||
86 | virtual bool setDisplayBrightness ( int b ); | 86 | virtual bool setDisplayBrightness ( int b ); |
87 | virtual int displayBrightnessResolution ( ) const; | 87 | virtual int displayBrightnessResolution ( ) const; |
88 | 88 | ||
89 | virtual void alarmSound ( ); | 89 | virtual void alarmSound ( ); |
90 | 90 | ||
91 | virtual QValueList <OLed> ledList ( ) const; | 91 | virtual QValueList <OLed> ledList ( ) const; |
92 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 92 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
93 | virtual OLedState ledState ( OLed led ) const; | 93 | virtual OLedState ledState ( OLed led ) const; |
94 | virtual bool setLedState ( OLed led, OLedState st ); | 94 | virtual bool setLedState ( OLed led, OLedState st ); |
95 | 95 | ||
96 | virtual bool hasLightSensor ( ) const; | 96 | virtual bool hasLightSensor ( ) const; |
97 | virtual int readLightSensor ( ); | 97 | virtual int readLightSensor ( ); |
98 | virtual int lightSensorResolution ( ) const; | 98 | virtual int lightSensorResolution ( ) const; |
99 | 99 | ||
100 | protected: | 100 | protected: |
101 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 101 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
102 | virtual void timerEvent ( QTimerEvent *te ); | 102 | virtual void timerEvent ( QTimerEvent *te ); |
103 | 103 | ||
104 | int m_power_timer; | 104 | int m_power_timer; |
105 | 105 | ||
106 | OLedState m_leds [2]; | 106 | OLedState m_leds [2]; |
107 | }; | 107 | }; |
108 | 108 | ||
109 | class Zaurus : public ODevice { | 109 | class Zaurus : public ODevice { |
110 | protected: | 110 | protected: |
111 | virtual void init ( ); | 111 | virtual void init ( ); |
112 | virtual void initButtons ( ); | 112 | virtual void initButtons ( ); |
113 | 113 | ||
114 | public: | 114 | public: |
115 | virtual bool setSoftSuspend ( bool soft ); | 115 | virtual bool setSoftSuspend ( bool soft ); |
116 | 116 | ||
117 | virtual bool setDisplayBrightness ( int b ); | 117 | virtual bool setDisplayBrightness ( int b ); |
118 | virtual int displayBrightnessResolution ( ) const; | 118 | virtual int displayBrightnessResolution ( ) const; |
119 | 119 | ||
120 | virtual void alarmSound ( ); | 120 | virtual void alarmSound ( ); |
121 | virtual void keySound ( ); | 121 | virtual void keySound ( ); |
122 | virtual void touchSound ( ); | 122 | virtual void touchSound ( ); |
123 | 123 | ||
124 | virtual QValueList <OLed> ledList ( ) const; | 124 | virtual QValueList <OLed> ledList ( ) const; |
125 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 125 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
126 | virtual OLedState ledState ( OLed led ) const; | 126 | virtual OLedState ledState ( OLed led ) const; |
127 | virtual bool setLedState ( OLed led, OLedState st ); | 127 | virtual bool setLedState ( OLed led, OLedState st ); |
128 | 128 | ||
129 | protected: | 129 | protected: |
130 | virtual void buzzer ( int snd ); | 130 | virtual void buzzer ( int snd ); |
131 | 131 | ||
132 | OLedState m_leds [1]; | 132 | OLedState m_leds [1]; |
133 | }; | 133 | }; |
134 | 134 | ||
135 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter { | ||
136 | protected: | ||
137 | virtual void init ( ); | ||
138 | virtual void initButtons ( ); | ||
139 | |||
140 | public: | ||
141 | virtual bool setSoftSuspend ( bool soft ); | ||
142 | |||
143 | virtual bool setDisplayBrightness ( int b ); | ||
144 | virtual int displayBrightnessResolution ( ) const; | ||
145 | |||
146 | virtual void alarmSound ( ); | ||
147 | |||
148 | virtual QValueList <OLed> ledList ( ) const; | ||
149 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | ||
150 | virtual OLedState ledState ( OLed led ) const; | ||
151 | virtual bool setLedState ( OLed led, OLedState st ); | ||
152 | |||
153 | protected: | ||
154 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | ||
155 | virtual void timerEvent ( QTimerEvent *te ); | ||
156 | |||
157 | int m_power_timer; | ||
158 | |||
159 | OLedState m_leds [1]; //FIXME check if really only one | ||
160 | }; | ||
135 | 161 | ||
136 | struct i_button { | 162 | struct i_button { |
137 | uint model; | 163 | uint model; |
138 | Qt::Key code; | 164 | Qt::Key code; |
139 | char *utext; | 165 | char *utext; |
140 | char *pix; | 166 | char *pix; |
141 | char *fpressedservice; | 167 | char *fpressedservice; |
142 | char *fpressedaction; | 168 | char *fpressedaction; |
143 | char *fheldservice; | 169 | char *fheldservice; |
144 | char *fheldaction; | 170 | char *fheldaction; |
145 | } ipaq_buttons [] = { | 171 | } ipaq_buttons [] = { |
146 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 172 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
147 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 173 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
148 | "devicebuttons/ipaq_calendar", | 174 | "devicebuttons/ipaq_calendar", |
149 | "datebook", "nextView()", | 175 | "datebook", "nextView()", |
150 | "today", "raise()" }, | 176 | "today", "raise()" }, |
151 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 177 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
152 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 178 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
153 | "devicebuttons/ipaq_contact", | 179 | "devicebuttons/ipaq_contact", |
154 | "addressbook", "raise()", | 180 | "addressbook", "raise()", |
155 | "addressbook", "beamBusinessCard()" }, | 181 | "addressbook", "beamBusinessCard()" }, |
156 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, | 182 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, |
157 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 183 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
158 | "devicebuttons/ipaq_menu", | 184 | "devicebuttons/ipaq_menu", |
159 | "QPE/TaskBar", "toggleMenu()", | 185 | "QPE/TaskBar", "toggleMenu()", |
160 | "QPE/TaskBar", "toggleStartMenu()" }, | 186 | "QPE/TaskBar", "toggleStartMenu()" }, |
161 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 187 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
162 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 188 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
163 | "devicebuttons/ipaq_mail", | 189 | "devicebuttons/ipaq_mail", |
164 | "mail", "raise()", | 190 | "mail", "raise()", |
165 | "mail", "newMail()" }, | 191 | "mail", "newMail()" }, |
166 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 192 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
167 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 193 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
168 | "devicebuttons/ipaq_home", | 194 | "devicebuttons/ipaq_home", |
169 | "QPE/Launcher", "home()", | 195 | "QPE/Launcher", "home()", |
170 | "buttonsettings", "raise()" }, | 196 | "buttonsettings", "raise()" }, |
171 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 197 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
172 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), | 198 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), |
173 | "devicebuttons/ipaq_record", | 199 | "devicebuttons/ipaq_record", |
174 | "QPE/VMemo", "toggleRecord()", | 200 | "QPE/VMemo", "toggleRecord()", |
175 | "sound", "raise()" }, | 201 | "sound", "raise()" }, |
176 | }; | 202 | }; |
177 | 203 | ||
178 | struct z_button { | 204 | struct z_button { |
179 | Qt::Key code; | 205 | Qt::Key code; |
180 | char *utext; | 206 | char *utext; |
181 | char *pix; | 207 | char *pix; |
182 | char *fpressedservice; | 208 | char *fpressedservice; |
183 | char *fpressedaction; | 209 | char *fpressedaction; |
184 | char *fheldservice; | 210 | char *fheldservice; |
185 | char *fheldaction; | 211 | char *fheldaction; |
186 | } z_buttons [] = { | 212 | } z_buttons [] = { |
187 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 213 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
188 | "devicebuttons/z_calendar", | 214 | "devicebuttons/z_calendar", |
189 | "datebook", "nextView()", | 215 | "datebook", "nextView()", |
190 | "today", "raise()" }, | 216 | "today", "raise()" }, |
191 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 217 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
192 | "devicebuttons/z_contact", | 218 | "devicebuttons/z_contact", |
193 | "addressbook", "raise()", | 219 | "addressbook", "raise()", |
194 | "addressbook", "beamBusinessCard()" }, | 220 | "addressbook", "beamBusinessCard()" }, |
195 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 221 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
196 | "devicebuttons/z_home", | 222 | "devicebuttons/z_home", |
197 | "QPE/Launcher", "home()", | 223 | "QPE/Launcher", "home()", |
198 | "buttonsettings", "raise()" }, | 224 | "buttonsettings", "raise()" }, |
199 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 225 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
200 | "devicebuttons/z_menu", | 226 | "devicebuttons/z_menu", |
201 | "QPE/TaskBar", "toggleMenu()", | 227 | "QPE/TaskBar", "toggleMenu()", |
202 | "QPE/TaskBar", "toggleStartMenu()" }, | 228 | "QPE/TaskBar", "toggleStartMenu()" }, |
203 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 229 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
204 | "devicebuttons/z_mail", | 230 | "devicebuttons/z_mail", |
205 | "mail", "raise()", | 231 | "mail", "raise()", |
206 | "mail", "newMail()" }, | 232 | "mail", "newMail()" }, |
207 | }; | 233 | }; |
208 | 234 | ||
209 | struct z_button z_buttons_c700 [] = { | 235 | struct z_button z_buttons_c700 [] = { |
210 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 236 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
211 | "devicebuttons/z_calendar", | 237 | "devicebuttons/z_calendar", |
212 | "datebook", "nextView()", | 238 | "datebook", "nextView()", |
213 | "today", "raise()" }, | 239 | "today", "raise()" }, |
214 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 240 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
215 | "devicebuttons/z_contact", | 241 | "devicebuttons/z_contact", |
216 | "addressbook", "raise()", | 242 | "addressbook", "raise()", |
217 | "addressbook", "beamBusinessCard()" }, | 243 | "addressbook", "beamBusinessCard()" }, |
218 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 244 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
219 | "devicebuttons/z_home", | 245 | "devicebuttons/z_home", |
220 | "QPE/Launcher", "home()", | 246 | "QPE/Launcher", "home()", |
221 | "buttonsettings", "raise()" }, | 247 | "buttonsettings", "raise()" }, |
222 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 248 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
223 | "devicebuttons/z_menu", | 249 | "devicebuttons/z_menu", |
224 | "QPE/TaskBar", "toggleMenu()", | 250 | "QPE/TaskBar", "toggleMenu()", |
225 | "QPE/TaskBar", "toggleStartMenu()" }, | 251 | "QPE/TaskBar", "toggleStartMenu()" }, |
226 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), | 252 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), |
227 | "", | 253 | "", |
228 | "QPE/Rotation", "flip()", | 254 | "QPE/Rotation", "flip()", |
229 | "QPE/Rotation", "flip()" }, | 255 | "QPE/Rotation", "flip()" }, |
230 | }; | 256 | }; |
231 | 257 | ||
258 | struct s_button { | ||
259 | uint model; | ||
260 | Qt::Key code; | ||
261 | char *utext; | ||
262 | char *pix; | ||
263 | char *fpressedservice; | ||
264 | char *fpressedaction; | ||
265 | char *fheldservice; | ||
266 | char *fheldaction; | ||
267 | } simpad_buttons [] = { | ||
268 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | ||
269 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | ||
270 | "devicebuttons/simpad_menu", | ||
271 | "QPE/TaskBar", "toggleMenu()", | ||
272 | "QPE/TaskBar", "toggleStartMenu()" }, | ||
273 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | ||
274 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | ||
275 | "devicebuttons/ipaq_home", | ||
276 | "QPE/Launcher", "home()", | ||
277 | "buttonsettings", "raise()" }, | ||
278 | }; | ||
279 | |||
232 | static QCString makeChannel ( const char *str ) | 280 | static QCString makeChannel ( const char *str ) |
233 | { | 281 | { |
234 | if ( str && !::strchr ( str, '/' )) | 282 | if ( str && !::strchr ( str, '/' )) |
235 | return QCString ( "QPE/Application/" ) + str; | 283 | return QCString ( "QPE/Application/" ) + str; |
236 | else | 284 | else |
237 | return str; | 285 | return str; |
238 | } | 286 | } |
239 | 287 | ||
240 | static inline bool isQWS() | 288 | static inline bool isQWS() |
241 | { | 289 | { |
242 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 290 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
243 | } | 291 | } |
244 | 292 | ||
245 | ODevice *ODevice::inst ( ) | 293 | ODevice *ODevice::inst ( ) |
246 | { | 294 | { |
247 | static ODevice *dev = 0; | 295 | static ODevice *dev = 0; |
248 | 296 | ||
249 | if ( !dev ) { | 297 | if ( !dev ) { |
250 | if ( QFile::exists ( "/proc/hal/model" )) | 298 | if ( QFile::exists ( "/proc/hal/model" )) |
251 | dev = new iPAQ ( ); | 299 | dev = new iPAQ ( ); |
252 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 300 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
253 | dev = new Zaurus ( ); | 301 | dev = new Zaurus ( ); |
302 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/CS3" )) | ||
303 | dev = new SIMpad ( ); | ||
254 | else | 304 | else |
255 | dev = new ODevice ( ); | 305 | dev = new ODevice ( ); |
256 | 306 | ||
257 | dev-> init ( ); | 307 | dev-> init ( ); |
258 | } | 308 | } |
259 | return dev; | 309 | return dev; |
260 | } | 310 | } |
261 | 311 | ||
262 | 312 | ||
263 | /************************************************** | 313 | /************************************************** |
264 | * | 314 | * |
265 | * common | 315 | * common |
266 | * | 316 | * |
267 | **************************************************/ | 317 | **************************************************/ |
268 | 318 | ||
269 | 319 | ||
270 | ODevice::ODevice ( ) | 320 | ODevice::ODevice ( ) |
271 | { | 321 | { |
272 | d = new ODeviceData; | 322 | d = new ODeviceData; |
273 | 323 | ||
274 | d-> m_modelstr = "Unknown"; | 324 | d-> m_modelstr = "Unknown"; |
275 | d-> m_model = Model_Unknown; | 325 | d-> m_model = Model_Unknown; |
276 | d-> m_vendorstr = "Unknown"; | 326 | d-> m_vendorstr = "Unknown"; |
277 | d-> m_vendor = Vendor_Unknown; | 327 | d-> m_vendor = Vendor_Unknown; |
278 | d-> m_systemstr = "Unknown"; | 328 | d-> m_systemstr = "Unknown"; |
279 | d-> m_system = System_Unknown; | 329 | d-> m_system = System_Unknown; |
280 | d-> m_sysverstr = "0.0"; | 330 | d-> m_sysverstr = "0.0"; |
281 | d-> m_rotation = Rot0; | 331 | d-> m_rotation = Rot0; |
282 | d-> m_direction = CW; | 332 | d-> m_direction = CW; |
283 | 333 | ||
284 | d-> m_holdtime = 1000; // 1000ms | 334 | d-> m_holdtime = 1000; // 1000ms |
285 | d-> m_buttons = 0; | 335 | d-> m_buttons = 0; |
286 | } | 336 | } |
287 | 337 | ||
288 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 338 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
289 | { | 339 | { |
290 | if ( msg == "deviceButtonMappingChanged()" ) { | 340 | if ( msg == "deviceButtonMappingChanged()" ) { |
291 | reloadButtonMapping ( ); | 341 | reloadButtonMapping ( ); |
292 | } | 342 | } |
293 | } | 343 | } |
294 | 344 | ||
295 | void ODevice::init ( ) | 345 | void ODevice::init ( ) |
296 | { | 346 | { |
297 | } | 347 | } |
298 | 348 | ||
299 | /** | 349 | /** |
300 | * This method initialises the button mapping | 350 | * This method initialises the button mapping |
301 | */ | 351 | */ |
302 | void ODevice::initButtons ( ) | 352 | void ODevice::initButtons ( ) |
303 | { | 353 | { |
304 | if ( d-> m_buttons ) | 354 | if ( d-> m_buttons ) |
305 | return; | 355 | return; |
306 | 356 | ||
307 | // Simulation uses iPAQ 3660 device buttons | 357 | // Simulation uses iPAQ 3660 device buttons |
308 | 358 | ||
309 | qDebug ( "init Buttons" ); | 359 | qDebug ( "init Buttons" ); |
310 | d-> m_buttons = new QValueList <ODeviceButton>; | 360 | d-> m_buttons = new QValueList <ODeviceButton>; |
311 | 361 | ||
312 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 362 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
313 | i_button *ib = ipaq_buttons + i; | 363 | i_button *ib = ipaq_buttons + i; |
314 | ODeviceButton b; | 364 | ODeviceButton b; |
315 | 365 | ||
316 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 366 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
317 | b. setKeycode ( ib-> code ); | 367 | b. setKeycode ( ib-> code ); |
318 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 368 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
319 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 369 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
320 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 370 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
321 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 371 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
322 | d-> m_buttons-> append ( b ); | 372 | d-> m_buttons-> append ( b ); |
323 | } | 373 | } |
324 | } | 374 | } |
325 | reloadButtonMapping ( ); | 375 | reloadButtonMapping ( ); |
326 | 376 | ||
327 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 377 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
328 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 378 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
329 | } | 379 | } |
330 | 380 | ||
331 | ODevice::~ODevice ( ) | 381 | ODevice::~ODevice ( ) |
332 | { | 382 | { |
333 | delete d; | 383 | delete d; |
334 | } | 384 | } |
335 | 385 | ||
336 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 386 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
337 | { | 387 | { |
338 | return false; | 388 | return false; |
339 | } | 389 | } |
340 | 390 | ||
341 | //#include <linux/apm_bios.h> | 391 | //#include <linux/apm_bios.h> |
342 | 392 | ||
343 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 393 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
344 | 394 | ||
345 | /** | 395 | /** |
346 | * This method will try to suspend the device | 396 | * This method will try to suspend the device |
347 | * It only works if the user is the QWS Server and the apm application | 397 | * It only works if the user is the QWS Server and the apm application |
348 | * is installed. | 398 | * is installed. |
349 | * It tries to suspend and then waits some time cause some distributions | 399 | * It tries to suspend and then waits some time cause some distributions |
350 | * do have asynchronus apm implementations. | 400 | * do have asynchronus apm implementations. |
351 | * This method will either fail and return false or it'll suspend the | 401 | * This method will either fail and return false or it'll suspend the |
352 | * device and return once the device got woken up | 402 | * device and return once the device got woken up |
353 | * | 403 | * |
354 | * @return if the device got suspended | 404 | * @return if the device got suspended |
355 | */ | 405 | */ |
356 | bool ODevice::suspend ( ) | 406 | bool ODevice::suspend ( ) |
357 | { | 407 | { |
358 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 408 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
359 | return false; | 409 | return false; |
360 | 410 | ||
361 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 411 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
362 | return false; | 412 | return false; |
363 | 413 | ||
364 | bool res = false; | 414 | bool res = false; |
365 | 415 | ||
366 | struct timeval tvs, tvn; | 416 | struct timeval tvs, tvn; |
367 | ::gettimeofday ( &tvs, 0 ); | 417 | ::gettimeofday ( &tvs, 0 ); |
368 | 418 | ||
369 | ::sync ( ); // flush fs caches | 419 | ::sync ( ); // flush fs caches |
370 | res = ( ::system ( "apm --suspend" ) == 0 ); | 420 | res = ( ::system ( "apm --suspend" ) == 0 ); |
371 | 421 | ||
372 | // This is needed because the iPAQ apm implementation is asynchronous and we | 422 | // This is needed because the iPAQ apm implementation is asynchronous and we |
373 | // can not be sure when exactly the device is really suspended | 423 | // can not be sure when exactly the device is really suspended |
374 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 424 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
375 | 425 | ||
376 | if ( res ) { | 426 | if ( res ) { |
377 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 427 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
378 | ::usleep ( 200 * 1000 ); | 428 | ::usleep ( 200 * 1000 ); |
379 | ::gettimeofday ( &tvn, 0 ); | 429 | ::gettimeofday ( &tvn, 0 ); |
380 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 430 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
381 | } | 431 | } |
382 | 432 | ||
383 | return res; | 433 | return res; |
384 | } | 434 | } |
385 | 435 | ||
386 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 436 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
387 | 437 | ||
388 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 438 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
389 | 439 | ||
390 | /* VESA Blanking Levels */ | 440 | /* VESA Blanking Levels */ |
391 | #define VESA_NO_BLANKING 0 | 441 | #define VESA_NO_BLANKING 0 |
392 | #define VESA_VSYNC_SUSPEND 1 | 442 | #define VESA_VSYNC_SUSPEND 1 |
393 | #define VESA_HSYNC_SUSPEND 2 | 443 | #define VESA_HSYNC_SUSPEND 2 |
394 | #define VESA_POWERDOWN 3 | 444 | #define VESA_POWERDOWN 3 |
395 | 445 | ||
396 | /** | 446 | /** |
397 | * This sets the display on or off | 447 | * This sets the display on or off |
398 | */ | 448 | */ |
399 | bool ODevice::setDisplayStatus ( bool on ) | 449 | bool ODevice::setDisplayStatus ( bool on ) |
400 | { | 450 | { |
401 | if ( d-> m_model == Model_Unknown ) | 451 | if ( d-> m_model == Model_Unknown ) |
402 | return false; | 452 | return false; |
403 | 453 | ||
404 | bool res = false; | 454 | bool res = false; |
405 | int fd; | 455 | int fd; |
406 | 456 | ||
407 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 457 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
408 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 458 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
409 | ::close ( fd ); | 459 | ::close ( fd ); |
410 | } | 460 | } |
411 | return res; | 461 | return res; |
412 | } | 462 | } |
413 | 463 | ||
414 | /** | 464 | /** |
415 | * This sets the display brightness | 465 | * This sets the display brightness |
416 | * @return success or failure | 466 | * @return success or failure |
417 | */ | 467 | */ |
418 | bool ODevice::setDisplayBrightness ( int p) | 468 | bool ODevice::setDisplayBrightness ( int p) |
419 | { | 469 | { |
420 | Q_UNUSED( p ) | 470 | Q_UNUSED( p ) |
421 | return false; | 471 | return false; |
422 | } | 472 | } |
423 | 473 | ||
424 | int ODevice::displayBrightnessResolution ( ) const | 474 | int ODevice::displayBrightnessResolution ( ) const |
425 | { | 475 | { |
426 | return 16; | 476 | return 16; |
427 | } | 477 | } |
428 | 478 | ||
429 | /** | 479 | /** |
430 | * This returns the vendor as string | 480 | * This returns the vendor as string |
431 | * @return Vendor as QString | 481 | * @return Vendor as QString |
432 | */ | 482 | */ |
433 | QString ODevice::vendorString ( ) const | 483 | QString ODevice::vendorString ( ) const |
434 | { | 484 | { |
435 | return d-> m_vendorstr; | 485 | return d-> m_vendorstr; |
436 | } | 486 | } |
437 | 487 | ||
438 | /** | 488 | /** |
439 | * This returns the vendor as one of the values of OVendor | 489 | * This returns the vendor as one of the values of OVendor |
440 | * @return OVendor | 490 | * @return OVendor |
441 | */ | 491 | */ |
442 | OVendor ODevice::vendor ( ) const | 492 | OVendor ODevice::vendor ( ) const |
443 | { | 493 | { |
444 | return d-> m_vendor; | 494 | return d-> m_vendor; |
445 | } | 495 | } |
446 | 496 | ||
447 | /** | 497 | /** |
448 | * This returns the model as a string | 498 | * This returns the model as a string |
449 | * @return A string representing the model | 499 | * @return A string representing the model |
450 | */ | 500 | */ |
451 | QString ODevice::modelString ( ) const | 501 | QString ODevice::modelString ( ) const |
452 | { | 502 | { |
453 | return d-> m_modelstr; | 503 | return d-> m_modelstr; |
454 | } | 504 | } |
455 | 505 | ||
456 | /** | 506 | /** |
457 | * This does return the OModel used | 507 | * This does return the OModel used |
458 | */ | 508 | */ |
459 | OModel ODevice::model ( ) const | 509 | OModel ODevice::model ( ) const |
460 | { | 510 | { |
461 | return d-> m_model; | 511 | return d-> m_model; |
462 | } | 512 | } |
463 | 513 | ||
464 | /** | 514 | /** |
465 | * This does return the systen name | 515 | * This does return the systen name |
466 | */ | 516 | */ |
467 | QString ODevice::systemString ( ) const | 517 | QString ODevice::systemString ( ) const |
468 | { | 518 | { |
469 | return d-> m_systemstr; | 519 | return d-> m_systemstr; |
470 | } | 520 | } |
471 | 521 | ||
472 | /** | 522 | /** |
473 | * Return System as OSystem value | 523 | * Return System as OSystem value |
474 | */ | 524 | */ |
475 | OSystem ODevice::system ( ) const | 525 | OSystem ODevice::system ( ) const |
476 | { | 526 | { |
477 | return d-> m_system; | 527 | return d-> m_system; |
478 | } | 528 | } |
479 | 529 | ||
480 | /** | 530 | /** |
481 | * @return the version string of the base system | 531 | * @return the version string of the base system |
482 | */ | 532 | */ |
483 | QString ODevice::systemVersionString ( ) const | 533 | QString ODevice::systemVersionString ( ) const |
484 | { | 534 | { |
485 | return d-> m_sysverstr; | 535 | return d-> m_sysverstr; |
486 | } | 536 | } |
487 | 537 | ||
488 | /** | 538 | /** |
489 | * @return the current Transformation | 539 | * @return the current Transformation |
490 | */ | 540 | */ |
491 | Transformation ODevice::rotation ( ) const | 541 | Transformation ODevice::rotation ( ) const |
492 | { | 542 | { |
493 | return d-> m_rotation; | 543 | return d-> m_rotation; |
494 | } | 544 | } |
495 | 545 | ||
496 | /** | 546 | /** |
497 | * @return the current rotation direction | 547 | * @return the current rotation direction |
498 | */ | 548 | */ |
499 | ODirection ODevice::direction ( ) const | 549 | ODirection ODevice::direction ( ) const |
500 | { | 550 | { |
501 | return d-> m_direction; | 551 | return d-> m_direction; |
502 | } | 552 | } |
503 | 553 | ||
504 | /** | 554 | /** |
505 | * This plays an alarmSound | 555 | * This plays an alarmSound |
506 | */ | 556 | */ |
507 | void ODevice::alarmSound ( ) | 557 | void ODevice::alarmSound ( ) |
508 | { | 558 | { |
509 | #ifndef QT_NO_SOUND | 559 | #ifndef QT_NO_SOUND |
510 | static Sound snd ( "alarm" ); | 560 | static Sound snd ( "alarm" ); |
511 | 561 | ||
512 | if ( snd. isFinished ( )) | 562 | if ( snd. isFinished ( )) |
513 | snd. play ( ); | 563 | snd. play ( ); |
514 | #endif | 564 | #endif |
515 | } | 565 | } |
516 | 566 | ||
517 | /** | 567 | /** |
518 | * This plays a key sound | 568 | * This plays a key sound |
519 | */ | 569 | */ |
520 | void ODevice::keySound ( ) | 570 | void ODevice::keySound ( ) |
521 | { | 571 | { |
522 | #ifndef QT_NO_SOUND | 572 | #ifndef QT_NO_SOUND |
523 | static Sound snd ( "keysound" ); | 573 | static Sound snd ( "keysound" ); |
524 | 574 | ||
525 | if ( snd. isFinished ( )) | 575 | if ( snd. isFinished ( )) |
526 | snd. play ( ); | 576 | snd. play ( ); |
527 | #endif | 577 | #endif |
528 | } | 578 | } |
529 | 579 | ||
530 | /** | 580 | /** |
531 | * This plays a touch sound | 581 | * This plays a touch sound |
532 | */ | 582 | */ |
533 | void ODevice::touchSound ( ) | 583 | void ODevice::touchSound ( ) |
534 | { | 584 | { |
535 | 585 | ||
536 | #ifndef QT_NO_SOUND | 586 | #ifndef QT_NO_SOUND |
537 | static Sound snd ( "touchsound" ); | 587 | static Sound snd ( "touchsound" ); |
538 | 588 | ||
539 | if ( snd. isFinished ( )) | 589 | if ( snd. isFinished ( )) |
540 | snd. play ( ); | 590 | snd. play ( ); |
541 | #endif | 591 | #endif |
542 | } | 592 | } |
543 | 593 | ||
544 | /** | 594 | /** |
545 | * This method will return a list of leds | 595 | * This method will return a list of leds |
546 | * available on this device | 596 | * available on this device |
547 | * @return a list of LEDs. | 597 | * @return a list of LEDs. |
548 | */ | 598 | */ |
549 | QValueList <OLed> ODevice::ledList ( ) const | 599 | QValueList <OLed> ODevice::ledList ( ) const |
550 | { | 600 | { |
551 | return QValueList <OLed> ( ); | 601 | return QValueList <OLed> ( ); |
552 | } | 602 | } |
553 | 603 | ||
554 | /** | 604 | /** |
555 | * This does return the state of the LEDs | 605 | * This does return the state of the LEDs |
556 | */ | 606 | */ |
557 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 607 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
558 | { | 608 | { |
559 | return QValueList <OLedState> ( ); | 609 | return QValueList <OLedState> ( ); |
560 | } | 610 | } |
561 | 611 | ||
562 | /** | 612 | /** |
563 | * @return the state for a given OLed | 613 | * @return the state for a given OLed |
564 | */ | 614 | */ |
565 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 615 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
566 | { | 616 | { |
567 | return Led_Off; | 617 | return Led_Off; |
568 | } | 618 | } |
569 | 619 | ||
570 | /** | 620 | /** |
571 | * Set the state for a LED | 621 | * Set the state for a LED |
572 | * @param which Which OLed to use | 622 | * @param which Which OLed to use |
573 | * @param st The state to set | 623 | * @param st The state to set |
574 | * @return success or failure | 624 | * @return success or failure |
575 | */ | 625 | */ |
576 | bool ODevice::setLedState ( OLed which, OLedState st ) | 626 | bool ODevice::setLedState ( OLed which, OLedState st ) |
577 | { | 627 | { |
578 | Q_UNUSED( which ) | 628 | Q_UNUSED( which ) |
579 | Q_UNUSED( st ) | 629 | Q_UNUSED( st ) |
580 | return false; | 630 | return false; |
581 | } | 631 | } |
582 | 632 | ||
583 | /** | 633 | /** |
584 | * @return if the device has a light sensor | 634 | * @return if the device has a light sensor |
585 | */ | 635 | */ |
586 | bool ODevice::hasLightSensor ( ) const | 636 | bool ODevice::hasLightSensor ( ) const |
587 | { | 637 | { |
588 | return false; | 638 | return false; |
589 | } | 639 | } |
590 | 640 | ||
591 | /** | 641 | /** |
592 | * @return a value from the light senso | 642 | * @return a value from the light senso |
593 | */ | 643 | */ |
594 | int ODevice::readLightSensor ( ) | 644 | int ODevice::readLightSensor ( ) |
595 | { | 645 | { |
596 | return -1; | 646 | return -1; |
597 | } | 647 | } |
598 | 648 | ||
599 | /** | 649 | /** |
600 | * @return the light sensor resolution whatever that is ;) | 650 | * @return the light sensor resolution whatever that is ;) |
601 | */ | 651 | */ |
602 | int ODevice::lightSensorResolution ( ) const | 652 | int ODevice::lightSensorResolution ( ) const |
603 | { | 653 | { |
604 | return 0; | 654 | return 0; |
605 | } | 655 | } |
606 | 656 | ||
607 | /** | 657 | /** |
608 | * @return a list of hardware buttons | 658 | * @return a list of hardware buttons |
609 | */ | 659 | */ |
610 | const QValueList <ODeviceButton> &ODevice::buttons ( ) | 660 | const QValueList <ODeviceButton> &ODevice::buttons ( ) |
611 | { | 661 | { |
612 | initButtons ( ); | 662 | initButtons ( ); |
613 | 663 | ||
614 | return *d-> m_buttons; | 664 | return *d-> m_buttons; |
615 | } | 665 | } |
616 | 666 | ||
617 | /** | 667 | /** |
618 | * @return The amount of time that would count as a hold | 668 | * @return The amount of time that would count as a hold |
619 | */ | 669 | */ |
620 | uint ODevice::buttonHoldTime ( ) const | 670 | uint ODevice::buttonHoldTime ( ) const |
621 | { | 671 | { |
622 | return d-> m_holdtime; | 672 | return d-> m_holdtime; |
623 | } | 673 | } |
624 | 674 | ||
625 | /** | 675 | /** |
626 | * This method return a ODeviceButton for a key code | 676 | * This method return a ODeviceButton for a key code |
627 | * or 0 if no special hardware button is available for the device | 677 | * or 0 if no special hardware button is available for the device |
628 | * | 678 | * |
629 | * @return The devicebutton or 0l | 679 | * @return The devicebutton or 0l |
630 | * @see ODeviceButton | 680 | * @see ODeviceButton |
631 | */ | 681 | */ |
632 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 682 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
633 | { | 683 | { |
634 | initButtons ( ); | 684 | initButtons ( ); |
635 | 685 | ||
636 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { | 686 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { |
637 | if ( (*it). keycode ( ) == code ) | 687 | if ( (*it). keycode ( ) == code ) |
@@ -1059,384 +1109,654 @@ int iPAQ::displayBrightnessResolution ( ) const | |||
1059 | case Model_iPAQ_H31xx: | 1109 | case Model_iPAQ_H31xx: |
1060 | case Model_iPAQ_H36xx: | 1110 | case Model_iPAQ_H36xx: |
1061 | case Model_iPAQ_H37xx: | 1111 | case Model_iPAQ_H37xx: |
1062 | return 128; // really 256, but >128 could damage the LCD | 1112 | return 128; // really 256, but >128 could damage the LCD |
1063 | 1113 | ||
1064 | case Model_iPAQ_H38xx: | 1114 | case Model_iPAQ_H38xx: |
1065 | case Model_iPAQ_H39xx: | 1115 | case Model_iPAQ_H39xx: |
1066 | return 64; | 1116 | return 64; |
1067 | 1117 | ||
1068 | default: | 1118 | default: |
1069 | return 2; | 1119 | return 2; |
1070 | } | 1120 | } |
1071 | } | 1121 | } |
1072 | 1122 | ||
1073 | 1123 | ||
1074 | bool iPAQ::hasLightSensor ( ) const | 1124 | bool iPAQ::hasLightSensor ( ) const |
1075 | { | 1125 | { |
1076 | return true; | 1126 | return true; |
1077 | } | 1127 | } |
1078 | 1128 | ||
1079 | int iPAQ::readLightSensor ( ) | 1129 | int iPAQ::readLightSensor ( ) |
1080 | { | 1130 | { |
1081 | int fd; | 1131 | int fd; |
1082 | int val = -1; | 1132 | int val = -1; |
1083 | 1133 | ||
1084 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 1134 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
1085 | char buffer [8]; | 1135 | char buffer [8]; |
1086 | 1136 | ||
1087 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 1137 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
1088 | char *endptr; | 1138 | char *endptr; |
1089 | 1139 | ||
1090 | buffer [4] = 0; | 1140 | buffer [4] = 0; |
1091 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 1141 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
1092 | 1142 | ||
1093 | if ( *endptr != 0 ) | 1143 | if ( *endptr != 0 ) |
1094 | val = -1; | 1144 | val = -1; |
1095 | } | 1145 | } |
1096 | ::close ( fd ); | 1146 | ::close ( fd ); |
1097 | } | 1147 | } |
1098 | 1148 | ||
1099 | return val; | 1149 | return val; |
1100 | } | 1150 | } |
1101 | 1151 | ||
1102 | int iPAQ::lightSensorResolution ( ) const | 1152 | int iPAQ::lightSensorResolution ( ) const |
1103 | { | 1153 | { |
1104 | return 256; | 1154 | return 256; |
1105 | } | 1155 | } |
1106 | 1156 | ||
1107 | /************************************************** | 1157 | /************************************************** |
1108 | * | 1158 | * |
1109 | * Zaurus | 1159 | * Zaurus |
1110 | * | 1160 | * |
1111 | **************************************************/ | 1161 | **************************************************/ |
1112 | 1162 | ||
1113 | 1163 | ||
1114 | 1164 | ||
1115 | void Zaurus::init ( ) | 1165 | void Zaurus::init ( ) |
1116 | { | 1166 | { |
1117 | d-> m_vendorstr = "Sharp"; | 1167 | d-> m_vendorstr = "Sharp"; |
1118 | d-> m_vendor = Vendor_Sharp; | 1168 | d-> m_vendor = Vendor_Sharp; |
1119 | 1169 | ||
1120 | QFile f ( "/proc/filesystems" ); | 1170 | QFile f ( "/proc/filesystems" ); |
1121 | QString model; | 1171 | QString model; |
1122 | 1172 | ||
1123 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 1173 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
1124 | d-> m_vendorstr = "OpenZaurus Team"; | 1174 | d-> m_vendorstr = "OpenZaurus Team"; |
1125 | d-> m_systemstr = "OpenZaurus"; | 1175 | d-> m_systemstr = "OpenZaurus"; |
1126 | d-> m_system = System_OpenZaurus; | 1176 | d-> m_system = System_OpenZaurus; |
1127 | 1177 | ||
1128 | f. close ( ); | 1178 | f. close ( ); |
1129 | 1179 | ||
1130 | f. setName ( "/etc/oz_version" ); | 1180 | f. setName ( "/etc/oz_version" ); |
1131 | if ( f. open ( IO_ReadOnly )) { | 1181 | if ( f. open ( IO_ReadOnly )) { |
1132 | QTextStream ts ( &f ); | 1182 | QTextStream ts ( &f ); |
1133 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 1183 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
1134 | f. close ( ); | 1184 | f. close ( ); |
1135 | } | 1185 | } |
1136 | } | 1186 | } |
1137 | else { | 1187 | else { |
1138 | d-> m_systemstr = "Zaurus"; | 1188 | d-> m_systemstr = "Zaurus"; |
1139 | d-> m_system = System_Zaurus; | 1189 | d-> m_system = System_Zaurus; |
1140 | } | 1190 | } |
1141 | 1191 | ||
1142 | f. setName ( "/proc/cpuinfo" ); | 1192 | f. setName ( "/proc/cpuinfo" ); |
1143 | if ( f. open ( IO_ReadOnly ) ) { | 1193 | if ( f. open ( IO_ReadOnly ) ) { |
1144 | QTextStream ts ( &f ); | 1194 | QTextStream ts ( &f ); |
1145 | QString line; | 1195 | QString line; |
1146 | while( line = ts. readLine ( ) ) { | 1196 | while( line = ts. readLine ( ) ) { |
1147 | if ( line. left ( 8 ) == "Hardware" ) | 1197 | if ( line. left ( 8 ) == "Hardware" ) |
1148 | break; | 1198 | break; |
1149 | } | 1199 | } |
1150 | int loc = line. find ( ":" ); | 1200 | int loc = line. find ( ":" ); |
1151 | if ( loc != -1 ) | 1201 | if ( loc != -1 ) |
1152 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1202 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1153 | } | 1203 | } |
1154 | 1204 | ||
1155 | if ( model == "SHARP Corgi" ) { | 1205 | if ( model == "SHARP Corgi" ) { |
1156 | d-> m_model = Model_Zaurus_SLC700; | 1206 | d-> m_model = Model_Zaurus_SLC700; |
1157 | d-> m_modelstr = "Zaurus SL-C700"; | 1207 | d-> m_modelstr = "Zaurus SL-C700"; |
1158 | } else if ( model == "SHARP Poodle" ) { | 1208 | } else if ( model == "SHARP Poodle" ) { |
1159 | d-> m_model = Model_Zaurus_SLB600; | 1209 | d-> m_model = Model_Zaurus_SLB600; |
1160 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; | 1210 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; |
1161 | } else if ( model = "Sharp-Collie" ) { | 1211 | } else if ( model = "Sharp-Collie" ) { |
1162 | d-> m_model = Model_Zaurus_SL5500; | 1212 | d-> m_model = Model_Zaurus_SL5500; |
1163 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 1213 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
1164 | } else { | 1214 | } else { |
1165 | d-> m_model = Model_Zaurus_SL5500; | 1215 | d-> m_model = Model_Zaurus_SL5500; |
1166 | d-> m_modelstr = "Zaurus (Model unknown)"; | 1216 | d-> m_modelstr = "Zaurus (Model unknown)"; |
1167 | } | 1217 | } |
1168 | 1218 | ||
1169 | bool flipstate = false; | 1219 | bool flipstate = false; |
1170 | switch ( d-> m_model ) { | 1220 | switch ( d-> m_model ) { |
1171 | case Model_Zaurus_SLA300: | 1221 | case Model_Zaurus_SLA300: |
1172 | d-> m_rotation = Rot0; | 1222 | d-> m_rotation = Rot0; |
1173 | break; | 1223 | break; |
1174 | case Model_Zaurus_SLC700: | 1224 | case Model_Zaurus_SLC700: |
1175 | // Note: need to 1) set flipstate based on physical screen orientation | 1225 | // Note: need to 1) set flipstate based on physical screen orientation |
1176 | // and 2) check to see if the user overrode the rotation direction | 1226 | // and 2) check to see if the user overrode the rotation direction |
1177 | // using appearance, and if so, remove that item from the Config to | 1227 | // using appearance, and if so, remove that item from the Config to |
1178 | // ensure the rotate applet flips us back to the previous state. | 1228 | // ensure the rotate applet flips us back to the previous state. |
1179 | if ( flipstate ) { | 1229 | if ( flipstate ) { |
1180 | // 480x640 | 1230 | // 480x640 |
1181 | d-> m_rotation = Rot0; | 1231 | d-> m_rotation = Rot0; |
1182 | d-> m_direction = CW; | 1232 | d-> m_direction = CW; |
1183 | } else { | 1233 | } else { |
1184 | // 640x480 | 1234 | // 640x480 |
1185 | d-> m_rotation = Rot270; | 1235 | d-> m_rotation = Rot270; |
1186 | d-> m_direction = CCW; | 1236 | d-> m_direction = CCW; |
1187 | } | 1237 | } |
1188 | break; | 1238 | break; |
1189 | case Model_Zaurus_SLB600: | 1239 | case Model_Zaurus_SLB600: |
1190 | case Model_Zaurus_SL5500: | 1240 | case Model_Zaurus_SL5500: |
1191 | case Model_Zaurus_SL5000: | 1241 | case Model_Zaurus_SL5000: |
1192 | default: | 1242 | default: |
1193 | d-> m_rotation = Rot270; | 1243 | d-> m_rotation = Rot270; |
1194 | break; | 1244 | break; |
1195 | } | 1245 | } |
1196 | m_leds [0] = Led_Off; | 1246 | m_leds [0] = Led_Off; |
1197 | } | 1247 | } |
1198 | 1248 | ||
1199 | void Zaurus::initButtons ( ) | 1249 | void Zaurus::initButtons ( ) |
1200 | { | 1250 | { |
1201 | if ( d-> m_buttons ) | 1251 | if ( d-> m_buttons ) |
1202 | return; | 1252 | return; |
1203 | 1253 | ||
1204 | d-> m_buttons = new QValueList <ODeviceButton>; | 1254 | d-> m_buttons = new QValueList <ODeviceButton>; |
1205 | 1255 | ||
1206 | struct z_button * pz_buttons; | 1256 | struct z_button * pz_buttons; |
1207 | int buttoncount; | 1257 | int buttoncount; |
1208 | switch ( d-> m_model ) { | 1258 | switch ( d-> m_model ) { |
1209 | case Model_Zaurus_SLC700: | 1259 | case Model_Zaurus_SLC700: |
1210 | pz_buttons = z_buttons_c700; | 1260 | pz_buttons = z_buttons_c700; |
1211 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 1261 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
1212 | break; | 1262 | break; |
1213 | default: | 1263 | default: |
1214 | pz_buttons = z_buttons; | 1264 | pz_buttons = z_buttons; |
1215 | buttoncount = ARRAY_SIZE(z_buttons); | 1265 | buttoncount = ARRAY_SIZE(z_buttons); |
1216 | break; | 1266 | break; |
1217 | } | 1267 | } |
1218 | 1268 | ||
1219 | for ( int i = 0; i < buttoncount; i++ ) { | 1269 | for ( int i = 0; i < buttoncount; i++ ) { |
1220 | struct z_button *zb = pz_buttons + i; | 1270 | struct z_button *zb = pz_buttons + i; |
1221 | ODeviceButton b; | 1271 | ODeviceButton b; |
1222 | 1272 | ||
1223 | b. setKeycode ( zb-> code ); | 1273 | b. setKeycode ( zb-> code ); |
1224 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); | 1274 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); |
1225 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); | 1275 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); |
1226 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); | 1276 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); |
1227 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); | 1277 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); |
1228 | 1278 | ||
1229 | d-> m_buttons-> append ( b ); | 1279 | d-> m_buttons-> append ( b ); |
1230 | } | 1280 | } |
1231 | 1281 | ||
1232 | reloadButtonMapping ( ); | 1282 | reloadButtonMapping ( ); |
1233 | 1283 | ||
1234 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1284 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1235 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1285 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1236 | } | 1286 | } |
1237 | 1287 | ||
1238 | #include <unistd.h> | 1288 | #include <unistd.h> |
1239 | #include <fcntl.h> | 1289 | #include <fcntl.h> |
1240 | #include <sys/ioctl.h> | 1290 | #include <sys/ioctl.h> |
1241 | 1291 | ||
1242 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 1292 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
1243 | 1293 | ||
1244 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 1294 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
1245 | 1295 | ||
1246 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1296 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1247 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1297 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1248 | 1298 | ||
1249 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1299 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1250 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1300 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1251 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1301 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1252 | 1302 | ||
1253 | /* --- for SHARP_BUZZER device --- */ | 1303 | /* --- for SHARP_BUZZER device --- */ |
1254 | 1304 | ||
1255 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1305 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1256 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1306 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1257 | 1307 | ||
1258 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 1308 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
1259 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 1309 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
1260 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 1310 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
1261 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 1311 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
1262 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 1312 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
1263 | 1313 | ||
1264 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1314 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1265 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1315 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1266 | 1316 | ||
1267 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 1317 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
1268 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 1318 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
1269 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 1319 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
1270 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 1320 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
1271 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 1321 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
1272 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 1322 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
1273 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 1323 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
1274 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 1324 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
1275 | 1325 | ||
1276 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1326 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1277 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 1327 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
1278 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 1328 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
1279 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 1329 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
1280 | // | 1330 | // |
1281 | 1331 | ||
1282 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1332 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1283 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 1333 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
1284 | 1334 | ||
1285 | typedef struct sharp_led_status { | 1335 | typedef struct sharp_led_status { |
1286 | int which; /* select which LED status is wanted. */ | 1336 | int which; /* select which LED status is wanted. */ |
1287 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 1337 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
1288 | } sharp_led_status; | 1338 | } sharp_led_status; |
1289 | 1339 | ||
1290 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 1340 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
1291 | 1341 | ||
1292 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 1342 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
1293 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 1343 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
1294 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 1344 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
1295 | 1345 | ||
1296 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 1346 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
1297 | 1347 | ||
1298 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 1348 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
1299 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 1349 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
1300 | #define APM_EVT_POWER_BUTTON (1 << 0) | 1350 | #define APM_EVT_POWER_BUTTON (1 << 0) |
1301 | 1351 | ||
1302 | #define FL_IOCTL_STEP_CONTRAST 100 | 1352 | #define FL_IOCTL_STEP_CONTRAST 100 |
1303 | 1353 | ||
1304 | 1354 | ||
1305 | void Zaurus::buzzer ( int sound ) | 1355 | void Zaurus::buzzer ( int sound ) |
1306 | { | 1356 | { |
1307 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 1357 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
1308 | 1358 | ||
1309 | if ( fd >= 0 ) { | 1359 | if ( fd >= 0 ) { |
1310 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 1360 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
1311 | ::close ( fd ); | 1361 | ::close ( fd ); |
1312 | } | 1362 | } |
1313 | } | 1363 | } |
1314 | 1364 | ||
1315 | 1365 | ||
1316 | void Zaurus::alarmSound ( ) | 1366 | void Zaurus::alarmSound ( ) |
1317 | { | 1367 | { |
1318 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 1368 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
1319 | } | 1369 | } |
1320 | 1370 | ||
1321 | void Zaurus::touchSound ( ) | 1371 | void Zaurus::touchSound ( ) |
1322 | { | 1372 | { |
1323 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 1373 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
1324 | } | 1374 | } |
1325 | 1375 | ||
1326 | void Zaurus::keySound ( ) | 1376 | void Zaurus::keySound ( ) |
1327 | { | 1377 | { |
1328 | buzzer ( SHARP_BUZ_KEYSOUND ); | 1378 | buzzer ( SHARP_BUZ_KEYSOUND ); |
1329 | } | 1379 | } |
1330 | 1380 | ||
1331 | 1381 | ||
1332 | QValueList <OLed> Zaurus::ledList ( ) const | 1382 | QValueList <OLed> Zaurus::ledList ( ) const |
1333 | { | 1383 | { |
1334 | QValueList <OLed> vl; | 1384 | QValueList <OLed> vl; |
1335 | vl << Led_Mail; | 1385 | vl << Led_Mail; |
1336 | return vl; | 1386 | return vl; |
1337 | } | 1387 | } |
1338 | 1388 | ||
1339 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 1389 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
1340 | { | 1390 | { |
1341 | QValueList <OLedState> vl; | 1391 | QValueList <OLedState> vl; |
1342 | 1392 | ||
1343 | if ( l == Led_Mail ) | 1393 | if ( l == Led_Mail ) |
1344 | vl << Led_Off << Led_On << Led_BlinkSlow; | 1394 | vl << Led_Off << Led_On << Led_BlinkSlow; |
1345 | return vl; | 1395 | return vl; |
1346 | } | 1396 | } |
1347 | 1397 | ||
1348 | OLedState Zaurus::ledState ( OLed which ) const | 1398 | OLedState Zaurus::ledState ( OLed which ) const |
1349 | { | 1399 | { |
1350 | if ( which == Led_Mail ) | 1400 | if ( which == Led_Mail ) |
1351 | return m_leds [0]; | 1401 | return m_leds [0]; |
1352 | else | 1402 | else |
1353 | return Led_Off; | 1403 | return Led_Off; |
1354 | } | 1404 | } |
1355 | 1405 | ||
1356 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 1406 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
1357 | { | 1407 | { |
1358 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 1408 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
1359 | 1409 | ||
1360 | if ( which == Led_Mail ) { | 1410 | if ( which == Led_Mail ) { |
1361 | if ( fd >= 0 ) { | 1411 | if ( fd >= 0 ) { |
1362 | struct sharp_led_status leds; | 1412 | struct sharp_led_status leds; |
1363 | ::memset ( &leds, 0, sizeof( leds )); | 1413 | ::memset ( &leds, 0, sizeof( leds )); |
1364 | leds. which = SHARP_LED_MAIL_EXISTS; | 1414 | leds. which = SHARP_LED_MAIL_EXISTS; |
1365 | bool ok = true; | 1415 | bool ok = true; |
1366 | 1416 | ||
1367 | switch ( st ) { | 1417 | switch ( st ) { |
1368 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 1418 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
1369 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 1419 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
1370 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 1420 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
1371 | default : ok = false; | 1421 | default : ok = false; |
1372 | } | 1422 | } |
1373 | 1423 | ||
1374 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 1424 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
1375 | m_leds [0] = st; | 1425 | m_leds [0] = st; |
1376 | return true; | 1426 | return true; |
1377 | } | 1427 | } |
1378 | } | 1428 | } |
1379 | } | 1429 | } |
1380 | return false; | 1430 | return false; |
1381 | } | 1431 | } |
1382 | 1432 | ||
1383 | bool Zaurus::setSoftSuspend ( bool soft ) | 1433 | bool Zaurus::setSoftSuspend ( bool soft ) |
1384 | { | 1434 | { |
1385 | bool res = false; | 1435 | bool res = false; |
1386 | int fd; | 1436 | int fd; |
1387 | 1437 | ||
1388 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 1438 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
1389 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 1439 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
1390 | 1440 | ||
1391 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 1441 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
1392 | 1442 | ||
1393 | if ( sources >= 0 ) { | 1443 | if ( sources >= 0 ) { |
1394 | if ( soft ) | 1444 | if ( soft ) |
1395 | sources &= ~APM_EVT_POWER_BUTTON; | 1445 | sources &= ~APM_EVT_POWER_BUTTON; |
1396 | else | 1446 | else |
1397 | sources |= APM_EVT_POWER_BUTTON; | 1447 | sources |= APM_EVT_POWER_BUTTON; |
1398 | 1448 | ||
1399 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 1449 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
1400 | res = true; | 1450 | res = true; |
1401 | else | 1451 | else |
1402 | perror ( "APM_IOCGEVTSRC" ); | 1452 | perror ( "APM_IOCGEVTSRC" ); |
1403 | } | 1453 | } |
1404 | else | 1454 | else |
1405 | perror ( "APM_IOCGEVTSRC" ); | 1455 | perror ( "APM_IOCGEVTSRC" ); |
1406 | 1456 | ||
1407 | ::close ( fd ); | 1457 | ::close ( fd ); |
1408 | } | 1458 | } |
1409 | else | 1459 | else |
1410 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 1460 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
1411 | 1461 | ||
1412 | return res; | 1462 | return res; |
1413 | } | 1463 | } |
1414 | 1464 | ||
1415 | 1465 | ||
1416 | bool Zaurus::setDisplayBrightness ( int bright ) | 1466 | bool Zaurus::setDisplayBrightness ( int bright ) |
1417 | { | 1467 | { |
1418 | bool res = false; | 1468 | bool res = false; |
1419 | int fd; | 1469 | int fd; |
1420 | 1470 | ||
1421 | if ( bright > 255 ) | 1471 | if ( bright > 255 ) |
1422 | bright = 255; | 1472 | bright = 255; |
1423 | if ( bright < 0 ) | 1473 | if ( bright < 0 ) |
1424 | bright = 0; | 1474 | bright = 0; |
1425 | 1475 | ||
1426 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 1476 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
1427 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 1477 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
1428 | if ( bright && !bl ) | 1478 | if ( bright && !bl ) |
1429 | bl = 1; | 1479 | bl = 1; |
1430 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 1480 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
1431 | ::close ( fd ); | 1481 | ::close ( fd ); |
1432 | } | 1482 | } |
1433 | return res; | 1483 | return res; |
1434 | } | 1484 | } |
1435 | 1485 | ||
1436 | 1486 | ||
1437 | int Zaurus::displayBrightnessResolution ( ) const | 1487 | int Zaurus::displayBrightnessResolution ( ) const |
1438 | { | 1488 | { |
1439 | return 5; | 1489 | return 5; |
1440 | } | 1490 | } |
1441 | 1491 | ||
1442 | 1492 | ||
1493 | /************************************************** | ||
1494 | * | ||
1495 | * SIMpad | ||
1496 | * | ||
1497 | **************************************************/ | ||
1498 | |||
1499 | void SIMpad::init ( ) | ||
1500 | { | ||
1501 | d-> m_vendorstr = "SIEMENS"; | ||
1502 | d-> m_vendor = Vendor_SIEMENS; | ||
1503 | |||
1504 | QFile f ( "/proc/hal/model" ); | ||
1505 | |||
1506 | //TODO Implement model checking | ||
1507 | //FIXME For now we assume an SL4 | ||
1508 | |||
1509 | d-> m_modelstr = "SL4"; | ||
1510 | d-> m_model = Model_SIMpad_SL4; | ||
1511 | |||
1512 | switch ( d-> m_model ) { | ||
1513 | default: | ||
1514 | d-> m_rotation = Rot270; | ||
1515 | break; | ||
1516 | } | ||
1517 | |||
1518 | f. setName ( "/etc/familiar-version" ); | ||
1519 | if ( f. open ( IO_ReadOnly )) { | ||
1520 | d-> m_systemstr = "Familiar"; | ||
1521 | d-> m_system = System_Familiar; | ||
1522 | |||
1523 | QTextStream ts ( &f ); | ||
1524 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | ||
1525 | |||
1526 | f. close ( ); | ||
1527 | } else { | ||
1528 | f. setName ( "/etc/oz_version" ); | ||
1529 | |||
1530 | if ( f. open ( IO_ReadOnly )) { | ||
1531 | d-> m_systemstr = "OpenEmbedded/SIMpad"; | ||
1532 | d-> m_system = System_OpenZaurus; | ||
1533 | |||
1534 | QTextStream ts ( &f ); | ||
1535 | ts.setDevice ( &f ); | ||
1536 | d-> m_sysverstr = ts. readLine ( ); | ||
1537 | f. close ( ); | ||
1538 | } | ||
1539 | } | ||
1540 | |||
1541 | m_leds [0] = m_leds [1] = Led_Off; | ||
1542 | |||
1543 | m_power_timer = 0; | ||
1544 | |||
1545 | } | ||
1546 | |||
1547 | void SIMpad::initButtons ( ) | ||
1548 | { | ||
1549 | if ( d-> m_buttons ) | ||
1550 | return; | ||
1551 | |||
1552 | if ( isQWS( ) ) | ||
1553 | QWSServer::setKeyboardFilter ( this ); | ||
1554 | |||
1555 | d-> m_buttons = new QValueList <ODeviceButton>; | ||
1556 | |||
1557 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { | ||
1558 | s_button *sb = simpad_buttons + i; | ||
1559 | ODeviceButton b; | ||
1560 | |||
1561 | if (( sb-> model & d-> m_model ) == d-> m_model ) { | ||
1562 | b. setKeycode ( sb-> code ); | ||
1563 | b. setUserText ( QObject::tr ( "Button", sb-> utext )); | ||
1564 | b. setPixmap ( Resource::loadPixmap ( sb-> pix )); | ||
1565 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); | ||
1566 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); | ||
1567 | |||
1568 | d-> m_buttons-> append ( b ); | ||
1569 | } | ||
1570 | } | ||
1571 | reloadButtonMapping ( ); | ||
1572 | |||
1573 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | ||
1574 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | ||
1575 | } | ||
1576 | |||
1577 | // SIMpad boardcontrol register CS3 | ||
1578 | #define SIMPAD_BOARDCONTROL "/proc/CS3" | ||
1579 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA | ||
1580 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA | ||
1581 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's | ||
1582 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V | ||
1583 | #define SIMPAD_DISPLAY_ON 0x0010 | ||
1584 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 | ||
1585 | #define SIMPAD_MQ_RESET 0x0040 | ||
1586 | #define SIMPAD_PCMCIA_RESET 0x0080 | ||
1587 | #define SIMPAD_DECT_POWER_ON 0x0100 | ||
1588 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave | ||
1589 | #define SIMPAD_RS232_ON 0x0400 | ||
1590 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave | ||
1591 | #define SIMPAD_LED2_ON 0x1000 | ||
1592 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode | ||
1593 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit | ||
1594 | #define SIMPAD_RESET_SIMCARD 0x8000 | ||
1595 | |||
1596 | //SIMpad touchscreen backlight strength control | ||
1597 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" | ||
1598 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 | ||
1599 | |||
1600 | QValueList <OLed> SIMpad::ledList ( ) const | ||
1601 | { | ||
1602 | QValueList <OLed> vl; | ||
1603 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? | ||
1604 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway | ||
1605 | return vl; | ||
1606 | } | ||
1607 | |||
1608 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const | ||
1609 | { | ||
1610 | QValueList <OLedState> vl; | ||
1611 | |||
1612 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? | ||
1613 | vl << Led_Off << Led_On; | ||
1614 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway | ||
1615 | //vl << Led_Off; | ||
1616 | return vl; | ||
1617 | } | ||
1618 | |||
1619 | OLedState SIMpad::ledState ( OLed l ) const | ||
1620 | { | ||
1621 | switch ( l ) { | ||
1622 | case Led_Power: | ||
1623 | return m_leds [0]; | ||
1624 | //case Led_Mail: | ||
1625 | //return m_leds [1]; | ||
1626 | default: | ||
1627 | return Led_Off; | ||
1628 | } | ||
1629 | } | ||
1630 | |||
1631 | bool SIMpad::setLedState ( OLed l, OLedState st ) | ||
1632 | { | ||
1633 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); | ||
1634 | |||
1635 | if ( l == Led_Power ) { | ||
1636 | if ( fd >= 0 ) { | ||
1637 | LED_IN leds; | ||
1638 | ::memset ( &leds, 0, sizeof( leds )); | ||
1639 | leds. TotalTime = 0; | ||
1640 | leds. OnTime = 0; | ||
1641 | leds. OffTime = 1; | ||
1642 | leds. OffOnBlink = 2; | ||
1643 | |||
1644 | switch ( st ) { | ||
1645 | case Led_Off : leds. OffOnBlink = 0; break; | ||
1646 | case Led_On : leds. OffOnBlink = 1; break; | ||
1647 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | ||
1648 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | ||
1649 | } | ||
1650 | |||
1651 | { | ||
1652 | /*TODO Implement this like that: | ||
1653 | read from CS3 | ||
1654 | && with SIMPAD_LED2_ON | ||
1655 | write to CS3 */ | ||
1656 | m_leds [0] = st; | ||
1657 | return true; | ||
1658 | } | ||
1659 | } | ||
1660 | } | ||
1661 | return false; | ||
1662 | } | ||
1663 | |||
1664 | |||
1665 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | ||
1666 | { | ||
1667 | //TODO | ||
1668 | return false; | ||
1669 | } | ||
1670 | |||
1671 | void SIMpad::timerEvent ( QTimerEvent * ) | ||
1672 | { | ||
1673 | killTimer ( m_power_timer ); | ||
1674 | m_power_timer = 0; | ||
1675 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | ||
1676 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | ||
1677 | } | ||
1678 | |||
1679 | |||
1680 | void SIMpad::alarmSound ( ) | ||
1681 | { | ||
1682 | #ifndef QT_NO_SOUND | ||
1683 | static Sound snd ( "alarm" ); | ||
1684 | int fd; | ||
1685 | int vol; | ||
1686 | bool vol_reset = false; | ||
1687 | |||
1688 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | ||
1689 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | ||
1690 | Config cfg ( "qpe" ); | ||
1691 | cfg. setGroup ( "Volume" ); | ||
1692 | |||
1693 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | ||
1694 | if ( volalarm < 0 ) | ||
1695 | volalarm = 0; | ||
1696 | else if ( volalarm > 100 ) | ||
1697 | volalarm = 100; | ||
1698 | volalarm |= ( volalarm << 8 ); | ||
1699 | |||
1700 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | ||
1701 | vol_reset = true; | ||
1702 | } | ||
1703 | } | ||
1704 | |||
1705 | snd. play ( ); | ||
1706 | while ( !snd. isFinished ( )) | ||
1707 | qApp-> processEvents ( ); | ||
1708 | |||
1709 | if ( fd >= 0 ) { | ||
1710 | if ( vol_reset ) | ||
1711 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | ||
1712 | ::close ( fd ); | ||
1713 | } | ||
1714 | #endif | ||
1715 | } | ||
1716 | |||
1717 | |||
1718 | bool SIMpad::setSoftSuspend ( bool soft ) | ||
1719 | { | ||
1720 | //TODO | ||
1721 | return false; | ||
1722 | } | ||
1723 | |||
1724 | |||
1725 | bool SIMpad::setDisplayBrightness ( int bright ) | ||
1726 | { | ||
1727 | bool res = false; | ||
1728 | int fd; | ||
1729 | |||
1730 | if ( bright > 255 ) | ||
1731 | bright = 255; | ||
1732 | if ( bright < 0 ) | ||
1733 | bright = 0; | ||
1734 | |||
1735 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | ||
1736 | int value = 255 - bright; | ||
1737 | const int mask = SIMPAD_BACKLIGHT_MASK; | ||
1738 | value = value << 8; | ||
1739 | value += mask; | ||
1740 | char writeCommand[100]; | ||
1741 | const int count = sprintf( writeCommand, "0x%x\n", value ); | ||
1742 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | ||
1743 | ::close ( fd ); | ||
1744 | } | ||
1745 | return res; | ||
1746 | } | ||
1747 | |||
1748 | |||
1749 | int SIMpad::displayBrightnessResolution ( ) const | ||
1750 | { | ||
1751 | switch ( model ( )) { | ||
1752 | case Model_SIMpad_CL4: | ||
1753 | case Model_SIMpad_SL4: | ||
1754 | case Model_SIMpad_SLC: | ||
1755 | case Model_SIMpad_TSinus: | ||
1756 | return 255; //TODO find out if this is save | ||
1757 | |||
1758 | default: | ||
1759 | return 2; | ||
1760 | } | ||
1761 | } | ||
1762 | |||
diff --git a/libopie/odevice.h b/libopie/odevice.h index 0c55ea0..dcdd4a8 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -1,229 +1,238 @@ | |||
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 | #ifndef _LIBOPIE_ODEVICE_H_ | 20 | #ifndef _LIBOPIE_ODEVICE_H_ |
21 | #define _LIBOPIE_ODEVICE_H_ | 21 | #define _LIBOPIE_ODEVICE_H_ |
22 | 22 | ||
23 | #include <qobject.h> | 23 | #include <qobject.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qnamespace.h> | 25 | #include <qnamespace.h> |
26 | 26 | ||
27 | #include <opie/odevicebutton.h> | 27 | #include <opie/odevicebutton.h> |
28 | 28 | ||
29 | #include <qpe/qpeapplication.h> /* for Transformation enum.. */ | 29 | #include <qpe/qpeapplication.h> /* for Transformation enum.. */ |
30 | 30 | ||
31 | class ODeviceData; | 31 | class ODeviceData; |
32 | 32 | ||
33 | namespace Opie { | 33 | namespace Opie { |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * The available devices | 36 | * The available devices |
37 | */ | 37 | */ |
38 | enum OModel { | 38 | enum OModel { |
39 | Model_Unknown, // = 0 | 39 | Model_Unknown, // = 0 |
40 | 40 | ||
41 | Model_Series_Mask = 0xff000000, | 41 | Model_Series_Mask = 0xff000000, |
42 | 42 | ||
43 | Model_iPAQ = ( 1 << 24 ), | 43 | Model_iPAQ = ( 1 << 24 ), |
44 | 44 | ||
45 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), | 45 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), |
46 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), | 46 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), |
47 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), | 47 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), |
48 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), | 48 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), |
49 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), | 49 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), |
50 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), | 50 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), |
51 | 51 | ||
52 | Model_Zaurus = ( 2 << 24 ), | 52 | Model_Zaurus = ( 2 << 24 ), |
53 | 53 | ||
54 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), | 54 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), |
55 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), | 55 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), |
56 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), | 56 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), |
57 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), | 57 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), |
58 | Model_Zaurus_SLC700 = ( Model_Zaurus | 0x000005 ), | 58 | Model_Zaurus_SLC700 = ( Model_Zaurus | 0x000005 ), |
59 | |||
60 | Model_SIMpad = ( 3 << 24 ), | ||
61 | |||
62 | Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), | ||
63 | Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), | ||
64 | Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), | ||
65 | Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), | ||
66 | Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), | ||
59 | }; | 67 | }; |
60 | 68 | ||
61 | /** | 69 | /** |
62 | * The vendor of the device | 70 | * The vendor of the device |
63 | */ | 71 | */ |
64 | enum OVendor { | 72 | enum OVendor { |
65 | Vendor_Unknown, | 73 | Vendor_Unknown, |
66 | 74 | ||
67 | Vendor_HP, | 75 | Vendor_HP, |
68 | Vendor_Sharp | 76 | Vendor_Sharp, |
77 | Vendor_SIEMENS, | ||
69 | }; | 78 | }; |
70 | 79 | ||
71 | /** | 80 | /** |
72 | * The System used | 81 | * The System used |
73 | */ | 82 | */ |
74 | enum OSystem { | 83 | enum OSystem { |
75 | System_Unknown, | 84 | System_Unknown, |
76 | 85 | ||
77 | System_Familiar, | 86 | System_Familiar, |
78 | System_Zaurus, | 87 | System_Zaurus, |
79 | System_OpenZaurus | 88 | System_OpenZaurus |
80 | }; | 89 | }; |
81 | 90 | ||
82 | enum OLedState { | 91 | enum OLedState { |
83 | Led_Off, | 92 | Led_Off, |
84 | Led_On, | 93 | Led_On, |
85 | Led_BlinkSlow, | 94 | Led_BlinkSlow, |
86 | Led_BlinkFast | 95 | Led_BlinkFast |
87 | }; | 96 | }; |
88 | 97 | ||
89 | enum OLed { | 98 | enum OLed { |
90 | Led_Mail, | 99 | Led_Mail, |
91 | Led_Power, | 100 | Led_Power, |
92 | Led_BlueTooth | 101 | Led_BlueTooth |
93 | }; | 102 | }; |
94 | 103 | ||
95 | enum OHardKey { | 104 | enum OHardKey { |
96 | HardKey_Datebook = Qt::Key_F9, | 105 | HardKey_Datebook = Qt::Key_F9, |
97 | HardKey_Contacts = Qt::Key_F10, | 106 | HardKey_Contacts = Qt::Key_F10, |
98 | HardKey_Menu = Qt::Key_F11, | 107 | HardKey_Menu = Qt::Key_F11, |
99 | HardKey_Home = Qt::Key_F12, | 108 | HardKey_Home = Qt::Key_F12, |
100 | HardKey_Mail = Qt::Key_F13, | 109 | HardKey_Mail = Qt::Key_F13, |
101 | HardKey_Record = Qt::Key_F24, | 110 | HardKey_Record = Qt::Key_F24, |
102 | HardKey_Suspend = Qt::Key_F34, | 111 | HardKey_Suspend = Qt::Key_F34, |
103 | HardKey_Backlight = Qt::Key_F35, | 112 | HardKey_Backlight = Qt::Key_F35, |
104 | }; | 113 | }; |
105 | 114 | ||
106 | enum ODirection { | 115 | enum ODirection { |
107 | CW = 0, | 116 | CW = 0, |
108 | CCW = 1, | 117 | CCW = 1, |
109 | Flip = 2, | 118 | Flip = 2, |
110 | }; | 119 | }; |
111 | 120 | ||
112 | /** | 121 | /** |
113 | * A singleton which gives informations about device specefic option | 122 | * A singleton which gives informations about device specefic option |
114 | * like the Hardware used, LEDs, the Base Distribution and | 123 | * like the Hardware used, LEDs, the Base Distribution and |
115 | * hardware key mappings. | 124 | * hardware key mappings. |
116 | * | 125 | * |
117 | * | 126 | * |
118 | * @short A small class for device specefic options | 127 | * @short A small class for device specefic options |
119 | * @see QObject | 128 | * @see QObject |
120 | * @author Robert Griebl | 129 | * @author Robert Griebl |
121 | * @version 1.0 | 130 | * @version 1.0 |
122 | */ | 131 | */ |
123 | class ODevice : public QObject { | 132 | class ODevice : public QObject { |
124 | Q_OBJECT | 133 | Q_OBJECT |
125 | 134 | ||
126 | private: | 135 | private: |
127 | /* disable copy */ | 136 | /* disable copy */ |
128 | ODevice ( const ODevice & ); | 137 | ODevice ( const ODevice & ); |
129 | 138 | ||
130 | protected: | 139 | protected: |
131 | ODevice ( ); | 140 | ODevice ( ); |
132 | virtual void init ( ); | 141 | virtual void init ( ); |
133 | virtual void initButtons ( ); | 142 | virtual void initButtons ( ); |
134 | 143 | ||
135 | ODeviceData *d; | 144 | ODeviceData *d; |
136 | 145 | ||
137 | public: | 146 | public: |
138 | // sandman do we want to allow destructions? -zecke? | 147 | // sandman do we want to allow destructions? -zecke? |
139 | virtual ~ODevice ( ); | 148 | virtual ~ODevice ( ); |
140 | 149 | ||
141 | 150 | ||
142 | static ODevice *inst ( ); | 151 | static ODevice *inst ( ); |
143 | 152 | ||
144 | // information | 153 | // information |
145 | 154 | ||
146 | QString modelString ( ) const; | 155 | QString modelString ( ) const; |
147 | OModel model ( ) const; | 156 | OModel model ( ) const; |
148 | inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } | 157 | inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } |
149 | 158 | ||
150 | QString vendorString ( ) const; | 159 | QString vendorString ( ) const; |
151 | OVendor vendor ( ) const; | 160 | OVendor vendor ( ) const; |
152 | 161 | ||
153 | QString systemString ( ) const; | 162 | QString systemString ( ) const; |
154 | OSystem system ( ) const; | 163 | OSystem system ( ) const; |
155 | 164 | ||
156 | QString systemVersionString ( ) const; | 165 | QString systemVersionString ( ) const; |
157 | 166 | ||
158 | Transformation rotation ( ) const; | 167 | Transformation rotation ( ) const; |
159 | ODirection direction ( ) const; | 168 | ODirection direction ( ) const; |
160 | 169 | ||
161 | // system | 170 | // system |
162 | 171 | ||
163 | virtual bool setSoftSuspend ( bool on ); | 172 | virtual bool setSoftSuspend ( bool on ); |
164 | virtual bool suspend ( ); | 173 | virtual bool suspend ( ); |
165 | 174 | ||
166 | virtual bool setDisplayStatus ( bool on ); | 175 | virtual bool setDisplayStatus ( bool on ); |
167 | virtual bool setDisplayBrightness ( int brightness ); | 176 | virtual bool setDisplayBrightness ( int brightness ); |
168 | virtual int displayBrightnessResolution ( ) const; | 177 | virtual int displayBrightnessResolution ( ) const; |
169 | 178 | ||
170 | // input / output | 179 | // input / output |
171 | //FIXME playAlarmSound and al might be better -zecke | 180 | //FIXME playAlarmSound and al might be better -zecke |
172 | virtual void alarmSound ( ); | 181 | virtual void alarmSound ( ); |
173 | virtual void keySound ( ); | 182 | virtual void keySound ( ); |
174 | virtual void touchSound ( ); | 183 | virtual void touchSound ( ); |
175 | 184 | ||
176 | virtual QValueList <OLed> ledList ( ) const; | 185 | virtual QValueList <OLed> ledList ( ) const; |
177 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 186 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
178 | virtual OLedState ledState ( OLed led ) const; | 187 | virtual OLedState ledState ( OLed led ) const; |
179 | virtual bool setLedState ( OLed led, OLedState st ); | 188 | virtual bool setLedState ( OLed led, OLedState st ); |
180 | 189 | ||
181 | virtual bool hasLightSensor ( ) const; | 190 | virtual bool hasLightSensor ( ) const; |
182 | virtual int readLightSensor ( ); | 191 | virtual int readLightSensor ( ); |
183 | virtual int lightSensorResolution ( ) const; | 192 | virtual int lightSensorResolution ( ) const; |
184 | 193 | ||
185 | /** | 194 | /** |
186 | * Returns the available buttons on this device. The number and location | 195 | * Returns the available buttons on this device. The number and location |
187 | * of buttons will vary depending on the device. Button numbers will be assigned | 196 | * of buttons will vary depending on the device. Button numbers will be assigned |
188 | * by the device manufacturer and will be from most preferred button to least preffered | 197 | * by the device manufacturer and will be from most preferred button to least preffered |
189 | * button. Note that this list only contains "user mappable" buttons. | 198 | * button. Note that this list only contains "user mappable" buttons. |
190 | */ | 199 | */ |
191 | const QValueList<ODeviceButton> &buttons ( ); | 200 | const QValueList<ODeviceButton> &buttons ( ); |
192 | 201 | ||
193 | /** | 202 | /** |
194 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it | 203 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it |
195 | * returns 0L | 204 | * returns 0L |
196 | */ | 205 | */ |
197 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); | 206 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); |
198 | 207 | ||
199 | /** | 208 | /** |
200 | * Reassigns the pressed action for \a button. To return to the factory | 209 | * Reassigns the pressed action for \a button. To return to the factory |
201 | * default pass an empty string as \a qcopMessage. | 210 | * default pass an empty string as \a qcopMessage. |
202 | */ | 211 | */ |
203 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); | 212 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); |
204 | 213 | ||
205 | /** | 214 | /** |
206 | * Reassigns the held action for \a button. To return to the factory | 215 | * Reassigns the held action for \a button. To return to the factory |
207 | * default pass an empty string as \a qcopMessage. | 216 | * default pass an empty string as \a qcopMessage. |
208 | */ | 217 | */ |
209 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); | 218 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); |
210 | 219 | ||
211 | /** | 220 | /** |
212 | * How long (in ms) you have to press a button for a "hold" action | 221 | * How long (in ms) you have to press a button for a "hold" action |
213 | */ | 222 | */ |
214 | uint buttonHoldTime ( ) const; | 223 | uint buttonHoldTime ( ) const; |
215 | 224 | ||
216 | signals: | 225 | signals: |
217 | void buttonMappingChanged ( ); | 226 | void buttonMappingChanged ( ); |
218 | 227 | ||
219 | private slots: | 228 | private slots: |
220 | void systemMessage ( const QCString &, const QByteArray & ); | 229 | void systemMessage ( const QCString &, const QByteArray & ); |
221 | 230 | ||
222 | protected: | 231 | protected: |
223 | void reloadButtonMapping ( ); | 232 | void reloadButtonMapping ( ); |
224 | }; | 233 | }; |
225 | 234 | ||
226 | } | 235 | } |
227 | 236 | ||
228 | #endif | 237 | #endif |
229 | 238 | ||