author | kergoth <kergoth> | 2003-04-18 21:54:43 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-04-18 21:54:43 (UTC) |
commit | d0852e67c15c5a973b7bc7f7bee238a6fd00dee6 (patch) (unidiff) | |
tree | 68acc72ac204045b2492693ca668ece78e5f3a2c | |
parent | 1cdd9c974e621f6992ddc6dfccbc815baebd19ee (diff) | |
download | opie-d0852e67c15c5a973b7bc7f7bee238a6fd00dee6.zip opie-d0852e67c15c5a973b7bc7f7bee238a6fd00dee6.tar.gz opie-d0852e67c15c5a973b7bc7f7bee238a6fd00dee6.tar.bz2 |
Add rotation direction to ODevice, to ensure the default is appropriate for the hardware in question.
-rw-r--r-- | libopie/odevice.cpp | 10 | ||||
-rw-r--r-- | libopie/odevice.h | 7 |
2 files changed, 17 insertions, 0 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 0e1c0dd..29c8ad2 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1,1240 +1,1250 @@ | |||
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 | 42 | ||
43 | // _IO and friends are only defined in kernel headers ... | 43 | // _IO and friends are only defined in kernel headers ... |
44 | 44 | ||
45 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 45 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
46 | 46 | ||
47 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 47 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
48 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 48 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
49 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 49 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
50 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 50 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
51 | 51 | ||
52 | using namespace Opie; | 52 | using namespace Opie; |
53 | 53 | ||
54 | class ODeviceData { | 54 | class ODeviceData { |
55 | public: | 55 | public: |
56 | bool m_qwsserver : 1; | 56 | bool m_qwsserver : 1; |
57 | 57 | ||
58 | QString m_vendorstr; | 58 | QString m_vendorstr; |
59 | OVendor m_vendor; | 59 | OVendor m_vendor; |
60 | 60 | ||
61 | QString m_modelstr; | 61 | QString m_modelstr; |
62 | OModel m_model; | 62 | OModel m_model; |
63 | 63 | ||
64 | QString m_systemstr; | 64 | QString m_systemstr; |
65 | OSystem m_system; | 65 | OSystem m_system; |
66 | 66 | ||
67 | QString m_sysverstr; | 67 | QString m_sysverstr; |
68 | 68 | ||
69 | Transformation m_rotation; | 69 | Transformation m_rotation; |
70 | ODirection m_direction; | ||
70 | 71 | ||
71 | QValueList <ODeviceButton> *m_buttons; | 72 | QValueList <ODeviceButton> *m_buttons; |
72 | uint m_holdtime; | 73 | uint m_holdtime; |
73 | }; | 74 | }; |
74 | 75 | ||
75 | 76 | ||
76 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { | 77 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { |
77 | protected: | 78 | protected: |
78 | virtual void init ( ); | 79 | virtual void init ( ); |
79 | virtual void initButtons ( ); | 80 | virtual void initButtons ( ); |
80 | 81 | ||
81 | public: | 82 | public: |
82 | virtual bool setSoftSuspend ( bool soft ); | 83 | virtual bool setSoftSuspend ( bool soft ); |
83 | 84 | ||
84 | virtual bool setDisplayBrightness ( int b ); | 85 | virtual bool setDisplayBrightness ( int b ); |
85 | virtual int displayBrightnessResolution ( ) const; | 86 | virtual int displayBrightnessResolution ( ) const; |
86 | 87 | ||
87 | virtual void alarmSound ( ); | 88 | virtual void alarmSound ( ); |
88 | 89 | ||
89 | virtual QValueList <OLed> ledList ( ) const; | 90 | virtual QValueList <OLed> ledList ( ) const; |
90 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 91 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
91 | virtual OLedState ledState ( OLed led ) const; | 92 | virtual OLedState ledState ( OLed led ) const; |
92 | virtual bool setLedState ( OLed led, OLedState st ); | 93 | virtual bool setLedState ( OLed led, OLedState st ); |
93 | 94 | ||
94 | virtual bool hasLightSensor ( ) const; | 95 | virtual bool hasLightSensor ( ) const; |
95 | virtual int readLightSensor ( ); | 96 | virtual int readLightSensor ( ); |
96 | virtual int lightSensorResolution ( ) const; | 97 | virtual int lightSensorResolution ( ) const; |
97 | 98 | ||
98 | protected: | 99 | protected: |
99 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 100 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
100 | virtual void timerEvent ( QTimerEvent *te ); | 101 | virtual void timerEvent ( QTimerEvent *te ); |
101 | 102 | ||
102 | int m_power_timer; | 103 | int m_power_timer; |
103 | 104 | ||
104 | OLedState m_leds [2]; | 105 | OLedState m_leds [2]; |
105 | }; | 106 | }; |
106 | 107 | ||
107 | class Zaurus : public ODevice { | 108 | class Zaurus : public ODevice { |
108 | protected: | 109 | protected: |
109 | virtual void init ( ); | 110 | virtual void init ( ); |
110 | virtual void initButtons ( ); | 111 | virtual void initButtons ( ); |
111 | 112 | ||
112 | public: | 113 | public: |
113 | virtual bool setSoftSuspend ( bool soft ); | 114 | virtual bool setSoftSuspend ( bool soft ); |
114 | 115 | ||
115 | virtual bool setDisplayBrightness ( int b ); | 116 | virtual bool setDisplayBrightness ( int b ); |
116 | virtual int displayBrightnessResolution ( ) const; | 117 | virtual int displayBrightnessResolution ( ) const; |
117 | 118 | ||
118 | virtual void alarmSound ( ); | 119 | virtual void alarmSound ( ); |
119 | virtual void keySound ( ); | 120 | virtual void keySound ( ); |
120 | virtual void touchSound ( ); | 121 | virtual void touchSound ( ); |
121 | 122 | ||
122 | virtual QValueList <OLed> ledList ( ) const; | 123 | virtual QValueList <OLed> ledList ( ) const; |
123 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 124 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
124 | virtual OLedState ledState ( OLed led ) const; | 125 | virtual OLedState ledState ( OLed led ) const; |
125 | virtual bool setLedState ( OLed led, OLedState st ); | 126 | virtual bool setLedState ( OLed led, OLedState st ); |
126 | 127 | ||
127 | protected: | 128 | protected: |
128 | virtual void buzzer ( int snd ); | 129 | virtual void buzzer ( int snd ); |
129 | 130 | ||
130 | OLedState m_leds [1]; | 131 | OLedState m_leds [1]; |
131 | }; | 132 | }; |
132 | 133 | ||
133 | 134 | ||
134 | struct i_button { | 135 | struct i_button { |
135 | uint model; | 136 | uint model; |
136 | Qt::Key code; | 137 | Qt::Key code; |
137 | char *utext; | 138 | char *utext; |
138 | char *pix; | 139 | char *pix; |
139 | char *fpressedservice; | 140 | char *fpressedservice; |
140 | char *fpressedaction; | 141 | char *fpressedaction; |
141 | char *fheldservice; | 142 | char *fheldservice; |
142 | char *fheldaction; | 143 | char *fheldaction; |
143 | } ipaq_buttons [] = { | 144 | } ipaq_buttons [] = { |
144 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 145 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
145 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 146 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
146 | "devicebuttons/ipaq_calendar", | 147 | "devicebuttons/ipaq_calendar", |
147 | "datebook", "nextView()", | 148 | "datebook", "nextView()", |
148 | "today", "raise()" }, | 149 | "today", "raise()" }, |
149 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 150 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
150 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 151 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
151 | "devicebuttons/ipaq_contact", | 152 | "devicebuttons/ipaq_contact", |
152 | "addressbook", "raise()", | 153 | "addressbook", "raise()", |
153 | "addressbook", "beamBusinessCard()" }, | 154 | "addressbook", "beamBusinessCard()" }, |
154 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, | 155 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, |
155 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 156 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
156 | "devicebuttons/ipaq_menu", | 157 | "devicebuttons/ipaq_menu", |
157 | "QPE/TaskBar", "toggleMenu()", | 158 | "QPE/TaskBar", "toggleMenu()", |
158 | "QPE/TaskBar", "toggleStartMenu()" }, | 159 | "QPE/TaskBar", "toggleStartMenu()" }, |
159 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 160 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
160 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 161 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
161 | "devicebuttons/ipaq_mail", | 162 | "devicebuttons/ipaq_mail", |
162 | "mail", "raise()", | 163 | "mail", "raise()", |
163 | "mail", "newMail()" }, | 164 | "mail", "newMail()" }, |
164 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 165 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
165 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 166 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
166 | "devicebuttons/ipaq_home", | 167 | "devicebuttons/ipaq_home", |
167 | "QPE/Launcher", "home()", | 168 | "QPE/Launcher", "home()", |
168 | "buttonsettings", "raise()" }, | 169 | "buttonsettings", "raise()" }, |
169 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 170 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
170 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), | 171 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), |
171 | "devicebuttons/ipaq_record", | 172 | "devicebuttons/ipaq_record", |
172 | "QPE/VMemo", "toggleRecord()", | 173 | "QPE/VMemo", "toggleRecord()", |
173 | "sound", "raise()" }, | 174 | "sound", "raise()" }, |
174 | }; | 175 | }; |
175 | 176 | ||
176 | struct z_button { | 177 | struct z_button { |
177 | Qt::Key code; | 178 | Qt::Key code; |
178 | char *utext; | 179 | char *utext; |
179 | char *pix; | 180 | char *pix; |
180 | char *fpressedservice; | 181 | char *fpressedservice; |
181 | char *fpressedaction; | 182 | char *fpressedaction; |
182 | char *fheldservice; | 183 | char *fheldservice; |
183 | char *fheldaction; | 184 | char *fheldaction; |
184 | } z_buttons [] = { | 185 | } z_buttons [] = { |
185 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 186 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
186 | "devicebuttons/z_calendar", | 187 | "devicebuttons/z_calendar", |
187 | "datebook", "nextView()", | 188 | "datebook", "nextView()", |
188 | "today", "raise()" }, | 189 | "today", "raise()" }, |
189 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 190 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
190 | "devicebuttons/z_contact", | 191 | "devicebuttons/z_contact", |
191 | "addressbook", "raise()", | 192 | "addressbook", "raise()", |
192 | "addressbook", "beamBusinessCard()" }, | 193 | "addressbook", "beamBusinessCard()" }, |
193 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 194 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
194 | "devicebuttons/z_home", | 195 | "devicebuttons/z_home", |
195 | "QPE/Launcher", "home()", | 196 | "QPE/Launcher", "home()", |
196 | "buttonsettings", "raise()" }, | 197 | "buttonsettings", "raise()" }, |
197 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 198 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
198 | "devicebuttons/z_menu", | 199 | "devicebuttons/z_menu", |
199 | "QPE/TaskBar", "toggleMenu()", | 200 | "QPE/TaskBar", "toggleMenu()", |
200 | "QPE/TaskBar", "toggleStartMenu()" }, | 201 | "QPE/TaskBar", "toggleStartMenu()" }, |
201 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 202 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
202 | "devicebuttons/z_mail", | 203 | "devicebuttons/z_mail", |
203 | "mail", "raise()", | 204 | "mail", "raise()", |
204 | "mail", "newMail()" }, | 205 | "mail", "newMail()" }, |
205 | }; | 206 | }; |
206 | 207 | ||
207 | static QCString makeChannel ( const char *str ) | 208 | static QCString makeChannel ( const char *str ) |
208 | { | 209 | { |
209 | if ( str && !::strchr ( str, '/' )) | 210 | if ( str && !::strchr ( str, '/' )) |
210 | return QCString ( "QPE/Application/" ) + str; | 211 | return QCString ( "QPE/Application/" ) + str; |
211 | else | 212 | else |
212 | return str; | 213 | return str; |
213 | } | 214 | } |
214 | 215 | ||
215 | 216 | ||
216 | 217 | ||
217 | 218 | ||
218 | ODevice *ODevice::inst ( ) | 219 | ODevice *ODevice::inst ( ) |
219 | { | 220 | { |
220 | static ODevice *dev = 0; | 221 | static ODevice *dev = 0; |
221 | 222 | ||
222 | if ( !dev ) { | 223 | if ( !dev ) { |
223 | if ( QFile::exists ( "/proc/hal/model" )) | 224 | if ( QFile::exists ( "/proc/hal/model" )) |
224 | dev = new iPAQ ( ); | 225 | dev = new iPAQ ( ); |
225 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 226 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
226 | dev = new Zaurus ( ); | 227 | dev = new Zaurus ( ); |
227 | else | 228 | else |
228 | dev = new ODevice ( ); | 229 | dev = new ODevice ( ); |
229 | 230 | ||
230 | dev-> init ( ); | 231 | dev-> init ( ); |
231 | } | 232 | } |
232 | return dev; | 233 | return dev; |
233 | } | 234 | } |
234 | 235 | ||
235 | 236 | ||
236 | /************************************************** | 237 | /************************************************** |
237 | * | 238 | * |
238 | * common | 239 | * common |
239 | * | 240 | * |
240 | **************************************************/ | 241 | **************************************************/ |
241 | 242 | ||
242 | 243 | ||
243 | ODevice::ODevice ( ) | 244 | ODevice::ODevice ( ) |
244 | { | 245 | { |
245 | d = new ODeviceData; | 246 | d = new ODeviceData; |
246 | 247 | ||
247 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 248 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
248 | 249 | ||
249 | d-> m_modelstr = "Unknown"; | 250 | d-> m_modelstr = "Unknown"; |
250 | d-> m_model = Model_Unknown; | 251 | d-> m_model = Model_Unknown; |
251 | d-> m_vendorstr = "Unknown"; | 252 | d-> m_vendorstr = "Unknown"; |
252 | d-> m_vendor = Vendor_Unknown; | 253 | d-> m_vendor = Vendor_Unknown; |
253 | d-> m_systemstr = "Unknown"; | 254 | d-> m_systemstr = "Unknown"; |
254 | d-> m_system = System_Unknown; | 255 | d-> m_system = System_Unknown; |
255 | d-> m_sysverstr = "0.0"; | 256 | d-> m_sysverstr = "0.0"; |
256 | d-> m_rotation = Rot0; | 257 | d-> m_rotation = Rot0; |
258 | d-> m_direction = CW; | ||
257 | 259 | ||
258 | d-> m_holdtime = 1000; // 1000ms | 260 | d-> m_holdtime = 1000; // 1000ms |
259 | d-> m_buttons = 0; | 261 | d-> m_buttons = 0; |
260 | } | 262 | } |
261 | 263 | ||
262 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 264 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
263 | { | 265 | { |
264 | if ( msg == "deviceButtonMappingChanged()" ) { | 266 | if ( msg == "deviceButtonMappingChanged()" ) { |
265 | reloadButtonMapping ( ); | 267 | reloadButtonMapping ( ); |
266 | } | 268 | } |
267 | } | 269 | } |
268 | 270 | ||
269 | void ODevice::init ( ) | 271 | void ODevice::init ( ) |
270 | { | 272 | { |
271 | } | 273 | } |
272 | 274 | ||
273 | /** | 275 | /** |
274 | * This method initialises the button mapping | 276 | * This method initialises the button mapping |
275 | */ | 277 | */ |
276 | void ODevice::initButtons ( ) | 278 | void ODevice::initButtons ( ) |
277 | { | 279 | { |
278 | if ( d-> m_buttons ) | 280 | if ( d-> m_buttons ) |
279 | return; | 281 | return; |
280 | 282 | ||
281 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 283 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
282 | 284 | ||
283 | // Simulation uses iPAQ 3660 device buttons | 285 | // Simulation uses iPAQ 3660 device buttons |
284 | 286 | ||
285 | qDebug ( "init Buttons" ); | 287 | qDebug ( "init Buttons" ); |
286 | d-> m_buttons = new QValueList <ODeviceButton>; | 288 | d-> m_buttons = new QValueList <ODeviceButton>; |
287 | 289 | ||
288 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 290 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
289 | i_button *ib = ipaq_buttons + i; | 291 | i_button *ib = ipaq_buttons + i; |
290 | ODeviceButton b; | 292 | ODeviceButton b; |
291 | 293 | ||
292 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 294 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
293 | b. setKeycode ( ib-> code ); | 295 | b. setKeycode ( ib-> code ); |
294 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 296 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
295 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 297 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
296 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 298 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
297 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 299 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
298 | d-> m_buttons-> append ( b ); | 300 | d-> m_buttons-> append ( b ); |
299 | } | 301 | } |
300 | } | 302 | } |
301 | reloadButtonMapping ( ); | 303 | reloadButtonMapping ( ); |
302 | 304 | ||
303 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 305 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
304 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 306 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
305 | } | 307 | } |
306 | 308 | ||
307 | ODevice::~ODevice ( ) | 309 | ODevice::~ODevice ( ) |
308 | { | 310 | { |
309 | delete d; | 311 | delete d; |
310 | } | 312 | } |
311 | 313 | ||
312 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 314 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
313 | { | 315 | { |
314 | return false; | 316 | return false; |
315 | } | 317 | } |
316 | 318 | ||
317 | //#include <linux/apm_bios.h> | 319 | //#include <linux/apm_bios.h> |
318 | 320 | ||
319 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 321 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
320 | 322 | ||
321 | /** | 323 | /** |
322 | * This method will try to suspend the device | 324 | * This method will try to suspend the device |
323 | * It only works if the user is the QWS Server and the apm application | 325 | * It only works if the user is the QWS Server and the apm application |
324 | * is installed. | 326 | * is installed. |
325 | * It tries to suspend and then waits some time cause some distributions | 327 | * It tries to suspend and then waits some time cause some distributions |
326 | * do have asynchronus apm implementations. | 328 | * do have asynchronus apm implementations. |
327 | * This method will either fail and return false or it'll suspend the | 329 | * This method will either fail and return false or it'll suspend the |
328 | * device and return once the device got woken up | 330 | * device and return once the device got woken up |
329 | * | 331 | * |
330 | * @return if the device got suspended | 332 | * @return if the device got suspended |
331 | */ | 333 | */ |
332 | bool ODevice::suspend ( ) | 334 | bool ODevice::suspend ( ) |
333 | { | 335 | { |
334 | if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend | 336 | if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend |
335 | return false; | 337 | return false; |
336 | 338 | ||
337 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 339 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
338 | return false; | 340 | return false; |
339 | 341 | ||
340 | bool res = false; | 342 | bool res = false; |
341 | 343 | ||
342 | struct timeval tvs, tvn; | 344 | struct timeval tvs, tvn; |
343 | ::gettimeofday ( &tvs, 0 ); | 345 | ::gettimeofday ( &tvs, 0 ); |
344 | 346 | ||
345 | ::sync ( ); // flush fs caches | 347 | ::sync ( ); // flush fs caches |
346 | res = ( ::system ( "apm --suspend" ) == 0 ); | 348 | res = ( ::system ( "apm --suspend" ) == 0 ); |
347 | 349 | ||
348 | // This is needed because the iPAQ apm implementation is asynchronous and we | 350 | // This is needed because the iPAQ apm implementation is asynchronous and we |
349 | // can not be sure when exactly the device is really suspended | 351 | // can not be sure when exactly the device is really suspended |
350 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 352 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
351 | 353 | ||
352 | if ( res ) { | 354 | if ( res ) { |
353 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 355 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
354 | ::usleep ( 200 * 1000 ); | 356 | ::usleep ( 200 * 1000 ); |
355 | ::gettimeofday ( &tvn, 0 ); | 357 | ::gettimeofday ( &tvn, 0 ); |
356 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 358 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
357 | } | 359 | } |
358 | 360 | ||
359 | return res; | 361 | return res; |
360 | } | 362 | } |
361 | 363 | ||
362 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 364 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
363 | 365 | ||
364 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 366 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
365 | 367 | ||
366 | /* VESA Blanking Levels */ | 368 | /* VESA Blanking Levels */ |
367 | #define VESA_NO_BLANKING 0 | 369 | #define VESA_NO_BLANKING 0 |
368 | #define VESA_VSYNC_SUSPEND 1 | 370 | #define VESA_VSYNC_SUSPEND 1 |
369 | #define VESA_HSYNC_SUSPEND 2 | 371 | #define VESA_HSYNC_SUSPEND 2 |
370 | #define VESA_POWERDOWN 3 | 372 | #define VESA_POWERDOWN 3 |
371 | 373 | ||
372 | /** | 374 | /** |
373 | * This sets the display on or off | 375 | * This sets the display on or off |
374 | */ | 376 | */ |
375 | bool ODevice::setDisplayStatus ( bool on ) | 377 | bool ODevice::setDisplayStatus ( bool on ) |
376 | { | 378 | { |
377 | if ( d-> m_model == Model_Unknown ) | 379 | if ( d-> m_model == Model_Unknown ) |
378 | return false; | 380 | return false; |
379 | 381 | ||
380 | bool res = false; | 382 | bool res = false; |
381 | int fd; | 383 | int fd; |
382 | 384 | ||
383 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 385 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
384 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 386 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
385 | ::close ( fd ); | 387 | ::close ( fd ); |
386 | } | 388 | } |
387 | return res; | 389 | return res; |
388 | } | 390 | } |
389 | 391 | ||
390 | /** | 392 | /** |
391 | * This sets the display brightness | 393 | * This sets the display brightness |
392 | * @return success or failure | 394 | * @return success or failure |
393 | */ | 395 | */ |
394 | bool ODevice::setDisplayBrightness ( int p) | 396 | bool ODevice::setDisplayBrightness ( int p) |
395 | { | 397 | { |
396 | Q_UNUSED( p ) | 398 | Q_UNUSED( p ) |
397 | return false; | 399 | return false; |
398 | } | 400 | } |
399 | 401 | ||
400 | int ODevice::displayBrightnessResolution ( ) const | 402 | int ODevice::displayBrightnessResolution ( ) const |
401 | { | 403 | { |
402 | return 16; | 404 | return 16; |
403 | } | 405 | } |
404 | 406 | ||
405 | /** | 407 | /** |
406 | * This returns the vendor as string | 408 | * This returns the vendor as string |
407 | * @return Vendor as QString | 409 | * @return Vendor as QString |
408 | */ | 410 | */ |
409 | QString ODevice::vendorString ( ) const | 411 | QString ODevice::vendorString ( ) const |
410 | { | 412 | { |
411 | return d-> m_vendorstr; | 413 | return d-> m_vendorstr; |
412 | } | 414 | } |
413 | 415 | ||
414 | /** | 416 | /** |
415 | * This returns the vendor as one of the values of OVendor | 417 | * This returns the vendor as one of the values of OVendor |
416 | * @return OVendor | 418 | * @return OVendor |
417 | */ | 419 | */ |
418 | OVendor ODevice::vendor ( ) const | 420 | OVendor ODevice::vendor ( ) const |
419 | { | 421 | { |
420 | return d-> m_vendor; | 422 | return d-> m_vendor; |
421 | } | 423 | } |
422 | 424 | ||
423 | /** | 425 | /** |
424 | * This returns the model as a string | 426 | * This returns the model as a string |
425 | * @return A string representing the model | 427 | * @return A string representing the model |
426 | */ | 428 | */ |
427 | QString ODevice::modelString ( ) const | 429 | QString ODevice::modelString ( ) const |
428 | { | 430 | { |
429 | return d-> m_modelstr; | 431 | return d-> m_modelstr; |
430 | } | 432 | } |
431 | 433 | ||
432 | /** | 434 | /** |
433 | * This does return the OModel used | 435 | * This does return the OModel used |
434 | */ | 436 | */ |
435 | OModel ODevice::model ( ) const | 437 | OModel ODevice::model ( ) const |
436 | { | 438 | { |
437 | return d-> m_model; | 439 | return d-> m_model; |
438 | } | 440 | } |
439 | 441 | ||
440 | /** | 442 | /** |
441 | * This does return the systen name | 443 | * This does return the systen name |
442 | */ | 444 | */ |
443 | QString ODevice::systemString ( ) const | 445 | QString ODevice::systemString ( ) const |
444 | { | 446 | { |
445 | return d-> m_systemstr; | 447 | return d-> m_systemstr; |
446 | } | 448 | } |
447 | 449 | ||
448 | /** | 450 | /** |
449 | * Return System as OSystem value | 451 | * Return System as OSystem value |
450 | */ | 452 | */ |
451 | OSystem ODevice::system ( ) const | 453 | OSystem ODevice::system ( ) const |
452 | { | 454 | { |
453 | return d-> m_system; | 455 | return d-> m_system; |
454 | } | 456 | } |
455 | 457 | ||
456 | /** | 458 | /** |
457 | * @return the version string of the base system | 459 | * @return the version string of the base system |
458 | */ | 460 | */ |
459 | QString ODevice::systemVersionString ( ) const | 461 | QString ODevice::systemVersionString ( ) const |
460 | { | 462 | { |
461 | return d-> m_sysverstr; | 463 | return d-> m_sysverstr; |
462 | } | 464 | } |
463 | 465 | ||
464 | /** | 466 | /** |
465 | * @return the current Transformation | 467 | * @return the current Transformation |
466 | */ | 468 | */ |
467 | Transformation ODevice::rotation ( ) const | 469 | Transformation ODevice::rotation ( ) const |
468 | { | 470 | { |
469 | return d-> m_rotation; | 471 | return d-> m_rotation; |
470 | } | 472 | } |
471 | 473 | ||
472 | /** | 474 | /** |
475 | * @return the current rotation direction | ||
476 | */ | ||
477 | ODirection ODevice::direction ( ) const | ||
478 | { | ||
479 | return d-> m_direction; | ||
480 | } | ||
481 | |||
482 | /** | ||
473 | * This plays an alarmSound | 483 | * This plays an alarmSound |
474 | */ | 484 | */ |
475 | void ODevice::alarmSound ( ) | 485 | void ODevice::alarmSound ( ) |
476 | { | 486 | { |
477 | #ifndef QT_NO_SOUND | 487 | #ifndef QT_NO_SOUND |
478 | static Sound snd ( "alarm" ); | 488 | static Sound snd ( "alarm" ); |
479 | 489 | ||
480 | if ( snd. isFinished ( )) | 490 | if ( snd. isFinished ( )) |
481 | snd. play ( ); | 491 | snd. play ( ); |
482 | #endif | 492 | #endif |
483 | } | 493 | } |
484 | 494 | ||
485 | /** | 495 | /** |
486 | * This plays a key sound | 496 | * This plays a key sound |
487 | */ | 497 | */ |
488 | void ODevice::keySound ( ) | 498 | void ODevice::keySound ( ) |
489 | { | 499 | { |
490 | #ifndef QT_NO_SOUND | 500 | #ifndef QT_NO_SOUND |
491 | static Sound snd ( "keysound" ); | 501 | static Sound snd ( "keysound" ); |
492 | 502 | ||
493 | if ( snd. isFinished ( )) | 503 | if ( snd. isFinished ( )) |
494 | snd. play ( ); | 504 | snd. play ( ); |
495 | #endif | 505 | #endif |
496 | } | 506 | } |
497 | 507 | ||
498 | /** | 508 | /** |
499 | * This plays a touch sound | 509 | * This plays a touch sound |
500 | */ | 510 | */ |
501 | void ODevice::touchSound ( ) | 511 | void ODevice::touchSound ( ) |
502 | { | 512 | { |
503 | 513 | ||
504 | #ifndef QT_NO_SOUND | 514 | #ifndef QT_NO_SOUND |
505 | static Sound snd ( "touchsound" ); | 515 | static Sound snd ( "touchsound" ); |
506 | 516 | ||
507 | if ( snd. isFinished ( )) | 517 | if ( snd. isFinished ( )) |
508 | snd. play ( ); | 518 | snd. play ( ); |
509 | #endif | 519 | #endif |
510 | } | 520 | } |
511 | 521 | ||
512 | /** | 522 | /** |
513 | * This method will return a list of leds | 523 | * This method will return a list of leds |
514 | * available on this device | 524 | * available on this device |
515 | * @return a list of LEDs. | 525 | * @return a list of LEDs. |
516 | */ | 526 | */ |
517 | QValueList <OLed> ODevice::ledList ( ) const | 527 | QValueList <OLed> ODevice::ledList ( ) const |
518 | { | 528 | { |
519 | return QValueList <OLed> ( ); | 529 | return QValueList <OLed> ( ); |
520 | } | 530 | } |
521 | 531 | ||
522 | /** | 532 | /** |
523 | * This does return the state of the LEDs | 533 | * This does return the state of the LEDs |
524 | */ | 534 | */ |
525 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 535 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
526 | { | 536 | { |
527 | return QValueList <OLedState> ( ); | 537 | return QValueList <OLedState> ( ); |
528 | } | 538 | } |
529 | 539 | ||
530 | /** | 540 | /** |
531 | * @return the state for a given OLed | 541 | * @return the state for a given OLed |
532 | */ | 542 | */ |
533 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 543 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
534 | { | 544 | { |
535 | return Led_Off; | 545 | return Led_Off; |
536 | } | 546 | } |
537 | 547 | ||
538 | /** | 548 | /** |
539 | * Set the state for a LED | 549 | * Set the state for a LED |
540 | * @param which Which OLed to use | 550 | * @param which Which OLed to use |
541 | * @param st The state to set | 551 | * @param st The state to set |
542 | * @return success or failure | 552 | * @return success or failure |
543 | */ | 553 | */ |
544 | bool ODevice::setLedState ( OLed which, OLedState st ) | 554 | bool ODevice::setLedState ( OLed which, OLedState st ) |
545 | { | 555 | { |
546 | Q_UNUSED( which ) | 556 | Q_UNUSED( which ) |
547 | Q_UNUSED( st ) | 557 | Q_UNUSED( st ) |
548 | return false; | 558 | return false; |
549 | } | 559 | } |
550 | 560 | ||
551 | /** | 561 | /** |
552 | * @return if the device has a light sensor | 562 | * @return if the device has a light sensor |
553 | */ | 563 | */ |
554 | bool ODevice::hasLightSensor ( ) const | 564 | bool ODevice::hasLightSensor ( ) const |
555 | { | 565 | { |
556 | return false; | 566 | return false; |
557 | } | 567 | } |
558 | 568 | ||
559 | /** | 569 | /** |
560 | * @return a value from the light senso | 570 | * @return a value from the light senso |
561 | */ | 571 | */ |
562 | int ODevice::readLightSensor ( ) | 572 | int ODevice::readLightSensor ( ) |
563 | { | 573 | { |
564 | return -1; | 574 | return -1; |
565 | } | 575 | } |
566 | 576 | ||
567 | /** | 577 | /** |
568 | * @return the light sensor resolution whatever that is ;) | 578 | * @return the light sensor resolution whatever that is ;) |
569 | */ | 579 | */ |
570 | int ODevice::lightSensorResolution ( ) const | 580 | int ODevice::lightSensorResolution ( ) const |
571 | { | 581 | { |
572 | return 0; | 582 | return 0; |
573 | } | 583 | } |
574 | 584 | ||
575 | /** | 585 | /** |
576 | * @return a list of hardware buttons | 586 | * @return a list of hardware buttons |
577 | */ | 587 | */ |
578 | const QValueList <ODeviceButton> &ODevice::buttons ( ) | 588 | const QValueList <ODeviceButton> &ODevice::buttons ( ) |
579 | { | 589 | { |
580 | initButtons ( ); | 590 | initButtons ( ); |
581 | 591 | ||
582 | return *d-> m_buttons; | 592 | return *d-> m_buttons; |
583 | } | 593 | } |
584 | 594 | ||
585 | /** | 595 | /** |
586 | * @return The amount of time that would count as a hold | 596 | * @return The amount of time that would count as a hold |
587 | */ | 597 | */ |
588 | uint ODevice::buttonHoldTime ( ) const | 598 | uint ODevice::buttonHoldTime ( ) const |
589 | { | 599 | { |
590 | return d-> m_holdtime; | 600 | return d-> m_holdtime; |
591 | } | 601 | } |
592 | 602 | ||
593 | /** | 603 | /** |
594 | * This method return a ODeviceButton for a key code | 604 | * This method return a ODeviceButton for a key code |
595 | * or 0 if no special hardware button is available for the device | 605 | * or 0 if no special hardware button is available for the device |
596 | * | 606 | * |
597 | * @return The devicebutton or 0l | 607 | * @return The devicebutton or 0l |
598 | * @see ODeviceButton | 608 | * @see ODeviceButton |
599 | */ | 609 | */ |
600 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 610 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
601 | { | 611 | { |
602 | initButtons ( ); | 612 | initButtons ( ); |
603 | 613 | ||
604 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { | 614 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { |
605 | if ( (*it). keycode ( ) == code ) | 615 | if ( (*it). keycode ( ) == code ) |
606 | return &(*it); | 616 | return &(*it); |
607 | } | 617 | } |
608 | return 0; | 618 | return 0; |
609 | } | 619 | } |
610 | 620 | ||
611 | void ODevice::reloadButtonMapping ( ) | 621 | void ODevice::reloadButtonMapping ( ) |
612 | { | 622 | { |
613 | initButtons ( ); | 623 | initButtons ( ); |
614 | 624 | ||
615 | Config cfg ( "ButtonSettings" ); | 625 | Config cfg ( "ButtonSettings" ); |
616 | 626 | ||
617 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { | 627 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { |
618 | ODeviceButton &b = ( *d-> m_buttons ) [i]; | 628 | ODeviceButton &b = ( *d-> m_buttons ) [i]; |
619 | QString group = "Button" + QString::number ( i ); | 629 | QString group = "Button" + QString::number ( i ); |
620 | 630 | ||
621 | QCString pch, hch; | 631 | QCString pch, hch; |
622 | QCString pm, hm; | 632 | QCString pm, hm; |
623 | QByteArray pdata, hdata; | 633 | QByteArray pdata, hdata; |
624 | 634 | ||
625 | if ( cfg. hasGroup ( group )) { | 635 | if ( cfg. hasGroup ( group )) { |
626 | cfg. setGroup ( group ); | 636 | cfg. setGroup ( group ); |
627 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); | 637 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); |
628 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); | 638 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); |
629 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 639 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
630 | 640 | ||
631 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); | 641 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); |
632 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); | 642 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); |
633 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 643 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
634 | } | 644 | } |
635 | 645 | ||
636 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 646 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
637 | 647 | ||
638 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 648 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
639 | } | 649 | } |
640 | } | 650 | } |
641 | 651 | ||
642 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 652 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
643 | { | 653 | { |
644 | initButtons ( ); | 654 | initButtons ( ); |
645 | 655 | ||
646 | QString mb_chan; | 656 | QString mb_chan; |
647 | 657 | ||
648 | if ( button >= (int) d-> m_buttons-> count ( )) | 658 | if ( button >= (int) d-> m_buttons-> count ( )) |
649 | return; | 659 | return; |
650 | 660 | ||
651 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 661 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
652 | b. setPressedAction ( action ); | 662 | b. setPressedAction ( action ); |
653 | 663 | ||
654 | mb_chan=b. pressedAction ( ). channel ( ); | 664 | mb_chan=b. pressedAction ( ). channel ( ); |
655 | 665 | ||
656 | Config buttonFile ( "ButtonSettings" ); | 666 | Config buttonFile ( "ButtonSettings" ); |
657 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 667 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
658 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 668 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
659 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 669 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
660 | 670 | ||
661 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 671 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
662 | 672 | ||
663 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 673 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
664 | } | 674 | } |
665 | 675 | ||
666 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 676 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
667 | { | 677 | { |
668 | initButtons ( ); | 678 | initButtons ( ); |
669 | 679 | ||
670 | if ( button >= (int) d-> m_buttons-> count ( )) | 680 | if ( button >= (int) d-> m_buttons-> count ( )) |
671 | return; | 681 | return; |
672 | 682 | ||
673 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 683 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
674 | b. setHeldAction ( action ); | 684 | b. setHeldAction ( action ); |
675 | 685 | ||
676 | Config buttonFile ( "ButtonSettings" ); | 686 | Config buttonFile ( "ButtonSettings" ); |
677 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 687 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
678 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 688 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
679 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 689 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
680 | 690 | ||
681 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 691 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
682 | 692 | ||
683 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 693 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
684 | } | 694 | } |
685 | 695 | ||
686 | 696 | ||
687 | 697 | ||
688 | 698 | ||
689 | /************************************************** | 699 | /************************************************** |
690 | * | 700 | * |
691 | * iPAQ | 701 | * iPAQ |
692 | * | 702 | * |
693 | **************************************************/ | 703 | **************************************************/ |
694 | 704 | ||
695 | void iPAQ::init ( ) | 705 | void iPAQ::init ( ) |
696 | { | 706 | { |
697 | d-> m_vendorstr = "HP"; | 707 | d-> m_vendorstr = "HP"; |
698 | d-> m_vendor = Vendor_HP; | 708 | d-> m_vendor = Vendor_HP; |
699 | 709 | ||
700 | QFile f ( "/proc/hal/model" ); | 710 | QFile f ( "/proc/hal/model" ); |
701 | 711 | ||
702 | if ( f. open ( IO_ReadOnly )) { | 712 | if ( f. open ( IO_ReadOnly )) { |
703 | QTextStream ts ( &f ); | 713 | QTextStream ts ( &f ); |
704 | 714 | ||
705 | d-> m_modelstr = "H" + ts. readLine ( ); | 715 | d-> m_modelstr = "H" + ts. readLine ( ); |
706 | 716 | ||
707 | if ( d-> m_modelstr == "H3100" ) | 717 | if ( d-> m_modelstr == "H3100" ) |
708 | d-> m_model = Model_iPAQ_H31xx; | 718 | d-> m_model = Model_iPAQ_H31xx; |
709 | else if ( d-> m_modelstr == "H3600" ) | 719 | else if ( d-> m_modelstr == "H3600" ) |
710 | d-> m_model = Model_iPAQ_H36xx; | 720 | d-> m_model = Model_iPAQ_H36xx; |
711 | else if ( d-> m_modelstr == "H3700" ) | 721 | else if ( d-> m_modelstr == "H3700" ) |
712 | d-> m_model = Model_iPAQ_H37xx; | 722 | d-> m_model = Model_iPAQ_H37xx; |
713 | else if ( d-> m_modelstr == "H3800" ) | 723 | else if ( d-> m_modelstr == "H3800" ) |
714 | d-> m_model = Model_iPAQ_H38xx; | 724 | d-> m_model = Model_iPAQ_H38xx; |
715 | else if ( d-> m_modelstr == "H3900" ) | 725 | else if ( d-> m_modelstr == "H3900" ) |
716 | d-> m_model = Model_iPAQ_H39xx; | 726 | d-> m_model = Model_iPAQ_H39xx; |
717 | else | 727 | else |
718 | d-> m_model = Model_Unknown; | 728 | d-> m_model = Model_Unknown; |
719 | 729 | ||
720 | f. close ( ); | 730 | f. close ( ); |
721 | } | 731 | } |
722 | 732 | ||
723 | switch ( d-> m_model ) { | 733 | switch ( d-> m_model ) { |
724 | case Model_iPAQ_H31xx: | 734 | case Model_iPAQ_H31xx: |
725 | case Model_iPAQ_H38xx: | 735 | case Model_iPAQ_H38xx: |
726 | d-> m_rotation = Rot90; | 736 | d-> m_rotation = Rot90; |
727 | break; | 737 | break; |
728 | case Model_iPAQ_H36xx: | 738 | case Model_iPAQ_H36xx: |
729 | case Model_iPAQ_H37xx: | 739 | case Model_iPAQ_H37xx: |
730 | case Model_iPAQ_H39xx: | 740 | case Model_iPAQ_H39xx: |
731 | default: | 741 | default: |
732 | d-> m_rotation = Rot270; | 742 | d-> m_rotation = Rot270; |
733 | break; | 743 | break; |
734 | } | 744 | } |
735 | 745 | ||
736 | f. setName ( "/etc/familiar-version" ); | 746 | f. setName ( "/etc/familiar-version" ); |
737 | if ( f. open ( IO_ReadOnly )) { | 747 | if ( f. open ( IO_ReadOnly )) { |
738 | d-> m_systemstr = "Familiar"; | 748 | d-> m_systemstr = "Familiar"; |
739 | d-> m_system = System_Familiar; | 749 | d-> m_system = System_Familiar; |
740 | 750 | ||
741 | QTextStream ts ( &f ); | 751 | QTextStream ts ( &f ); |
742 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 752 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
743 | 753 | ||
744 | f. close ( ); | 754 | f. close ( ); |
745 | } else { | 755 | } else { |
746 | f. setName ( "/etc/oz_version" ); | 756 | f. setName ( "/etc/oz_version" ); |
747 | 757 | ||
748 | if ( f. open ( IO_ReadOnly )) { | 758 | if ( f. open ( IO_ReadOnly )) { |
749 | d-> m_systemstr = "OpenEmbedded/iPaq"; | 759 | d-> m_systemstr = "OpenEmbedded/iPaq"; |
750 | d-> m_system = System_Familiar; | 760 | d-> m_system = System_Familiar; |
751 | 761 | ||
752 | QTextStream ts ( &f ); | 762 | QTextStream ts ( &f ); |
753 | ts.setDevice ( &f ); | 763 | ts.setDevice ( &f ); |
754 | d-> m_sysverstr = ts. readLine ( ); | 764 | d-> m_sysverstr = ts. readLine ( ); |
755 | f. close ( ); | 765 | f. close ( ); |
756 | } | 766 | } |
757 | } | 767 | } |
758 | 768 | ||
759 | 769 | ||
760 | 770 | ||
761 | 771 | ||
762 | 772 | ||
763 | m_leds [0] = m_leds [1] = Led_Off; | 773 | m_leds [0] = m_leds [1] = Led_Off; |
764 | 774 | ||
765 | m_power_timer = 0; | 775 | m_power_timer = 0; |
766 | 776 | ||
767 | } | 777 | } |
768 | 778 | ||
769 | void iPAQ::initButtons ( ) | 779 | void iPAQ::initButtons ( ) |
770 | { | 780 | { |
771 | if ( d-> m_buttons ) | 781 | if ( d-> m_buttons ) |
772 | return; | 782 | return; |
773 | 783 | ||
774 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 784 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
775 | 785 | ||
776 | if ( d-> m_qwsserver ) | 786 | if ( d-> m_qwsserver ) |
777 | QWSServer::setKeyboardFilter ( this ); | 787 | QWSServer::setKeyboardFilter ( this ); |
778 | 788 | ||
779 | d-> m_buttons = new QValueList <ODeviceButton>; | 789 | d-> m_buttons = new QValueList <ODeviceButton>; |
780 | 790 | ||
781 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 791 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
782 | i_button *ib = ipaq_buttons + i; | 792 | i_button *ib = ipaq_buttons + i; |
783 | ODeviceButton b; | 793 | ODeviceButton b; |
784 | 794 | ||
785 | if (( ib-> model & d-> m_model ) == d-> m_model ) { | 795 | if (( ib-> model & d-> m_model ) == d-> m_model ) { |
786 | b. setKeycode ( ib-> code ); | 796 | b. setKeycode ( ib-> code ); |
787 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 797 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
788 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 798 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
789 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 799 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
790 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 800 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
791 | 801 | ||
792 | d-> m_buttons-> append ( b ); | 802 | d-> m_buttons-> append ( b ); |
793 | } | 803 | } |
794 | } | 804 | } |
795 | reloadButtonMapping ( ); | 805 | reloadButtonMapping ( ); |
796 | 806 | ||
797 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 807 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
798 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 808 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
799 | } | 809 | } |
800 | 810 | ||
801 | 811 | ||
802 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 812 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
803 | 813 | ||
804 | typedef struct { | 814 | typedef struct { |
805 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 815 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
806 | unsigned char TotalTime; /* Units of 5 seconds */ | 816 | unsigned char TotalTime; /* Units of 5 seconds */ |
807 | unsigned char OnTime; /* units of 100m/s */ | 817 | unsigned char OnTime; /* units of 100m/s */ |
808 | unsigned char OffTime; /* units of 100m/s */ | 818 | unsigned char OffTime; /* units of 100m/s */ |
809 | } LED_IN; | 819 | } LED_IN; |
810 | 820 | ||
811 | typedef struct { | 821 | typedef struct { |
812 | unsigned char mode; | 822 | unsigned char mode; |
813 | unsigned char pwr; | 823 | unsigned char pwr; |
814 | unsigned char brightness; | 824 | unsigned char brightness; |
815 | } FLITE_IN; | 825 | } FLITE_IN; |
816 | 826 | ||
817 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 827 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
818 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 828 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
819 | 829 | ||
820 | 830 | ||
821 | QValueList <OLed> iPAQ::ledList ( ) const | 831 | QValueList <OLed> iPAQ::ledList ( ) const |
822 | { | 832 | { |
823 | QValueList <OLed> vl; | 833 | QValueList <OLed> vl; |
824 | vl << Led_Power; | 834 | vl << Led_Power; |
825 | 835 | ||
826 | if ( d-> m_model == Model_iPAQ_H38xx ) | 836 | if ( d-> m_model == Model_iPAQ_H38xx ) |
827 | vl << Led_BlueTooth; | 837 | vl << Led_BlueTooth; |
828 | return vl; | 838 | return vl; |
829 | } | 839 | } |
830 | 840 | ||
831 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 841 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
832 | { | 842 | { |
833 | QValueList <OLedState> vl; | 843 | QValueList <OLedState> vl; |
834 | 844 | ||
835 | if ( l == Led_Power ) | 845 | if ( l == Led_Power ) |
836 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 846 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
837 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 847 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
838 | vl << Led_Off; // << Led_On << ??? | 848 | vl << Led_Off; // << Led_On << ??? |
839 | 849 | ||
840 | return vl; | 850 | return vl; |
841 | } | 851 | } |
842 | 852 | ||
843 | OLedState iPAQ::ledState ( OLed l ) const | 853 | OLedState iPAQ::ledState ( OLed l ) const |
844 | { | 854 | { |
845 | switch ( l ) { | 855 | switch ( l ) { |
846 | case Led_Power: | 856 | case Led_Power: |
847 | return m_leds [0]; | 857 | return m_leds [0]; |
848 | case Led_BlueTooth: | 858 | case Led_BlueTooth: |
849 | return m_leds [1]; | 859 | return m_leds [1]; |
850 | default: | 860 | default: |
851 | return Led_Off; | 861 | return Led_Off; |
852 | } | 862 | } |
853 | } | 863 | } |
854 | 864 | ||
855 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 865 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
856 | { | 866 | { |
857 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 867 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
858 | 868 | ||
859 | if ( l == Led_Power ) { | 869 | if ( l == Led_Power ) { |
860 | if ( fd >= 0 ) { | 870 | if ( fd >= 0 ) { |
861 | LED_IN leds; | 871 | LED_IN leds; |
862 | ::memset ( &leds, 0, sizeof( leds )); | 872 | ::memset ( &leds, 0, sizeof( leds )); |
863 | leds. TotalTime = 0; | 873 | leds. TotalTime = 0; |
864 | leds. OnTime = 0; | 874 | leds. OnTime = 0; |
865 | leds. OffTime = 1; | 875 | leds. OffTime = 1; |
866 | leds. OffOnBlink = 2; | 876 | leds. OffOnBlink = 2; |
867 | 877 | ||
868 | switch ( st ) { | 878 | switch ( st ) { |
869 | case Led_Off : leds. OffOnBlink = 0; break; | 879 | case Led_Off : leds. OffOnBlink = 0; break; |
870 | case Led_On : leds. OffOnBlink = 1; break; | 880 | case Led_On : leds. OffOnBlink = 1; break; |
871 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 881 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
872 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 882 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
873 | } | 883 | } |
874 | 884 | ||
875 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 885 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
876 | m_leds [0] = st; | 886 | m_leds [0] = st; |
877 | return true; | 887 | return true; |
878 | } | 888 | } |
879 | } | 889 | } |
880 | } | 890 | } |
881 | return false; | 891 | return false; |
882 | } | 892 | } |
883 | 893 | ||
884 | 894 | ||
885 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 895 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
886 | { | 896 | { |
887 | int newkeycode = keycode; | 897 | int newkeycode = keycode; |
888 | 898 | ||
889 | switch ( keycode ) { | 899 | switch ( keycode ) { |
890 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 900 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
891 | case HardKey_Menu: { | 901 | case HardKey_Menu: { |
892 | if (( d-> m_model == Model_iPAQ_H38xx ) || | 902 | if (( d-> m_model == Model_iPAQ_H38xx ) || |
893 | ( d-> m_model == Model_iPAQ_H39xx )) { | 903 | ( d-> m_model == Model_iPAQ_H39xx )) { |
894 | newkeycode = HardKey_Mail; | 904 | newkeycode = HardKey_Mail; |
895 | } | 905 | } |
896 | break; | 906 | break; |
897 | } | 907 | } |
898 | 908 | ||
899 | // Rotate cursor keys 180° | 909 | // Rotate cursor keys 180° |
900 | case Key_Left : | 910 | case Key_Left : |
901 | case Key_Right: | 911 | case Key_Right: |
902 | case Key_Up : | 912 | case Key_Up : |
903 | case Key_Down : { | 913 | case Key_Down : { |
904 | if (( d-> m_model == Model_iPAQ_H31xx ) || | 914 | if (( d-> m_model == Model_iPAQ_H31xx ) || |
905 | ( d-> m_model == Model_iPAQ_H38xx )) { | 915 | ( d-> m_model == Model_iPAQ_H38xx )) { |
906 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 916 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
907 | } | 917 | } |
908 | break; | 918 | break; |
909 | } | 919 | } |
910 | 920 | ||
911 | // map Power Button short/long press to F34/F35 | 921 | // map Power Button short/long press to F34/F35 |
912 | case Key_SysReq: { | 922 | case Key_SysReq: { |
913 | if ( isPress ) { | 923 | if ( isPress ) { |
914 | if ( m_power_timer ) | 924 | if ( m_power_timer ) |
915 | killTimer ( m_power_timer ); | 925 | killTimer ( m_power_timer ); |
916 | m_power_timer = startTimer ( 500 ); | 926 | m_power_timer = startTimer ( 500 ); |
917 | } | 927 | } |
918 | else if ( m_power_timer ) { | 928 | else if ( m_power_timer ) { |
919 | killTimer ( m_power_timer ); | 929 | killTimer ( m_power_timer ); |
920 | m_power_timer = 0; | 930 | m_power_timer = 0; |
921 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 931 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
922 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 932 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
923 | } | 933 | } |
924 | newkeycode = Key_unknown; | 934 | newkeycode = Key_unknown; |
925 | break; | 935 | break; |
926 | } | 936 | } |
927 | } | 937 | } |
928 | 938 | ||
929 | if ( newkeycode != keycode ) { | 939 | if ( newkeycode != keycode ) { |
930 | if ( newkeycode != Key_unknown ) | 940 | if ( newkeycode != Key_unknown ) |
931 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 941 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
932 | return true; | 942 | return true; |
933 | } | 943 | } |
934 | else | 944 | else |
935 | return false; | 945 | return false; |
936 | } | 946 | } |
937 | 947 | ||
938 | void iPAQ::timerEvent ( QTimerEvent * ) | 948 | void iPAQ::timerEvent ( QTimerEvent * ) |
939 | { | 949 | { |
940 | killTimer ( m_power_timer ); | 950 | killTimer ( m_power_timer ); |
941 | m_power_timer = 0; | 951 | m_power_timer = 0; |
942 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 952 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
943 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 953 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
944 | } | 954 | } |
945 | 955 | ||
946 | 956 | ||
947 | void iPAQ::alarmSound ( ) | 957 | void iPAQ::alarmSound ( ) |
948 | { | 958 | { |
949 | #ifndef QT_NO_SOUND | 959 | #ifndef QT_NO_SOUND |
950 | static Sound snd ( "alarm" ); | 960 | static Sound snd ( "alarm" ); |
951 | int fd; | 961 | int fd; |
952 | int vol; | 962 | int vol; |
953 | bool vol_reset = false; | 963 | bool vol_reset = false; |
954 | 964 | ||
955 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 965 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
956 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 966 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
957 | Config cfg ( "qpe" ); | 967 | Config cfg ( "qpe" ); |
958 | cfg. setGroup ( "Volume" ); | 968 | cfg. setGroup ( "Volume" ); |
959 | 969 | ||
960 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 970 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
961 | if ( volalarm < 0 ) | 971 | if ( volalarm < 0 ) |
962 | volalarm = 0; | 972 | volalarm = 0; |
963 | else if ( volalarm > 100 ) | 973 | else if ( volalarm > 100 ) |
964 | volalarm = 100; | 974 | volalarm = 100; |
965 | volalarm |= ( volalarm << 8 ); | 975 | volalarm |= ( volalarm << 8 ); |
966 | 976 | ||
967 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 977 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
968 | vol_reset = true; | 978 | vol_reset = true; |
969 | } | 979 | } |
970 | } | 980 | } |
971 | 981 | ||
972 | snd. play ( ); | 982 | snd. play ( ); |
973 | while ( !snd. isFinished ( )) | 983 | while ( !snd. isFinished ( )) |
974 | qApp-> processEvents ( ); | 984 | qApp-> processEvents ( ); |
975 | 985 | ||
976 | if ( fd >= 0 ) { | 986 | if ( fd >= 0 ) { |
977 | if ( vol_reset ) | 987 | if ( vol_reset ) |
978 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 988 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
979 | ::close ( fd ); | 989 | ::close ( fd ); |
980 | } | 990 | } |
981 | #endif | 991 | #endif |
982 | } | 992 | } |
983 | 993 | ||
984 | 994 | ||
985 | bool iPAQ::setSoftSuspend ( bool soft ) | 995 | bool iPAQ::setSoftSuspend ( bool soft ) |
986 | { | 996 | { |
987 | bool res = false; | 997 | bool res = false; |
988 | int fd; | 998 | int fd; |
989 | 999 | ||
990 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 1000 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
991 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 1001 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
992 | res = true; | 1002 | res = true; |
993 | else | 1003 | else |
994 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 1004 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
995 | 1005 | ||
996 | ::close ( fd ); | 1006 | ::close ( fd ); |
997 | } | 1007 | } |
998 | else | 1008 | else |
999 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 1009 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
1000 | 1010 | ||
1001 | return res; | 1011 | return res; |
1002 | } | 1012 | } |
1003 | 1013 | ||
1004 | 1014 | ||
1005 | bool iPAQ::setDisplayBrightness ( int bright ) | 1015 | bool iPAQ::setDisplayBrightness ( int bright ) |
1006 | { | 1016 | { |
1007 | bool res = false; | 1017 | bool res = false; |
1008 | int fd; | 1018 | int fd; |
1009 | 1019 | ||
1010 | if ( bright > 255 ) | 1020 | if ( bright > 255 ) |
1011 | bright = 255; | 1021 | bright = 255; |
1012 | if ( bright < 0 ) | 1022 | if ( bright < 0 ) |
1013 | bright = 0; | 1023 | bright = 0; |
1014 | 1024 | ||
1015 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 1025 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
1016 | FLITE_IN bl; | 1026 | FLITE_IN bl; |
1017 | bl. mode = 1; | 1027 | bl. mode = 1; |
1018 | bl. pwr = bright ? 1 : 0; | 1028 | bl. pwr = bright ? 1 : 0; |
1019 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 1029 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
1020 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 1030 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
1021 | ::close ( fd ); | 1031 | ::close ( fd ); |
1022 | } | 1032 | } |
1023 | return res; | 1033 | return res; |
1024 | } | 1034 | } |
1025 | 1035 | ||
1026 | int iPAQ::displayBrightnessResolution ( ) const | 1036 | int iPAQ::displayBrightnessResolution ( ) const |
1027 | { | 1037 | { |
1028 | switch ( model ( )) { | 1038 | switch ( model ( )) { |
1029 | case Model_iPAQ_H31xx: | 1039 | case Model_iPAQ_H31xx: |
1030 | case Model_iPAQ_H36xx: | 1040 | case Model_iPAQ_H36xx: |
1031 | case Model_iPAQ_H37xx: | 1041 | case Model_iPAQ_H37xx: |
1032 | return 128; // really 256, but >128 could damage the LCD | 1042 | return 128; // really 256, but >128 could damage the LCD |
1033 | 1043 | ||
1034 | case Model_iPAQ_H38xx: | 1044 | case Model_iPAQ_H38xx: |
1035 | case Model_iPAQ_H39xx: | 1045 | case Model_iPAQ_H39xx: |
1036 | return 64; | 1046 | return 64; |
1037 | 1047 | ||
1038 | default: | 1048 | default: |
1039 | return 2; | 1049 | return 2; |
1040 | } | 1050 | } |
1041 | } | 1051 | } |
1042 | 1052 | ||
1043 | 1053 | ||
1044 | bool iPAQ::hasLightSensor ( ) const | 1054 | bool iPAQ::hasLightSensor ( ) const |
1045 | { | 1055 | { |
1046 | return true; | 1056 | return true; |
1047 | } | 1057 | } |
1048 | 1058 | ||
1049 | int iPAQ::readLightSensor ( ) | 1059 | int iPAQ::readLightSensor ( ) |
1050 | { | 1060 | { |
1051 | int fd; | 1061 | int fd; |
1052 | int val = -1; | 1062 | int val = -1; |
1053 | 1063 | ||
1054 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 1064 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
1055 | char buffer [8]; | 1065 | char buffer [8]; |
1056 | 1066 | ||
1057 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 1067 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
1058 | char *endptr; | 1068 | char *endptr; |
1059 | 1069 | ||
1060 | buffer [4] = 0; | 1070 | buffer [4] = 0; |
1061 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 1071 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
1062 | 1072 | ||
1063 | if ( *endptr != 0 ) | 1073 | if ( *endptr != 0 ) |
1064 | val = -1; | 1074 | val = -1; |
1065 | } | 1075 | } |
1066 | ::close ( fd ); | 1076 | ::close ( fd ); |
1067 | } | 1077 | } |
1068 | 1078 | ||
1069 | return val; | 1079 | return val; |
1070 | } | 1080 | } |
1071 | 1081 | ||
1072 | int iPAQ::lightSensorResolution ( ) const | 1082 | int iPAQ::lightSensorResolution ( ) const |
1073 | { | 1083 | { |
1074 | return 256; | 1084 | return 256; |
1075 | } | 1085 | } |
1076 | 1086 | ||
1077 | /************************************************** | 1087 | /************************************************** |
1078 | * | 1088 | * |
1079 | * Zaurus | 1089 | * Zaurus |
1080 | * | 1090 | * |
1081 | **************************************************/ | 1091 | **************************************************/ |
1082 | 1092 | ||
1083 | 1093 | ||
1084 | 1094 | ||
1085 | void Zaurus::init ( ) | 1095 | void Zaurus::init ( ) |
1086 | { | 1096 | { |
1087 | d-> m_vendorstr = "Sharp"; | 1097 | d-> m_vendorstr = "Sharp"; |
1088 | d-> m_vendor = Vendor_Sharp; | 1098 | d-> m_vendor = Vendor_Sharp; |
1089 | 1099 | ||
1090 | QFile f ( "/proc/filesystems" ); | 1100 | QFile f ( "/proc/filesystems" ); |
1091 | 1101 | ||
1092 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 1102 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
1093 | d-> m_vendorstr = "OpenZaurus Team"; | 1103 | d-> m_vendorstr = "OpenZaurus Team"; |
1094 | d-> m_systemstr = "OpenZaurus"; | 1104 | d-> m_systemstr = "OpenZaurus"; |
1095 | d-> m_system = System_OpenZaurus; | 1105 | d-> m_system = System_OpenZaurus; |
1096 | 1106 | ||
1097 | f. close ( ); | 1107 | f. close ( ); |
1098 | 1108 | ||
1099 | f. setName ( "/etc/oz_version" ); | 1109 | f. setName ( "/etc/oz_version" ); |
1100 | if ( f. open ( IO_ReadOnly )) { | 1110 | if ( f. open ( IO_ReadOnly )) { |
1101 | QTextStream ts ( &f ); | 1111 | QTextStream ts ( &f ); |
1102 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 1112 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
1103 | f. close ( ); | 1113 | f. close ( ); |
1104 | } | 1114 | } |
1105 | } | 1115 | } |
1106 | else { | 1116 | else { |
1107 | d-> m_systemstr = "Zaurus"; | 1117 | d-> m_systemstr = "Zaurus"; |
1108 | d-> m_system = System_Zaurus; | 1118 | d-> m_system = System_Zaurus; |
1109 | } | 1119 | } |
1110 | 1120 | ||
1111 | f. setName ( "/proc/deviceinfo/product" ); | 1121 | f. setName ( "/proc/deviceinfo/product" ); |
1112 | if ( f. open ( IO_ReadOnly ) ) { | 1122 | if ( f. open ( IO_ReadOnly ) ) { |
1113 | QTextStream ts ( &f ); | 1123 | QTextStream ts ( &f ); |
1114 | QString model = ts. readLine ( ); | 1124 | QString model = ts. readLine ( ); |
1115 | f. close ( ); | 1125 | f. close ( ); |
1116 | 1126 | ||
1117 | d-> m_modelstr = QString("Zaurus ") + model; | 1127 | d-> m_modelstr = QString("Zaurus ") + model; |
1118 | if ( model == "SL-5500" ) | 1128 | if ( model == "SL-5500" ) |
1119 | d-> m_model = Model_Zaurus_SL5500; | 1129 | d-> m_model = Model_Zaurus_SL5500; |
1120 | else if ( model == "SL-C700" ) | 1130 | else if ( model == "SL-C700" ) |
1121 | d-> m_model = Model_Zaurus_SLC700; | 1131 | d-> m_model = Model_Zaurus_SLC700; |
1122 | else if ( model == "SL-A300" ) | 1132 | else if ( model == "SL-A300" ) |
1123 | d-> m_model = Model_Zaurus_SLA300; | 1133 | d-> m_model = Model_Zaurus_SLA300; |
1124 | else if ( model == "SL-B600" || model == "SL-5600" ) | 1134 | else if ( model == "SL-B600" || model == "SL-5600" ) |
1125 | d-> m_model = Model_Zaurus_SLB600; | 1135 | d-> m_model = Model_Zaurus_SLB600; |
1126 | else | 1136 | else |
1127 | d-> m_model = Model_Zaurus_SL5000; | 1137 | d-> m_model = Model_Zaurus_SL5000; |
1128 | } | 1138 | } |
1129 | else { | 1139 | else { |
1130 | d-> m_model = Model_Zaurus_SL5000; | 1140 | d-> m_model = Model_Zaurus_SL5000; |
1131 | d-> m_modelstr = "Zaurus (model unknown)"; | 1141 | d-> m_modelstr = "Zaurus (model unknown)"; |
1132 | } | 1142 | } |
1133 | 1143 | ||
1134 | switch ( d-> m_model ) { | 1144 | switch ( d-> m_model ) { |
1135 | case Model_Zaurus_SLA300: | 1145 | case Model_Zaurus_SLA300: |
1136 | d-> m_rotation = Rot0; | 1146 | d-> m_rotation = Rot0; |
1137 | break; | 1147 | break; |
1138 | case Model_Zaurus_SLC700: | 1148 | case Model_Zaurus_SLC700: |
1139 | /* note for C700, we must check the display rotation | 1149 | /* note for C700, we must check the display rotation |
1140 | * sensor to set an appropriate value | 1150 | * sensor to set an appropriate value |
1141 | */ | 1151 | */ |
1142 | case Model_Zaurus_SLB600: | 1152 | case Model_Zaurus_SLB600: |
1143 | case Model_Zaurus_SL5500: | 1153 | case Model_Zaurus_SL5500: |
1144 | case Model_Zaurus_SL5000: | 1154 | case Model_Zaurus_SL5000: |
1145 | default: | 1155 | default: |
1146 | d-> m_rotation = Rot270; | 1156 | d-> m_rotation = Rot270; |
1147 | break; | 1157 | break; |
1148 | } | 1158 | } |
1149 | m_leds [0] = Led_Off; | 1159 | m_leds [0] = Led_Off; |
1150 | } | 1160 | } |
1151 | 1161 | ||
1152 | void Zaurus::initButtons ( ) | 1162 | void Zaurus::initButtons ( ) |
1153 | { | 1163 | { |
1154 | if ( d-> m_buttons ) | 1164 | if ( d-> m_buttons ) |
1155 | return; | 1165 | return; |
1156 | 1166 | ||
1157 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 1167 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
1158 | 1168 | ||
1159 | d-> m_buttons = new QValueList <ODeviceButton>; | 1169 | d-> m_buttons = new QValueList <ODeviceButton>; |
1160 | 1170 | ||
1161 | for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { | 1171 | for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { |
1162 | z_button *zb = z_buttons + i; | 1172 | z_button *zb = z_buttons + i; |
1163 | ODeviceButton b; | 1173 | ODeviceButton b; |
1164 | 1174 | ||
1165 | b. setKeycode ( zb-> code ); | 1175 | b. setKeycode ( zb-> code ); |
1166 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); | 1176 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); |
1167 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); | 1177 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); |
1168 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); | 1178 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); |
1169 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); | 1179 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); |
1170 | 1180 | ||
1171 | d-> m_buttons-> append ( b ); | 1181 | d-> m_buttons-> append ( b ); |
1172 | } | 1182 | } |
1173 | 1183 | ||
1174 | reloadButtonMapping ( ); | 1184 | reloadButtonMapping ( ); |
1175 | 1185 | ||
1176 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1186 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1177 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1187 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1178 | } | 1188 | } |
1179 | 1189 | ||
1180 | #include <unistd.h> | 1190 | #include <unistd.h> |
1181 | #include <fcntl.h> | 1191 | #include <fcntl.h> |
1182 | #include <sys/ioctl.h> | 1192 | #include <sys/ioctl.h> |
1183 | 1193 | ||
1184 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 1194 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
1185 | 1195 | ||
1186 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 1196 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
1187 | 1197 | ||
1188 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1198 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1189 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1199 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1190 | 1200 | ||
1191 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1201 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1192 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1202 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1193 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1203 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1194 | 1204 | ||
1195 | /* --- for SHARP_BUZZER device --- */ | 1205 | /* --- for SHARP_BUZZER device --- */ |
1196 | 1206 | ||
1197 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1207 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1198 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1208 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1199 | 1209 | ||
1200 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 1210 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
1201 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 1211 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
1202 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 1212 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
1203 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 1213 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
1204 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 1214 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
1205 | 1215 | ||
1206 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1216 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1207 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1217 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1208 | 1218 | ||
1209 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 1219 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
1210 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 1220 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
1211 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 1221 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
1212 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 1222 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
1213 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 1223 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
1214 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 1224 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
1215 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 1225 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
1216 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 1226 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
1217 | 1227 | ||
1218 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1228 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1219 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 1229 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
1220 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 1230 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
1221 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 1231 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
1222 | // | 1232 | // |
1223 | 1233 | ||
1224 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1234 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1225 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 1235 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
1226 | 1236 | ||
1227 | typedef struct sharp_led_status { | 1237 | typedef struct sharp_led_status { |
1228 | int which; /* select which LED status is wanted. */ | 1238 | int which; /* select which LED status is wanted. */ |
1229 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 1239 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
1230 | } sharp_led_status; | 1240 | } sharp_led_status; |
1231 | 1241 | ||
1232 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 1242 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
1233 | 1243 | ||
1234 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 1244 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
1235 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 1245 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
1236 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 1246 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
1237 | 1247 | ||
1238 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 1248 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
1239 | 1249 | ||
1240 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 1250 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
diff --git a/libopie/odevice.h b/libopie/odevice.h index 45a790b..0c55ea0 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -1,222 +1,229 @@ | |||
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 | }; | 59 | }; |
60 | 60 | ||
61 | /** | 61 | /** |
62 | * The vendor of the device | 62 | * The vendor of the device |
63 | */ | 63 | */ |
64 | enum OVendor { | 64 | enum OVendor { |
65 | Vendor_Unknown, | 65 | Vendor_Unknown, |
66 | 66 | ||
67 | Vendor_HP, | 67 | Vendor_HP, |
68 | Vendor_Sharp | 68 | Vendor_Sharp |
69 | }; | 69 | }; |
70 | 70 | ||
71 | /** | 71 | /** |
72 | * The System used | 72 | * The System used |
73 | */ | 73 | */ |
74 | enum OSystem { | 74 | enum OSystem { |
75 | System_Unknown, | 75 | System_Unknown, |
76 | 76 | ||
77 | System_Familiar, | 77 | System_Familiar, |
78 | System_Zaurus, | 78 | System_Zaurus, |
79 | System_OpenZaurus | 79 | System_OpenZaurus |
80 | }; | 80 | }; |
81 | 81 | ||
82 | enum OLedState { | 82 | enum OLedState { |
83 | Led_Off, | 83 | Led_Off, |
84 | Led_On, | 84 | Led_On, |
85 | Led_BlinkSlow, | 85 | Led_BlinkSlow, |
86 | Led_BlinkFast | 86 | Led_BlinkFast |
87 | }; | 87 | }; |
88 | 88 | ||
89 | enum OLed { | 89 | enum OLed { |
90 | Led_Mail, | 90 | Led_Mail, |
91 | Led_Power, | 91 | Led_Power, |
92 | Led_BlueTooth | 92 | Led_BlueTooth |
93 | }; | 93 | }; |
94 | 94 | ||
95 | enum OHardKey { | 95 | enum OHardKey { |
96 | HardKey_Datebook = Qt::Key_F9, | 96 | HardKey_Datebook = Qt::Key_F9, |
97 | HardKey_Contacts = Qt::Key_F10, | 97 | HardKey_Contacts = Qt::Key_F10, |
98 | HardKey_Menu = Qt::Key_F11, | 98 | HardKey_Menu = Qt::Key_F11, |
99 | HardKey_Home = Qt::Key_F12, | 99 | HardKey_Home = Qt::Key_F12, |
100 | HardKey_Mail = Qt::Key_F13, | 100 | HardKey_Mail = Qt::Key_F13, |
101 | HardKey_Record = Qt::Key_F24, | 101 | HardKey_Record = Qt::Key_F24, |
102 | HardKey_Suspend = Qt::Key_F34, | 102 | HardKey_Suspend = Qt::Key_F34, |
103 | HardKey_Backlight = Qt::Key_F35, | 103 | HardKey_Backlight = Qt::Key_F35, |
104 | }; | 104 | }; |
105 | 105 | ||
106 | enum ODirection { | ||
107 | CW = 0, | ||
108 | CCW = 1, | ||
109 | Flip = 2, | ||
110 | }; | ||
111 | |||
106 | /** | 112 | /** |
107 | * A singleton which gives informations about device specefic option | 113 | * A singleton which gives informations about device specefic option |
108 | * like the Hardware used, LEDs, the Base Distribution and | 114 | * like the Hardware used, LEDs, the Base Distribution and |
109 | * hardware key mappings. | 115 | * hardware key mappings. |
110 | * | 116 | * |
111 | * | 117 | * |
112 | * @short A small class for device specefic options | 118 | * @short A small class for device specefic options |
113 | * @see QObject | 119 | * @see QObject |
114 | * @author Robert Griebl | 120 | * @author Robert Griebl |
115 | * @version 1.0 | 121 | * @version 1.0 |
116 | */ | 122 | */ |
117 | class ODevice : public QObject { | 123 | class ODevice : public QObject { |
118 | Q_OBJECT | 124 | Q_OBJECT |
119 | 125 | ||
120 | private: | 126 | private: |
121 | /* disable copy */ | 127 | /* disable copy */ |
122 | ODevice ( const ODevice & ); | 128 | ODevice ( const ODevice & ); |
123 | 129 | ||
124 | protected: | 130 | protected: |
125 | ODevice ( ); | 131 | ODevice ( ); |
126 | virtual void init ( ); | 132 | virtual void init ( ); |
127 | virtual void initButtons ( ); | 133 | virtual void initButtons ( ); |
128 | 134 | ||
129 | ODeviceData *d; | 135 | ODeviceData *d; |
130 | 136 | ||
131 | public: | 137 | public: |
132 | // sandman do we want to allow destructions? -zecke? | 138 | // sandman do we want to allow destructions? -zecke? |
133 | virtual ~ODevice ( ); | 139 | virtual ~ODevice ( ); |
134 | 140 | ||
135 | 141 | ||
136 | static ODevice *inst ( ); | 142 | static ODevice *inst ( ); |
137 | 143 | ||
138 | // information | 144 | // information |
139 | 145 | ||
140 | QString modelString ( ) const; | 146 | QString modelString ( ) const; |
141 | OModel model ( ) const; | 147 | OModel model ( ) const; |
142 | inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } | 148 | inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } |
143 | 149 | ||
144 | QString vendorString ( ) const; | 150 | QString vendorString ( ) const; |
145 | OVendor vendor ( ) const; | 151 | OVendor vendor ( ) const; |
146 | 152 | ||
147 | QString systemString ( ) const; | 153 | QString systemString ( ) const; |
148 | OSystem system ( ) const; | 154 | OSystem system ( ) const; |
149 | 155 | ||
150 | QString systemVersionString ( ) const; | 156 | QString systemVersionString ( ) const; |
151 | 157 | ||
152 | Transformation rotation ( ) const; | 158 | Transformation rotation ( ) const; |
159 | ODirection direction ( ) const; | ||
153 | 160 | ||
154 | // system | 161 | // system |
155 | 162 | ||
156 | virtual bool setSoftSuspend ( bool on ); | 163 | virtual bool setSoftSuspend ( bool on ); |
157 | virtual bool suspend ( ); | 164 | virtual bool suspend ( ); |
158 | 165 | ||
159 | virtual bool setDisplayStatus ( bool on ); | 166 | virtual bool setDisplayStatus ( bool on ); |
160 | virtual bool setDisplayBrightness ( int brightness ); | 167 | virtual bool setDisplayBrightness ( int brightness ); |
161 | virtual int displayBrightnessResolution ( ) const; | 168 | virtual int displayBrightnessResolution ( ) const; |
162 | 169 | ||
163 | // input / output | 170 | // input / output |
164 | //FIXME playAlarmSound and al might be better -zecke | 171 | //FIXME playAlarmSound and al might be better -zecke |
165 | virtual void alarmSound ( ); | 172 | virtual void alarmSound ( ); |
166 | virtual void keySound ( ); | 173 | virtual void keySound ( ); |
167 | virtual void touchSound ( ); | 174 | virtual void touchSound ( ); |
168 | 175 | ||
169 | virtual QValueList <OLed> ledList ( ) const; | 176 | virtual QValueList <OLed> ledList ( ) const; |
170 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 177 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
171 | virtual OLedState ledState ( OLed led ) const; | 178 | virtual OLedState ledState ( OLed led ) const; |
172 | virtual bool setLedState ( OLed led, OLedState st ); | 179 | virtual bool setLedState ( OLed led, OLedState st ); |
173 | 180 | ||
174 | virtual bool hasLightSensor ( ) const; | 181 | virtual bool hasLightSensor ( ) const; |
175 | virtual int readLightSensor ( ); | 182 | virtual int readLightSensor ( ); |
176 | virtual int lightSensorResolution ( ) const; | 183 | virtual int lightSensorResolution ( ) const; |
177 | 184 | ||
178 | /** | 185 | /** |
179 | * Returns the available buttons on this device. The number and location | 186 | * Returns the available buttons on this device. The number and location |
180 | * of buttons will vary depending on the device. Button numbers will be assigned | 187 | * of buttons will vary depending on the device. Button numbers will be assigned |
181 | * by the device manufacturer and will be from most preferred button to least preffered | 188 | * by the device manufacturer and will be from most preferred button to least preffered |
182 | * button. Note that this list only contains "user mappable" buttons. | 189 | * button. Note that this list only contains "user mappable" buttons. |
183 | */ | 190 | */ |
184 | const QValueList<ODeviceButton> &buttons ( ); | 191 | const QValueList<ODeviceButton> &buttons ( ); |
185 | 192 | ||
186 | /** | 193 | /** |
187 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it | 194 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it |
188 | * returns 0L | 195 | * returns 0L |
189 | */ | 196 | */ |
190 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); | 197 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); |
191 | 198 | ||
192 | /** | 199 | /** |
193 | * Reassigns the pressed action for \a button. To return to the factory | 200 | * Reassigns the pressed action for \a button. To return to the factory |
194 | * default pass an empty string as \a qcopMessage. | 201 | * default pass an empty string as \a qcopMessage. |
195 | */ | 202 | */ |
196 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); | 203 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); |
197 | 204 | ||
198 | /** | 205 | /** |
199 | * Reassigns the held action for \a button. To return to the factory | 206 | * Reassigns the held action for \a button. To return to the factory |
200 | * default pass an empty string as \a qcopMessage. | 207 | * default pass an empty string as \a qcopMessage. |
201 | */ | 208 | */ |
202 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); | 209 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); |
203 | 210 | ||
204 | /** | 211 | /** |
205 | * How long (in ms) you have to press a button for a "hold" action | 212 | * How long (in ms) you have to press a button for a "hold" action |
206 | */ | 213 | */ |
207 | uint buttonHoldTime ( ) const; | 214 | uint buttonHoldTime ( ) const; |
208 | 215 | ||
209 | signals: | 216 | signals: |
210 | void buttonMappingChanged ( ); | 217 | void buttonMappingChanged ( ); |
211 | 218 | ||
212 | private slots: | 219 | private slots: |
213 | void systemMessage ( const QCString &, const QByteArray & ); | 220 | void systemMessage ( const QCString &, const QByteArray & ); |
214 | 221 | ||
215 | protected: | 222 | protected: |
216 | void reloadButtonMapping ( ); | 223 | void reloadButtonMapping ( ); |
217 | }; | 224 | }; |
218 | 225 | ||
219 | } | 226 | } |
220 | 227 | ||
221 | #endif | 228 | #endif |
222 | 229 | ||