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