-rw-r--r-- | libopie/odevice.cpp | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 103104f..02f13b5 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1,334 +1,336 @@ | |||
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 | 143 | ||
144 | virtual bool setDisplayStatus( bool on ); | ||
143 | virtual bool setDisplayBrightness ( int b ); | 145 | virtual bool setDisplayBrightness ( int b ); |
144 | virtual int displayBrightnessResolution ( ) const; | 146 | virtual int displayBrightnessResolution ( ) const; |
145 | 147 | ||
146 | virtual void alarmSound ( ); | 148 | virtual void alarmSound ( ); |
147 | 149 | ||
148 | virtual QValueList <OLed> ledList ( ) const; | 150 | virtual QValueList <OLed> ledList ( ) const; |
149 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 151 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
150 | virtual OLedState ledState ( OLed led ) const; | 152 | virtual OLedState ledState ( OLed led ) const; |
151 | virtual bool setLedState ( OLed led, OLedState st ); | 153 | virtual bool setLedState ( OLed led, OLedState st ); |
152 | 154 | ||
153 | protected: | 155 | protected: |
154 | 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 ); |
155 | virtual void timerEvent ( QTimerEvent *te ); | 157 | virtual void timerEvent ( QTimerEvent *te ); |
156 | 158 | ||
157 | int m_power_timer; | 159 | int m_power_timer; |
158 | 160 | ||
159 | OLedState m_leds [1]; //FIXME check if really only one | 161 | OLedState m_leds [1]; //FIXME check if really only one |
160 | }; | 162 | }; |
161 | 163 | ||
162 | struct i_button { | 164 | struct i_button { |
163 | uint model; | 165 | uint model; |
164 | Qt::Key code; | 166 | Qt::Key code; |
165 | char *utext; | 167 | char *utext; |
166 | char *pix; | 168 | char *pix; |
167 | char *fpressedservice; | 169 | char *fpressedservice; |
168 | char *fpressedaction; | 170 | char *fpressedaction; |
169 | char *fheldservice; | 171 | char *fheldservice; |
170 | char *fheldaction; | 172 | char *fheldaction; |
171 | } ipaq_buttons [] = { | 173 | } ipaq_buttons [] = { |
172 | { 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, |
173 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 175 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
174 | "devicebuttons/ipaq_calendar", | 176 | "devicebuttons/ipaq_calendar", |
175 | "datebook", "nextView()", | 177 | "datebook", "nextView()", |
176 | "today", "raise()" }, | 178 | "today", "raise()" }, |
177 | { 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, |
178 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 180 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
179 | "devicebuttons/ipaq_contact", | 181 | "devicebuttons/ipaq_contact", |
180 | "addressbook", "raise()", | 182 | "addressbook", "raise()", |
181 | "addressbook", "beamBusinessCard()" }, | 183 | "addressbook", "beamBusinessCard()" }, |
182 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, | 184 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, |
183 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 185 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
184 | "devicebuttons/ipaq_menu", | 186 | "devicebuttons/ipaq_menu", |
185 | "QPE/TaskBar", "toggleMenu()", | 187 | "QPE/TaskBar", "toggleMenu()", |
186 | "QPE/TaskBar", "toggleStartMenu()" }, | 188 | "QPE/TaskBar", "toggleStartMenu()" }, |
187 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 189 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
188 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 190 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
189 | "devicebuttons/ipaq_mail", | 191 | "devicebuttons/ipaq_mail", |
190 | "mail", "raise()", | 192 | "mail", "raise()", |
191 | "mail", "newMail()" }, | 193 | "mail", "newMail()" }, |
192 | { 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, |
193 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 195 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
194 | "devicebuttons/ipaq_home", | 196 | "devicebuttons/ipaq_home", |
195 | "QPE/Launcher", "home()", | 197 | "QPE/Launcher", "home()", |
196 | "buttonsettings", "raise()" }, | 198 | "buttonsettings", "raise()" }, |
197 | { 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, |
198 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), | 200 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), |
199 | "devicebuttons/ipaq_record", | 201 | "devicebuttons/ipaq_record", |
200 | "QPE/VMemo", "toggleRecord()", | 202 | "QPE/VMemo", "toggleRecord()", |
201 | "sound", "raise()" }, | 203 | "sound", "raise()" }, |
202 | }; | 204 | }; |
203 | 205 | ||
204 | struct z_button { | 206 | struct z_button { |
205 | Qt::Key code; | 207 | Qt::Key code; |
206 | char *utext; | 208 | char *utext; |
207 | char *pix; | 209 | char *pix; |
208 | char *fpressedservice; | 210 | char *fpressedservice; |
209 | char *fpressedaction; | 211 | char *fpressedaction; |
210 | char *fheldservice; | 212 | char *fheldservice; |
211 | char *fheldaction; | 213 | char *fheldaction; |
212 | } z_buttons [] = { | 214 | } z_buttons [] = { |
213 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 215 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
214 | "devicebuttons/z_calendar", | 216 | "devicebuttons/z_calendar", |
215 | "datebook", "nextView()", | 217 | "datebook", "nextView()", |
216 | "today", "raise()" }, | 218 | "today", "raise()" }, |
217 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 219 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
218 | "devicebuttons/z_contact", | 220 | "devicebuttons/z_contact", |
219 | "addressbook", "raise()", | 221 | "addressbook", "raise()", |
220 | "addressbook", "beamBusinessCard()" }, | 222 | "addressbook", "beamBusinessCard()" }, |
221 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 223 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
222 | "devicebuttons/z_home", | 224 | "devicebuttons/z_home", |
223 | "QPE/Launcher", "home()", | 225 | "QPE/Launcher", "home()", |
224 | "buttonsettings", "raise()" }, | 226 | "buttonsettings", "raise()" }, |
225 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 227 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
226 | "devicebuttons/z_menu", | 228 | "devicebuttons/z_menu", |
227 | "QPE/TaskBar", "toggleMenu()", | 229 | "QPE/TaskBar", "toggleMenu()", |
228 | "QPE/TaskBar", "toggleStartMenu()" }, | 230 | "QPE/TaskBar", "toggleStartMenu()" }, |
229 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 231 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
230 | "devicebuttons/z_mail", | 232 | "devicebuttons/z_mail", |
231 | "mail", "raise()", | 233 | "mail", "raise()", |
232 | "mail", "newMail()" }, | 234 | "mail", "newMail()" }, |
233 | }; | 235 | }; |
234 | 236 | ||
235 | struct z_button z_buttons_c700 [] = { | 237 | struct z_button z_buttons_c700 [] = { |
236 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 238 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
237 | "devicebuttons/z_calendar", | 239 | "devicebuttons/z_calendar", |
238 | "datebook", "nextView()", | 240 | "datebook", "nextView()", |
239 | "today", "raise()" }, | 241 | "today", "raise()" }, |
240 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 242 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
241 | "devicebuttons/z_contact", | 243 | "devicebuttons/z_contact", |
242 | "addressbook", "raise()", | 244 | "addressbook", "raise()", |
243 | "addressbook", "beamBusinessCard()" }, | 245 | "addressbook", "beamBusinessCard()" }, |
244 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 246 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
245 | "devicebuttons/z_home", | 247 | "devicebuttons/z_home", |
246 | "QPE/Launcher", "home()", | 248 | "QPE/Launcher", "home()", |
247 | "buttonsettings", "raise()" }, | 249 | "buttonsettings", "raise()" }, |
248 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 250 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
249 | "devicebuttons/z_menu", | 251 | "devicebuttons/z_menu", |
250 | "QPE/TaskBar", "toggleMenu()", | 252 | "QPE/TaskBar", "toggleMenu()", |
251 | "QPE/TaskBar", "toggleStartMenu()" }, | 253 | "QPE/TaskBar", "toggleStartMenu()" }, |
252 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), | 254 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), |
253 | "", | 255 | "", |
254 | "QPE/Rotation", "flip()", | 256 | "QPE/Rotation", "flip()", |
255 | "QPE/Rotation", "flip()" }, | 257 | "QPE/Rotation", "flip()" }, |
256 | }; | 258 | }; |
257 | 259 | ||
258 | struct s_button { | 260 | struct s_button { |
259 | uint model; | 261 | uint model; |
260 | Qt::Key code; | 262 | Qt::Key code; |
261 | char *utext; | 263 | char *utext; |
262 | char *pix; | 264 | char *pix; |
263 | char *fpressedservice; | 265 | char *fpressedservice; |
264 | char *fpressedaction; | 266 | char *fpressedaction; |
265 | char *fheldservice; | 267 | char *fheldservice; |
266 | char *fheldaction; | 268 | char *fheldaction; |
267 | } simpad_buttons [] = { | 269 | } simpad_buttons [] = { |
268 | { 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, |
269 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 271 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
270 | "devicebuttons/simpad_menu", | 272 | "devicebuttons/simpad_menu", |
271 | "QPE/TaskBar", "toggleMenu()", | 273 | "QPE/TaskBar", "toggleMenu()", |
272 | "QPE/TaskBar", "toggleStartMenu()" }, | 274 | "QPE/TaskBar", "toggleStartMenu()" }, |
273 | { 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, |
274 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 276 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
275 | "devicebuttons/ipaq_home", | 277 | "devicebuttons/ipaq_home", |
276 | "QPE/Launcher", "home()", | 278 | "QPE/Launcher", "home()", |
277 | "buttonsettings", "raise()" }, | 279 | "buttonsettings", "raise()" }, |
278 | }; | 280 | }; |
279 | 281 | ||
280 | static QCString makeChannel ( const char *str ) | 282 | static QCString makeChannel ( const char *str ) |
281 | { | 283 | { |
282 | if ( str && !::strchr ( str, '/' )) | 284 | if ( str && !::strchr ( str, '/' )) |
283 | return QCString ( "QPE/Application/" ) + str; | 285 | return QCString ( "QPE/Application/" ) + str; |
284 | else | 286 | else |
285 | return str; | 287 | return str; |
286 | } | 288 | } |
287 | 289 | ||
288 | static inline bool isQWS() | 290 | static inline bool isQWS() |
289 | { | 291 | { |
290 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 292 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
291 | } | 293 | } |
292 | 294 | ||
293 | ODevice *ODevice::inst ( ) | 295 | ODevice *ODevice::inst ( ) |
294 | { | 296 | { |
295 | static ODevice *dev = 0; | 297 | static ODevice *dev = 0; |
296 | 298 | ||
297 | if ( !dev ) { | 299 | if ( !dev ) { |
298 | if ( QFile::exists ( "/proc/hal/model" )) | 300 | if ( QFile::exists ( "/proc/hal/model" )) |
299 | dev = new iPAQ ( ); | 301 | dev = new iPAQ ( ); |
300 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 302 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
301 | dev = new Zaurus ( ); | 303 | dev = new Zaurus ( ); |
302 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) | 304 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) |
303 | dev = new SIMpad ( ); | 305 | dev = new SIMpad ( ); |
304 | else | 306 | else |
305 | dev = new ODevice ( ); | 307 | dev = new ODevice ( ); |
306 | 308 | ||
307 | dev-> init ( ); | 309 | dev-> init ( ); |
308 | } | 310 | } |
309 | return dev; | 311 | return dev; |
310 | } | 312 | } |
311 | 313 | ||
312 | 314 | ||
313 | /************************************************** | 315 | /************************************************** |
314 | * | 316 | * |
315 | * common | 317 | * common |
316 | * | 318 | * |
317 | **************************************************/ | 319 | **************************************************/ |
318 | 320 | ||
319 | 321 | ||
320 | ODevice::ODevice ( ) | 322 | ODevice::ODevice ( ) |
321 | { | 323 | { |
322 | d = new ODeviceData; | 324 | d = new ODeviceData; |
323 | 325 | ||
324 | d-> m_modelstr = "Unknown"; | 326 | d-> m_modelstr = "Unknown"; |
325 | d-> m_model = Model_Unknown; | 327 | d-> m_model = Model_Unknown; |
326 | d-> m_vendorstr = "Unknown"; | 328 | d-> m_vendorstr = "Unknown"; |
327 | d-> m_vendor = Vendor_Unknown; | 329 | d-> m_vendor = Vendor_Unknown; |
328 | d-> m_systemstr = "Unknown"; | 330 | d-> m_systemstr = "Unknown"; |
329 | d-> m_system = System_Unknown; | 331 | d-> m_system = System_Unknown; |
330 | d-> m_sysverstr = "0.0"; | 332 | d-> m_sysverstr = "0.0"; |
331 | d-> m_rotation = Rot0; | 333 | d-> m_rotation = Rot0; |
332 | d-> m_direction = CW; | 334 | d-> m_direction = CW; |
333 | 335 | ||
334 | d-> m_holdtime = 1000; // 1000ms | 336 | d-> m_holdtime = 1000; // 1000ms |
@@ -1526,237 +1528,273 @@ void SIMpad::init ( ) | |||
1526 | f. close ( ); | 1528 | f. close ( ); |
1527 | } else { | 1529 | } else { |
1528 | f. setName ( "/etc/oz_version" ); | 1530 | f. setName ( "/etc/oz_version" ); |
1529 | 1531 | ||
1530 | if ( f. open ( IO_ReadOnly )) { | 1532 | if ( f. open ( IO_ReadOnly )) { |
1531 | d-> m_systemstr = "OpenEmbedded/SIMpad"; | 1533 | d-> m_systemstr = "OpenEmbedded/SIMpad"; |
1532 | d-> m_system = System_OpenZaurus; | 1534 | d-> m_system = System_OpenZaurus; |
1533 | 1535 | ||
1534 | QTextStream ts ( &f ); | 1536 | QTextStream ts ( &f ); |
1535 | ts.setDevice ( &f ); | 1537 | ts.setDevice ( &f ); |
1536 | d-> m_sysverstr = ts. readLine ( ); | 1538 | d-> m_sysverstr = ts. readLine ( ); |
1537 | f. close ( ); | 1539 | f. close ( ); |
1538 | } | 1540 | } |
1539 | } | 1541 | } |
1540 | 1542 | ||
1541 | m_leds [0] = m_leds [1] = Led_Off; | 1543 | m_leds [0] = m_leds [1] = Led_Off; |
1542 | 1544 | ||
1543 | m_power_timer = 0; | 1545 | m_power_timer = 0; |
1544 | 1546 | ||
1545 | } | 1547 | } |
1546 | 1548 | ||
1547 | void SIMpad::initButtons ( ) | 1549 | void SIMpad::initButtons ( ) |
1548 | { | 1550 | { |
1549 | if ( d-> m_buttons ) | 1551 | if ( d-> m_buttons ) |
1550 | return; | 1552 | return; |
1551 | 1553 | ||
1552 | if ( isQWS( ) ) | 1554 | if ( isQWS( ) ) |
1553 | QWSServer::setKeyboardFilter ( this ); | 1555 | QWSServer::setKeyboardFilter ( this ); |
1554 | 1556 | ||
1555 | d-> m_buttons = new QValueList <ODeviceButton>; | 1557 | d-> m_buttons = new QValueList <ODeviceButton>; |
1556 | 1558 | ||
1557 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { | 1559 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { |
1558 | s_button *sb = simpad_buttons + i; | 1560 | s_button *sb = simpad_buttons + i; |
1559 | ODeviceButton b; | 1561 | ODeviceButton b; |
1560 | 1562 | ||
1561 | if (( sb-> model & d-> m_model ) == d-> m_model ) { | 1563 | if (( sb-> model & d-> m_model ) == d-> m_model ) { |
1562 | b. setKeycode ( sb-> code ); | 1564 | b. setKeycode ( sb-> code ); |
1563 | b. setUserText ( QObject::tr ( "Button", sb-> utext )); | 1565 | b. setUserText ( QObject::tr ( "Button", sb-> utext )); |
1564 | b. setPixmap ( Resource::loadPixmap ( sb-> pix )); | 1566 | b. setPixmap ( Resource::loadPixmap ( sb-> pix )); |
1565 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); | 1567 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); |
1566 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); | 1568 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); |
1567 | 1569 | ||
1568 | d-> m_buttons-> append ( b ); | 1570 | d-> m_buttons-> append ( b ); |
1569 | } | 1571 | } |
1570 | } | 1572 | } |
1571 | reloadButtonMapping ( ); | 1573 | reloadButtonMapping ( ); |
1572 | 1574 | ||
1573 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1575 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1574 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1576 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1575 | } | 1577 | } |
1576 | 1578 | ||
1577 | // SIMpad boardcontrol register CS3 | 1579 | // SIMpad boardcontrol register CS3 |
1578 | #define SIMPAD_BOARDCONTROL "/proc/cs3" | 1580 | #define SIMPAD_BOARDCONTROL "/proc/cs3" |
1579 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA | 1581 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA |
1580 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA | 1582 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA |
1581 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's | 1583 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's |
1582 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V | 1584 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V |
1583 | #define SIMPAD_DISPLAY_ON 0x0010 | 1585 | #define SIMPAD_DISPLAY_ON 0x0010 |
1584 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 | 1586 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 |
1585 | #define SIMPAD_MQ_RESET 0x0040 | 1587 | #define SIMPAD_MQ_RESET 0x0040 |
1586 | #define SIMPAD_PCMCIA_RESET 0x0080 | 1588 | #define SIMPAD_PCMCIA_RESET 0x0080 |
1587 | #define SIMPAD_DECT_POWER_ON 0x0100 | 1589 | #define SIMPAD_DECT_POWER_ON 0x0100 |
1588 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave | 1590 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave |
1589 | #define SIMPAD_RS232_ON 0x0400 | 1591 | #define SIMPAD_RS232_ON 0x0400 |
1590 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave | 1592 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave |
1591 | #define SIMPAD_LED2_ON 0x1000 | 1593 | #define SIMPAD_LED2_ON 0x1000 |
1592 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode | 1594 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode |
1593 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit | 1595 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit |
1594 | #define SIMPAD_RESET_SIMCARD 0x8000 | 1596 | #define SIMPAD_RESET_SIMCARD 0x8000 |
1595 | 1597 | ||
1596 | //SIMpad touchscreen backlight strength control | 1598 | //SIMpad touchscreen backlight strength control |
1597 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" | 1599 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" |
1598 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 | 1600 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 |
1599 | 1601 | ||
1600 | QValueList <OLed> SIMpad::ledList ( ) const | 1602 | QValueList <OLed> SIMpad::ledList ( ) const |
1601 | { | 1603 | { |
1602 | QValueList <OLed> vl; | 1604 | QValueList <OLed> vl; |
1603 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? | 1605 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? |
1604 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway | 1606 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway |
1605 | return vl; | 1607 | return vl; |
1606 | } | 1608 | } |
1607 | 1609 | ||
1608 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const | 1610 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const |
1609 | { | 1611 | { |
1610 | QValueList <OLedState> vl; | 1612 | QValueList <OLedState> vl; |
1611 | 1613 | ||
1612 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? | 1614 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? |
1613 | vl << Led_Off << Led_On; | 1615 | vl << Led_Off << Led_On; |
1614 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway | 1616 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway |
1615 | //vl << Led_Off; | 1617 | //vl << Led_Off; |
1616 | return vl; | 1618 | return vl; |
1617 | } | 1619 | } |
1618 | 1620 | ||
1619 | OLedState SIMpad::ledState ( OLed l ) const | 1621 | OLedState SIMpad::ledState ( OLed l ) const |
1620 | { | 1622 | { |
1621 | switch ( l ) { | 1623 | switch ( l ) { |
1622 | case Led_Power: | 1624 | case Led_Power: |
1623 | return m_leds [0]; | 1625 | return m_leds [0]; |
1624 | //case Led_Mail: | 1626 | //case Led_Mail: |
1625 | //return m_leds [1]; | 1627 | //return m_leds [1]; |
1626 | default: | 1628 | default: |
1627 | return Led_Off; | 1629 | return Led_Off; |
1628 | } | 1630 | } |
1629 | } | 1631 | } |
1630 | 1632 | ||
1631 | bool SIMpad::setLedState ( OLed l, OLedState st ) | 1633 | bool SIMpad::setLedState ( OLed l, OLedState st ) |
1632 | { | 1634 | { |
1633 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); | 1635 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); |
1634 | 1636 | ||
1635 | if ( l == Led_Power ) { | 1637 | if ( l == Led_Power ) { |
1636 | if ( fd >= 0 ) { | 1638 | if ( fd >= 0 ) { |
1637 | LED_IN leds; | 1639 | LED_IN leds; |
1638 | ::memset ( &leds, 0, sizeof( leds )); | 1640 | ::memset ( &leds, 0, sizeof( leds )); |
1639 | leds. TotalTime = 0; | 1641 | leds. TotalTime = 0; |
1640 | leds. OnTime = 0; | 1642 | leds. OnTime = 0; |
1641 | leds. OffTime = 1; | 1643 | leds. OffTime = 1; |
1642 | leds. OffOnBlink = 2; | 1644 | leds. OffOnBlink = 2; |
1643 | 1645 | ||
1644 | switch ( st ) { | 1646 | switch ( st ) { |
1645 | case Led_Off : leds. OffOnBlink = 0; break; | 1647 | case Led_Off : leds. OffOnBlink = 0; break; |
1646 | case Led_On : leds. OffOnBlink = 1; break; | 1648 | case Led_On : leds. OffOnBlink = 1; break; |
1647 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 1649 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
1648 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 1650 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
1649 | } | 1651 | } |
1650 | 1652 | ||
1651 | { | 1653 | { |
1652 | /*TODO Implement this like that: | 1654 | /*TODO Implement this like that: |
1653 | read from cs3 | 1655 | read from cs3 |
1654 | && with SIMPAD_LED2_ON | 1656 | && with SIMPAD_LED2_ON |
1655 | write to cs3 */ | 1657 | write to cs3 */ |
1656 | m_leds [0] = st; | 1658 | m_leds [0] = st; |
1657 | return true; | 1659 | return true; |
1658 | } | 1660 | } |
1659 | } | 1661 | } |
1660 | } | 1662 | } |
1661 | return false; | 1663 | return false; |
1662 | } | 1664 | } |
1663 | 1665 | ||
1664 | 1666 | ||
1665 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 1667 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
1666 | { | 1668 | { |
1667 | //TODO | 1669 | //TODO |
1668 | return false; | 1670 | return false; |
1669 | } | 1671 | } |
1670 | 1672 | ||
1671 | void SIMpad::timerEvent ( QTimerEvent * ) | 1673 | void SIMpad::timerEvent ( QTimerEvent * ) |
1672 | { | 1674 | { |
1673 | killTimer ( m_power_timer ); | 1675 | killTimer ( m_power_timer ); |
1674 | m_power_timer = 0; | 1676 | m_power_timer = 0; |
1675 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 1677 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
1676 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 1678 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
1677 | } | 1679 | } |
1678 | 1680 | ||
1679 | 1681 | ||
1680 | void SIMpad::alarmSound ( ) | 1682 | void SIMpad::alarmSound ( ) |
1681 | { | 1683 | { |
1682 | #ifndef QT_NO_SOUND | 1684 | #ifndef QT_NO_SOUND |
1683 | static Sound snd ( "alarm" ); | 1685 | static Sound snd ( "alarm" ); |
1684 | int fd; | 1686 | int fd; |
1685 | int vol; | 1687 | int vol; |
1686 | bool vol_reset = false; | 1688 | bool vol_reset = false; |
1687 | 1689 | ||
1688 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 1690 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
1689 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 1691 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
1690 | Config cfg ( "qpe" ); | 1692 | Config cfg ( "qpe" ); |
1691 | cfg. setGroup ( "Volume" ); | 1693 | cfg. setGroup ( "Volume" ); |
1692 | 1694 | ||
1693 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1695 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1694 | if ( volalarm < 0 ) | 1696 | if ( volalarm < 0 ) |
1695 | volalarm = 0; | 1697 | volalarm = 0; |
1696 | else if ( volalarm > 100 ) | 1698 | else if ( volalarm > 100 ) |
1697 | volalarm = 100; | 1699 | volalarm = 100; |
1698 | volalarm |= ( volalarm << 8 ); | 1700 | volalarm |= ( volalarm << 8 ); |
1699 | 1701 | ||
1700 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1702 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1701 | vol_reset = true; | 1703 | vol_reset = true; |
1702 | } | 1704 | } |
1703 | } | 1705 | } |
1704 | 1706 | ||
1705 | snd. play ( ); | 1707 | snd. play ( ); |
1706 | while ( !snd. isFinished ( )) | 1708 | while ( !snd. isFinished ( )) |
1707 | qApp-> processEvents ( ); | 1709 | qApp-> processEvents ( ); |
1708 | 1710 | ||
1709 | if ( fd >= 0 ) { | 1711 | if ( fd >= 0 ) { |
1710 | if ( vol_reset ) | 1712 | if ( vol_reset ) |
1711 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1713 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
1712 | ::close ( fd ); | 1714 | ::close ( fd ); |
1713 | } | 1715 | } |
1714 | #endif | 1716 | #endif |
1715 | } | 1717 | } |
1716 | 1718 | ||
1717 | 1719 | ||
1720 | bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm | ||
1721 | { | ||
1722 | qDebug( "ODevice for SIMpad: suspend()" ); | ||
1723 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | ||
1724 | return false; | ||
1725 | |||
1726 | bool res = false; | ||
1727 | |||
1728 | struct timeval tvs, tvn; | ||
1729 | ::gettimeofday ( &tvs, 0 ); | ||
1730 | |||
1731 | ::sync ( ); // flush fs caches | ||
1732 | res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :) | ||
1733 | |||
1734 | return res; | ||
1735 | } | ||
1736 | |||
1737 | |||
1718 | bool SIMpad::setSoftSuspend ( bool soft ) | 1738 | bool SIMpad::setSoftSuspend ( bool soft ) |
1719 | { | 1739 | { |
1720 | //TODO | 1740 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); |
1721 | return false; | 1741 | return false; |
1722 | } | 1742 | } |
1723 | 1743 | ||
1724 | 1744 | ||
1745 | bool SIMpad::setDisplayStatus ( bool on ) | ||
1746 | { | ||
1747 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | ||
1748 | |||
1749 | bool res = false; | ||
1750 | int fd; | ||
1751 | |||
1752 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) | ||
1753 | |||
1754 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | ||
1755 | res = ( ::system( (const char*) cmdline ) == 0 ); | ||
1756 | ::close ( fd ); | ||
1757 | } | ||
1758 | return res; | ||
1759 | } | ||
1760 | |||
1761 | |||
1725 | bool SIMpad::setDisplayBrightness ( int bright ) | 1762 | bool SIMpad::setDisplayBrightness ( int bright ) |
1726 | { | 1763 | { |
1764 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); | ||
1727 | bool res = false; | 1765 | bool res = false; |
1728 | int fd; | 1766 | int fd; |
1729 | 1767 | ||
1730 | if ( bright > 255 ) | 1768 | if ( bright > 255 ) |
1731 | bright = 255; | 1769 | bright = 255; |
1732 | if ( bright < 0 ) | 1770 | if ( bright < 0 ) |
1733 | bright = 0; | 1771 | bright = 0; |
1734 | 1772 | ||
1735 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 1773 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
1736 | int value = 255 - bright; | 1774 | int value = 255 - bright; |
1737 | const int mask = SIMPAD_BACKLIGHT_MASK; | 1775 | const int mask = SIMPAD_BACKLIGHT_MASK; |
1738 | value = value << 8; | 1776 | value = value << 8; |
1739 | value += mask; | 1777 | value += mask; |
1740 | char writeCommand[100]; | 1778 | char writeCommand[100]; |
1741 | const int count = sprintf( writeCommand, "0x%x\n", value ); | 1779 | const int count = sprintf( writeCommand, "0x%x\n", value ); |
1742 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 1780 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
1743 | ::close ( fd ); | 1781 | ::close ( fd ); |
1744 | } | 1782 | } |
1745 | return res; | 1783 | return res; |
1746 | } | 1784 | } |
1747 | 1785 | ||
1748 | 1786 | ||
1749 | int SIMpad::displayBrightnessResolution ( ) const | 1787 | int SIMpad::displayBrightnessResolution ( ) const |
1750 | { | 1788 | { |
1751 | switch ( model ( )) { | 1789 | switch ( model ( )) { |
1752 | case Model_SIMpad_CL4: | 1790 | case Model_SIMpad_CL4: |
1753 | case Model_SIMpad_SL4: | 1791 | case Model_SIMpad_SL4: |
1754 | case Model_SIMpad_SLC: | 1792 | case Model_SIMpad_SLC: |
1755 | case Model_SIMpad_TSinus: | 1793 | case Model_SIMpad_TSinus: |
1756 | return 255; //TODO find out if this is save | 1794 | return 255; //TODO find out if this is save |
1757 | 1795 | ||
1758 | default: | 1796 | default: |
1759 | return 2; | 1797 | return 2; |
1760 | } | 1798 | } |
1761 | } | 1799 | } |
1762 | 1800 | ||