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 /libopie | |
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,1088 +1,1090 @@ | |||
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 ); |