author | ocheong <ocheong> | 2003-10-09 10:57:25 (UTC) |
---|---|---|
committer | ocheong <ocheong> | 2003-10-09 10:57:25 (UTC) |
commit | 5103b92c2fc7e28f87dcbdc3650820494359dcca (patch) (unidiff) | |
tree | 0236f032f6b30adfbe208f3303e50ddccc772db6 | |
parent | c37ffc2854d1c968eb28d4ae185b5c64877c6e9d (diff) | |
download | opie-5103b92c2fc7e28f87dcbdc3650820494359dcca.zip opie-5103b92c2fc7e28f87dcbdc3650820494359dcca.tar.gz opie-5103b92c2fc7e28f87dcbdc3650820494359dcca.tar.bz2 |
Added class for Yopy devices.
It doesn't really do much, as power and backlight is still
handled by the demons running under X (Opie is meant to be used
without terminating X).
-rw-r--r-- | libopie/odevice.cpp | 149 |
1 files changed, 147 insertions, 2 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 3ff029e..aadd0bf 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1,206 +1,205 @@ | |||
1 | /* This file is part of the OPIE libraries | 1 | /* This file is part of the OPIE libraries |
2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) | 2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | #include <unistd.h> | 21 | #include <unistd.h> |
22 | #include <fcntl.h> | 22 | #include <fcntl.h> |
23 | #include <sys/ioctl.h> | 23 | #include <sys/ioctl.h> |
24 | #include <signal.h> | 24 | #include <signal.h> |
25 | #include <sys/time.h> | 25 | #include <sys/time.h> |
26 | #include <linux/soundcard.h> | 26 | #include <linux/soundcard.h> |
27 | #include <math.h> | 27 | #include <math.h> |
28 | 28 | ||
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | 30 | ||
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qpe/sound.h> | 33 | #include <qpe/sound.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | #include <qpe/qcopenvelope_qws.h> | 36 | #include <qpe/qcopenvelope_qws.h> |
37 | 37 | ||
38 | #include "odevice.h" | 38 | #include "odevice.h" |
39 | 39 | ||
40 | #include <qwindowsystem_qws.h> | 40 | #include <qwindowsystem_qws.h> |
41 | 41 | ||
42 | #ifndef ARRAY_SIZE | 42 | #ifndef ARRAY_SIZE |
43 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | 43 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | // _IO and friends are only defined in kernel headers ... | 46 | // _IO and friends are only defined in kernel headers ... |
47 | 47 | ||
48 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 48 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
49 | 49 | ||
50 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 50 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
51 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 51 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
52 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 52 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
53 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 53 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
54 | 54 | ||
55 | using namespace Opie; | 55 | using namespace Opie; |
56 | 56 | ||
57 | class ODeviceData { | 57 | class ODeviceData { |
58 | public: | 58 | public: |
59 | QString m_vendorstr; | 59 | QString m_vendorstr; |
60 | OVendor m_vendor; | 60 | OVendor m_vendor; |
61 | 61 | ||
62 | QString m_modelstr; | 62 | QString m_modelstr; |
63 | OModel m_model; | 63 | OModel m_model; |
64 | 64 | ||
65 | QString m_systemstr; | 65 | QString m_systemstr; |
66 | OSystem m_system; | 66 | OSystem m_system; |
67 | 67 | ||
68 | QString m_sysverstr; | 68 | QString m_sysverstr; |
69 | 69 | ||
70 | Transformation m_rotation; | 70 | Transformation m_rotation; |
71 | ODirection m_direction; | 71 | ODirection m_direction; |
72 | 72 | ||
73 | QValueList <ODeviceButton> *m_buttons; | 73 | QValueList <ODeviceButton> *m_buttons; |
74 | uint m_holdtime; | 74 | uint m_holdtime; |
75 | QStrList *m_cpu_frequencies; | 75 | QStrList *m_cpu_frequencies; |
76 | }; | 76 | }; |
77 | 77 | ||
78 | |||
79 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { | 78 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter { |
80 | protected: | 79 | protected: |
81 | virtual void init ( ); | 80 | virtual void init ( ); |
82 | virtual void initButtons ( ); | 81 | virtual void initButtons ( ); |
83 | 82 | ||
84 | public: | 83 | public: |
85 | virtual bool setSoftSuspend ( bool soft ); | 84 | virtual bool setSoftSuspend ( bool soft ); |
86 | 85 | ||
87 | virtual bool setDisplayBrightness ( int b ); | 86 | virtual bool setDisplayBrightness ( int b ); |
88 | virtual int displayBrightnessResolution ( ) const; | 87 | virtual int displayBrightnessResolution ( ) const; |
89 | 88 | ||
90 | virtual void alarmSound ( ); | 89 | virtual void alarmSound ( ); |
91 | 90 | ||
92 | virtual QValueList <OLed> ledList ( ) const; | 91 | virtual QValueList <OLed> ledList ( ) const; |
93 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 92 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
94 | virtual OLedState ledState ( OLed led ) const; | 93 | virtual OLedState ledState ( OLed led ) const; |
95 | virtual bool setLedState ( OLed led, OLedState st ); | 94 | virtual bool setLedState ( OLed led, OLedState st ); |
96 | 95 | ||
97 | virtual bool hasLightSensor ( ) const; | 96 | virtual bool hasLightSensor ( ) const; |
98 | virtual int readLightSensor ( ); | 97 | virtual int readLightSensor ( ); |
99 | virtual int lightSensorResolution ( ) const; | 98 | virtual int lightSensorResolution ( ) const; |
100 | 99 | ||
101 | protected: | 100 | protected: |
102 | 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 ); |
103 | virtual void timerEvent ( QTimerEvent *te ); | 102 | virtual void timerEvent ( QTimerEvent *te ); |
104 | 103 | ||
105 | int m_power_timer; | 104 | int m_power_timer; |
106 | 105 | ||
107 | OLedState m_leds [2]; | 106 | OLedState m_leds [2]; |
108 | }; | 107 | }; |
109 | 108 | ||
110 | class Zaurus : public ODevice { | 109 | class Zaurus : public ODevice { |
111 | protected: | 110 | protected: |
112 | virtual void init ( ); | 111 | virtual void init ( ); |
113 | virtual void initButtons ( ); | 112 | virtual void initButtons ( ); |
114 | 113 | ||
115 | public: | 114 | public: |
116 | virtual bool setSoftSuspend ( bool soft ); | 115 | virtual bool setSoftSuspend ( bool soft ); |
117 | 116 | ||
118 | virtual bool setDisplayBrightness ( int b ); | 117 | virtual bool setDisplayBrightness ( int b ); |
119 | virtual int displayBrightnessResolution ( ) const; | 118 | virtual int displayBrightnessResolution ( ) const; |
120 | 119 | ||
121 | virtual void alarmSound ( ); | 120 | virtual void alarmSound ( ); |
122 | virtual void keySound ( ); | 121 | virtual void keySound ( ); |
123 | virtual void touchSound ( ); | 122 | virtual void touchSound ( ); |
124 | 123 | ||
125 | virtual QValueList <OLed> ledList ( ) const; | 124 | virtual QValueList <OLed> ledList ( ) const; |
126 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 125 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
127 | virtual OLedState ledState ( OLed led ) const; | 126 | virtual OLedState ledState ( OLed led ) const; |
128 | virtual bool setLedState ( OLed led, OLedState st ); | 127 | virtual bool setLedState ( OLed led, OLedState st ); |
129 | 128 | ||
130 | static bool isZaurus(); | 129 | static bool isZaurus(); |
131 | 130 | ||
132 | protected: | 131 | protected: |
133 | virtual void buzzer ( int snd ); | 132 | virtual void buzzer ( int snd ); |
134 | 133 | ||
135 | OLedState m_leds [1]; | 134 | OLedState m_leds [1]; |
136 | bool m_embedix; | 135 | bool m_embedix; |
137 | }; | 136 | }; |
138 | 137 | ||
139 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter { | 138 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter { |
140 | protected: | 139 | protected: |
141 | virtual void init ( ); | 140 | virtual void init ( ); |
142 | virtual void initButtons ( ); | 141 | virtual void initButtons ( ); |
143 | 142 | ||
144 | public: | 143 | public: |
145 | virtual bool setSoftSuspend ( bool soft ); | 144 | virtual bool setSoftSuspend ( bool soft ); |
146 | virtual bool suspend(); | 145 | virtual bool suspend(); |
147 | 146 | ||
148 | virtual bool setDisplayStatus( bool on ); | 147 | virtual bool setDisplayStatus( bool on ); |
149 | virtual bool setDisplayBrightness ( int b ); | 148 | virtual bool setDisplayBrightness ( int b ); |
150 | virtual int displayBrightnessResolution ( ) const; | 149 | virtual int displayBrightnessResolution ( ) const; |
151 | 150 | ||
152 | virtual void alarmSound ( ); | 151 | virtual void alarmSound ( ); |
153 | 152 | ||
154 | virtual QValueList <OLed> ledList ( ) const; | 153 | virtual QValueList <OLed> ledList ( ) const; |
155 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 154 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
156 | virtual OLedState ledState ( OLed led ) const; | 155 | virtual OLedState ledState ( OLed led ) const; |
157 | virtual bool setLedState ( OLed led, OLedState st ); | 156 | virtual bool setLedState ( OLed led, OLedState st ); |
158 | 157 | ||
159 | protected: | 158 | protected: |
160 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 159 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
161 | virtual void timerEvent ( QTimerEvent *te ); | 160 | virtual void timerEvent ( QTimerEvent *te ); |
162 | 161 | ||
163 | int m_power_timer; | 162 | int m_power_timer; |
164 | 163 | ||
165 | OLedState m_leds [1]; //FIXME check if really only one | 164 | OLedState m_leds [1]; //FIXME check if really only one |
166 | }; | 165 | }; |
167 | 166 | ||
168 | class Ramses : public ODevice, public QWSServer::KeyboardFilter { | 167 | class Ramses : public ODevice, public QWSServer::KeyboardFilter { |
169 | protected: | 168 | protected: |
170 | virtual void init ( ); | 169 | virtual void init ( ); |
171 | 170 | ||
172 | public: | 171 | public: |
173 | virtual bool setSoftSuspend ( bool soft ); | 172 | virtual bool setSoftSuspend ( bool soft ); |
174 | virtual bool suspend ( ); | 173 | virtual bool suspend ( ); |
175 | 174 | ||
176 | virtual bool setDisplayStatus( bool on ); | 175 | virtual bool setDisplayStatus( bool on ); |
177 | virtual bool setDisplayBrightness ( int b ); | 176 | virtual bool setDisplayBrightness ( int b ); |
178 | virtual int displayBrightnessResolution ( ) const; | 177 | virtual int displayBrightnessResolution ( ) const; |
179 | virtual bool setDisplayContrast ( int b ); | 178 | virtual bool setDisplayContrast ( int b ); |
180 | virtual int displayContrastResolution ( ) const; | 179 | virtual int displayContrastResolution ( ) const; |
181 | 180 | ||
182 | protected: | 181 | protected: |
183 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 182 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
184 | virtual void timerEvent ( QTimerEvent *te ); | 183 | virtual void timerEvent ( QTimerEvent *te ); |
185 | 184 | ||
186 | int m_power_timer; | 185 | int m_power_timer; |
187 | }; | 186 | }; |
188 | 187 | ||
189 | struct i_button { | 188 | struct i_button { |
190 | uint model; | 189 | uint model; |
191 | Qt::Key code; | 190 | Qt::Key code; |
192 | char *utext; | 191 | char *utext; |
193 | char *pix; | 192 | char *pix; |
194 | char *fpressedservice; | 193 | char *fpressedservice; |
195 | char *fpressedaction; | 194 | char *fpressedaction; |
196 | char *fheldservice; | 195 | char *fheldservice; |
197 | char *fheldaction; | 196 | char *fheldaction; |
198 | } ipaq_buttons [] = { | 197 | } ipaq_buttons [] = { |
199 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 198 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
200 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 199 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
201 | "devicebuttons/ipaq_calendar", | 200 | "devicebuttons/ipaq_calendar", |
202 | "datebook", "nextView()", | 201 | "datebook", "nextView()", |
203 | "today", "raise()" }, | 202 | "today", "raise()" }, |
204 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 203 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
205 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 204 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
206 | "devicebuttons/ipaq_contact", | 205 | "devicebuttons/ipaq_contact", |
@@ -244,285 +243,323 @@ struct z_button { | |||
244 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 243 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
245 | "devicebuttons/z_contact", | 244 | "devicebuttons/z_contact", |
246 | "addressbook", "raise()", | 245 | "addressbook", "raise()", |
247 | "addressbook", "beamBusinessCard()" }, | 246 | "addressbook", "beamBusinessCard()" }, |
248 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 247 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
249 | "devicebuttons/z_home", | 248 | "devicebuttons/z_home", |
250 | "QPE/Launcher", "home()", | 249 | "QPE/Launcher", "home()", |
251 | "buttonsettings", "raise()" }, | 250 | "buttonsettings", "raise()" }, |
252 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 251 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
253 | "devicebuttons/z_menu", | 252 | "devicebuttons/z_menu", |
254 | "QPE/TaskBar", "toggleMenu()", | 253 | "QPE/TaskBar", "toggleMenu()", |
255 | "QPE/TaskBar", "toggleStartMenu()" }, | 254 | "QPE/TaskBar", "toggleStartMenu()" }, |
256 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 255 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
257 | "devicebuttons/z_mail", | 256 | "devicebuttons/z_mail", |
258 | "mail", "raise()", | 257 | "mail", "raise()", |
259 | "mail", "newMail()" }, | 258 | "mail", "newMail()" }, |
260 | }; | 259 | }; |
261 | 260 | ||
262 | struct z_button z_buttons_c700 [] = { | 261 | struct z_button z_buttons_c700 [] = { |
263 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 262 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
264 | "devicebuttons/z_calendar", | 263 | "devicebuttons/z_calendar", |
265 | "datebook", "nextView()", | 264 | "datebook", "nextView()", |
266 | "today", "raise()" }, | 265 | "today", "raise()" }, |
267 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 266 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
268 | "devicebuttons/z_contact", | 267 | "devicebuttons/z_contact", |
269 | "addressbook", "raise()", | 268 | "addressbook", "raise()", |
270 | "addressbook", "beamBusinessCard()" }, | 269 | "addressbook", "beamBusinessCard()" }, |
271 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 270 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
272 | "devicebuttons/z_home", | 271 | "devicebuttons/z_home", |
273 | "QPE/Launcher", "home()", | 272 | "QPE/Launcher", "home()", |
274 | "buttonsettings", "raise()" }, | 273 | "buttonsettings", "raise()" }, |
275 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 274 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
276 | "devicebuttons/z_menu", | 275 | "devicebuttons/z_menu", |
277 | "QPE/TaskBar", "toggleMenu()", | 276 | "QPE/TaskBar", "toggleMenu()", |
278 | "QPE/TaskBar", "toggleStartMenu()" }, | 277 | "QPE/TaskBar", "toggleStartMenu()" }, |
279 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), | 278 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), |
280 | "", | 279 | "", |
281 | "QPE/Rotation", "flip()", | 280 | "QPE/Rotation", "flip()", |
282 | "QPE/Rotation", "flip()" }, | 281 | "QPE/Rotation", "flip()" }, |
283 | }; | 282 | }; |
284 | 283 | ||
285 | struct s_button { | 284 | struct s_button { |
286 | uint model; | 285 | uint model; |
287 | Qt::Key code; | 286 | Qt::Key code; |
288 | char *utext; | 287 | char *utext; |
289 | char *pix; | 288 | char *pix; |
290 | char *fpressedservice; | 289 | char *fpressedservice; |
291 | char *fpressedaction; | 290 | char *fpressedaction; |
292 | char *fheldservice; | 291 | char *fheldservice; |
293 | char *fheldaction; | 292 | char *fheldaction; |
294 | } simpad_buttons [] = { | 293 | } simpad_buttons [] = { |
295 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 294 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
296 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), | 295 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), |
297 | "devicebuttons/simpad_lower_up", | 296 | "devicebuttons/simpad_lower_up", |
298 | "datebook", "nextView()", | 297 | "datebook", "nextView()", |
299 | "today", "raise()" }, | 298 | "today", "raise()" }, |
300 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 299 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
301 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), | 300 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), |
302 | "devicebuttons/simpad_lower_down", | 301 | "devicebuttons/simpad_lower_down", |
303 | "addressbook", "raise()", | 302 | "addressbook", "raise()", |
304 | "addressbook", "beamBusinessCard()" }, | 303 | "addressbook", "beamBusinessCard()" }, |
305 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 304 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
306 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), | 305 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), |
307 | "devicebuttons/simpad_lower_right", | 306 | "devicebuttons/simpad_lower_right", |
308 | "QPE/TaskBar", "toggleMenu()", | 307 | "QPE/TaskBar", "toggleMenu()", |
309 | "QPE/TaskBar", "toggleStartMenu()" }, | 308 | "QPE/TaskBar", "toggleStartMenu()" }, |
310 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 309 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
311 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), | 310 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), |
312 | "devicebuttons/simpad_lower_left", | 311 | "devicebuttons/simpad_lower_left", |
313 | "mail", "raise()", | 312 | "mail", "raise()", |
314 | "mail", "newMail()" }, | 313 | "mail", "newMail()" }, |
315 | 314 | ||
316 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 315 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
317 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), | 316 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), |
318 | "devicebuttons/simpad_upper_up", | 317 | "devicebuttons/simpad_upper_up", |
319 | "QPE/Launcher", "home()", | 318 | "QPE/Launcher", "home()", |
320 | "buttonsettings", "raise()" }, | 319 | "buttonsettings", "raise()" }, |
321 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 320 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
322 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), | 321 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), |
323 | "devicebuttons/simpad_upper_down", | 322 | "devicebuttons/simpad_upper_down", |
324 | "addressbook", "raise()", | 323 | "addressbook", "raise()", |
325 | "addressbook", "beamBusinessCard()" }, | 324 | "addressbook", "beamBusinessCard()" }, |
326 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 325 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
327 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), | 326 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), |
328 | "devicebuttons/simpad_upper_right", | 327 | "devicebuttons/simpad_upper_right", |
329 | "QPE/TaskBar", "toggleMenu()", | 328 | "QPE/TaskBar", "toggleMenu()", |
330 | "QPE/TaskBar", "toggleStartMenu()" }, | 329 | "QPE/TaskBar", "toggleStartMenu()" }, |
331 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 330 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
332 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), | 331 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), |
333 | "devicebuttons/simpad_upper_left", | 332 | "devicebuttons/simpad_upper_left", |
334 | "QPE/Rotation", "flip()", | 333 | "QPE/Rotation", "flip()", |
335 | "QPE/Rotation", "flip()" }, | 334 | "QPE/Rotation", "flip()" }, |
336 | /* | 335 | /* |
337 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 336 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
338 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 337 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
339 | "devicebuttons/simpad_lower_upper", | 338 | "devicebuttons/simpad_lower_upper", |
340 | "QPE/Launcher", "home()", | 339 | "QPE/Launcher", "home()", |
341 | "buttonsettings", "raise()" }, | 340 | "buttonsettings", "raise()" }, |
342 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 341 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
343 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 342 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
344 | "devicebuttons/simpad_upper_lower", | 343 | "devicebuttons/simpad_upper_lower", |
345 | "QPE/Launcher", "home()", | 344 | "QPE/Launcher", "home()", |
346 | "buttonsettings", "raise()" }, | 345 | "buttonsettings", "raise()" }, |
347 | */ | 346 | */ |
348 | }; | 347 | }; |
349 | 348 | ||
350 | struct r_button { | 349 | struct r_button { |
351 | uint model; | 350 | uint model; |
352 | Qt::Key code; | 351 | Qt::Key code; |
353 | char *utext; | 352 | char *utext; |
354 | char *pix; | 353 | char *pix; |
355 | char *fpressedservice; | 354 | char *fpressedservice; |
356 | char *fpressedaction; | 355 | char *fpressedaction; |
357 | char *fheldservice; | 356 | char *fheldservice; |
358 | char *fheldaction; | 357 | char *fheldaction; |
359 | } ramses_buttons [] = { | 358 | } ramses_buttons [] = { |
360 | { Model_Ramses_MNCI, | 359 | { Model_Ramses_MNCI, |
361 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 360 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
362 | "devicebuttons/z_menu", | 361 | "devicebuttons/z_menu", |
363 | "QPE/TaskBar", "toggleMenu()", | 362 | "QPE/TaskBar", "toggleMenu()", |
364 | "QPE/TaskBar", "toggleStartMenu()" }, | 363 | "QPE/TaskBar", "toggleStartMenu()" }, |
365 | { Model_Ramses_MNCI, | 364 | { Model_Ramses_MNCI, |
366 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 365 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
367 | "devicebuttons/ipaq_home", | 366 | "devicebuttons/ipaq_home", |
368 | "QPE/Launcher", "home()", | 367 | "QPE/Launcher", "home()", |
369 | "buttonsettings", "raise()" }, | 368 | "buttonsettings", "raise()" }, |
370 | }; | 369 | }; |
371 | 370 | ||
371 | class Yopy : public ODevice { | ||
372 | protected: | ||
373 | virtual void init ( ); | ||
374 | virtual void initButtons ( ); | ||
375 | |||
376 | public: | ||
377 | virtual bool suspend ( ); | ||
378 | |||
379 | virtual bool setDisplayBrightness ( int b ); | ||
380 | virtual int displayBrightnessResolution ( ) const; | ||
381 | |||
382 | static bool isYopy ( ); | ||
383 | }; | ||
384 | |||
385 | struct yopy_button { | ||
386 | Qt::Key code; | ||
387 | char *utext; | ||
388 | char *pix; | ||
389 | char *fpressedservice; | ||
390 | char *fpressedaction; | ||
391 | char *fheldservice; | ||
392 | char *fheldaction; | ||
393 | } yopy_buttons [] = { | ||
394 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), | ||
395 | "devicebuttons/yopy_action", | ||
396 | "datebook", "nextView()", | ||
397 | "today", "raise()" }, | ||
398 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), | ||
399 | "devicebuttons/yopy_ok", | ||
400 | "addressbook", "raise()", | ||
401 | "addressbook", "beamBusinessCard()" }, | ||
402 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), | ||
403 | "devicebuttons/yopy_end", | ||
404 | "QPE/Launcher", "home()", | ||
405 | "buttonsettings", "raise()" }, | ||
406 | }; | ||
407 | |||
372 | static QCString makeChannel ( const char *str ) | 408 | static QCString makeChannel ( const char *str ) |
373 | { | 409 | { |
374 | if ( str && !::strchr ( str, '/' )) | 410 | if ( str && !::strchr ( str, '/' )) |
375 | return QCString ( "QPE/Application/" ) + str; | 411 | return QCString ( "QPE/Application/" ) + str; |
376 | else | 412 | else |
377 | return str; | 413 | return str; |
378 | } | 414 | } |
379 | 415 | ||
380 | static inline bool isQWS() | 416 | static inline bool isQWS() |
381 | { | 417 | { |
382 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 418 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
383 | } | 419 | } |
384 | 420 | ||
385 | ODevice *ODevice::inst ( ) | 421 | ODevice *ODevice::inst ( ) |
386 | { | 422 | { |
387 | static ODevice *dev = 0; | 423 | static ODevice *dev = 0; |
388 | 424 | ||
389 | if ( !dev ) { | 425 | if ( !dev ) { |
390 | if ( QFile::exists ( "/proc/hal/model" )) | 426 | if ( QFile::exists ( "/proc/hal/model" )) |
391 | dev = new iPAQ ( ); | 427 | dev = new iPAQ ( ); |
392 | else if ( Zaurus::isZaurus() ) | 428 | else if ( Zaurus::isZaurus() ) |
393 | dev = new Zaurus ( ); | 429 | dev = new Zaurus ( ); |
394 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) | 430 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) |
395 | dev = new SIMpad ( ); | 431 | dev = new SIMpad ( ); |
396 | else if ( QFile::exists ( "/proc/sys/board/name" )) | 432 | else if ( QFile::exists ( "/proc/sys/board/name" )) |
397 | dev = new Ramses ( ); | 433 | dev = new Ramses ( ); |
434 | else if ( Yopy::isYopy() ) | ||
435 | dev = new Yopy ( ); | ||
398 | else | 436 | else |
399 | dev = new ODevice ( ); | 437 | dev = new ODevice ( ); |
400 | |||
401 | dev-> init ( ); | 438 | dev-> init ( ); |
402 | } | 439 | } |
403 | return dev; | 440 | return dev; |
404 | } | 441 | } |
405 | 442 | ||
406 | 443 | ||
407 | /************************************************** | 444 | /************************************************** |
408 | * | 445 | * |
409 | * common | 446 | * common |
410 | * | 447 | * |
411 | **************************************************/ | 448 | **************************************************/ |
412 | 449 | ||
413 | 450 | ||
414 | ODevice::ODevice ( ) | 451 | ODevice::ODevice ( ) |
415 | { | 452 | { |
416 | d = new ODeviceData; | 453 | d = new ODeviceData; |
417 | 454 | ||
418 | d-> m_modelstr = "Unknown"; | 455 | d-> m_modelstr = "Unknown"; |
419 | d-> m_model = Model_Unknown; | 456 | d-> m_model = Model_Unknown; |
420 | d-> m_vendorstr = "Unknown"; | 457 | d-> m_vendorstr = "Unknown"; |
421 | d-> m_vendor = Vendor_Unknown; | 458 | d-> m_vendor = Vendor_Unknown; |
422 | d-> m_systemstr = "Unknown"; | 459 | d-> m_systemstr = "Unknown"; |
423 | d-> m_system = System_Unknown; | 460 | d-> m_system = System_Unknown; |
424 | d-> m_sysverstr = "0.0"; | 461 | d-> m_sysverstr = "0.0"; |
425 | d-> m_rotation = Rot0; | 462 | d-> m_rotation = Rot0; |
426 | d-> m_direction = CW; | 463 | d-> m_direction = CW; |
427 | 464 | ||
428 | d-> m_holdtime = 1000; // 1000ms | 465 | d-> m_holdtime = 1000; // 1000ms |
429 | d-> m_buttons = 0; | 466 | d-> m_buttons = 0; |
430 | d-> m_cpu_frequencies = new QStrList; | 467 | d-> m_cpu_frequencies = new QStrList; |
431 | } | 468 | } |
432 | 469 | ||
433 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 470 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
434 | { | 471 | { |
435 | if ( msg == "deviceButtonMappingChanged()" ) { | 472 | if ( msg == "deviceButtonMappingChanged()" ) { |
436 | reloadButtonMapping ( ); | 473 | reloadButtonMapping ( ); |
437 | } | 474 | } |
438 | } | 475 | } |
439 | 476 | ||
440 | void ODevice::init ( ) | 477 | void ODevice::init ( ) |
441 | { | 478 | { |
442 | } | 479 | } |
443 | 480 | ||
444 | /** | 481 | /** |
445 | * This method initialises the button mapping | 482 | * This method initialises the button mapping |
446 | */ | 483 | */ |
447 | void ODevice::initButtons ( ) | 484 | void ODevice::initButtons ( ) |
448 | { | 485 | { |
449 | if ( d-> m_buttons ) | 486 | if ( d-> m_buttons ) |
450 | return; | 487 | return; |
451 | 488 | ||
452 | // Simulation uses iPAQ 3660 device buttons | 489 | // Simulation uses iPAQ 3660 device buttons |
453 | 490 | ||
454 | qDebug ( "init Buttons" ); | 491 | qDebug ( "init Buttons" ); |
455 | d-> m_buttons = new QValueList <ODeviceButton>; | 492 | d-> m_buttons = new QValueList <ODeviceButton>; |
456 | 493 | ||
457 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 494 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
458 | i_button *ib = ipaq_buttons + i; | 495 | i_button *ib = ipaq_buttons + i; |
459 | ODeviceButton b; | 496 | ODeviceButton b; |
460 | 497 | ||
461 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 498 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
462 | b. setKeycode ( ib-> code ); | 499 | b. setKeycode ( ib-> code ); |
463 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 500 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
464 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 501 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
465 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 502 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
466 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 503 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
467 | d-> m_buttons-> append ( b ); | 504 | d-> m_buttons-> append ( b ); |
468 | } | 505 | } |
469 | } | 506 | } |
470 | reloadButtonMapping ( ); | 507 | reloadButtonMapping ( ); |
471 | 508 | ||
472 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 509 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
473 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 510 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
474 | } | 511 | } |
475 | 512 | ||
476 | ODevice::~ODevice ( ) | 513 | ODevice::~ODevice ( ) |
477 | { | 514 | { |
478 | // we leak m_devicebuttons and m_cpu_frequency | 515 | // we leak m_devicebuttons and m_cpu_frequency |
479 | // but it's a singleton and it is not so importantant | 516 | // but it's a singleton and it is not so importantant |
480 | // -zecke | 517 | // -zecke |
481 | delete d; | 518 | delete d; |
482 | } | 519 | } |
483 | 520 | ||
484 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 521 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
485 | { | 522 | { |
486 | return false; | 523 | return false; |
487 | } | 524 | } |
488 | 525 | ||
489 | //#include <linux/apm_bios.h> | 526 | //#include <linux/apm_bios.h> |
490 | 527 | ||
491 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 528 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
492 | 529 | ||
493 | /** | 530 | /** |
494 | * This method will try to suspend the device | 531 | * This method will try to suspend the device |
495 | * It only works if the user is the QWS Server and the apm application | 532 | * It only works if the user is the QWS Server and the apm application |
496 | * is installed. | 533 | * is installed. |
497 | * It tries to suspend and then waits some time cause some distributions | 534 | * It tries to suspend and then waits some time cause some distributions |
498 | * do have asynchronus apm implementations. | 535 | * do have asynchronus apm implementations. |
499 | * This method will either fail and return false or it'll suspend the | 536 | * This method will either fail and return false or it'll suspend the |
500 | * device and return once the device got woken up | 537 | * device and return once the device got woken up |
501 | * | 538 | * |
502 | * @return if the device got suspended | 539 | * @return if the device got suspended |
503 | */ | 540 | */ |
504 | bool ODevice::suspend ( ) | 541 | bool ODevice::suspend ( ) |
505 | { | 542 | { |
506 | qDebug("ODevice::suspend"); | 543 | qDebug("ODevice::suspend"); |
507 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 544 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
508 | return false; | 545 | return false; |
509 | 546 | ||
510 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 547 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
511 | return false; | 548 | return false; |
512 | 549 | ||
513 | bool res = false; | 550 | bool res = false; |
514 | 551 | ||
515 | struct timeval tvs, tvn; | 552 | struct timeval tvs, tvn; |
516 | ::gettimeofday ( &tvs, 0 ); | 553 | ::gettimeofday ( &tvs, 0 ); |
517 | 554 | ||
518 | ::sync ( ); // flush fs caches | 555 | ::sync ( ); // flush fs caches |
519 | res = ( ::system ( "apm --suspend" ) == 0 ); | 556 | res = ( ::system ( "apm --suspend" ) == 0 ); |
520 | 557 | ||
521 | // This is needed because the iPAQ apm implementation is asynchronous and we | 558 | // This is needed because the iPAQ apm implementation is asynchronous and we |
522 | // can not be sure when exactly the device is really suspended | 559 | // can not be sure when exactly the device is really suspended |
523 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 560 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
524 | 561 | ||
525 | if ( res ) { | 562 | if ( res ) { |
526 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 563 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
527 | ::usleep ( 200 * 1000 ); | 564 | ::usleep ( 200 * 1000 ); |
528 | ::gettimeofday ( &tvn, 0 ); | 565 | ::gettimeofday ( &tvn, 0 ); |
@@ -805,256 +842,364 @@ bool ODevice::setCurrentCpuFrequency(uint index) | |||
805 | int fd; | 842 | int fd; |
806 | 843 | ||
807 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { | 844 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { |
808 | char writeCommand[50]; | 845 | char writeCommand[50]; |
809 | const int count = sprintf(writeCommand, "%s\n", freq); | 846 | const int count = sprintf(writeCommand, "%s\n", freq); |
810 | int res = (::write(fd, writeCommand, count) != -1); | 847 | int res = (::write(fd, writeCommand, count) != -1); |
811 | ::close(fd); | 848 | ::close(fd); |
812 | return res; | 849 | return res; |
813 | } | 850 | } |
814 | 851 | ||
815 | return false; | 852 | return false; |
816 | } | 853 | } |
817 | 854 | ||
818 | 855 | ||
819 | /** | 856 | /** |
820 | * @return a list of hardware buttons | 857 | * @return a list of hardware buttons |
821 | */ | 858 | */ |
822 | const QValueList <ODeviceButton> &ODevice::buttons ( ) | 859 | const QValueList <ODeviceButton> &ODevice::buttons ( ) |
823 | { | 860 | { |
824 | initButtons ( ); | 861 | initButtons ( ); |
825 | 862 | ||
826 | return *d-> m_buttons; | 863 | return *d-> m_buttons; |
827 | } | 864 | } |
828 | 865 | ||
829 | /** | 866 | /** |
830 | * @return The amount of time that would count as a hold | 867 | * @return The amount of time that would count as a hold |
831 | */ | 868 | */ |
832 | uint ODevice::buttonHoldTime ( ) const | 869 | uint ODevice::buttonHoldTime ( ) const |
833 | { | 870 | { |
834 | return d-> m_holdtime; | 871 | return d-> m_holdtime; |
835 | } | 872 | } |
836 | 873 | ||
837 | /** | 874 | /** |
838 | * This method return a ODeviceButton for a key code | 875 | * This method return a ODeviceButton for a key code |
839 | * or 0 if no special hardware button is available for the device | 876 | * or 0 if no special hardware button is available for the device |
840 | * | 877 | * |
841 | * @return The devicebutton or 0l | 878 | * @return The devicebutton or 0l |
842 | * @see ODeviceButton | 879 | * @see ODeviceButton |
843 | */ | 880 | */ |
844 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 881 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
845 | { | 882 | { |
846 | initButtons ( ); | 883 | initButtons ( ); |
847 | 884 | ||
848 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { | 885 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { |
849 | if ( (*it). keycode ( ) == code ) | 886 | if ( (*it). keycode ( ) == code ) |
850 | return &(*it); | 887 | return &(*it); |
851 | } | 888 | } |
852 | return 0; | 889 | return 0; |
853 | } | 890 | } |
854 | 891 | ||
855 | void ODevice::reloadButtonMapping ( ) | 892 | void ODevice::reloadButtonMapping ( ) |
856 | { | 893 | { |
857 | initButtons ( ); | 894 | initButtons ( ); |
858 | 895 | ||
859 | Config cfg ( "ButtonSettings" ); | 896 | Config cfg ( "ButtonSettings" ); |
860 | 897 | ||
861 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { | 898 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { |
862 | ODeviceButton &b = ( *d-> m_buttons ) [i]; | 899 | ODeviceButton &b = ( *d-> m_buttons ) [i]; |
863 | QString group = "Button" + QString::number ( i ); | 900 | QString group = "Button" + QString::number ( i ); |
864 | 901 | ||
865 | QCString pch, hch; | 902 | QCString pch, hch; |
866 | QCString pm, hm; | 903 | QCString pm, hm; |
867 | QByteArray pdata, hdata; | 904 | QByteArray pdata, hdata; |
868 | 905 | ||
869 | if ( cfg. hasGroup ( group )) { | 906 | if ( cfg. hasGroup ( group )) { |
870 | cfg. setGroup ( group ); | 907 | cfg. setGroup ( group ); |
871 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); | 908 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); |
872 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); | 909 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); |
873 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 910 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
874 | 911 | ||
875 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); | 912 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); |
876 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); | 913 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); |
877 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 914 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
878 | } | 915 | } |
879 | 916 | ||
880 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 917 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
881 | 918 | ||
882 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 919 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
883 | } | 920 | } |
884 | } | 921 | } |
885 | 922 | ||
886 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 923 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
887 | { | 924 | { |
888 | initButtons ( ); | 925 | initButtons ( ); |
889 | 926 | ||
890 | QString mb_chan; | 927 | QString mb_chan; |
891 | 928 | ||
892 | if ( button >= (int) d-> m_buttons-> count ( )) | 929 | if ( button >= (int) d-> m_buttons-> count ( )) |
893 | return; | 930 | return; |
894 | 931 | ||
895 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 932 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
896 | b. setPressedAction ( action ); | 933 | b. setPressedAction ( action ); |
897 | 934 | ||
898 | mb_chan=b. pressedAction ( ). channel ( ); | 935 | mb_chan=b. pressedAction ( ). channel ( ); |
899 | 936 | ||
900 | Config buttonFile ( "ButtonSettings" ); | 937 | Config buttonFile ( "ButtonSettings" ); |
901 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 938 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
902 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 939 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
903 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 940 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
904 | 941 | ||
905 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 942 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
906 | 943 | ||
907 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 944 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
908 | } | 945 | } |
909 | 946 | ||
910 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 947 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
911 | { | 948 | { |
912 | initButtons ( ); | 949 | initButtons ( ); |
913 | 950 | ||
914 | if ( button >= (int) d-> m_buttons-> count ( )) | 951 | if ( button >= (int) d-> m_buttons-> count ( )) |
915 | return; | 952 | return; |
916 | 953 | ||
917 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 954 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
918 | b. setHeldAction ( action ); | 955 | b. setHeldAction ( action ); |
919 | 956 | ||
920 | Config buttonFile ( "ButtonSettings" ); | 957 | Config buttonFile ( "ButtonSettings" ); |
921 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 958 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
922 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 959 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
923 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 960 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
924 | 961 | ||
925 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 962 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
926 | 963 | ||
927 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 964 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
928 | } | 965 | } |
929 | void ODevice::virtual_hook(int, void* ){ | 966 | void ODevice::virtual_hook(int, void* ){ |
930 | 967 | ||
931 | } | 968 | } |
932 | 969 | ||
970 | /************************************************** | ||
971 | * | ||
972 | * Yopy 3500/3700 | ||
973 | * | ||
974 | **************************************************/ | ||
975 | |||
976 | bool Yopy::isYopy ( ) | ||
977 | { | ||
978 | QFile f( "/proc/cpuinfo" ); | ||
979 | if ( f. open ( IO_ReadOnly ) ) { | ||
980 | QTextStream ts ( &f ); | ||
981 | QString line; | ||
982 | while( line = ts. readLine ( ) ) { | ||
983 | if ( line. left ( 8 ) == "Hardware" ) { | ||
984 | int loc = line. find ( ":" ); | ||
985 | if ( loc != -1 ) { | ||
986 | QString model = | ||
987 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); | ||
988 | return ( model == "Yopy" ); | ||
989 | } | ||
990 | } | ||
991 | } | ||
992 | } | ||
993 | return false; | ||
994 | } | ||
995 | |||
996 | void Yopy::init ( ) | ||
997 | { | ||
998 | d-> m_vendorstr = "G.Mate"; | ||
999 | d-> m_vendor = Vendor_GMate; | ||
1000 | d-> m_modelstr = "Yopy3700"; | ||
1001 | d-> m_model = Model_Yopy_3700; | ||
1002 | d-> m_rotation = Rot0; | ||
1003 | |||
1004 | d-> m_systemstr = "Linupy"; | ||
1005 | d-> m_system = System_Linupy; | ||
1006 | |||
1007 | QFile f ( "/etc/issue" ); | ||
1008 | if ( f. open ( IO_ReadOnly )) { | ||
1009 | QTextStream ts ( &f ); | ||
1010 | ts.readLine(); | ||
1011 | d-> m_sysverstr = ts. readLine ( ); | ||
1012 | f. close ( ); | ||
1013 | } | ||
1014 | } | ||
1015 | |||
1016 | void Yopy::initButtons ( ) | ||
1017 | { | ||
1018 | if ( d-> m_buttons ) | ||
1019 | return; | ||
1020 | |||
1021 | d-> m_buttons = new QValueList <ODeviceButton>; | ||
1022 | |||
1023 | for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { | ||
1024 | |||
1025 | yopy_button *ib = yopy_buttons + i; | ||
1026 | |||
1027 | ODeviceButton b; | ||
1028 | |||
1029 | b. setKeycode ( ib-> code ); | ||
1030 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | ||
1031 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | ||
1032 | b. setFactoryPresetPressedAction | ||
1033 | (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); | ||
1034 | b. setFactoryPresetHeldAction | ||
1035 | (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); | ||
1036 | |||
1037 | d-> m_buttons-> append ( b ); | ||
1038 | } | ||
1039 | reloadButtonMapping ( ); | ||
1040 | |||
1041 | QCopChannel *sysch = new QCopChannel("QPE/System", this); | ||
1042 | connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), | ||
1043 | this, SLOT(systemMessage(const QCString &, const QByteArray & ))); | ||
1044 | } | ||
1045 | |||
1046 | bool Yopy::suspend() | ||
1047 | { | ||
1048 | /* Opie for Yopy does not implement its own power management at the | ||
1049 | moment. The public version runs parallel to X, and relies on the | ||
1050 | existing power management features. */ | ||
1051 | return false; | ||
1052 | } | ||
1053 | |||
1054 | bool Yopy::setDisplayBrightness(int bright) | ||
1055 | { | ||
1056 | /* The code here works, but is disabled as the current version runs | ||
1057 | parallel to X, and relies on the existing backlight demon. */ | ||
1058 | #if 0 | ||
1059 | if ( QFile::exists("/proc/sys/pm/light") ) { | ||
1060 | int fd = ::open("/proc/sys/pm/light", O_WRONLY); | ||
1061 | if (fd >= 0 ) { | ||
1062 | if (bright) | ||
1063 | ::write(fd, "1\n", 2); | ||
1064 | else | ||
1065 | ::write(fd, "0\n", 2); | ||
1066 | ::close(fd); | ||
1067 | return true; | ||
1068 | } | ||
1069 | } | ||
1070 | #endif | ||
1071 | return false; | ||
1072 | } | ||
1073 | |||
1074 | int Yopy::displayBrightnessResolution() const | ||
1075 | { | ||
1076 | return 2; | ||
1077 | } | ||
933 | 1078 | ||
934 | /************************************************** | 1079 | /************************************************** |
935 | * | 1080 | * |
936 | * iPAQ | 1081 | * iPAQ |
937 | * | 1082 | * |
938 | **************************************************/ | 1083 | **************************************************/ |
939 | 1084 | ||
940 | void iPAQ::init ( ) | 1085 | void iPAQ::init ( ) |
941 | { | 1086 | { |
942 | d-> m_vendorstr = "HP"; | 1087 | d-> m_vendorstr = "HP"; |
943 | d-> m_vendor = Vendor_HP; | 1088 | d-> m_vendor = Vendor_HP; |
944 | 1089 | ||
945 | QFile f ( "/proc/hal/model" ); | 1090 | QFile f ( "/proc/hal/model" ); |
946 | 1091 | ||
947 | if ( f. open ( IO_ReadOnly )) { | 1092 | if ( f. open ( IO_ReadOnly )) { |
948 | QTextStream ts ( &f ); | 1093 | QTextStream ts ( &f ); |
949 | 1094 | ||
950 | d-> m_modelstr = "H" + ts. readLine ( ); | 1095 | d-> m_modelstr = "H" + ts. readLine ( ); |
951 | 1096 | ||
952 | if ( d-> m_modelstr == "H3100" ) | 1097 | if ( d-> m_modelstr == "H3100" ) |
953 | d-> m_model = Model_iPAQ_H31xx; | 1098 | d-> m_model = Model_iPAQ_H31xx; |
954 | else if ( d-> m_modelstr == "H3600" ) | 1099 | else if ( d-> m_modelstr == "H3600" ) |
955 | d-> m_model = Model_iPAQ_H36xx; | 1100 | d-> m_model = Model_iPAQ_H36xx; |
956 | else if ( d-> m_modelstr == "H3700" ) | 1101 | else if ( d-> m_modelstr == "H3700" ) |
957 | d-> m_model = Model_iPAQ_H37xx; | 1102 | d-> m_model = Model_iPAQ_H37xx; |
958 | else if ( d-> m_modelstr == "H3800" ) | 1103 | else if ( d-> m_modelstr == "H3800" ) |
959 | d-> m_model = Model_iPAQ_H38xx; | 1104 | d-> m_model = Model_iPAQ_H38xx; |
960 | else if ( d-> m_modelstr == "H3900" ) | 1105 | else if ( d-> m_modelstr == "H3900" ) |
961 | d-> m_model = Model_iPAQ_H39xx; | 1106 | d-> m_model = Model_iPAQ_H39xx; |
962 | else | 1107 | else |
963 | d-> m_model = Model_Unknown; | 1108 | d-> m_model = Model_Unknown; |
964 | 1109 | ||
965 | f. close ( ); | 1110 | f. close ( ); |
966 | } | 1111 | } |
967 | 1112 | ||
968 | switch ( d-> m_model ) { | 1113 | switch ( d-> m_model ) { |
969 | case Model_iPAQ_H31xx: | 1114 | case Model_iPAQ_H31xx: |
970 | case Model_iPAQ_H38xx: | 1115 | case Model_iPAQ_H38xx: |
971 | d-> m_rotation = Rot90; | 1116 | d-> m_rotation = Rot90; |
972 | break; | 1117 | break; |
973 | case Model_iPAQ_H36xx: | 1118 | case Model_iPAQ_H36xx: |
974 | case Model_iPAQ_H37xx: | 1119 | case Model_iPAQ_H37xx: |
975 | case Model_iPAQ_H39xx: | 1120 | case Model_iPAQ_H39xx: |
976 | default: | 1121 | default: |
977 | d-> m_rotation = Rot270; | 1122 | d-> m_rotation = Rot270; |
978 | break; | 1123 | break; |
979 | } | 1124 | } |
980 | 1125 | ||
981 | f. setName ( "/etc/familiar-version" ); | 1126 | f. setName ( "/etc/familiar-version" ); |
982 | if ( f. open ( IO_ReadOnly )) { | 1127 | if ( f. open ( IO_ReadOnly )) { |
983 | d-> m_systemstr = "Familiar"; | 1128 | d-> m_systemstr = "Familiar"; |
984 | d-> m_system = System_Familiar; | 1129 | d-> m_system = System_Familiar; |
985 | 1130 | ||
986 | QTextStream ts ( &f ); | 1131 | QTextStream ts ( &f ); |
987 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 1132 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
988 | 1133 | ||
989 | f. close ( ); | 1134 | f. close ( ); |
990 | } else { | 1135 | } else { |
991 | f. setName ( "/etc/oz_version" ); | 1136 | f. setName ( "/etc/oz_version" ); |
992 | 1137 | ||
993 | if ( f. open ( IO_ReadOnly )) { | 1138 | if ( f. open ( IO_ReadOnly )) { |
994 | d-> m_systemstr = "OpenEmbedded/iPaq"; | 1139 | d-> m_systemstr = "OpenEmbedded/iPaq"; |
995 | d-> m_system = System_Familiar; | 1140 | d-> m_system = System_Familiar; |
996 | 1141 | ||
997 | QTextStream ts ( &f ); | 1142 | QTextStream ts ( &f ); |
998 | ts.setDevice ( &f ); | 1143 | ts.setDevice ( &f ); |
999 | d-> m_sysverstr = ts. readLine ( ); | 1144 | d-> m_sysverstr = ts. readLine ( ); |
1000 | f. close ( ); | 1145 | f. close ( ); |
1001 | } | 1146 | } |
1002 | } | 1147 | } |
1003 | 1148 | ||
1004 | 1149 | ||
1005 | 1150 | ||
1006 | 1151 | ||
1007 | 1152 | ||
1008 | m_leds [0] = m_leds [1] = Led_Off; | 1153 | m_leds [0] = m_leds [1] = Led_Off; |
1009 | 1154 | ||
1010 | m_power_timer = 0; | 1155 | m_power_timer = 0; |
1011 | 1156 | ||
1012 | } | 1157 | } |
1013 | 1158 | ||
1014 | void iPAQ::initButtons ( ) | 1159 | void iPAQ::initButtons ( ) |
1015 | { | 1160 | { |
1016 | if ( d-> m_buttons ) | 1161 | if ( d-> m_buttons ) |
1017 | return; | 1162 | return; |
1018 | 1163 | ||
1019 | if ( isQWS( ) ) | 1164 | if ( isQWS( ) ) |
1020 | QWSServer::setKeyboardFilter ( this ); | 1165 | QWSServer::setKeyboardFilter ( this ); |
1021 | 1166 | ||
1022 | d-> m_buttons = new QValueList <ODeviceButton>; | 1167 | d-> m_buttons = new QValueList <ODeviceButton>; |
1023 | 1168 | ||
1024 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 1169 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
1025 | i_button *ib = ipaq_buttons + i; | 1170 | i_button *ib = ipaq_buttons + i; |
1026 | ODeviceButton b; | 1171 | ODeviceButton b; |
1027 | 1172 | ||
1028 | if (( ib-> model & d-> m_model ) == d-> m_model ) { | 1173 | if (( ib-> model & d-> m_model ) == d-> m_model ) { |
1029 | b. setKeycode ( ib-> code ); | 1174 | b. setKeycode ( ib-> code ); |
1030 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 1175 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
1031 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 1176 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
1032 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 1177 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
1033 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 1178 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
1034 | 1179 | ||
1035 | d-> m_buttons-> append ( b ); | 1180 | d-> m_buttons-> append ( b ); |
1036 | } | 1181 | } |
1037 | } | 1182 | } |
1038 | reloadButtonMapping ( ); | 1183 | reloadButtonMapping ( ); |
1039 | 1184 | ||
1040 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1185 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1041 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1186 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1042 | } | 1187 | } |
1043 | 1188 | ||
1044 | 1189 | ||
1045 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 1190 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
1046 | 1191 | ||
1047 | typedef struct { | 1192 | typedef struct { |
1048 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 1193 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
1049 | unsigned char TotalTime; /* Units of 5 seconds */ | 1194 | unsigned char TotalTime; /* Units of 5 seconds */ |
1050 | unsigned char OnTime; /* units of 100m/s */ | 1195 | unsigned char OnTime; /* units of 100m/s */ |
1051 | unsigned char OffTime; /* units of 100m/s */ | 1196 | unsigned char OffTime; /* units of 100m/s */ |
1052 | } LED_IN; | 1197 | } LED_IN; |
1053 | 1198 | ||
1054 | typedef struct { | 1199 | typedef struct { |
1055 | unsigned char mode; | 1200 | unsigned char mode; |
1056 | unsigned char pwr; | 1201 | unsigned char pwr; |
1057 | unsigned char brightness; | 1202 | unsigned char brightness; |
1058 | } FLITE_IN; | 1203 | } FLITE_IN; |
1059 | 1204 | ||
1060 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 1205 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |