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