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