-rw-r--r-- | libopie/odevice.cpp | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index d39d72f..78eb416 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1,740 +1,760 @@ | |||
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; | 56 | bool m_qwsserver; |
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 | |||
69 | Transformation m_rotation; | ||
68 | 70 | ||
69 | QValueList <ODeviceButton> m_buttons; | 71 | QValueList <ODeviceButton> m_buttons; |
70 | uint m_holdtime; | 72 | uint m_holdtime; |
71 | }; | 73 | }; |
72 | 74 | ||
73 | 75 | ||
74 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { | 76 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { |
75 | protected: | 77 | protected: |
76 | virtual void init ( ); | 78 | virtual void init ( ); |
77 | 79 | ||
78 | public: | 80 | public: |
79 | virtual bool setSoftSuspend ( bool soft ); | 81 | virtual bool setSoftSuspend ( bool soft ); |
80 | 82 | ||
81 | virtual bool setDisplayBrightness ( int b ); | 83 | virtual bool setDisplayBrightness ( int b ); |
82 | virtual int displayBrightnessResolution ( ) const; | 84 | virtual int displayBrightnessResolution ( ) const; |
83 | 85 | ||
84 | virtual void alarmSound ( ); | 86 | virtual void alarmSound ( ); |
85 | 87 | ||
86 | virtual QValueList <OLed> ledList ( ) const; | 88 | virtual QValueList <OLed> ledList ( ) const; |
87 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 89 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
88 | virtual OLedState ledState ( OLed led ) const; | 90 | virtual OLedState ledState ( OLed led ) const; |
89 | virtual bool setLedState ( OLed led, OLedState st ); | 91 | virtual bool setLedState ( OLed led, OLedState st ); |
90 | 92 | ||
91 | virtual bool hasLightSensor ( ) const; | 93 | virtual bool hasLightSensor ( ) const; |
92 | virtual int readLightSensor ( ); | 94 | virtual int readLightSensor ( ); |
93 | virtual int lightSensorResolution ( ) const; | 95 | virtual int lightSensorResolution ( ) const; |
94 | 96 | ||
95 | protected: | 97 | protected: |
96 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 98 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
97 | virtual void timerEvent ( QTimerEvent *te ); | 99 | virtual void timerEvent ( QTimerEvent *te ); |
98 | 100 | ||
99 | int m_power_timer; | 101 | int m_power_timer; |
100 | 102 | ||
101 | OLedState m_leds [2]; | 103 | OLedState m_leds [2]; |
102 | }; | 104 | }; |
103 | 105 | ||
104 | class Zaurus : public ODevice { | 106 | class Zaurus : public ODevice { |
105 | protected: | 107 | protected: |
106 | virtual void init ( ); | 108 | virtual void init ( ); |
107 | 109 | ||
108 | public: | 110 | public: |
109 | virtual bool setSoftSuspend ( bool soft ); | 111 | virtual bool setSoftSuspend ( bool soft ); |
110 | 112 | ||
111 | virtual bool setDisplayBrightness ( int b ); | 113 | virtual bool setDisplayBrightness ( int b ); |
112 | virtual int displayBrightnessResolution ( ) const; | 114 | virtual int displayBrightnessResolution ( ) const; |
113 | 115 | ||
114 | virtual void alarmSound ( ); | 116 | virtual void alarmSound ( ); |
115 | virtual void keySound ( ); | 117 | virtual void keySound ( ); |
116 | virtual void touchSound ( ); | 118 | virtual void touchSound ( ); |
117 | 119 | ||
118 | virtual QValueList <OLed> ledList ( ) const; | 120 | virtual QValueList <OLed> ledList ( ) const; |
119 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 121 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
120 | virtual OLedState ledState ( OLed led ) const; | 122 | virtual OLedState ledState ( OLed led ) const; |
121 | virtual bool setLedState ( OLed led, OLedState st ); | 123 | virtual bool setLedState ( OLed led, OLedState st ); |
122 | 124 | ||
123 | protected: | 125 | protected: |
124 | virtual void buzzer ( int snd ); | 126 | virtual void buzzer ( int snd ); |
125 | 127 | ||
126 | OLedState m_leds [1]; | 128 | OLedState m_leds [1]; |
127 | }; | 129 | }; |
128 | 130 | ||
129 | 131 | ||
130 | struct i_button { | 132 | struct i_button { |
131 | uint model; | 133 | uint model; |
132 | Qt::Key code; | 134 | Qt::Key code; |
133 | char *utext; | 135 | char *utext; |
134 | char *pix; | 136 | char *pix; |
135 | char *fpressedservice; | 137 | char *fpressedservice; |
136 | char *fpressedaction; | 138 | char *fpressedaction; |
137 | char *fheldservice; | 139 | char *fheldservice; |
138 | char *fheldaction; | 140 | char *fheldaction; |
139 | } ipaq_buttons [] = { | 141 | } ipaq_buttons [] = { |
140 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 142 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
141 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 143 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
142 | "devicebuttons/ipaq_calendar", | 144 | "devicebuttons/ipaq_calendar", |
143 | "datebook", "nextView()", | 145 | "datebook", "nextView()", |
144 | "today", "raise()" }, | 146 | "today", "raise()" }, |
145 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 147 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
146 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 148 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
147 | "devicebuttons/ipaq_contact", | 149 | "devicebuttons/ipaq_contact", |
148 | "addressbook", "raise()", | 150 | "addressbook", "raise()", |
149 | "addressbook", "beamBusinessCard()" }, | 151 | "addressbook", "beamBusinessCard()" }, |
150 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, | 152 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, |
151 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 153 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
152 | "devicebuttons/ipaq_menu", | 154 | "devicebuttons/ipaq_menu", |
153 | "QPE/TaskBar", "toggleMenu()", | 155 | "QPE/TaskBar", "toggleMenu()", |
154 | "QPE/TaskBar", "toggleStartMenu()" }, | 156 | "QPE/TaskBar", "toggleStartMenu()" }, |
155 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 157 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
156 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 158 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
157 | "devicebuttons/ipaq_mail", | 159 | "devicebuttons/ipaq_mail", |
158 | "mail", "raise()", | 160 | "mail", "raise()", |
159 | "mail", "newMail()" }, | 161 | "mail", "newMail()" }, |
160 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 162 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
161 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 163 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
162 | "devicebuttons/ipaq_home", | 164 | "devicebuttons/ipaq_home", |
163 | "QPE/Launcher", "home()", | 165 | "QPE/Launcher", "home()", |
164 | "buttonsettings", "raise()" }, | 166 | "buttonsettings", "raise()" }, |
165 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 167 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
166 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), | 168 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), |
167 | "devicebuttons/ipaq_record", | 169 | "devicebuttons/ipaq_record", |
168 | "QPE/VMemo", "toggleRecord()", | 170 | "QPE/VMemo", "toggleRecord()", |
169 | "sound", "raise()" }, | 171 | "sound", "raise()" }, |
170 | }; | 172 | }; |
171 | 173 | ||
172 | struct z_button { | 174 | struct z_button { |
173 | Qt::Key code; | 175 | Qt::Key code; |
174 | char *utext; | 176 | char *utext; |
175 | char *pix; | 177 | char *pix; |
176 | char *fpressedservice; | 178 | char *fpressedservice; |
177 | char *fpressedaction; | 179 | char *fpressedaction; |
178 | char *fheldservice; | 180 | char *fheldservice; |
179 | char *fheldaction; | 181 | char *fheldaction; |
180 | } z_buttons [] = { | 182 | } z_buttons [] = { |
181 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 183 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
182 | "devicebuttons/z_calendar", | 184 | "devicebuttons/z_calendar", |
183 | "datebook", "nextView()", | 185 | "datebook", "nextView()", |
184 | "today", "raise()" }, | 186 | "today", "raise()" }, |
185 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 187 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
186 | "devicebuttons/z_contact", | 188 | "devicebuttons/z_contact", |
187 | "addressbook", "raise()", | 189 | "addressbook", "raise()", |
188 | "addressbook", "beamBusinessCard()" }, | 190 | "addressbook", "beamBusinessCard()" }, |
189 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 191 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
190 | "devicebuttons/z_home", | 192 | "devicebuttons/z_home", |
191 | "QPE/Launcher", "home()", | 193 | "QPE/Launcher", "home()", |
192 | "buttonsettings", "raise()" }, | 194 | "buttonsettings", "raise()" }, |
193 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 195 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
194 | "devicebuttons/z_menu", | 196 | "devicebuttons/z_menu", |
195 | "QPE/TaskBar", "toggleMenu()", | 197 | "QPE/TaskBar", "toggleMenu()", |
196 | "QPE/TaskBar", "toggleStartMenu()" }, | 198 | "QPE/TaskBar", "toggleStartMenu()" }, |
197 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 199 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
198 | "devicebuttons/z_mail", | 200 | "devicebuttons/z_mail", |
199 | "mail", "raise()", | 201 | "mail", "raise()", |
200 | "mail", "newMail()" }, | 202 | "mail", "newMail()" }, |
201 | }; | 203 | }; |
202 | 204 | ||
203 | static QCString makeChannel ( const char *str ) | 205 | static QCString makeChannel ( const char *str ) |
204 | { | 206 | { |
205 | if ( str && !::strchr ( str, '/' )) | 207 | if ( str && !::strchr ( str, '/' )) |
206 | return QCString ( "QPE/Application/" ) + str; | 208 | return QCString ( "QPE/Application/" ) + str; |
207 | else | 209 | else |
208 | return str; | 210 | return str; |
209 | } | 211 | } |
210 | 212 | ||
211 | 213 | ||
212 | 214 | ||
213 | 215 | ||
214 | ODevice *ODevice::inst ( ) | 216 | ODevice *ODevice::inst ( ) |
215 | { | 217 | { |
216 | static ODevice *dev = 0; | 218 | static ODevice *dev = 0; |
217 | 219 | ||
218 | if ( !dev ) { | 220 | if ( !dev ) { |
219 | if ( QFile::exists ( "/proc/hal/model" )) | 221 | if ( QFile::exists ( "/proc/hal/model" )) |
220 | dev = new iPAQ ( ); | 222 | dev = new iPAQ ( ); |
221 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 223 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
222 | dev = new Zaurus ( ); | 224 | dev = new Zaurus ( ); |
223 | else | 225 | else |
224 | dev = new ODevice ( ); | 226 | dev = new ODevice ( ); |
225 | 227 | ||
226 | dev-> init ( ); | 228 | dev-> init ( ); |
227 | } | 229 | } |
228 | return dev; | 230 | return dev; |
229 | } | 231 | } |
230 | 232 | ||
231 | 233 | ||
232 | /************************************************** | 234 | /************************************************** |
233 | * | 235 | * |
234 | * common | 236 | * common |
235 | * | 237 | * |
236 | **************************************************/ | 238 | **************************************************/ |
237 | 239 | ||
238 | 240 | ||
239 | ODevice::ODevice ( ) | 241 | ODevice::ODevice ( ) |
240 | { | 242 | { |
241 | d = new ODeviceData; | 243 | d = new ODeviceData; |
242 | 244 | ||
243 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 245 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
244 | 246 | ||
245 | d-> m_modelstr = "Unknown"; | 247 | d-> m_modelstr = "Unknown"; |
246 | d-> m_model = Model_Unknown; | 248 | d-> m_model = Model_Unknown; |
247 | d-> m_vendorstr = "Unknown"; | 249 | d-> m_vendorstr = "Unknown"; |
248 | d-> m_vendor = Vendor_Unknown; | 250 | d-> m_vendor = Vendor_Unknown; |
249 | d-> m_systemstr = "Unknown"; | 251 | d-> m_systemstr = "Unknown"; |
250 | d-> m_system = System_Unknown; | 252 | d-> m_system = System_Unknown; |
251 | d-> m_sysverstr = "0.0"; | 253 | d-> m_sysverstr = "0.0"; |
254 | d-> m_rotation = None; | ||
252 | 255 | ||
253 | d-> m_holdtime = 1000; // 1000ms | 256 | d-> m_holdtime = 1000; // 1000ms |
254 | 257 | ||
255 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 258 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
256 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 259 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
257 | } | 260 | } |
258 | 261 | ||
259 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 262 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
260 | { | 263 | { |
261 | if ( msg == "deviceButtonMappingChanged()" ) { | 264 | if ( msg == "deviceButtonMappingChanged()" ) { |
262 | reloadButtonMapping ( ); | 265 | reloadButtonMapping ( ); |
263 | } | 266 | } |
264 | } | 267 | } |
265 | 268 | ||
266 | void ODevice::init ( ) | 269 | void ODevice::init ( ) |
267 | { | 270 | { |
268 | // Simulation uses iPAQ 3660 device buttons | 271 | // Simulation uses iPAQ 3660 device buttons |
269 | 272 | ||
270 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 273 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
271 | i_button *ib = ipaq_buttons + i; | 274 | i_button *ib = ipaq_buttons + i; |
272 | ODeviceButton b; | 275 | ODeviceButton b; |
273 | 276 | ||
274 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 277 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
275 | b. setKeycode ( ib-> code ); | 278 | b. setKeycode ( ib-> code ); |
276 | b. setUserText ( qApp-> translate ( "Button", ib-> utext )); | 279 | b. setUserText ( qApp-> translate ( "Button", ib-> utext )); |
277 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 280 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
278 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 281 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
279 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 282 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
280 | 283 | ||
281 | d-> m_buttons. append ( b ); | 284 | d-> m_buttons. append ( b ); |
282 | } | 285 | } |
283 | } | 286 | } |
284 | reloadButtonMapping ( ); | 287 | reloadButtonMapping ( ); |
285 | } | 288 | } |
286 | 289 | ||
287 | ODevice::~ODevice ( ) | 290 | ODevice::~ODevice ( ) |
288 | { | 291 | { |
289 | delete d; | 292 | delete d; |
290 | } | 293 | } |
291 | 294 | ||
292 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 295 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
293 | { | 296 | { |
294 | return false; | 297 | return false; |
295 | } | 298 | } |
296 | 299 | ||
297 | //#include <linux/apm_bios.h> | 300 | //#include <linux/apm_bios.h> |
298 | 301 | ||
299 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 302 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
300 | 303 | ||
301 | 304 | ||
302 | bool ODevice::suspend ( ) | 305 | bool ODevice::suspend ( ) |
303 | { | 306 | { |
304 | if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend | 307 | if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend |
305 | return false; | 308 | return false; |
306 | 309 | ||
307 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 310 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
308 | return false; | 311 | return false; |
309 | 312 | ||
310 | bool res = false; | 313 | bool res = false; |
311 | 314 | ||
312 | struct timeval tvs, tvn; | 315 | struct timeval tvs, tvn; |
313 | ::gettimeofday ( &tvs, 0 ); | 316 | ::gettimeofday ( &tvs, 0 ); |
314 | 317 | ||
315 | ::sync ( ); // flush fs caches | 318 | ::sync ( ); // flush fs caches |
316 | res = ( ::system ( "apm --suspend" ) == 0 ); | 319 | res = ( ::system ( "apm --suspend" ) == 0 ); |
317 | 320 | ||
318 | // This is needed because the iPAQ apm implementation is asynchronous and we | 321 | // This is needed because the iPAQ apm implementation is asynchronous and we |
319 | // can not be sure when exactly the device is really suspended | 322 | // can not be sure when exactly the device is really suspended |
320 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 323 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
321 | 324 | ||
322 | if ( res ) { | 325 | if ( res ) { |
323 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 326 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
324 | ::usleep ( 200 * 1000 ); | 327 | ::usleep ( 200 * 1000 ); |
325 | ::gettimeofday ( &tvn, 0 ); | 328 | ::gettimeofday ( &tvn, 0 ); |
326 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 329 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
327 | } | 330 | } |
328 | 331 | ||
329 | return res; | 332 | return res; |
330 | } | 333 | } |
331 | 334 | ||
332 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 335 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
333 | 336 | ||
334 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 337 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
335 | 338 | ||
336 | /* VESA Blanking Levels */ | 339 | /* VESA Blanking Levels */ |
337 | #define VESA_NO_BLANKING 0 | 340 | #define VESA_NO_BLANKING 0 |
338 | #define VESA_VSYNC_SUSPEND 1 | 341 | #define VESA_VSYNC_SUSPEND 1 |
339 | #define VESA_HSYNC_SUSPEND 2 | 342 | #define VESA_HSYNC_SUSPEND 2 |
340 | #define VESA_POWERDOWN 3 | 343 | #define VESA_POWERDOWN 3 |
341 | 344 | ||
342 | 345 | ||
343 | bool ODevice::setDisplayStatus ( bool on ) | 346 | bool ODevice::setDisplayStatus ( bool on ) |
344 | { | 347 | { |
345 | if ( d-> m_model == Model_Unknown ) | 348 | if ( d-> m_model == Model_Unknown ) |
346 | return false; | 349 | return false; |
347 | 350 | ||
348 | bool res = false; | 351 | bool res = false; |
349 | int fd; | 352 | int fd; |
350 | 353 | ||
351 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 354 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
352 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 355 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
353 | ::close ( fd ); | 356 | ::close ( fd ); |
354 | } | 357 | } |
355 | return res; | 358 | return res; |
356 | } | 359 | } |
357 | 360 | ||
358 | bool ODevice::setDisplayBrightness ( int ) | 361 | bool ODevice::setDisplayBrightness ( int ) |
359 | { | 362 | { |
360 | return false; | 363 | return false; |
361 | } | 364 | } |
362 | 365 | ||
363 | int ODevice::displayBrightnessResolution ( ) const | 366 | int ODevice::displayBrightnessResolution ( ) const |
364 | { | 367 | { |
365 | return 16; | 368 | return 16; |
366 | } | 369 | } |
367 | 370 | ||
368 | QString ODevice::vendorString ( ) const | 371 | QString ODevice::vendorString ( ) const |
369 | { | 372 | { |
370 | return d-> m_vendorstr; | 373 | return d-> m_vendorstr; |
371 | } | 374 | } |
372 | 375 | ||
373 | OVendor ODevice::vendor ( ) const | 376 | OVendor ODevice::vendor ( ) const |
374 | { | 377 | { |
375 | return d-> m_vendor; | 378 | return d-> m_vendor; |
376 | } | 379 | } |
377 | 380 | ||
378 | QString ODevice::modelString ( ) const | 381 | QString ODevice::modelString ( ) const |
379 | { | 382 | { |
380 | return d-> m_modelstr; | 383 | return d-> m_modelstr; |
381 | } | 384 | } |
382 | 385 | ||
383 | OModel ODevice::model ( ) const | 386 | OModel ODevice::model ( ) const |
384 | { | 387 | { |
385 | return d-> m_model; | 388 | return d-> m_model; |
386 | } | 389 | } |
387 | 390 | ||
388 | QString ODevice::systemString ( ) const | 391 | QString ODevice::systemString ( ) const |
389 | { | 392 | { |
390 | return d-> m_systemstr; | 393 | return d-> m_systemstr; |
391 | } | 394 | } |
392 | 395 | ||
393 | OSystem ODevice::system ( ) const | 396 | OSystem ODevice::system ( ) const |
394 | { | 397 | { |
395 | return d-> m_system; | 398 | return d-> m_system; |
396 | } | 399 | } |
397 | 400 | ||
398 | QString ODevice::systemVersionString ( ) const | 401 | QString ODevice::systemVersionString ( ) const |
399 | { | 402 | { |
400 | return d-> m_sysverstr; | 403 | return d-> m_sysverstr; |
401 | } | 404 | } |
402 | 405 | ||
406 | Transformation ODevice::rotation ( ) const | ||
407 | { | ||
408 | return d-> m_rotation; | ||
409 | } | ||
410 | |||
403 | void ODevice::alarmSound ( ) | 411 | void ODevice::alarmSound ( ) |
404 | { | 412 | { |
405 | #ifndef QT_NO_SOUND | 413 | #ifndef QT_NO_SOUND |
406 | static Sound snd ( "alarm" ); | 414 | static Sound snd ( "alarm" ); |
407 | 415 | ||
408 | if ( snd. isFinished ( )) | 416 | if ( snd. isFinished ( )) |
409 | snd. play ( ); | 417 | snd. play ( ); |
410 | #endif | 418 | #endif |
411 | } | 419 | } |
412 | 420 | ||
413 | void ODevice::keySound ( ) | 421 | void ODevice::keySound ( ) |
414 | { | 422 | { |
415 | #ifndef QT_NO_SOUND | 423 | #ifndef QT_NO_SOUND |
416 | static Sound snd ( "keysound" ); | 424 | static Sound snd ( "keysound" ); |
417 | 425 | ||
418 | if ( snd. isFinished ( )) | 426 | if ( snd. isFinished ( )) |
419 | snd. play ( ); | 427 | snd. play ( ); |
420 | #endif | 428 | #endif |
421 | } | 429 | } |
422 | 430 | ||
423 | void ODevice::touchSound ( ) | 431 | void ODevice::touchSound ( ) |
424 | { | 432 | { |
425 | 433 | ||
426 | #ifndef QT_NO_SOUND | 434 | #ifndef QT_NO_SOUND |
427 | static Sound snd ( "touchsound" ); | 435 | static Sound snd ( "touchsound" ); |
428 | 436 | ||
429 | if ( snd. isFinished ( )) | 437 | if ( snd. isFinished ( )) |
430 | snd. play ( ); | 438 | snd. play ( ); |
431 | #endif | 439 | #endif |
432 | } | 440 | } |
433 | 441 | ||
434 | 442 | ||
435 | QValueList <OLed> ODevice::ledList ( ) const | 443 | QValueList <OLed> ODevice::ledList ( ) const |
436 | { | 444 | { |
437 | return QValueList <OLed> ( ); | 445 | return QValueList <OLed> ( ); |
438 | } | 446 | } |
439 | 447 | ||
440 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 448 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
441 | { | 449 | { |
442 | return QValueList <OLedState> ( ); | 450 | return QValueList <OLedState> ( ); |
443 | } | 451 | } |
444 | 452 | ||
445 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 453 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
446 | { | 454 | { |
447 | return Led_Off; | 455 | return Led_Off; |
448 | } | 456 | } |
449 | 457 | ||
450 | bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) | 458 | bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) |
451 | { | 459 | { |
452 | return false; | 460 | return false; |
453 | } | 461 | } |
454 | 462 | ||
455 | bool ODevice::hasLightSensor ( ) const | 463 | bool ODevice::hasLightSensor ( ) const |
456 | { | 464 | { |
457 | return false; | 465 | return false; |
458 | } | 466 | } |
459 | 467 | ||
460 | int ODevice::readLightSensor ( ) | 468 | int ODevice::readLightSensor ( ) |
461 | { | 469 | { |
462 | return -1; | 470 | return -1; |
463 | } | 471 | } |
464 | 472 | ||
465 | int ODevice::lightSensorResolution ( ) const | 473 | int ODevice::lightSensorResolution ( ) const |
466 | { | 474 | { |
467 | return 0; | 475 | return 0; |
468 | } | 476 | } |
469 | 477 | ||
470 | const QValueList <ODeviceButton> &ODevice::buttons ( ) const | 478 | const QValueList <ODeviceButton> &ODevice::buttons ( ) const |
471 | { | 479 | { |
472 | return d-> m_buttons; | 480 | return d-> m_buttons; |
473 | } | 481 | } |
474 | 482 | ||
475 | uint ODevice::buttonHoldTime ( ) const | 483 | uint ODevice::buttonHoldTime ( ) const |
476 | { | 484 | { |
477 | return d-> m_holdtime; | 485 | return d-> m_holdtime; |
478 | } | 486 | } |
479 | 487 | ||
480 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 488 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
481 | { | 489 | { |
482 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons. begin ( ); it != d-> m_buttons. end ( ); ++it ) { | 490 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons. begin ( ); it != d-> m_buttons. end ( ); ++it ) { |
483 | if ( (*it). keycode ( ) == code ) | 491 | if ( (*it). keycode ( ) == code ) |
484 | return &(*it); | 492 | return &(*it); |
485 | } | 493 | } |
486 | return 0; | 494 | return 0; |
487 | } | 495 | } |
488 | 496 | ||
489 | void ODevice::reloadButtonMapping ( ) | 497 | void ODevice::reloadButtonMapping ( ) |
490 | { | 498 | { |
491 | Config cfg ( "ButtonSettings" ); | 499 | Config cfg ( "ButtonSettings" ); |
492 | 500 | ||
493 | for ( uint i = 0; i < d-> m_buttons. count ( ); i++ ) { | 501 | for ( uint i = 0; i < d-> m_buttons. count ( ); i++ ) { |
494 | ODeviceButton &b = d-> m_buttons [i]; | 502 | ODeviceButton &b = d-> m_buttons [i]; |
495 | QString group = "Button" + QString::number ( i ); | 503 | QString group = "Button" + QString::number ( i ); |
496 | 504 | ||
497 | QCString pch, hch; | 505 | QCString pch, hch; |
498 | QCString pm, hm; | 506 | QCString pm, hm; |
499 | QByteArray pdata, hdata; | 507 | QByteArray pdata, hdata; |
500 | 508 | ||
501 | if ( cfg. hasGroup ( group )) { | 509 | if ( cfg. hasGroup ( group )) { |
502 | cfg. setGroup ( group ); | 510 | cfg. setGroup ( group ); |
503 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); | 511 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); |
504 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); | 512 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); |
505 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 513 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
506 | 514 | ||
507 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); | 515 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); |
508 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); | 516 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); |
509 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 517 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
510 | } | 518 | } |
511 | 519 | ||
512 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 520 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
513 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 521 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
514 | } | 522 | } |
515 | } | 523 | } |
516 | 524 | ||
517 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 525 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
518 | { | 526 | { |
519 | if ( button >= (int) d-> m_buttons. count ( )) | 527 | if ( button >= (int) d-> m_buttons. count ( )) |
520 | return; | 528 | return; |
521 | 529 | ||
522 | ODeviceButton &b = d-> m_buttons [button]; | 530 | ODeviceButton &b = d-> m_buttons [button]; |
523 | b. setPressedAction ( action ); | 531 | b. setPressedAction ( action ); |
524 | 532 | ||
525 | Config buttonFile ( "ButtonSettings" ); | 533 | Config buttonFile ( "ButtonSettings" ); |
526 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 534 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
527 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) b. pressedAction ( ). channel ( )); | 535 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) b. pressedAction ( ). channel ( )); |
528 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 536 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
529 | 537 | ||
530 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 538 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
531 | 539 | ||
532 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 540 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
533 | } | 541 | } |
534 | 542 | ||
535 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 543 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
536 | { | 544 | { |
537 | if ( button >= (int) d-> m_buttons. count ( )) | 545 | if ( button >= (int) d-> m_buttons. count ( )) |
538 | return; | 546 | return; |
539 | 547 | ||
540 | ODeviceButton &b = d-> m_buttons [button]; | 548 | ODeviceButton &b = d-> m_buttons [button]; |
541 | b. setHeldAction ( action ); | 549 | b. setHeldAction ( action ); |
542 | 550 | ||
543 | Config buttonFile ( "ButtonSettings" ); | 551 | Config buttonFile ( "ButtonSettings" ); |
544 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 552 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
545 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 553 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
546 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 554 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
547 | 555 | ||
548 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 556 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
549 | 557 | ||
550 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 558 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
551 | } | 559 | } |
552 | 560 | ||
553 | 561 | ||
554 | 562 | ||
555 | 563 | ||
556 | /************************************************** | 564 | /************************************************** |
557 | * | 565 | * |
558 | * iPAQ | 566 | * iPAQ |
559 | * | 567 | * |
560 | **************************************************/ | 568 | **************************************************/ |
561 | 569 | ||
562 | void iPAQ::init ( ) | 570 | void iPAQ::init ( ) |
563 | { | 571 | { |
564 | d-> m_vendorstr = "HP"; | 572 | d-> m_vendorstr = "HP"; |
565 | d-> m_vendor = Vendor_HP; | 573 | d-> m_vendor = Vendor_HP; |
566 | 574 | ||
567 | QFile f ( "/proc/hal/model" ); | 575 | QFile f ( "/proc/hal/model" ); |
568 | 576 | ||
569 | if ( f. open ( IO_ReadOnly )) { | 577 | if ( f. open ( IO_ReadOnly )) { |
570 | QTextStream ts ( &f ); | 578 | QTextStream ts ( &f ); |
571 | 579 | ||
572 | d-> m_modelstr = "H" + ts. readLine ( ); | 580 | d-> m_modelstr = "H" + ts. readLine ( ); |
573 | 581 | ||
574 | if ( d-> m_modelstr == "H3100" ) | 582 | if ( d-> m_modelstr == "H3100" ) |
575 | d-> m_model = Model_iPAQ_H31xx; | 583 | d-> m_model = Model_iPAQ_H31xx; |
576 | else if ( d-> m_modelstr == "H3600" ) | 584 | else if ( d-> m_modelstr == "H3600" ) |
577 | d-> m_model = Model_iPAQ_H36xx; | 585 | d-> m_model = Model_iPAQ_H36xx; |
578 | else if ( d-> m_modelstr == "H3700" ) | 586 | else if ( d-> m_modelstr == "H3700" ) |
579 | d-> m_model = Model_iPAQ_H37xx; | 587 | d-> m_model = Model_iPAQ_H37xx; |
580 | else if ( d-> m_modelstr == "H3800" ) | 588 | else if ( d-> m_modelstr == "H3800" ) |
581 | d-> m_model = Model_iPAQ_H38xx; | 589 | d-> m_model = Model_iPAQ_H38xx; |
582 | else if ( d-> m_modelstr == "H3900" ) | 590 | else if ( d-> m_modelstr == "H3900" ) |
583 | d-> m_model = Model_iPAQ_H39xx; | 591 | d-> m_model = Model_iPAQ_H39xx; |
584 | else | 592 | else |
585 | d-> m_model = Model_Unknown; | 593 | d-> m_model = Model_Unknown; |
586 | 594 | ||
587 | f. close ( ); | 595 | f. close ( ); |
588 | } | 596 | } |
589 | 597 | ||
598 | switch ( d-> m_model ) { | ||
599 | case Model_iPAQ_H31xx: | ||
600 | case Model_iPAQ_H38xx: | ||
601 | d-> m_rotation = Rot90; | ||
602 | break; | ||
603 | case Model_iPAQ_H36xx: | ||
604 | case Model_iPAQ_H37xx: | ||
605 | case Model_iPAQ_H39xx: | ||
606 | default: | ||
607 | d-> m_rotation = Rot270; | ||
608 | break; | ||
609 | } | ||
610 | |||
590 | f. setName ( "/etc/familiar-version" ); | 611 | f. setName ( "/etc/familiar-version" ); |
591 | if ( f. open ( IO_ReadOnly )) { | 612 | if ( f. open ( IO_ReadOnly )) { |
592 | d-> m_systemstr = "Familiar"; | 613 | d-> m_systemstr = "Familiar"; |
593 | d-> m_system = System_Familiar; | 614 | d-> m_system = System_Familiar; |
594 | 615 | ||
595 | QTextStream ts ( &f ); | 616 | QTextStream ts ( &f ); |
596 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 617 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
597 | 618 | ||
598 | f. close ( ); | 619 | f. close ( ); |
599 | } | 620 | } |
600 | 621 | ||
601 | m_leds [0] = m_leds [1] = Led_Off; | 622 | m_leds [0] = m_leds [1] = Led_Off; |
602 | 623 | ||
603 | m_power_timer = 0; | 624 | m_power_timer = 0; |
604 | 625 | ||
605 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 626 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
606 | i_button *ib = ipaq_buttons + i; | 627 | i_button *ib = ipaq_buttons + i; |
607 | ODeviceButton b; | 628 | ODeviceButton b; |
608 | 629 | ||
609 | if (( ib-> model & d-> m_model ) == d-> m_model ) { | 630 | if (( ib-> model & d-> m_model ) == d-> m_model ) { |
610 | b. setKeycode ( ib-> code ); | 631 | b. setKeycode ( ib-> code ); |
611 | b. setUserText ( qApp-> translate ( "Button", ib-> utext )); | 632 | b. setUserText ( qApp-> translate ( "Button", ib-> utext )); |
612 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 633 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
613 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 634 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
614 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 635 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
615 | 636 | ||
616 | d-> m_buttons. append ( b ); | 637 | d-> m_buttons. append ( b ); |
617 | } | 638 | } |
618 | } | 639 | } |
619 | reloadButtonMapping ( ); | 640 | reloadButtonMapping ( ); |
620 | 641 | ||
621 | if ( d-> m_qwsserver ) | 642 | if ( d-> m_qwsserver ) |
622 | QWSServer::setKeyboardFilter ( this ); | 643 | QWSServer::setKeyboardFilter ( this ); |
623 | } | 644 | } |
624 | 645 | ||
625 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 646 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
626 | 647 | ||
627 | typedef struct { | 648 | typedef struct { |
628 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 649 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
629 | unsigned char TotalTime; /* Units of 5 seconds */ | 650 | unsigned char TotalTime; /* Units of 5 seconds */ |
630 | unsigned char OnTime; /* units of 100m/s */ | 651 | unsigned char OnTime; /* units of 100m/s */ |
631 | unsigned char OffTime; /* units of 100m/s */ | 652 | unsigned char OffTime; /* units of 100m/s */ |
632 | } LED_IN; | 653 | } LED_IN; |
633 | 654 | ||
634 | typedef struct { | 655 | typedef struct { |
635 | unsigned char mode; | 656 | unsigned char mode; |
636 | unsigned char pwr; | 657 | unsigned char pwr; |
637 | unsigned char brightness; | 658 | unsigned char brightness; |
638 | } FLITE_IN; | 659 | } FLITE_IN; |
639 | 660 | ||
640 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 661 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
641 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 662 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
642 | 663 | ||
643 | 664 | ||
644 | |||
645 | QValueList <OLed> iPAQ::ledList ( ) const | 665 | QValueList <OLed> iPAQ::ledList ( ) const |
646 | { | 666 | { |
647 | QValueList <OLed> vl; | 667 | QValueList <OLed> vl; |
648 | vl << Led_Power; | 668 | vl << Led_Power; |
649 | 669 | ||
650 | if ( d-> m_model == Model_iPAQ_H38xx ) | 670 | if ( d-> m_model == Model_iPAQ_H38xx ) |
651 | vl << Led_BlueTooth; | 671 | vl << Led_BlueTooth; |
652 | return vl; | 672 | return vl; |
653 | } | 673 | } |
654 | 674 | ||
655 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 675 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
656 | { | 676 | { |
657 | QValueList <OLedState> vl; | 677 | QValueList <OLedState> vl; |
658 | 678 | ||
659 | if ( l == Led_Power ) | 679 | if ( l == Led_Power ) |
660 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 680 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
661 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 681 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
662 | vl << Led_Off; // << Led_On << ??? | 682 | vl << Led_Off; // << Led_On << ??? |
663 | 683 | ||
664 | return vl; | 684 | return vl; |
665 | } | 685 | } |
666 | 686 | ||
667 | OLedState iPAQ::ledState ( OLed l ) const | 687 | OLedState iPAQ::ledState ( OLed l ) const |
668 | { | 688 | { |
669 | switch ( l ) { | 689 | switch ( l ) { |
670 | case Led_Power: | 690 | case Led_Power: |
671 | return m_leds [0]; | 691 | return m_leds [0]; |
672 | case Led_BlueTooth: | 692 | case Led_BlueTooth: |
673 | return m_leds [1]; | 693 | return m_leds [1]; |
674 | default: | 694 | default: |
675 | return Led_Off; | 695 | return Led_Off; |
676 | } | 696 | } |
677 | } | 697 | } |
678 | 698 | ||
679 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 699 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
680 | { | 700 | { |
681 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 701 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
682 | 702 | ||
683 | if ( l == Led_Power ) { | 703 | if ( l == Led_Power ) { |
684 | if ( fd >= 0 ) { | 704 | if ( fd >= 0 ) { |
685 | LED_IN leds; | 705 | LED_IN leds; |
686 | ::memset ( &leds, 0, sizeof( leds )); | 706 | ::memset ( &leds, 0, sizeof( leds )); |
687 | leds. TotalTime = 0; | 707 | leds. TotalTime = 0; |
688 | leds. OnTime = 0; | 708 | leds. OnTime = 0; |
689 | leds. OffTime = 1; | 709 | leds. OffTime = 1; |
690 | leds. OffOnBlink = 2; | 710 | leds. OffOnBlink = 2; |
691 | 711 | ||
692 | switch ( st ) { | 712 | switch ( st ) { |
693 | case Led_Off : leds. OffOnBlink = 0; break; | 713 | case Led_Off : leds. OffOnBlink = 0; break; |
694 | case Led_On : leds. OffOnBlink = 1; break; | 714 | case Led_On : leds. OffOnBlink = 1; break; |
695 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 715 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
696 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 716 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
697 | } | 717 | } |
698 | 718 | ||
699 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 719 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
700 | m_leds [0] = st; | 720 | m_leds [0] = st; |
701 | return true; | 721 | return true; |
702 | } | 722 | } |
703 | } | 723 | } |
704 | } | 724 | } |
705 | return false; | 725 | return false; |
706 | } | 726 | } |
707 | 727 | ||
708 | 728 | ||
709 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 729 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
710 | { | 730 | { |
711 | int newkeycode = keycode; | 731 | int newkeycode = keycode; |
712 | 732 | ||
713 | switch ( keycode ) { | 733 | switch ( keycode ) { |
714 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 734 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
715 | case HardKey_Menu: { | 735 | case HardKey_Menu: { |
716 | if (( d-> m_model == Model_iPAQ_H38xx ) || | 736 | if (( d-> m_model == Model_iPAQ_H38xx ) || |
717 | ( d-> m_model == Model_iPAQ_H39xx )) { | 737 | ( d-> m_model == Model_iPAQ_H39xx )) { |
718 | newkeycode = HardKey_Mail; | 738 | newkeycode = HardKey_Mail; |
719 | } | 739 | } |
720 | break; | 740 | break; |
721 | } | 741 | } |
722 | 742 | ||
723 | // Rotate cursor keys 180° | 743 | // Rotate cursor keys 180° |
724 | case Key_Left : | 744 | case Key_Left : |
725 | case Key_Right: | 745 | case Key_Right: |
726 | case Key_Up : | 746 | case Key_Up : |
727 | case Key_Down : { | 747 | case Key_Down : { |
728 | if (( d-> m_model == Model_iPAQ_H31xx ) || | 748 | if (( d-> m_model == Model_iPAQ_H31xx ) || |
729 | ( d-> m_model == Model_iPAQ_H38xx )) { | 749 | ( d-> m_model == Model_iPAQ_H38xx )) { |
730 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 750 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
731 | } | 751 | } |
732 | break; | 752 | break; |
733 | } | 753 | } |
734 | 754 | ||
735 | // map Power Button short/long press to F34/F35 | 755 | // map Power Button short/long press to F34/F35 |
736 | case Key_SysReq: { | 756 | case Key_SysReq: { |
737 | if ( isPress ) { | 757 | if ( isPress ) { |
738 | if ( m_power_timer ) | 758 | if ( m_power_timer ) |
739 | killTimer ( m_power_timer ); | 759 | killTimer ( m_power_timer ); |
740 | m_power_timer = startTimer ( 500 ); | 760 | m_power_timer = startTimer ( 500 ); |
@@ -844,203 +864,222 @@ bool iPAQ::setDisplayBrightness ( int bright ) | |||
844 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 864 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
845 | ::close ( fd ); | 865 | ::close ( fd ); |
846 | } | 866 | } |
847 | return res; | 867 | return res; |
848 | } | 868 | } |
849 | 869 | ||
850 | int iPAQ::displayBrightnessResolution ( ) const | 870 | int iPAQ::displayBrightnessResolution ( ) const |
851 | { | 871 | { |
852 | switch ( model ( )) { | 872 | switch ( model ( )) { |
853 | case Model_iPAQ_H31xx: | 873 | case Model_iPAQ_H31xx: |
854 | case Model_iPAQ_H36xx: | 874 | case Model_iPAQ_H36xx: |
855 | case Model_iPAQ_H37xx: | 875 | case Model_iPAQ_H37xx: |
856 | return 128; // really 256, but >128 could damage the LCD | 876 | return 128; // really 256, but >128 could damage the LCD |
857 | 877 | ||
858 | case Model_iPAQ_H38xx: | 878 | case Model_iPAQ_H38xx: |
859 | case Model_iPAQ_H39xx: | 879 | case Model_iPAQ_H39xx: |
860 | return 64; | 880 | return 64; |
861 | 881 | ||
862 | default: | 882 | default: |
863 | return 2; | 883 | return 2; |
864 | } | 884 | } |
865 | } | 885 | } |
866 | 886 | ||
867 | 887 | ||
868 | bool iPAQ::hasLightSensor ( ) const | 888 | bool iPAQ::hasLightSensor ( ) const |
869 | { | 889 | { |
870 | return true; | 890 | return true; |
871 | } | 891 | } |
872 | 892 | ||
873 | int iPAQ::readLightSensor ( ) | 893 | int iPAQ::readLightSensor ( ) |
874 | { | 894 | { |
875 | int fd; | 895 | int fd; |
876 | int val = -1; | 896 | int val = -1; |
877 | 897 | ||
878 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 898 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
879 | char buffer [8]; | 899 | char buffer [8]; |
880 | 900 | ||
881 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 901 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
882 | char *endptr; | 902 | char *endptr; |
883 | 903 | ||
884 | buffer [4] = 0; | 904 | buffer [4] = 0; |
885 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 905 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
886 | 906 | ||
887 | if ( *endptr != 0 ) | 907 | if ( *endptr != 0 ) |
888 | val = -1; | 908 | val = -1; |
889 | } | 909 | } |
890 | ::close ( fd ); | 910 | ::close ( fd ); |
891 | } | 911 | } |
892 | 912 | ||
893 | return val; | 913 | return val; |
894 | } | 914 | } |
895 | 915 | ||
896 | int iPAQ::lightSensorResolution ( ) const | 916 | int iPAQ::lightSensorResolution ( ) const |
897 | { | 917 | { |
898 | return 256; | 918 | return 256; |
899 | } | 919 | } |
900 | 920 | ||
901 | /************************************************** | 921 | /************************************************** |
902 | * | 922 | * |
903 | * Zaurus | 923 | * Zaurus |
904 | * | 924 | * |
905 | **************************************************/ | 925 | **************************************************/ |
906 | 926 | ||
907 | 927 | ||
908 | 928 | ||
909 | void Zaurus::init ( ) | 929 | void Zaurus::init ( ) |
910 | { | 930 | { |
911 | d-> m_vendorstr = "Sharp"; | 931 | d-> m_vendorstr = "Sharp"; |
912 | d-> m_vendor = Vendor_Sharp; | 932 | d-> m_vendor = Vendor_Sharp; |
913 | 933 | ||
914 | QFile f ( "/proc/filesystems" ); | 934 | QFile f ( "/proc/filesystems" ); |
915 | 935 | ||
916 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 936 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
917 | d-> m_vendorstr = "OpenZaurus Team"; | 937 | d-> m_vendorstr = "OpenZaurus Team"; |
918 | d-> m_systemstr = "OpenZaurus"; | 938 | d-> m_systemstr = "OpenZaurus"; |
919 | d-> m_system = System_OpenZaurus; | 939 | d-> m_system = System_OpenZaurus; |
920 | 940 | ||
921 | f. close ( ); | 941 | f. close ( ); |
922 | 942 | ||
923 | f. setName ( "/etc/oz_version" ); | 943 | f. setName ( "/etc/oz_version" ); |
924 | if ( f. open ( IO_ReadOnly )) { | 944 | if ( f. open ( IO_ReadOnly )) { |
925 | QTextStream ts ( &f ); | 945 | QTextStream ts ( &f ); |
926 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 946 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
927 | f. close ( ); | 947 | f. close ( ); |
928 | } | 948 | } |
929 | } | 949 | } |
930 | else { | 950 | else { |
931 | d-> m_systemstr = "Zaurus"; | 951 | d-> m_systemstr = "Zaurus"; |
932 | d-> m_system = System_Zaurus; | 952 | d-> m_system = System_Zaurus; |
933 | } | 953 | } |
934 | 954 | ||
935 | f. setName ( "/proc/deviceinfo/product" ); | 955 | f. setName ( "/proc/deviceinfo/product" ); |
936 | if ( f. open ( IO_ReadOnly ) ) { | 956 | if ( f. open ( IO_ReadOnly ) ) { |
937 | QTextStream ts ( &f ); | 957 | QTextStream ts ( &f ); |
938 | QString model = ts. readLine ( ); | 958 | QString model = ts. readLine ( ); |
939 | f. close ( ); | 959 | f. close ( ); |
940 | if ( model == "SL-5000D" ) { | 960 | |
941 | d-> m_model = Model_Zaurus_SL5000; | 961 | d-> m_modelstr = QString("Zaurus ") + model; |
942 | d-> m_modelstr = "Zaurus SL-5000D"; | 962 | if ( model == "SL-5500" ) |
943 | } else if ( model == "SL-5500" ) { | ||
944 | d-> m_model = Model_Zaurus_SL5500; | 963 | d-> m_model = Model_Zaurus_SL5500; |
945 | d-> m_modelstr = "Zaurus SL-5500"; | 964 | else if ( model == "SL-C700" ) |
946 | } | 965 | d-> m_model = Model_Zaurus_SLC700; |
966 | else if ( model == "SL-A300" ) | ||
967 | d-> m_model = Model_Zaurus_SLA300; | ||
968 | else if ( model == "SL-B600" || model == "SL-5600" ) | ||
969 | d-> m_model = Model_Zaurus_SLB600; | ||
970 | else | ||
971 | d-> m_model = Model_Zaurus_SL5000; | ||
947 | } | 972 | } |
948 | else { | 973 | else { |
949 | d-> m_model = Model_Zaurus_SL5000; | 974 | d-> m_model = Model_Zaurus_SL5000; |
950 | d-> m_modelstr = "Zaurus SL-5000D (unverified)"; | 975 | d-> m_modelstr = "Zaurus (model unknown)"; |
976 | } | ||
977 | |||
978 | switch ( d-> m_model ) { | ||
979 | case Model_Zaurus_SLC700: | ||
980 | /* note for C700, we must check the display rotation | ||
981 | * sensor to set an appropriate value | ||
982 | */ | ||
983 | case Model_Zaurus_SLA300: | ||
984 | case Model_Zaurus_SLB600: | ||
985 | case Model_Zaurus_SL5500: | ||
986 | case Model_Zaurus_SL5000: | ||
987 | default: | ||
988 | d-> m_rotation = Rot270; | ||
989 | break; | ||
951 | } | 990 | } |
952 | 991 | ||
953 | for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { | 992 | for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { |
954 | z_button *zb = z_buttons + i; | 993 | z_button *zb = z_buttons + i; |
955 | ODeviceButton b; | 994 | ODeviceButton b; |
956 | 995 | ||
957 | b. setKeycode ( zb-> code ); | 996 | b. setKeycode ( zb-> code ); |
958 | b. setUserText ( qApp-> translate ( "Button", zb-> utext )); | 997 | b. setUserText ( qApp-> translate ( "Button", zb-> utext )); |
959 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); | 998 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); |
960 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); | 999 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); |
961 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); | 1000 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); |
962 | 1001 | ||
963 | d-> m_buttons. append ( b ); | 1002 | d-> m_buttons. append ( b ); |
964 | } | 1003 | } |
965 | reloadButtonMapping ( ); | 1004 | reloadButtonMapping ( ); |
966 | 1005 | ||
967 | m_leds [0] = Led_Off; | 1006 | m_leds [0] = Led_Off; |
968 | } | 1007 | } |
969 | 1008 | ||
970 | #include <unistd.h> | 1009 | #include <unistd.h> |
971 | #include <fcntl.h> | 1010 | #include <fcntl.h> |
972 | #include <sys/ioctl.h> | 1011 | #include <sys/ioctl.h> |
973 | 1012 | ||
974 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 1013 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
975 | 1014 | ||
976 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 1015 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
977 | 1016 | ||
978 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1017 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
979 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1018 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
980 | 1019 | ||
981 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1020 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
982 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1021 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
983 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1022 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
984 | 1023 | ||
985 | /* --- for SHARP_BUZZER device --- */ | 1024 | /* --- for SHARP_BUZZER device --- */ |
986 | 1025 | ||
987 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1026 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
988 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1027 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
989 | 1028 | ||
990 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 1029 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
991 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 1030 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
992 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 1031 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
993 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 1032 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
994 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 1033 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
995 | 1034 | ||
996 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1035 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
997 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1036 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
998 | 1037 | ||
999 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 1038 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
1000 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 1039 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
1001 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 1040 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
1002 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 1041 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
1003 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 1042 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
1004 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 1043 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
1005 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 1044 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
1006 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 1045 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
1007 | 1046 | ||
1008 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1047 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1009 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 1048 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
1010 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 1049 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
1011 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 1050 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
1012 | // | 1051 | // |
1013 | 1052 | ||
1014 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1053 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1015 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 1054 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
1016 | 1055 | ||
1017 | typedef struct sharp_led_status { | 1056 | typedef struct sharp_led_status { |
1018 | int which; /* select which LED status is wanted. */ | 1057 | int which; /* select which LED status is wanted. */ |
1019 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 1058 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
1020 | } sharp_led_status; | 1059 | } sharp_led_status; |
1021 | 1060 | ||
1022 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 1061 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
1023 | 1062 | ||
1024 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 1063 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
1025 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 1064 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
1026 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 1065 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
1027 | 1066 | ||
1028 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 1067 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
1029 | 1068 | ||
1030 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 1069 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
1031 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 1070 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
1032 | #define APM_EVT_POWER_BUTTON (1 << 0) | 1071 | #define APM_EVT_POWER_BUTTON (1 << 0) |
1033 | 1072 | ||
1034 | #define FL_IOCTL_STEP_CONTRAST 100 | 1073 | #define FL_IOCTL_STEP_CONTRAST 100 |
1035 | 1074 | ||
1036 | 1075 | ||
1037 | void Zaurus::buzzer ( int sound ) | 1076 | void Zaurus::buzzer ( int sound ) |
1038 | { | 1077 | { |
1039 | static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); | 1078 | static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); |
1040 | 1079 | ||
1041 | if ( fd >= 0 ) | 1080 | if ( fd >= 0 ) |
1042 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 1081 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
1043 | } | 1082 | } |
1044 | 1083 | ||
1045 | 1084 | ||
1046 | void Zaurus::alarmSound ( ) | 1085 | void Zaurus::alarmSound ( ) |