author | zecke <zecke> | 2005-02-17 23:52:46 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-02-17 23:52:46 (UTC) |
commit | 9bf35a9978c8a9e8b9c2100abf9137ffefc73e17 (patch) (unidiff) | |
tree | f251c1697f2ed091d8f55eca7aa1b8f4a85c7889 | |
parent | 87cbafeb59d0505b631be811bd96fb1d0b1df1f7 (diff) | |
download | opie-9bf35a9978c8a9e8b9c2100abf9137ffefc73e17.zip opie-9bf35a9978c8a9e8b9c2100abf9137ffefc73e17.tar.gz opie-9bf35a9978c8a9e8b9c2100abf9137ffefc73e17.tar.bz2 |
Add OAbstractMobileDevice with implementations for suspend and setDisplayStatus
Switch our implementations over to this partial implementation of ODevice
-rw-r--r-- | libopie2/opiecore/device/device.pro | 2 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 14 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_abstractmobiledevice.cpp | 119 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_abstractmobiledevice.h | 64 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_beagle.h | 4 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_ipaq.h | 4 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_jornada.cpp | 21 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_jornada.h | 5 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_ramses.h | 2 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.h | 6 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_yopy.h | 4 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 36 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.h | 5 |
14 files changed, 204 insertions, 84 deletions
diff --git a/libopie2/opiecore/device/device.pro b/libopie2/opiecore/device/device.pro index 9a409e1..08bd4e1 100644 --- a/libopie2/opiecore/device/device.pro +++ b/libopie2/opiecore/device/device.pro | |||
@@ -1,22 +1,24 @@ | |||
1 | HEADERS += device/odevice.h \ | 1 | HEADERS += device/odevice.h \ |
2 | device/odevicebutton.h \ | 2 | device/odevicebutton.h \ |
3 | device/odevice_abstractmobiledevice.h \ | ||
3 | device/odevice_beagle.h \ | 4 | device/odevice_beagle.h \ |
4 | device/odevice_ipaq.h \ | 5 | device/odevice_ipaq.h \ |
5 | device/odevice_jornada.h \ | 6 | device/odevice_jornada.h \ |
6 | device/odevice_ramses.h \ | 7 | device/odevice_ramses.h \ |
7 | device/odevice_simpad.h \ | 8 | device/odevice_simpad.h \ |
8 | device/odevice_zaurus.h \ | 9 | device/odevice_zaurus.h \ |
9 | device/odevice_genuineintel.h \ | 10 | device/odevice_genuineintel.h \ |
10 | device/odevice_yopy.h | 11 | device/odevice_yopy.h |
11 | 12 | ||
12 | SOURCES += device/odevice.cpp \ | 13 | SOURCES += device/odevice.cpp \ |
13 | device/odevicebutton.cpp \ | 14 | device/odevicebutton.cpp \ |
15 | device/odevice_abstractmobiledevice.cpp \ | ||
14 | device/odevice_beagle.cpp \ | 16 | device/odevice_beagle.cpp \ |
15 | device/odevice_ipaq.cpp \ | 17 | device/odevice_ipaq.cpp \ |
16 | device/odevice_jornada.cpp\ | 18 | device/odevice_jornada.cpp\ |
17 | device/odevice_ramses.cpp \ | 19 | device/odevice_ramses.cpp \ |
18 | device/odevice_simpad.cpp \ | 20 | device/odevice_simpad.cpp \ |
19 | device/odevice_zaurus.cpp \ | 21 | device/odevice_zaurus.cpp \ |
20 | device/odevice_genuineintel.cpp \ | 22 | device/odevice_genuineintel.cpp \ |
21 | device/odevice_yopy.cpp | 23 | device/odevice_yopy.cpp |
22 | 24 | ||
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index 2c5190c..ed705a6 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -65,414 +65,400 @@ | |||
65 | namespace Opie { | 65 | namespace Opie { |
66 | namespace Core { | 66 | namespace Core { |
67 | 67 | ||
68 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; | 68 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; |
69 | 69 | ||
70 | 70 | ||
71 | /* STATIC and common implementation */ | 71 | /* STATIC and common implementation */ |
72 | /* EXPORT */ ODistribution distributions[] = { | 72 | /* EXPORT */ ODistribution distributions[] = { |
73 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, | 73 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, |
74 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, | 74 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, |
75 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, | 75 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, |
76 | { System_Unknown, "Linux", "/etc/issue" }, | 76 | { System_Unknown, "Linux", "/etc/issue" }, |
77 | }; | 77 | }; |
78 | 78 | ||
79 | 79 | ||
80 | /* EXPORT */ bool isQWS(){ | 80 | /* EXPORT */ bool isQWS(){ |
81 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; | 81 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; |
82 | } | 82 | } |
83 | 83 | ||
84 | /* EXPORT */ QCString makeChannel ( const char *str ){ | 84 | /* EXPORT */ QCString makeChannel ( const char *str ){ |
85 | if ( str && !::strchr ( str, '/' )) | 85 | if ( str && !::strchr ( str, '/' )) |
86 | return QCString ( "QPE/Application/" ) + str; | 86 | return QCString ( "QPE/Application/" ) + str; |
87 | else | 87 | else |
88 | return str; | 88 | return str; |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | 92 | ||
93 | /* Now the default implementation of ODevice */ | 93 | /* Now the default implementation of ODevice */ |
94 | 94 | ||
95 | struct default_button default_buttons [] = { | 95 | struct default_button default_buttons [] = { |
96 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 96 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
97 | "devicebuttons/z_calendar", | 97 | "devicebuttons/z_calendar", |
98 | "datebook", "nextView()", | 98 | "datebook", "nextView()", |
99 | "today", "raise()" }, | 99 | "today", "raise()" }, |
100 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 100 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
101 | "devicebuttons/z_contact", | 101 | "devicebuttons/z_contact", |
102 | "addressbook", "raise()", | 102 | "addressbook", "raise()", |
103 | "addressbook", "beamBusinessCard()" }, | 103 | "addressbook", "beamBusinessCard()" }, |
104 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 104 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
105 | "devicebuttons/z_home", | 105 | "devicebuttons/z_home", |
106 | "QPE/Launcher", "home()", | 106 | "QPE/Launcher", "home()", |
107 | "buttonsettings", "raise()" }, | 107 | "buttonsettings", "raise()" }, |
108 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 108 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
109 | "devicebuttons/z_menu", | 109 | "devicebuttons/z_menu", |
110 | "QPE/TaskBar", "toggleMenu()", | 110 | "QPE/TaskBar", "toggleMenu()", |
111 | "QPE/TaskBar", "toggleStartMenu()" }, | 111 | "QPE/TaskBar", "toggleStartMenu()" }, |
112 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 112 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
113 | "devicebuttons/z_mail", | 113 | "devicebuttons/z_mail", |
114 | "opiemail", "raise()", | 114 | "opiemail", "raise()", |
115 | "opiemail", "newMail()" }, | 115 | "opiemail", "newMail()" }, |
116 | }; | 116 | }; |
117 | 117 | ||
118 | ODevice *ODevice::inst() | 118 | ODevice *ODevice::inst() |
119 | { | 119 | { |
120 | static ODevice *dev = 0; | 120 | static ODevice *dev = 0; |
121 | 121 | ||
122 | // rewrite this to only use /proc/cpuinfo or so | 122 | // rewrite this to only use /proc/cpuinfo or so |
123 | QString cpu_info; | 123 | QString cpu_info; |
124 | 124 | ||
125 | if ( !dev ) | 125 | if ( !dev ) |
126 | { | 126 | { |
127 | QFile f( PATH_PROC_CPUINFO ); | 127 | QFile f( PATH_PROC_CPUINFO ); |
128 | if ( f.open( IO_ReadOnly ) ) | 128 | if ( f.open( IO_ReadOnly ) ) |
129 | { | 129 | { |
130 | QTextStream s( &f ); | 130 | QTextStream s( &f ); |
131 | while ( !s.atEnd() ) | 131 | while ( !s.atEnd() ) |
132 | { | 132 | { |
133 | QString line; | 133 | QString line; |
134 | line = s.readLine(); | 134 | line = s.readLine(); |
135 | if ( line.startsWith( "Hardware" ) ) | 135 | if ( line.startsWith( "Hardware" ) ) |
136 | { | 136 | { |
137 | qDebug( "ODevice() - found '%s'", (const char*) line ); | 137 | qDebug( "ODevice() - found '%s'", (const char*) line ); |
138 | cpu_info = line; | 138 | cpu_info = line; |
139 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); | 139 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); |
140 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); | 140 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); |
141 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); | 141 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); |
142 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); | 142 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); |
143 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); | 143 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); |
144 | else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); | 144 | else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); |
145 | else qWarning( "ODevice() - unknown hardware - using default." ); | 145 | else qWarning( "ODevice() - unknown hardware - using default." ); |
146 | break; | 146 | break; |
147 | } else if ( line.startsWith( "vendor_id" ) ) { | 147 | } else if ( line.startsWith( "vendor_id" ) ) { |
148 | qDebug( "ODevice() - found '%s'", (const char*) line ); | 148 | qDebug( "ODevice() - found '%s'", (const char*) line ); |
149 | cpu_info = line; | 149 | cpu_info = line; |
150 | if( line.contains( "genuineintel", false ) ) { | 150 | if( line.contains( "genuineintel", false ) ) { |
151 | dev = new Internal::GenuineIntel(); | 151 | dev = new Internal::GenuineIntel(); |
152 | break; | 152 | break; |
153 | } | 153 | } |
154 | } | 154 | } |
155 | } | 155 | } |
156 | } | 156 | } |
157 | else | 157 | else |
158 | { | 158 | { |
159 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); | 159 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); |
160 | } | 160 | } |
161 | if ( !dev ) dev = new ODevice(); | 161 | if ( !dev ) dev = new ODevice(); |
162 | dev->init(cpu_info); | 162 | dev->init(cpu_info); |
163 | } | 163 | } |
164 | return dev; | 164 | return dev; |
165 | } | 165 | } |
166 | 166 | ||
167 | ODevice::ODevice() | 167 | ODevice::ODevice() |
168 | { | 168 | { |
169 | d = new ODeviceData; | 169 | d = new ODeviceData; |
170 | 170 | ||
171 | d->m_modelstr = "Unknown"; | 171 | d->m_modelstr = "Unknown"; |
172 | d->m_model = Model_Unknown; | 172 | d->m_model = Model_Unknown; |
173 | d->m_vendorstr = "Unknown"; | 173 | d->m_vendorstr = "Unknown"; |
174 | d->m_vendor = Vendor_Unknown; | 174 | d->m_vendor = Vendor_Unknown; |
175 | d->m_systemstr = "Unknown"; | 175 | d->m_systemstr = "Unknown"; |
176 | d->m_system = System_Unknown; | 176 | d->m_system = System_Unknown; |
177 | d->m_sysverstr = "0.0"; | 177 | d->m_sysverstr = "0.0"; |
178 | d->m_rotation = Rot0; | 178 | d->m_rotation = Rot0; |
179 | d->m_direction = CW; | 179 | d->m_direction = CW; |
180 | 180 | ||
181 | d->m_holdtime = 1000; // 1000ms | 181 | d->m_holdtime = 1000; // 1000ms |
182 | d->m_buttons = 0; | 182 | d->m_buttons = 0; |
183 | d->m_cpu_frequencies = new QStrList; | 183 | d->m_cpu_frequencies = new QStrList; |
184 | 184 | ||
185 | 185 | ||
186 | /* mixer */ | 186 | /* mixer */ |
187 | d->m_sound = d->m_vol = d->m_mixer = -1; | 187 | d->m_sound = d->m_vol = d->m_mixer = -1; |
188 | 188 | ||
189 | /* System QCopChannel created */ | 189 | /* System QCopChannel created */ |
190 | d->m_initializedButtonQcop = false; | 190 | d->m_initializedButtonQcop = false; |
191 | 191 | ||
192 | // New distribution detection code first checks for legacy distributions, | 192 | // New distribution detection code first checks for legacy distributions, |
193 | // identified by /etc/familiar-version or /etc/oz_version. | 193 | // identified by /etc/familiar-version or /etc/oz_version. |
194 | // Then check for OpenEmbedded and lastly, read /etc/issue | 194 | // Then check for OpenEmbedded and lastly, read /etc/issue |
195 | 195 | ||
196 | for ( unsigned int i = 0; i < sizeof distributions; ++i ) | 196 | for ( unsigned int i = 0; i < sizeof distributions; ++i ) |
197 | { | 197 | { |
198 | if ( QFile::exists( distributions[i].sysvfile ) ) | 198 | if ( QFile::exists( distributions[i].sysvfile ) ) |
199 | { | 199 | { |
200 | d->m_systemstr = distributions[i].sysstr; | 200 | d->m_systemstr = distributions[i].sysstr; |
201 | d->m_system = distributions[i].system; | 201 | d->m_system = distributions[i].system; |
202 | d->m_sysverstr = "<Unknown>"; | 202 | d->m_sysverstr = "<Unknown>"; |
203 | QFile f( distributions[i].sysvfile ); | 203 | QFile f( distributions[i].sysvfile ); |
204 | if ( f.open( IO_ReadOnly ) ) | 204 | if ( f.open( IO_ReadOnly ) ) |
205 | { | 205 | { |
206 | QTextStream ts( &f ); | 206 | QTextStream ts( &f ); |
207 | d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); | 207 | d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); |
208 | } | 208 | } |
209 | break; | 209 | break; |
210 | } | 210 | } |
211 | } | 211 | } |
212 | } | 212 | } |
213 | 213 | ||
214 | void ODevice::systemMessage( const QCString &msg, const QByteArray & ) | 214 | void ODevice::systemMessage( const QCString &msg, const QByteArray & ) |
215 | { | 215 | { |
216 | if ( msg == "deviceButtonMappingChanged()" ) { | 216 | if ( msg == "deviceButtonMappingChanged()" ) { |
217 | reloadButtonMapping(); | 217 | reloadButtonMapping(); |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | void ODevice::init(const QString&) | 221 | void ODevice::init(const QString&) |
222 | { | 222 | { |
223 | } | 223 | } |
224 | 224 | ||
225 | /** | 225 | /** |
226 | * This method initialises the button mapping | 226 | * This method initialises the button mapping |
227 | */ | 227 | */ |
228 | void ODevice::initButtons() | 228 | void ODevice::initButtons() |
229 | { | 229 | { |
230 | if ( d->m_buttons ) | 230 | if ( d->m_buttons ) |
231 | return; | 231 | return; |
232 | 232 | ||
233 | qDebug ( "init Buttons" ); | 233 | qDebug ( "init Buttons" ); |
234 | d->m_buttons = new QValueList <ODeviceButton>; | 234 | d->m_buttons = new QValueList <ODeviceButton>; |
235 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { | 235 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { |
236 | default_button *db = default_buttons + i; | 236 | default_button *db = default_buttons + i; |
237 | ODeviceButton b; | 237 | ODeviceButton b; |
238 | b. setKeycode ( db->code ); | 238 | b. setKeycode ( db->code ); |
239 | b. setUserText ( QObject::tr ( "Button", db->utext )); | 239 | b. setUserText ( QObject::tr ( "Button", db->utext )); |
240 | b. setPixmap ( Resource::loadPixmap ( db->pix )); | 240 | b. setPixmap ( Resource::loadPixmap ( db->pix )); |
241 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); | 241 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); |
242 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); | 242 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); |
243 | d->m_buttons->append ( b ); | 243 | d->m_buttons->append ( b ); |
244 | } | 244 | } |
245 | 245 | ||
246 | reloadButtonMapping(); | 246 | reloadButtonMapping(); |
247 | } | 247 | } |
248 | 248 | ||
249 | ODevice::~ODevice() | 249 | ODevice::~ODevice() |
250 | { | 250 | { |
251 | // we leak m_devicebuttons and m_cpu_frequency | 251 | // we leak m_devicebuttons and m_cpu_frequency |
252 | // but it's a singleton and it is not so importantant | 252 | // but it's a singleton and it is not so importantant |
253 | // -zecke | 253 | // -zecke |
254 | delete d; | 254 | delete d; |
255 | } | 255 | } |
256 | 256 | ||
257 | //#include <linux/apm_bios.h> | ||
258 | |||
259 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | ||
260 | |||
261 | /** | 257 | /** |
262 | * This method will try to suspend the device | 258 | * This method will try to suspend the device |
263 | * It only works if the user is the QWS Server and the apm application | 259 | * It only works if the user is the QWS Server and the apm application |
264 | * is installed. | 260 | * is installed. |
265 | * It tries to suspend and then waits some time cause some distributions | 261 | * It tries to suspend and then waits some time cause some distributions |
266 | * do have asynchronus apm implementations. | 262 | * do have asynchronus apm implementations. |
267 | * This method will either fail and return false or it'll suspend the | 263 | * This method will either fail and return false or it'll suspend the |
268 | * device and return once the device got woken up | 264 | * device and return once the device got woken up |
269 | * | 265 | * |
270 | * @return if the device got suspended | 266 | * @return if the device got suspended |
271 | */ | 267 | */ |
272 | bool ODevice::suspend() | 268 | bool ODevice::suspend() |
273 | { | 269 | { |
274 | return false; // default implementation == unknown device or qvfb | 270 | return false; // default implementation == unknown device or qvfb |
275 | } | 271 | } |
276 | 272 | ||
277 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | ||
278 | |||
279 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | ||
280 | |||
281 | /* VESA Blanking Levels */ | ||
282 | #define VESA_NO_BLANKING 0 | ||
283 | #define VESA_VSYNC_SUSPEND 1 | ||
284 | #define VESA_HSYNC_SUSPEND 2 | ||
285 | #define VESA_POWERDOWN 3 | ||
286 | |||
287 | /** | 273 | /** |
288 | * This sets the display on or off | 274 | * This sets the display on or off |
289 | */ | 275 | */ |
290 | bool ODevice::setDisplayStatus( bool on ) | 276 | bool ODevice::setDisplayStatus( bool on ) |
291 | { | 277 | { |
292 | qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on ); | 278 | qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on ); |
293 | return false; // don't do anything for unknown models | 279 | return false; // don't do anything for unknown models |
294 | } | 280 | } |
295 | 281 | ||
296 | /** | 282 | /** |
297 | * This sets the display brightness | 283 | * This sets the display brightness |
298 | * | 284 | * |
299 | * @param b The brightness to be set on a scale from 0 to 255 | 285 | * @param b The brightness to be set on a scale from 0 to 255 |
300 | * @return success or failure | 286 | * @return success or failure |
301 | */ | 287 | */ |
302 | bool ODevice::setDisplayBrightness( int b ) | 288 | bool ODevice::setDisplayBrightness( int b ) |
303 | { | 289 | { |
304 | qDebug( "ODevice::setDisplayBrightness( %d ) - please override me.", b ); | 290 | qDebug( "ODevice::setDisplayBrightness( %d ) - please override me.", b ); |
305 | return false; | 291 | return false; |
306 | } | 292 | } |
307 | 293 | ||
308 | /** | 294 | /** |
309 | * | 295 | * |
310 | * @returns the number of steppings on the brightness slider | 296 | * @returns the number of steppings on the brightness slider |
311 | * in the Light-'n-Power settings. Values smaller than zero and bigger | 297 | * in the Light-'n-Power settings. Values smaller than zero and bigger |
312 | * than 255 do not make sense. | 298 | * than 255 do not make sense. |
313 | * | 299 | * |
314 | * \sa QSlider::setLineStep | 300 | * \sa QSlider::setLineStep |
315 | * \sa QSlider::setPageStep | 301 | * \sa QSlider::setPageStep |
316 | */ | 302 | */ |
317 | int ODevice::displayBrightnessResolution() const | 303 | int ODevice::displayBrightnessResolution() const |
318 | { | 304 | { |
319 | qDebug( "ODevice::displayBrightnessResolution() - please override me." ); | 305 | qDebug( "ODevice::displayBrightnessResolution() - please override me." ); |
320 | return 16; | 306 | return 16; |
321 | } | 307 | } |
322 | 308 | ||
323 | /** | 309 | /** |
324 | * This sets the display contrast | 310 | * This sets the display contrast |
325 | * @param p The contrast to be set on a scale from 0 to 255 | 311 | * @param p The contrast to be set on a scale from 0 to 255 |
326 | * @returns success or failure | 312 | * @returns success or failure |
327 | */ | 313 | */ |
328 | bool ODevice::setDisplayContrast( int p ) | 314 | bool ODevice::setDisplayContrast( int p ) |
329 | { | 315 | { |
330 | qDebug( "ODevice::setDisplayContrast( %d ) - please override me.", p ); | 316 | qDebug( "ODevice::setDisplayContrast( %d ) - please override me.", p ); |
331 | return false; | 317 | return false; |
332 | } | 318 | } |
333 | 319 | ||
334 | /** | 320 | /** |
335 | * @returns the maximum value for the contrast settings slider | 321 | * @returns the maximum value for the contrast settings slider |
336 | * or 0 if the device doesn't support setting of a contrast | 322 | * or 0 if the device doesn't support setting of a contrast |
337 | */ | 323 | */ |
338 | int ODevice::displayContrastResolution() const | 324 | int ODevice::displayContrastResolution() const |
339 | { | 325 | { |
340 | qDebug( "ODevice::displayBrightnessResolution() - please override me." ); | 326 | qDebug( "ODevice::displayBrightnessResolution() - please override me." ); |
341 | return 0; | 327 | return 0; |
342 | } | 328 | } |
343 | 329 | ||
344 | /** | 330 | /** |
345 | * This returns the vendor as string | 331 | * This returns the vendor as string |
346 | * @return Vendor as QString | 332 | * @return Vendor as QString |
347 | */ | 333 | */ |
348 | QString ODevice::vendorString() const | 334 | QString ODevice::vendorString() const |
349 | { | 335 | { |
350 | return d->m_vendorstr; | 336 | return d->m_vendorstr; |
351 | } | 337 | } |
352 | 338 | ||
353 | /** | 339 | /** |
354 | * This returns the vendor as one of the values of OVendor | 340 | * This returns the vendor as one of the values of OVendor |
355 | * @return OVendor | 341 | * @return OVendor |
356 | */ | 342 | */ |
357 | OVendor ODevice::vendor() const | 343 | OVendor ODevice::vendor() const |
358 | { | 344 | { |
359 | return d->m_vendor; | 345 | return d->m_vendor; |
360 | } | 346 | } |
361 | 347 | ||
362 | /** | 348 | /** |
363 | * This returns the model as a string | 349 | * This returns the model as a string |
364 | * @return A string representing the model | 350 | * @return A string representing the model |
365 | */ | 351 | */ |
366 | QString ODevice::modelString() const | 352 | QString ODevice::modelString() const |
367 | { | 353 | { |
368 | return d->m_modelstr; | 354 | return d->m_modelstr; |
369 | } | 355 | } |
370 | 356 | ||
371 | /** | 357 | /** |
372 | * This does return the OModel used | 358 | * This does return the OModel used |
373 | */ | 359 | */ |
374 | OModel ODevice::model() const | 360 | OModel ODevice::model() const |
375 | { | 361 | { |
376 | return d->m_model; | 362 | return d->m_model; |
377 | } | 363 | } |
378 | 364 | ||
379 | /** | 365 | /** |
380 | * This does return the systen name | 366 | * This does return the systen name |
381 | */ | 367 | */ |
382 | QString ODevice::systemString() const | 368 | QString ODevice::systemString() const |
383 | { | 369 | { |
384 | return d->m_systemstr; | 370 | return d->m_systemstr; |
385 | } | 371 | } |
386 | 372 | ||
387 | /** | 373 | /** |
388 | * Return System as OSystem value | 374 | * Return System as OSystem value |
389 | */ | 375 | */ |
390 | OSystem ODevice::system() const | 376 | OSystem ODevice::system() const |
391 | { | 377 | { |
392 | return d->m_system; | 378 | return d->m_system; |
393 | } | 379 | } |
394 | 380 | ||
395 | /** | 381 | /** |
396 | * @return the version string of the base system | 382 | * @return the version string of the base system |
397 | */ | 383 | */ |
398 | QString ODevice::systemVersionString() const | 384 | QString ODevice::systemVersionString() const |
399 | { | 385 | { |
400 | return d->m_sysverstr; | 386 | return d->m_sysverstr; |
401 | } | 387 | } |
402 | 388 | ||
403 | /** | 389 | /** |
404 | * @return the current Transformation | 390 | * @return the current Transformation |
405 | */ | 391 | */ |
406 | Transformation ODevice::rotation() const | 392 | Transformation ODevice::rotation() const |
407 | { | 393 | { |
408 | return d->m_rotation; | 394 | return d->m_rotation; |
409 | } | 395 | } |
410 | 396 | ||
411 | /** | 397 | /** |
412 | * @return the current rotation direction | 398 | * @return the current rotation direction |
413 | */ | 399 | */ |
414 | ODirection ODevice::direction() const | 400 | ODirection ODevice::direction() const |
415 | { | 401 | { |
416 | return d->m_direction; | 402 | return d->m_direction; |
417 | } | 403 | } |
418 | 404 | ||
419 | /** | 405 | /** |
420 | * This plays an alarm sound | 406 | * This plays an alarm sound |
421 | */ | 407 | */ |
422 | void ODevice::playAlarmSound() | 408 | void ODevice::playAlarmSound() |
423 | { | 409 | { |
424 | #ifndef QT_NO_SOUND | 410 | #ifndef QT_NO_SOUND |
425 | static Sound snd ( "alarm" ); | 411 | static Sound snd ( "alarm" ); |
426 | 412 | ||
427 | if ( snd. isFinished()) | 413 | if ( snd. isFinished()) |
428 | snd. play(); | 414 | snd. play(); |
429 | #endif | 415 | #endif |
430 | } | 416 | } |
431 | 417 | ||
432 | /** | 418 | /** |
433 | * This plays a key sound | 419 | * This plays a key sound |
434 | */ | 420 | */ |
435 | void ODevice::playKeySound() | 421 | void ODevice::playKeySound() |
436 | { | 422 | { |
437 | #ifndef QT_NO_SOUND | 423 | #ifndef QT_NO_SOUND |
438 | static Sound snd ( "keysound" ); | 424 | static Sound snd ( "keysound" ); |
439 | 425 | ||
440 | if ( snd. isFinished()) | 426 | if ( snd. isFinished()) |
441 | snd. play(); | 427 | snd. play(); |
442 | #endif | 428 | #endif |
443 | } | 429 | } |
444 | 430 | ||
445 | /** | 431 | /** |
446 | * This plays a touch sound | 432 | * This plays a touch sound |
447 | */ | 433 | */ |
448 | void ODevice::playTouchSound() | 434 | void ODevice::playTouchSound() |
449 | { | 435 | { |
450 | #ifndef QT_NO_SOUND | 436 | #ifndef QT_NO_SOUND |
451 | static Sound snd ( "touchsound" ); | 437 | static Sound snd ( "touchsound" ); |
452 | 438 | ||
453 | if ( snd. isFinished()) | 439 | if ( snd. isFinished()) |
454 | snd. play(); | 440 | snd. play(); |
455 | #endif | 441 | #endif |
456 | } | 442 | } |
457 | 443 | ||
458 | /** | 444 | /** |
459 | * This method will return a list of leds | 445 | * This method will return a list of leds |
460 | * available on this device | 446 | * available on this device |
461 | * @return a list of LEDs. | 447 | * @return a list of LEDs. |
462 | */ | 448 | */ |
463 | QValueList <OLed> ODevice::ledList() const | 449 | QValueList <OLed> ODevice::ledList() const |
464 | { | 450 | { |
465 | return QValueList <OLed>(); | 451 | return QValueList <OLed>(); |
466 | } | 452 | } |
467 | 453 | ||
468 | /** | 454 | /** |
469 | * This does return the state of the LEDs | 455 | * This does return the state of the LEDs |
470 | */ | 456 | */ |
471 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 457 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
472 | { | 458 | { |
473 | return QValueList <OLedState>(); | 459 | return QValueList <OLedState>(); |
474 | } | 460 | } |
475 | 461 | ||
476 | /** | 462 | /** |
477 | * @return the state for a given OLed | 463 | * @return the state for a given OLed |
478 | */ | 464 | */ |
diff --git a/libopie2/opiecore/device/odevice_abstractmobiledevice.cpp b/libopie2/opiecore/device/odevice_abstractmobiledevice.cpp new file mode 100644 index 0000000..f3f6af5 --- a/dev/null +++ b/libopie2/opiecore/device/odevice_abstractmobiledevice.cpp | |||
@@ -0,0 +1,119 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) 2004, 2005 Holger Hans Peter Freyther <freyther@handhelds.org> | ||
4 | Copyright (C) 2004, 2005 Michael 'mickey' Lauer <mickeyl@handhelds.org> | ||
5 | Copyright (C) 2002, 2003 Robert Griebl <sandman@handhelds.org> | ||
6 | |||
7 | |||
8 | =. | ||
9 | .=l. | ||
10 | .>+-= | ||
11 | _;:, .> :=|. This program is free software; you can | ||
12 | .> <`_, > . <= redistribute it and/or modify it under | ||
13 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
14 | .="- .-=="i, .._ License as published by the Free Software | ||
15 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
16 | ._= =} : or (at your option) any later version. | ||
17 | .%`+i> _;_. | ||
18 | .i_,=:_. -<s. This program is distributed in the hope that | ||
19 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
20 | : .. .:, . . . without even the implied warranty of | ||
21 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
22 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
23 | ..}^=.= = ; Library General Public License for more | ||
24 | ++= -. .` .: details. | ||
25 | : = ...= . :.=- | ||
26 | -. .:....=;==+<; You should have received a copy of the GNU | ||
27 | -_. . . )=. = Library General Public License along with | ||
28 | -- :-=` this library; see the file COPYING.LIB. | ||
29 | If not, write to the Free Software Foundation, | ||
30 | Inc., 59 Temple Place - Suite 330, | ||
31 | Boston, MA 02111-1307, USA. | ||
32 | */ | ||
33 | |||
34 | #include "odevice_abstractmobiledevice.h" | ||
35 | |||
36 | #include <sys/time.h> | ||
37 | #include <sys/ioctl.h> | ||
38 | |||
39 | #include <time.h> | ||
40 | #include <fcntl.h> | ||
41 | #include <unistd.h> | ||
42 | #include <stdlib.h> | ||
43 | |||
44 | namespace Opie { | ||
45 | namespace Core { | ||
46 | OAbstractMobileDevice::OAbstractMobileDevice() | ||
47 | : m_timeOut( 1500 ) | ||
48 | {} | ||
49 | |||
50 | /** | ||
51 | * @short Time to wait for the asynchronos APM implementation to suspend | ||
52 | * | ||
53 | * Milli Seconds to wait before returning from the suspend method. | ||
54 | * This is needed due asynchrnonus implementations of the APM bios. | ||
55 | * | ||
56 | */ | ||
57 | void OAbstractMobileDevice::setAPMTimeOut( int time ) { | ||
58 | m_timeOut = time; | ||
59 | } | ||
60 | |||
61 | |||
62 | bool OAbstractMobileDevice::suspend() { | ||
63 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | ||
64 | return false; | ||
65 | |||
66 | bool res = false; | ||
67 | ODevice::sendSuspendmsg(); | ||
68 | |||
69 | struct timeval tvs, tvn; | ||
70 | ::gettimeofday ( &tvs, 0 ); | ||
71 | |||
72 | ::sync(); // flush fs caches | ||
73 | res = ( ::system ( "apm --suspend" ) == 0 ); | ||
74 | |||
75 | // This is needed because some apm implementations are asynchronous and we | ||
76 | // can not be sure when exactly the device is really suspended | ||
77 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | ||
78 | |||
79 | if ( res ) { | ||
80 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | ||
81 | ::usleep ( 200 * 1000 ); | ||
82 | ::gettimeofday ( &tvn, 0 ); | ||
83 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < m_timeOut ); | ||
84 | } | ||
85 | |||
86 | return res; | ||
87 | } | ||
88 | |||
89 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | ||
90 | |||
91 | // _IO and friends are only defined in kernel headers ... | ||
92 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | ||
93 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | ||
94 | |||
95 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | ||
96 | |||
97 | /* VESA Blanking Levels */ | ||
98 | #define VESA_NO_BLANKING 0 | ||
99 | #define VESA_VSYNC_SUSPEND 1 | ||
100 | #define VESA_HSYNC_SUSPEND 2 | ||
101 | #define VESA_POWERDOWN 3 | ||
102 | |||
103 | bool OAbstractMobileDevice::setDisplayStatus ( bool on ) { | ||
104 | bool res = false; | ||
105 | int fd; | ||
106 | |||
107 | #ifdef QT_QWS_DEVFS | ||
108 | if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { | ||
109 | #else | ||
110 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | ||
111 | #endif | ||
112 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | ||
113 | ::close ( fd ); | ||
114 | } | ||
115 | |||
116 | return res; | ||
117 | } | ||
118 | } | ||
119 | } | ||
diff --git a/libopie2/opiecore/device/odevice_abstractmobiledevice.h b/libopie2/opiecore/device/odevice_abstractmobiledevice.h new file mode 100644 index 0000000..9467e82 --- a/dev/null +++ b/libopie2/opiecore/device/odevice_abstractmobiledevice.h | |||
@@ -0,0 +1,64 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) 2004, 2005 Holger Hans Peter Freyther <freyther@handhelds.org> | ||
4 | Copyright (C) 2004, 2005 Michael 'mickey' Lauer <mickeyl@handhelds.org> | ||
5 | |||
6 | |||
7 | =. | ||
8 | .=l. | ||
9 | .>+-= | ||
10 | _;:, .> :=|. This program is free software; you can | ||
11 | .> <`_, > . <= redistribute it and/or modify it under | ||
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
13 | .="- .-=="i, .._ License as published by the Free Software | ||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
15 | ._= =} : or (at your option) any later version. | ||
16 | .%`+i> _;_. | ||
17 | .i_,=:_. -<s. This program is distributed in the hope that | ||
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
19 | : .. .:, . . . without even the implied warranty of | ||
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
22 | ..}^=.= = ; Library General Public License for more | ||
23 | ++= -. .` .: details. | ||
24 | : = ...= . :.=- | ||
25 | -. .:....=;==+<; You should have received a copy of the GNU | ||
26 | -_. . . )=. = Library General Public License along with | ||
27 | -- :-=` this library; see the file COPYING.LIB. | ||
28 | If not, write to the Free Software Foundation, | ||
29 | Inc., 59 Temple Place - Suite 330, | ||
30 | Boston, MA 02111-1307, USA. | ||
31 | */ | ||
32 | |||
33 | #ifndef OPIE_CORE_DEVICE_ABSTRACT_MOBILE_DEVICE | ||
34 | #define OPIE_CORE_DEVICE_ABSTRACT_MOBILE_DEVICE | ||
35 | |||
36 | #include "odevice.h" | ||
37 | |||
38 | namespace Opie { | ||
39 | namespace Core { | ||
40 | /** | ||
41 | * @short Common Implementations for Linux Handheld Devices | ||
42 | * | ||
43 | * Abstract Class with implementation for suspending using | ||
44 | * asynchrnonus apm implementations and displaystatus using | ||
45 | * the Linux Frame Buffer API | ||
46 | * | ||
47 | */ | ||
48 | class OAbstractMobileDevice : public ODevice { | ||
49 | Q_OBJECT | ||
50 | protected: | ||
51 | OAbstractMobileDevice(); | ||
52 | void setAPMTimeOut( int time ); | ||
53 | public: | ||
54 | virtual bool suspend(); | ||
55 | virtual bool setDisplayStatus(bool); | ||
56 | |||
57 | private: | ||
58 | int m_timeOut; | ||
59 | }; | ||
60 | } | ||
61 | } | ||
62 | |||
63 | |||
64 | #endif | ||
diff --git a/libopie2/opiecore/device/odevice_beagle.h b/libopie2/opiecore/device/odevice_beagle.h index 17b040c..697d689 100644 --- a/libopie2/opiecore/device/odevice_beagle.h +++ b/libopie2/opiecore/device/odevice_beagle.h | |||
@@ -1,61 +1,61 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2004 The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) 2004 The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef OPIE_CORE_DEVICE_BEAGLE_H | 30 | #ifndef OPIE_CORE_DEVICE_BEAGLE_H |
31 | #define OPIE_CORE_DEVICE_BEAGLE_H | 31 | #define OPIE_CORE_DEVICE_BEAGLE_H |
32 | 32 | ||
33 | #include "odevice.h" | 33 | #include "odevice_abstractmobiledevice.h" |
34 | 34 | ||
35 | namespace Opie { | 35 | namespace Opie { |
36 | namespace Core { | 36 | namespace Core { |
37 | namespace Internal { | 37 | namespace Internal { |
38 | class Beagle : public ODevice { | 38 | class Beagle : public OAbstractMobileDevice { |
39 | public: | 39 | public: |
40 | Beagle(); | 40 | Beagle(); |
41 | ~Beagle(); | 41 | ~Beagle(); |
42 | 42 | ||
43 | //@{ | 43 | //@{ |
44 | void init( const QString& init ); | 44 | void init( const QString& init ); |
45 | void initButtons(); | 45 | void initButtons(); |
46 | //@} | 46 | //@} |
47 | 47 | ||
48 | 48 | ||
49 | //@{ | 49 | //@{ |
50 | bool setDisplayStatus( bool on ); | 50 | bool setDisplayStatus( bool on ); |
51 | int displayBrightnessResolution()const; | 51 | int displayBrightnessResolution()const; |
52 | bool setDisplayBrightness( int brightness ); | 52 | bool setDisplayBrightness( int brightness ); |
53 | //@} | 53 | //@} |
54 | 54 | ||
55 | }; | 55 | }; |
56 | } | 56 | } |
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||
60 | 60 | ||
61 | #endif | 61 | #endif |
diff --git a/libopie2/opiecore/device/odevice_ipaq.h b/libopie2/opiecore/device/odevice_ipaq.h index b1dac74..1889467 100644 --- a/libopie2/opiecore/device/odevice_ipaq.h +++ b/libopie2/opiecore/device/odevice_ipaq.h | |||
@@ -1,88 +1,88 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef ODEVICE_IPAQ | 30 | #ifndef ODEVICE_IPAQ |
31 | #define ODEVICE_IPAQ | 31 | #define ODEVICE_IPAQ |
32 | 32 | ||
33 | #include "odevice.h" | 33 | #include "odevice_abstractmobiledevice.h" |
34 | 34 | ||
35 | /* QT */ | 35 | /* QT */ |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | namespace Opie { | 38 | namespace Opie { |
39 | namespace Core { | 39 | namespace Core { |
40 | namespace Internal { | 40 | namespace Internal { |
41 | 41 | ||
42 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter | 42 | class iPAQ : public OAbstractMobileDevice, public QWSServer::KeyboardFilter |
43 | { | 43 | { |
44 | 44 | ||
45 | protected: | 45 | protected: |
46 | virtual void init(const QString&); | 46 | virtual void init(const QString&); |
47 | virtual void initButtons(); | 47 | virtual void initButtons(); |
48 | 48 | ||
49 | public: | 49 | public: |
50 | virtual bool setDisplayBrightness( int b ); | 50 | virtual bool setDisplayBrightness( int b ); |
51 | virtual int displayBrightnessResolution() const; | 51 | virtual int displayBrightnessResolution() const; |
52 | 52 | ||
53 | virtual void playAlarmSound(); | 53 | virtual void playAlarmSound(); |
54 | 54 | ||
55 | virtual QValueList <OLed> ledList() const; | 55 | virtual QValueList <OLed> ledList() const; |
56 | virtual QValueList <OLedState> ledStateList( OLed led ) const; | 56 | virtual QValueList <OLedState> ledStateList( OLed led ) const; |
57 | virtual OLedState ledState( OLed led ) const; | 57 | virtual OLedState ledState( OLed led ) const; |
58 | virtual bool setLedState( OLed led, OLedState st ); | 58 | virtual bool setLedState( OLed led, OLedState st ); |
59 | 59 | ||
60 | virtual bool hasLightSensor() const; | 60 | virtual bool hasLightSensor() const; |
61 | virtual int readLightSensor(); | 61 | virtual int readLightSensor(); |
62 | virtual int lightSensorResolution() const; | 62 | virtual int lightSensorResolution() const; |
63 | 63 | ||
64 | protected: | 64 | protected: |
65 | virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 65 | virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
66 | virtual void timerEvent( QTimerEvent *te ); | 66 | virtual void timerEvent( QTimerEvent *te ); |
67 | 67 | ||
68 | int m_power_timer; | 68 | int m_power_timer; |
69 | 69 | ||
70 | OLedState m_leds [2]; | 70 | OLedState m_leds [2]; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | struct i_button { | 73 | struct i_button { |
74 | uint model; | 74 | uint model; |
75 | Qt::Key code; | 75 | Qt::Key code; |
76 | char *utext; | 76 | char *utext; |
77 | char *pix; | 77 | char *pix; |
78 | char *fpressedservice; | 78 | char *fpressedservice; |
79 | char *fpressedaction; | 79 | char *fpressedaction; |
80 | char *fheldservice; | 80 | char *fheldservice; |
81 | char *fheldaction; | 81 | char *fheldaction; |
82 | }; | 82 | }; |
83 | 83 | ||
84 | } | 84 | } |
85 | } | 85 | } |
86 | } | 86 | } |
87 | 87 | ||
88 | #endif | 88 | #endif |
diff --git a/libopie2/opiecore/device/odevice_jornada.cpp b/libopie2/opiecore/device/odevice_jornada.cpp index 8141f1c..5f95e42 100644 --- a/libopie2/opiecore/device/odevice_jornada.cpp +++ b/libopie2/opiecore/device/odevice_jornada.cpp | |||
@@ -1,204 +1,183 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "odevice_jornada.h" | 30 | #include "odevice_jornada.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | 43 | ||
44 | /* STD */ | 44 | /* STD */ |
45 | #include <fcntl.h> | 45 | #include <fcntl.h> |
46 | #include <math.h> | 46 | #include <math.h> |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> |
48 | #include <signal.h> | 48 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 50 | #include <sys/time.h> |
51 | #include <unistd.h> | 51 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 52 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 53 | #include <linux/soundcard.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | /* KERNEL */ | 56 | /* KERNEL */ |
57 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 57 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
58 | 58 | ||
59 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 59 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
60 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 60 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
61 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 61 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
62 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 62 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
63 | 63 | ||
64 | typedef struct { | 64 | typedef struct { |
65 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 65 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
66 | unsigned char TotalTime; /* Units of 5 seconds */ | 66 | unsigned char TotalTime; /* Units of 5 seconds */ |
67 | unsigned char OnTime; /* units of 100m/s */ | 67 | unsigned char OnTime; /* units of 100m/s */ |
68 | unsigned char OffTime; /* units of 100m/s */ | 68 | unsigned char OffTime; /* units of 100m/s */ |
69 | } LED_IN; | 69 | } LED_IN; |
70 | 70 | ||
71 | typedef struct { | 71 | typedef struct { |
72 | unsigned char mode; | 72 | unsigned char mode; |
73 | unsigned char pwr; | 73 | unsigned char pwr; |
74 | unsigned char brightness; | 74 | unsigned char brightness; |
75 | } FLITE_IN; | 75 | } FLITE_IN; |
76 | 76 | ||
77 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 77 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
78 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 78 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
79 | 79 | ||
80 | using namespace Opie::Core; | 80 | using namespace Opie::Core; |
81 | using namespace Opie::Core::Internal; | 81 | using namespace Opie::Core::Internal; |
82 | 82 | ||
83 | struct j_button jornada56x_buttons [] = { | 83 | struct j_button jornada56x_buttons [] = { |
84 | { Model_Jornada_56x, | 84 | { Model_Jornada_56x, |
85 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 85 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
86 | "devicebuttons/jornada56x_calendar", | 86 | "devicebuttons/jornada56x_calendar", |
87 | "datebook", "nextView()", | 87 | "datebook", "nextView()", |
88 | "today", "raise()" }, | 88 | "today", "raise()" }, |
89 | { Model_Jornada_56x, | 89 | { Model_Jornada_56x, |
90 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 90 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
91 | "devicebuttons/jornada56x_contact", | 91 | "devicebuttons/jornada56x_contact", |
92 | "addressbook", "raise()", | 92 | "addressbook", "raise()", |
93 | "addressbook", "beamBusinessCard()" }, | 93 | "addressbook", "beamBusinessCard()" }, |
94 | { Model_Jornada_56x, | 94 | { Model_Jornada_56x, |
95 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"), | 95 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"), |
96 | "devicebuttons/jornada56x_todo", | 96 | "devicebuttons/jornada56x_todo", |
97 | "todolist", "raise()", | 97 | "todolist", "raise()", |
98 | "todolist", "create()" }, | 98 | "todolist", "create()" }, |
99 | { Model_Jornada_56x, | 99 | { Model_Jornada_56x, |
100 | Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Home Button"), | 100 | Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Home Button"), |
101 | "devicebuttons/jornada56x_home", | 101 | "devicebuttons/jornada56x_home", |
102 | "QPE/Launcher", "home()", | 102 | "QPE/Launcher", "home()", |
103 | "buttonsettings", "raise()" }, | 103 | "buttonsettings", "raise()" }, |
104 | { Model_Jornada_56x, | 104 | { Model_Jornada_56x, |
105 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Record Button"), | 105 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Record Button"), |
106 | "devicebuttons/jornada56x_record", | 106 | "devicebuttons/jornada56x_record", |
107 | "QPE/VMemo", "toggleRecord()", | 107 | "QPE/VMemo", "toggleRecord()", |
108 | "sound", "raise()" }, | 108 | "sound", "raise()" }, |
109 | }; | 109 | }; |
110 | 110 | ||
111 | void Jornada::init(const QString&) | 111 | void Jornada::init(const QString&) |
112 | { | 112 | { |
113 | d->m_vendorstr = "HP"; | 113 | d->m_vendorstr = "HP"; |
114 | d->m_vendor = Vendor_HP; | 114 | d->m_vendor = Vendor_HP; |
115 | d->m_modelstr = "Jornada 56x"; | 115 | d->m_modelstr = "Jornada 56x"; |
116 | d->m_model = Model_Jornada_56x; | 116 | d->m_model = Model_Jornada_56x; |
117 | d->m_rotation = Rot0; | 117 | d->m_rotation = Rot0; |
118 | //Distribution detecting code is now in base class | 118 | //Distribution detecting code is now in base class |
119 | } | 119 | } |
120 | 120 | ||
121 | void Jornada::initButtons() | 121 | void Jornada::initButtons() |
122 | { | 122 | { |
123 | if ( d->m_buttons ) | 123 | if ( d->m_buttons ) |
124 | return; | 124 | return; |
125 | 125 | ||
126 | d->m_buttons = new QValueList <ODeviceButton>; | 126 | d->m_buttons = new QValueList <ODeviceButton>; |
127 | 127 | ||
128 | for ( uint i = 0; i < ( sizeof( jornada56x_buttons ) / sizeof( j_button )); i++ ) { | 128 | for ( uint i = 0; i < ( sizeof( jornada56x_buttons ) / sizeof( j_button )); i++ ) { |
129 | j_button *ib = jornada56x_buttons + i; | 129 | j_button *ib = jornada56x_buttons + i; |
130 | ODeviceButton b; | 130 | ODeviceButton b; |
131 | 131 | ||
132 | if (( ib->model & d->m_model ) == d->m_model ) { | 132 | if (( ib->model & d->m_model ) == d->m_model ) { |
133 | b. setKeycode ( ib->code ); | 133 | b. setKeycode ( ib->code ); |
134 | b. setUserText ( QObject::tr ( "Button", ib->utext )); | 134 | b. setUserText ( QObject::tr ( "Button", ib->utext )); |
135 | b. setPixmap ( Resource::loadPixmap ( ib->pix )); | 135 | b. setPixmap ( Resource::loadPixmap ( ib->pix )); |
136 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); | 136 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); |
137 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); | 137 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); |
138 | 138 | ||
139 | d->m_buttons->append ( b ); | 139 | d->m_buttons->append ( b ); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | reloadButtonMapping(); | 142 | reloadButtonMapping(); |
143 | } | 143 | } |
144 | 144 | ||
145 | int Jornada::displayBrightnessResolution() const | 145 | int Jornada::displayBrightnessResolution() const |
146 | { | 146 | { |
147 | return 255; | 147 | return 255; |
148 | } | 148 | } |
149 | 149 | ||
150 | 150 | ||
151 | bool Jornada::setDisplayBrightness( int bright ) | 151 | bool Jornada::setDisplayBrightness( int bright ) |
152 | { | 152 | { |
153 | bool res = false; | 153 | bool res = false; |
154 | 154 | ||
155 | if ( bright > 255 ) | 155 | if ( bright > 255 ) |
156 | bright = 255; | 156 | bright = 255; |
157 | if ( bright < 0 ) | 157 | if ( bright < 0 ) |
158 | bright = 0; | 158 | bright = 0; |
159 | 159 | ||
160 | QString cmdline; | 160 | QString cmdline; |
161 | 161 | ||
162 | if ( !bright ) | 162 | if ( !bright ) |
163 | cmdline = QString().sprintf( "echo 4 > /sys/class/backlight/sa1100fb/power"); | 163 | cmdline = QString().sprintf( "echo 4 > /sys/class/backlight/sa1100fb/power"); |
164 | else | 164 | else |
165 | cmdline = QString().sprintf( "echo 0 > /sys/class/backlight/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/brightness", bright ); | 165 | cmdline = QString().sprintf( "echo 0 > /sys/class/backlight/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/brightness", bright ); |
166 | 166 | ||
167 | res = ( ::system( (const char*) cmdline ) == 0 ); | 167 | res = ( ::system( (const char*) cmdline ) == 0 ); |
168 | 168 | ||
169 | return res; | 169 | return res; |
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | bool Jornada::suspend( ) | ||
174 | { | ||
175 | qDebug("ODevice::suspend"); | ||
176 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | ||
177 | return false; | ||
178 | |||
179 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | ||
180 | return false; | ||
181 | |||
182 | bool res = false; | ||
183 | ODevice::sendSuspendmsg(); | ||
184 | |||
185 | struct timeval tvs; | ||
186 | ::gettimeofday ( &tvs, 0 ); | ||
187 | |||
188 | ::sync(); // flush fs caches | ||
189 | res = ( ::system ( "apm --suspend" ) == 0 ); | ||
190 | |||
191 | return res; | ||
192 | } | ||
193 | |||
194 | bool Jornada::setDisplayStatus ( bool on ) | 173 | bool Jornada::setDisplayStatus ( bool on ) |
195 | { | 174 | { |
196 | bool res = false; | 175 | bool res = false; |
197 | 176 | ||
198 | QString cmdline = QString( "echo %1 > /sys/class/lcd/sa1100fb/power; echo %2 > /sys/class/backlight/sa1100fb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); | 177 | QString cmdline = QString( "echo %1 > /sys/class/lcd/sa1100fb/power; echo %2 > /sys/class/backlight/sa1100fb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); |
199 | 178 | ||
200 | res = ( ::system( (const char*) cmdline ) == 0 ); | 179 | res = ( ::system( (const char*) cmdline ) == 0 ); |
201 | 180 | ||
202 | return res; | 181 | return res; |
203 | } | 182 | } |
204 | 183 | ||
diff --git a/libopie2/opiecore/device/odevice_jornada.h b/libopie2/opiecore/device/odevice_jornada.h index b17fa8b..480efff 100644 --- a/libopie2/opiecore/device/odevice_jornada.h +++ b/libopie2/opiecore/device/odevice_jornada.h | |||
@@ -1,67 +1,66 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef ODEVICE_JORNADA | 30 | #ifndef ODEVICE_JORNADA |
31 | #define ODEVICE_JORNADA | 31 | #define ODEVICE_JORNADA |
32 | 32 | ||
33 | #include <opie2/odevice.h> | 33 | #include "odevice_abstractmobiledevice.h" |
34 | 34 | ||
35 | namespace Opie { | 35 | namespace Opie { |
36 | namespace Core { | 36 | namespace Core { |
37 | namespace Internal { | 37 | namespace Internal { |
38 | class Jornada : public ODevice | 38 | class Jornada : public OAbstractMobileDevice |
39 | { | 39 | { |
40 | 40 | ||
41 | protected: | 41 | protected: |
42 | virtual void init(const QString&); | 42 | virtual void init(const QString&); |
43 | virtual void initButtons(); | 43 | virtual void initButtons(); |
44 | 44 | ||
45 | public: | 45 | public: |
46 | virtual bool suspend ( ); | ||
47 | virtual bool setDisplayBrightness ( int b ); | 46 | virtual bool setDisplayBrightness ( int b ); |
48 | virtual bool setDisplayStatus ( bool on); | 47 | virtual bool setDisplayStatus ( bool on); |
49 | virtual int displayBrightnessResolution() const; | 48 | virtual int displayBrightnessResolution() const; |
50 | }; | 49 | }; |
51 | 50 | ||
52 | struct j_button { | 51 | struct j_button { |
53 | uint model; | 52 | uint model; |
54 | Qt::Key code; | 53 | Qt::Key code; |
55 | char *utext; | 54 | char *utext; |
56 | char *pix; | 55 | char *pix; |
57 | char *fpressedservice; | 56 | char *fpressedservice; |
58 | char *fpressedaction; | 57 | char *fpressedaction; |
59 | char *fheldservice; | 58 | char *fheldservice; |
60 | char *fheldaction; | 59 | char *fheldaction; |
61 | }; | 60 | }; |
62 | 61 | ||
63 | } | 62 | } |
64 | } | 63 | } |
65 | } | 64 | } |
66 | #endif | 65 | #endif |
67 | 66 | ||
diff --git a/libopie2/opiecore/device/odevice_ramses.h b/libopie2/opiecore/device/odevice_ramses.h index bbd3862..50963dc 100644 --- a/libopie2/opiecore/device/odevice_ramses.h +++ b/libopie2/opiecore/device/odevice_ramses.h | |||
@@ -1,69 +1,69 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef ODEVICE_RAMSES | 30 | #ifndef ODEVICE_RAMSES |
31 | #define ODEVICE_RAMSES | 31 | #define ODEVICE_RAMSES |
32 | 32 | ||
33 | #include <opie2/odevice.h> | 33 | #include "odevice_abstractmobiledevice.h" |
34 | /* QT */ | 34 | /* QT */ |
35 | #include <qwindowsystem_qws.h> | 35 | #include <qwindowsystem_qws.h> |
36 | 36 | ||
37 | 37 | ||
38 | #ifndef OD_IOC | 38 | #ifndef OD_IOC |
39 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 39 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
40 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 40 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
41 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 41 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
42 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 42 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
43 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 43 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | 46 | ||
47 | 47 | ||
48 | namespace Opie { | 48 | namespace Opie { |
49 | namespace Core { | 49 | namespace Core { |
50 | namespace Internal { | 50 | namespace Internal { |
51 | 51 | ||
52 | class Ramses : public ODevice | 52 | class Ramses : public ODevice |
53 | { | 53 | { |
54 | protected: | 54 | protected: |
55 | virtual void init(const QString&); | 55 | virtual void init(const QString&); |
56 | 56 | ||
57 | public: | 57 | public: |
58 | virtual bool suspend(); | 58 | virtual bool suspend(); |
59 | 59 | ||
60 | virtual bool setDisplayBrightness( int b ); | 60 | virtual bool setDisplayBrightness( int b ); |
61 | virtual int displayBrightnessResolution() const; | 61 | virtual int displayBrightnessResolution() const; |
62 | virtual void playAlarmSound(); | 62 | virtual void playAlarmSound(); |
63 | }; | 63 | }; |
64 | 64 | ||
65 | } | 65 | } |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | #endif | 69 | #endif |
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp index d6c2c80..550da5e 100644 --- a/libopie2/opiecore/device/odevice_simpad.cpp +++ b/libopie2/opiecore/device/odevice_simpad.cpp | |||
@@ -143,258 +143,258 @@ void SIMpad::init(const QString&) | |||
143 | switch ( d->m_model ) { | 143 | switch ( d->m_model ) { |
144 | default: | 144 | default: |
145 | d->m_rotation = Rot0; | 145 | d->m_rotation = Rot0; |
146 | d->m_direction = CCW; | 146 | d->m_direction = CCW; |
147 | d->m_holdtime = 1000; // 1000ms | 147 | d->m_holdtime = 1000; // 1000ms |
148 | 148 | ||
149 | break; | 149 | break; |
150 | } | 150 | } |
151 | 151 | ||
152 | //Distribution detecting code is now in base class | 152 | //Distribution detecting code is now in base class |
153 | m_leds [0] = m_leds [1] = Led_Off; | 153 | m_leds [0] = m_leds [1] = Led_Off; |
154 | 154 | ||
155 | m_power_timer = 0; | 155 | m_power_timer = 0; |
156 | 156 | ||
157 | } | 157 | } |
158 | 158 | ||
159 | void SIMpad::initButtons() | 159 | void SIMpad::initButtons() |
160 | { | 160 | { |
161 | if ( d->m_buttons ) | 161 | if ( d->m_buttons ) |
162 | return; | 162 | return; |
163 | 163 | ||
164 | d->m_buttons = new QValueList <ODeviceButton>; | 164 | d->m_buttons = new QValueList <ODeviceButton>; |
165 | 165 | ||
166 | uint size = sizeof(simpad_buttons)/sizeof(s_button); | 166 | uint size = sizeof(simpad_buttons)/sizeof(s_button); |
167 | for ( uint i = 0; i < size; i++ ) { | 167 | for ( uint i = 0; i < size; i++ ) { |
168 | s_button *sb = simpad_buttons + i; | 168 | s_button *sb = simpad_buttons + i; |
169 | ODeviceButton b; | 169 | ODeviceButton b; |
170 | 170 | ||
171 | if (( sb->model & d->m_model ) == d->m_model ) { | 171 | if (( sb->model & d->m_model ) == d->m_model ) { |
172 | b. setKeycode ( sb->code ); | 172 | b. setKeycode ( sb->code ); |
173 | b. setUserText ( QObject::tr ( "Button", sb->utext )); | 173 | b. setUserText ( QObject::tr ( "Button", sb->utext )); |
174 | b. setPixmap ( Resource::loadPixmap ( sb->pix )); | 174 | b. setPixmap ( Resource::loadPixmap ( sb->pix )); |
175 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); | 175 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); |
176 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); | 176 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); |
177 | 177 | ||
178 | d->m_buttons->append ( b ); | 178 | d->m_buttons->append ( b ); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | reloadButtonMapping(); | 181 | reloadButtonMapping(); |
182 | } | 182 | } |
183 | 183 | ||
184 | // SIMpad boardcontrol register CS3 | 184 | // SIMpad boardcontrol register CS3 |
185 | #define SIMPAD_BOARDCONTROL "/proc/cs3" | 185 | #define SIMPAD_BOARDCONTROL "/proc/cs3" |
186 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA | 186 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA |
187 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA | 187 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA |
188 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's | 188 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's |
189 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V | 189 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V |
190 | #define SIMPAD_DISPLAY_ON 0x0010 | 190 | #define SIMPAD_DISPLAY_ON 0x0010 |
191 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 | 191 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 |
192 | #define SIMPAD_MQ_RESET 0x0040 | 192 | #define SIMPAD_MQ_RESET 0x0040 |
193 | #define SIMPAD_PCMCIA_RESET 0x0080 | 193 | #define SIMPAD_PCMCIA_RESET 0x0080 |
194 | #define SIMPAD_DECT_POWER_ON 0x0100 | 194 | #define SIMPAD_DECT_POWER_ON 0x0100 |
195 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave | 195 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave |
196 | #define SIMPAD_RS232_ON 0x0400 | 196 | #define SIMPAD_RS232_ON 0x0400 |
197 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave | 197 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave |
198 | #define SIMPAD_LED2_ON 0x1000 | 198 | #define SIMPAD_LED2_ON 0x1000 |
199 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode | 199 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode |
200 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit | 200 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit |
201 | #define SIMPAD_RESET_SIMCARD 0x8000 | 201 | #define SIMPAD_RESET_SIMCARD 0x8000 |
202 | 202 | ||
203 | //SIMpad touchscreen backlight strength control | 203 | //SIMpad touchscreen backlight strength control |
204 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/backlight" | 204 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/backlight" |
205 | 205 | ||
206 | 206 | ||
207 | /* | 207 | /* |
208 | * The SIMpad exposes ChipSelect3 to userspace | 208 | * The SIMpad exposes ChipSelect3 to userspace |
209 | * via a proc filesystem file. Using this register | 209 | * via a proc filesystem file. Using this register |
210 | * one can toggle power of serial, irda, dect circuits | 210 | * one can toggle power of serial, irda, dect circuits |
211 | * change the video driver and display status and | 211 | * change the video driver and display status and |
212 | * many more things. | 212 | * many more things. |
213 | * To not lose the current setting we read the current | 213 | * To not lose the current setting we read the current |
214 | * cs3 setting and toggle the necessary bits and then | 214 | * cs3 setting and toggle the necessary bits and then |
215 | * write it. | 215 | * write it. |
216 | */ | 216 | */ |
217 | static bool setCS3Bit( bool bitset, int bit ) { | 217 | static bool setCS3Bit( bool bitset, int bit ) { |
218 | QFile file( SIMPAD_BOARDCONTROL ); | 218 | QFile file( SIMPAD_BOARDCONTROL ); |
219 | if ( !file.open( IO_ReadOnly ) ) | 219 | if ( !file.open( IO_ReadOnly ) ) |
220 | return false; | 220 | return false; |
221 | 221 | ||
222 | unsigned int val = 0; | 222 | unsigned int val = 0; |
223 | bool ok = false; | 223 | bool ok = false; |
224 | QTextStream stream( &file ); | 224 | QTextStream stream( &file ); |
225 | 225 | ||
226 | /* | 226 | /* |
227 | * Use QFile and QTextStream for parsing to be more | 227 | * Use QFile and QTextStream for parsing to be more |
228 | * robust | 228 | * robust |
229 | */ | 229 | */ |
230 | while ( !stream.atEnd() ) { | 230 | while ( !stream.atEnd() ) { |
231 | QString line = stream.readLine(); | 231 | QString line = stream.readLine(); |
232 | if ( line.startsWith( "Chipselect3 : " ) ) { | 232 | if ( line.startsWith( "Chipselect3 : " ) ) { |
233 | val = line.mid( 14 ).toUInt( 0, 16 ); | 233 | val = line.mid( 14 ).toUInt( 0, 16 ); |
234 | ok = true; | 234 | ok = true; |
235 | break; | 235 | break; |
236 | } | 236 | } |
237 | } | 237 | } |
238 | 238 | ||
239 | if ( !ok ) | 239 | if ( !ok ) |
240 | return false; | 240 | return false; |
241 | 241 | ||
242 | file.close(); | 242 | file.close(); |
243 | 243 | ||
244 | /* | 244 | /* |
245 | * change the value | 245 | * change the value |
246 | */ | 246 | */ |
247 | val = bitset ? (val | bit) : (val & ~bit); | 247 | val = bitset ? (val | bit) : (val & ~bit); |
248 | 248 | ||
249 | /* | 249 | /* |
250 | * write it back | 250 | * write it back |
251 | */ | 251 | */ |
252 | int cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_WRONLY ); | 252 | int cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_WRONLY ); |
253 | if ( cs3_fd < 0 ) | 253 | if ( cs3_fd < 0 ) |
254 | return false; | 254 | return false; |
255 | 255 | ||
256 | char line[32]; | 256 | char line[32]; |
257 | ::snprintf(line, sizeof(line), "0x%04x\n", val); | 257 | ::snprintf(line, sizeof(line), "0x%04x\n", val); |
258 | ::write(cs3_fd, line, strlen(line)); | 258 | ::write(cs3_fd, line, strlen(line)); |
259 | ::close(cs3_fd); | 259 | ::close(cs3_fd); |
260 | 260 | ||
261 | return true; | 261 | return true; |
262 | } | 262 | } |
263 | 263 | ||
264 | 264 | ||
265 | QValueList <OLed> SIMpad::ledList() const | 265 | QValueList <OLed> SIMpad::ledList() const |
266 | { | 266 | { |
267 | QValueList <OLed> vl; | 267 | QValueList <OLed> vl; |
268 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? | 268 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? |
269 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway | 269 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway |
270 | return vl; | 270 | return vl; |
271 | } | 271 | } |
272 | 272 | ||
273 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const | 273 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const |
274 | { | 274 | { |
275 | QValueList <OLedState> vl; | 275 | QValueList <OLedState> vl; |
276 | 276 | ||
277 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? | 277 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? |
278 | vl << Led_Off << Led_On; | 278 | vl << Led_Off << Led_On; |
279 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway | 279 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway |
280 | //vl << Led_Off; | 280 | //vl << Led_Off; |
281 | return vl; | 281 | return vl; |
282 | } | 282 | } |
283 | 283 | ||
284 | OLedState SIMpad::ledState ( OLed l ) const | 284 | OLedState SIMpad::ledState ( OLed l ) const |
285 | { | 285 | { |
286 | switch ( l ) { | 286 | switch ( l ) { |
287 | case Led_Power: | 287 | case Led_Power: |
288 | return m_leds [0]; | 288 | return m_leds [0]; |
289 | //case Led_Mail: | 289 | //case Led_Mail: |
290 | // return m_leds [1]; | 290 | // return m_leds [1]; |
291 | default: | 291 | default: |
292 | return Led_Off; | 292 | return Led_Off; |
293 | } | 293 | } |
294 | } | 294 | } |
295 | 295 | ||
296 | bool SIMpad::setLedState ( OLed l, OLedState st ) | 296 | bool SIMpad::setLedState ( OLed l, OLedState st ) |
297 | { | 297 | { |
298 | if ( l == Led_Power ) { | 298 | if ( l == Led_Power ) { |
299 | m_leds [0] = st; | 299 | m_leds [0] = st; |
300 | setCS3Bit(st == Led_On, SIMPAD_LED2_ON); | 300 | setCS3Bit(st == Led_On, SIMPAD_LED2_ON); |
301 | return true; | 301 | return true; |
302 | } | 302 | } |
303 | 303 | ||
304 | return false; | 304 | return false; |
305 | } | 305 | } |
306 | 306 | ||
307 | void SIMpad::timerEvent ( QTimerEvent * ) | 307 | void SIMpad::timerEvent ( QTimerEvent * ) |
308 | { | 308 | { |
309 | killTimer ( m_power_timer ); | 309 | killTimer ( m_power_timer ); |
310 | m_power_timer = 0; | 310 | m_power_timer = 0; |
311 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 311 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
312 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 312 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
313 | } | 313 | } |
314 | 314 | ||
315 | 315 | ||
316 | void SIMpad::playAlarmSound() | 316 | void SIMpad::playAlarmSound() |
317 | { | 317 | { |
318 | #ifndef QT_NO_SOUND | 318 | #ifndef QT_NO_SOUND |
319 | static Sound snd ( "alarm" ); | 319 | static Sound snd ( "alarm" ); |
320 | if(!snd.isFinished()) | 320 | if(!snd.isFinished()) |
321 | return; | 321 | return; |
322 | 322 | ||
323 | /* save as the Sound is static! */ | 323 | /* save as the Sound is static! */ |
324 | changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); | 324 | changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); |
325 | snd. play(); | 325 | snd. play(); |
326 | #endif | 326 | #endif |
327 | } | 327 | } |
328 | 328 | ||
329 | 329 | ||
330 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm | 330 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm |
331 | { | 331 | { |
332 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 332 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
333 | return false; | 333 | return false; |
334 | 334 | ||
335 | bool res = ODevice::suspend(); | 335 | bool res = OAbstractMobileDevice::suspend(); |
336 | 336 | ||
337 | /* | 337 | /* |
338 | * restore the screen content if we really | 338 | * restore the screen content if we really |
339 | * supended the device | 339 | * supended the device |
340 | */ | 340 | */ |
341 | if ( res ) | 341 | if ( res ) |
342 | updateAllWidgets(); | 342 | updateAllWidgets(); |
343 | 343 | ||
344 | return res; | 344 | return res; |
345 | } | 345 | } |
346 | 346 | ||
347 | bool SIMpad::setDisplayStatus ( bool on ) | 347 | bool SIMpad::setDisplayStatus ( bool on ) |
348 | { | 348 | { |
349 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 349 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
350 | 350 | ||
351 | return setCS3Bit(on, SIMPAD_DISPLAY_ON); | 351 | return setCS3Bit(on, SIMPAD_DISPLAY_ON); |
352 | } | 352 | } |
353 | 353 | ||
354 | 354 | ||
355 | bool SIMpad::setDisplayBrightness ( int bright ) | 355 | bool SIMpad::setDisplayBrightness ( int bright ) |
356 | { | 356 | { |
357 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); | 357 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); |
358 | bool res = false; | 358 | bool res = false; |
359 | int fd; | 359 | int fd; |
360 | 360 | ||
361 | if ( bright > 255 ) | 361 | if ( bright > 255 ) |
362 | bright = 255; | 362 | bright = 255; |
363 | if ( bright < 1 ) | 363 | if ( bright < 1 ) |
364 | bright = 0; | 364 | bright = 0; |
365 | 365 | ||
366 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 366 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
367 | QCString str = QFile::encodeName( QString::number(bright)); | 367 | QCString str = QFile::encodeName( QString::number(bright)); |
368 | res = ( ::write(fd, str, str.length()) != -1 ); | 368 | res = ( ::write(fd, str, str.length()) != -1 ); |
369 | ::close ( fd ); | 369 | ::close ( fd ); |
370 | } | 370 | } |
371 | return res; | 371 | return res; |
372 | } | 372 | } |
373 | 373 | ||
374 | 374 | ||
375 | int SIMpad::displayBrightnessResolution() const | 375 | int SIMpad::displayBrightnessResolution() const |
376 | { | 376 | { |
377 | return 255; // All SIMpad models share the same display | 377 | return 255; // All SIMpad models share the same display |
378 | } | 378 | } |
379 | 379 | ||
380 | 380 | ||
381 | /* | 381 | /* |
382 | * The MQ200 DRAM content is lost during suspend | 382 | * The MQ200 DRAM content is lost during suspend |
383 | * so we will just repaint every widget on resume | 383 | * so we will just repaint every widget on resume |
384 | */ | 384 | */ |
385 | void SIMpad::updateAllWidgets() { | 385 | void SIMpad::updateAllWidgets() { |
386 | QWidgetList *list = QApplication::allWidgets(); | 386 | QWidgetList *list = QApplication::allWidgets(); |
387 | QWidgetListIt it( *list ); | 387 | QWidgetListIt it( *list ); |
388 | QWidget *wid; | 388 | QWidget *wid; |
389 | 389 | ||
390 | while ((wid=it.current()) != 0 ) { | 390 | while ((wid=it.current()) != 0 ) { |
391 | wid->update(); | 391 | wid->update(); |
392 | ++it; | 392 | ++it; |
393 | } | 393 | } |
394 | 394 | ||
395 | delete list; | 395 | delete list; |
396 | } | 396 | } |
397 | 397 | ||
398 | } | 398 | } |
399 | } | 399 | } |
400 | } | 400 | } |
diff --git a/libopie2/opiecore/device/odevice_simpad.h b/libopie2/opiecore/device/odevice_simpad.h index 41b94d1..1276603 100644 --- a/libopie2/opiecore/device/odevice_simpad.h +++ b/libopie2/opiecore/device/odevice_simpad.h | |||
@@ -1,75 +1,75 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003, 2004 The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) 2003, 2004 The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef ODEVICE_SIMPAD | 30 | #ifndef ODEVICE_SIMPAD |
31 | #define ODEVICE_SIMPAD | 31 | #define ODEVICE_SIMPAD |
32 | 32 | ||
33 | #include <opie2/odevice.h> | 33 | #include "odevice_abstractmobiledevice.h" |
34 | 34 | ||
35 | /* QT */ | 35 | /* QT */ |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | namespace Opie { | 38 | namespace Opie { |
39 | namespace Core { | 39 | namespace Core { |
40 | namespace Internal { | 40 | namespace Internal { |
41 | 41 | ||
42 | class SIMpad : public ODevice | 42 | class SIMpad : public OAbstractMobileDevice |
43 | { | 43 | { |
44 | protected: | 44 | protected: |
45 | virtual void init(const QString&); | 45 | virtual void init(const QString&); |
46 | virtual void initButtons(); | 46 | virtual void initButtons(); |
47 | 47 | ||
48 | public: | 48 | public: |
49 | virtual bool suspend(); | 49 | virtual bool suspend(); |
50 | 50 | ||
51 | virtual bool setDisplayStatus( bool on ); | 51 | virtual bool setDisplayStatus( bool on ); |
52 | virtual bool setDisplayBrightness( int b ); | 52 | virtual bool setDisplayBrightness( int b ); |
53 | virtual int displayBrightnessResolution() const; | 53 | virtual int displayBrightnessResolution() const; |
54 | 54 | ||
55 | virtual void playAlarmSound(); | 55 | virtual void playAlarmSound(); |
56 | 56 | ||
57 | virtual QValueList <OLed> ledList() const; | 57 | virtual QValueList <OLed> ledList() const; |
58 | virtual QValueList <OLedState> ledStateList( OLed led ) const; | 58 | virtual QValueList <OLedState> ledStateList( OLed led ) const; |
59 | virtual OLedState ledState( OLed led ) const; | 59 | virtual OLedState ledState( OLed led ) const; |
60 | virtual bool setLedState( OLed led, OLedState st ); | 60 | virtual bool setLedState( OLed led, OLedState st ); |
61 | 61 | ||
62 | protected: | 62 | protected: |
63 | virtual void timerEvent( QTimerEvent *te ); | 63 | virtual void timerEvent( QTimerEvent *te ); |
64 | 64 | ||
65 | int m_power_timer; | 65 | int m_power_timer; |
66 | 66 | ||
67 | OLedState m_leds [2]; | 67 | OLedState m_leds [2]; |
68 | private: | 68 | private: |
69 | static void updateAllWidgets(); | 69 | static void updateAllWidgets(); |
70 | }; | 70 | }; |
71 | } | 71 | } |
72 | } | 72 | } |
73 | } | 73 | } |
74 | 74 | ||
75 | #endif | 75 | #endif |
diff --git a/libopie2/opiecore/device/odevice_yopy.h b/libopie2/opiecore/device/odevice_yopy.h index f6bf061..02a19c9 100644 --- a/libopie2/opiecore/device/odevice_yopy.h +++ b/libopie2/opiecore/device/odevice_yopy.h | |||
@@ -1,67 +1,67 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef ODEVICE_YOPY | 30 | #ifndef ODEVICE_YOPY |
31 | #define ODEVICE_YOPY | 31 | #define ODEVICE_YOPY |
32 | 32 | ||
33 | #include <opie2/odevice.h> | 33 | #include "odevice_abstractmobiledevice.h" |
34 | 34 | ||
35 | namespace Opie { | 35 | namespace Opie { |
36 | namespace Core { | 36 | namespace Core { |
37 | namespace Internal { | 37 | namespace Internal { |
38 | class Yopy : public ODevice | 38 | class Yopy : public OAbstractMobileDevice |
39 | { | 39 | { |
40 | protected: | 40 | protected: |
41 | 41 | ||
42 | virtual void init(const QString&); | 42 | virtual void init(const QString&); |
43 | virtual void initButtons(); | 43 | virtual void initButtons(); |
44 | 44 | ||
45 | public: | 45 | public: |
46 | virtual bool suspend(); | 46 | virtual bool suspend(); |
47 | 47 | ||
48 | virtual bool setDisplayBrightness ( int b ); | 48 | virtual bool setDisplayBrightness ( int b ); |
49 | virtual int displayBrightnessResolution() const; | 49 | virtual int displayBrightnessResolution() const; |
50 | }; | 50 | }; |
51 | 51 | ||
52 | struct yopy_button | 52 | struct yopy_button |
53 | { | 53 | { |
54 | Qt::Key code; | 54 | Qt::Key code; |
55 | char *utext; | 55 | char *utext; |
56 | char *pix; | 56 | char *pix; |
57 | char *fpressedservice; | 57 | char *fpressedservice; |
58 | char *fpressedaction; | 58 | char *fpressedaction; |
59 | char *fheldservice; | 59 | char *fheldservice; |
60 | char *fheldaction; | 60 | char *fheldaction; |
61 | }; | 61 | }; |
62 | 62 | ||
63 | } | 63 | } |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | #endif | 67 | #endif |
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index 82e127e..67dfa41 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -1,621 +1,593 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 4 | =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "odevice_zaurus.h" | 30 | #include "odevice_zaurus.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <opie2/oinputsystem.h> | 39 | #include <opie2/oinputsystem.h> |
40 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | #include <qpe/sound.h> | 42 | #include <qpe/sound.h> |
43 | #include <qpe/qcopenvelope_qws.h> | 43 | #include <qpe/qcopenvelope_qws.h> |
44 | 44 | ||
45 | /* STD */ | 45 | /* STD */ |
46 | #include <fcntl.h> | 46 | #include <fcntl.h> |
47 | #include <math.h> | 47 | #include <math.h> |
48 | #include <stdlib.h> | 48 | #include <stdlib.h> |
49 | #include <signal.h> | 49 | #include <signal.h> |
50 | #include <sys/ioctl.h> | 50 | #include <sys/ioctl.h> |
51 | #include <sys/time.h> | 51 | #include <sys/time.h> |
52 | #include <unistd.h> | 52 | #include <unistd.h> |
53 | #ifndef QT_NO_SOUND | 53 | #ifndef QT_NO_SOUND |
54 | #include <linux/soundcard.h> | 54 | #include <linux/soundcard.h> |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | using namespace Opie::Core; | 57 | using namespace Opie::Core; |
58 | using namespace Opie::Core::Internal; | 58 | using namespace Opie::Core::Internal; |
59 | 59 | ||
60 | struct z_button z_buttons [] = { | 60 | struct z_button z_buttons [] = { |
61 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 61 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
62 | "devicebuttons/z_calendar", | 62 | "devicebuttons/z_calendar", |
63 | "datebook", "nextView()", | 63 | "datebook", "nextView()", |
64 | "today", "raise()" }, | 64 | "today", "raise()" }, |
65 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 65 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
66 | "devicebuttons/z_contact", | 66 | "devicebuttons/z_contact", |
67 | "addressbook", "raise()", | 67 | "addressbook", "raise()", |
68 | "addressbook", "beamBusinessCard()" }, | 68 | "addressbook", "beamBusinessCard()" }, |
69 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 69 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
70 | "devicebuttons/z_home", | 70 | "devicebuttons/z_home", |
71 | "QPE/Launcher", "home()", | 71 | "QPE/Launcher", "home()", |
72 | "buttonsettings", "raise()" }, | 72 | "buttonsettings", "raise()" }, |
73 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 73 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
74 | "devicebuttons/z_menu", | 74 | "devicebuttons/z_menu", |
75 | "QPE/TaskBar", "toggleMenu()", | 75 | "QPE/TaskBar", "toggleMenu()", |
76 | "QPE/TaskBar", "toggleStartMenu()" }, | 76 | "QPE/TaskBar", "toggleStartMenu()" }, |
77 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 77 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
78 | "devicebuttons/z_mail", | 78 | "devicebuttons/z_mail", |
79 | "opiemail", "raise()", | 79 | "opiemail", "raise()", |
80 | "opiemail", "newMail()" }, | 80 | "opiemail", "newMail()" }, |
81 | }; | 81 | }; |
82 | 82 | ||
83 | struct z_button z_buttons_c700 [] = { | 83 | struct z_button z_buttons_c700 [] = { |
84 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 84 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
85 | "devicebuttons/z_calendar", | 85 | "devicebuttons/z_calendar", |
86 | "datebook", "nextView()", | 86 | "datebook", "nextView()", |
87 | "today", "raise()" }, | 87 | "today", "raise()" }, |
88 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 88 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
89 | "devicebuttons/z_contact", | 89 | "devicebuttons/z_contact", |
90 | "addressbook", "raise()", | 90 | "addressbook", "raise()", |
91 | "addressbook", "beamBusinessCard()" }, | 91 | "addressbook", "beamBusinessCard()" }, |
92 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 92 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
93 | "devicebuttons/z_home", | 93 | "devicebuttons/z_home", |
94 | "QPE/Launcher", "home()", | 94 | "QPE/Launcher", "home()", |
95 | "buttonsettings", "raise()" }, | 95 | "buttonsettings", "raise()" }, |
96 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 96 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
97 | "devicebuttons/z_menu", | 97 | "devicebuttons/z_menu", |
98 | "QPE/TaskBar", "toggleMenu()", | 98 | "QPE/TaskBar", "toggleMenu()", |
99 | "QPE/TaskBar", "toggleStartMenu()" }, | 99 | "QPE/TaskBar", "toggleStartMenu()" }, |
100 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 100 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
101 | "devicebuttons/z_mail", | 101 | "devicebuttons/z_mail", |
102 | "opiemail", "raise()", | 102 | "opiemail", "raise()", |
103 | "opiemail", "newMail()" }, | 103 | "opiemail", "newMail()" }, |
104 | 104 | ||
105 | { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"), | 105 | { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"), |
106 | "devicebuttons/z_hinge1", | 106 | "devicebuttons/z_hinge1", |
107 | "QPE/Rotation", "rotateDefault()", | 107 | "QPE/Rotation", "rotateDefault()", |
108 | "QPE/Rotation", "rotateDefault()" }, | 108 | "QPE/Rotation", "rotateDefault()" }, |
109 | { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), | 109 | { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), |
110 | "devicebuttons/z_hinge2", | 110 | "devicebuttons/z_hinge2", |
111 | "QPE/Rotation", "rotateDefault()", | 111 | "QPE/Rotation", "rotateDefault()", |
112 | "QPE/Rotation", "rotateDefault()" }, | 112 | "QPE/Rotation", "rotateDefault()" }, |
113 | { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), | 113 | { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), |
114 | "devicebuttons/z_hinge3", | 114 | "devicebuttons/z_hinge3", |
115 | "QPE/Rotation", "rotateDefault()", | 115 | "QPE/Rotation", "rotateDefault()", |
116 | "QPE/Rotation", "rotateDefault()" }, | 116 | "QPE/Rotation", "rotateDefault()" }, |
117 | }; | 117 | }; |
118 | 118 | ||
119 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus | 119 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus |
120 | // class up into individual classes. We need three classes | 120 | // class up into individual classes. We need three classes |
121 | // | 121 | // |
122 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) | 122 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) |
123 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) | 123 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) |
124 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000) | 124 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000) |
125 | // Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) | 125 | // Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) |
126 | // | 126 | // |
127 | // Only question right now is: Do we really need to do it? Because as soon | 127 | // Only question right now is: Do we really need to do it? Because as soon |
128 | // as the OpenZaurus kernel is ready, there will be a unified interface for all | 128 | // as the OpenZaurus kernel is ready, there will be a unified interface for all |
129 | // Zaurus models (concerning apm, backlight, buttons, etc.) | 129 | // Zaurus models (concerning apm, backlight, buttons, etc.) |
130 | // | 130 | // |
131 | // Comments? - mickeyl. | 131 | // Comments? - mickeyl. |
132 | 132 | ||
133 | void Zaurus::init(const QString& cpu_info) | 133 | void Zaurus::init(const QString& cpu_info) |
134 | { | 134 | { |
135 | // Set the time to wait until the system is realy suspended | ||
136 | // the delta between apm --suspend and sleeping | ||
137 | setAPMTimeOut( 15000 ); | ||
138 | |||
135 | // generic distribution code already scanned /etc/issue at that point - | 139 | // generic distribution code already scanned /etc/issue at that point - |
136 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" | 140 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" |
137 | if ( d->m_sysverstr.contains( "embedix", false ) ) | 141 | if ( d->m_sysverstr.contains( "embedix", false ) ) |
138 | { | 142 | { |
139 | d->m_vendorstr = "Sharp"; | 143 | d->m_vendorstr = "Sharp"; |
140 | d->m_vendor = Vendor_Sharp; | 144 | d->m_vendor = Vendor_Sharp; |
141 | d->m_systemstr = "Zaurus"; | 145 | d->m_systemstr = "Zaurus"; |
142 | d->m_system = System_Zaurus; | 146 | d->m_system = System_Zaurus; |
143 | m_embedix = true; | 147 | m_embedix = true; |
144 | } | 148 | } |
145 | else | 149 | else |
146 | { | 150 | { |
147 | d->m_vendorstr = "OpenZaurus Team"; | 151 | d->m_vendorstr = "OpenZaurus Team"; |
148 | d->m_systemstr = "OpenZaurus"; | 152 | d->m_systemstr = "OpenZaurus"; |
149 | d->m_system = System_OpenZaurus; | 153 | d->m_system = System_OpenZaurus; |
150 | // sysver already gathered | 154 | // sysver already gathered |
151 | 155 | ||
152 | // OpenZaurus sometimes uses the embedix kernel, check if this is one | 156 | // OpenZaurus sometimes uses the embedix kernel, check if this is one |
153 | FILE *uname = popen("uname -r", "r"); | 157 | FILE *uname = popen("uname -r", "r"); |
154 | QFile f; | 158 | QFile f; |
155 | QString line; | 159 | QString line; |
156 | if ( f.open(IO_ReadOnly, uname) ) { | 160 | if ( f.open(IO_ReadOnly, uname) ) { |
157 | QTextStream ts ( &f ); | 161 | QTextStream ts ( &f ); |
158 | line = ts. readLine(); | 162 | line = ts. readLine(); |
159 | int loc = line. find ( "embedix" ); | 163 | int loc = line. find ( "embedix" ); |
160 | if ( loc != -1 ) | 164 | if ( loc != -1 ) |
161 | m_embedix = true; | 165 | m_embedix = true; |
162 | else | 166 | else |
163 | m_embedix = false; | 167 | m_embedix = false; |
164 | f.close(); | 168 | f.close(); |
165 | } | 169 | } |
166 | pclose(uname); | 170 | pclose(uname); |
167 | } | 171 | } |
168 | 172 | ||
169 | // check the Zaurus model | 173 | // check the Zaurus model |
170 | QString model; | 174 | QString model; |
171 | int loc = cpu_info.find( ":" ); | 175 | int loc = cpu_info.find( ":" ); |
172 | if ( loc != -1 ) | 176 | if ( loc != -1 ) |
173 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 177 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
174 | else | 178 | else |
175 | model = cpu_info; | 179 | model = cpu_info; |
176 | 180 | ||
177 | if ( model == "SHARP Corgi" ) { | 181 | if ( model == "SHARP Corgi" ) { |
178 | d->m_model = Model_Zaurus_SLC7x0; | 182 | d->m_model = Model_Zaurus_SLC7x0; |
179 | d->m_modelstr = "Zaurus SL-C700"; | 183 | d->m_modelstr = "Zaurus SL-C700"; |
180 | } else if ( model == "SHARP Shepherd" ) { | 184 | } else if ( model == "SHARP Shepherd" ) { |
181 | d->m_model = Model_Zaurus_SLC7x0; | 185 | d->m_model = Model_Zaurus_SLC7x0; |
182 | d->m_modelstr = "Zaurus SL-C750"; | 186 | d->m_modelstr = "Zaurus SL-C750"; |
183 | } else if ( model == "SHARP Husky" ) { | 187 | } else if ( model == "SHARP Husky" ) { |
184 | d->m_model = Model_Zaurus_SLC7x0; | 188 | d->m_model = Model_Zaurus_SLC7x0; |
185 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; | 189 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; |
186 | } else if ( model == "SHARP Boxer" ) { | 190 | } else if ( model == "SHARP Boxer" ) { |
187 | d->m_model = Model_Zaurus_SLC7x0; | 191 | d->m_model = Model_Zaurus_SLC7x0; |
188 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; | 192 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; |
189 | } else if ( model == "SHARP Poodle" ) { | 193 | } else if ( model == "SHARP Poodle" ) { |
190 | d->m_model = Model_Zaurus_SLB600; | 194 | d->m_model = Model_Zaurus_SLB600; |
191 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; | 195 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; |
192 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 196 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
193 | d->m_model = Model_Zaurus_SL5500; | 197 | d->m_model = Model_Zaurus_SL5500; |
194 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 198 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
195 | } else if ( model == "SHARP Tosa" ) { | 199 | } else if ( model == "SHARP Tosa" ) { |
196 | d->m_model = Model_Zaurus_SL6000; | 200 | d->m_model = Model_Zaurus_SL6000; |
197 | d->m_modelstr = "Zaurus SL-6000"; | 201 | d->m_modelstr = "Zaurus SL-6000"; |
198 | } else if ( model == "SHARP Spitz" ) { | 202 | } else if ( model == "SHARP Spitz" ) { |
199 | d->m_model = Model_Zaurus_SLC3000; | 203 | d->m_model = Model_Zaurus_SLC3000; |
200 | d->m_modelstr = "Zaurus SL-C3000"; | 204 | d->m_modelstr = "Zaurus SL-C3000"; |
201 | } else { | 205 | } else { |
202 | d->m_model = Model_Zaurus_SL5500; | 206 | d->m_model = Model_Zaurus_SL5500; |
203 | d->m_modelstr = "Unknown Zaurus"; | 207 | d->m_modelstr = "Unknown Zaurus"; |
204 | } | 208 | } |
205 | 209 | ||
206 | // set initial rotation | 210 | // set initial rotation |
207 | switch( d->m_model ) { | 211 | switch( d->m_model ) { |
208 | case Model_Zaurus_SL6000: // fallthrough | 212 | case Model_Zaurus_SL6000: // fallthrough |
209 | case Model_Zaurus_SLA300: | 213 | case Model_Zaurus_SLA300: |
210 | d->m_rotation = Rot0; | 214 | d->m_rotation = Rot0; |
211 | break; | 215 | break; |
212 | case Model_Zaurus_SLC3000: // fallthrough | 216 | case Model_Zaurus_SLC3000: // fallthrough |
213 | case Model_Zaurus_SLC7x0: | 217 | case Model_Zaurus_SLC7x0: |
214 | d->m_rotation = rotation(); | 218 | d->m_rotation = rotation(); |
215 | d->m_direction = direction(); | 219 | d->m_direction = direction(); |
216 | break; | 220 | break; |
217 | case Model_Zaurus_SLB600: // fallthrough | 221 | case Model_Zaurus_SLB600: // fallthrough |
218 | case Model_Zaurus_SL5000: // fallthrough | 222 | case Model_Zaurus_SL5000: // fallthrough |
219 | case Model_Zaurus_SL5500: // fallthrough | 223 | case Model_Zaurus_SL5500: // fallthrough |
220 | default: | 224 | default: |
221 | d->m_rotation = Rot270; | 225 | d->m_rotation = Rot270; |
222 | break; | 226 | break; |
223 | } | 227 | } |
224 | m_leds[0] = Led_Off; | 228 | m_leds[0] = Led_Off; |
225 | 229 | ||
226 | if ( m_embedix ) | 230 | if ( m_embedix ) |
227 | qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr ); | 231 | qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr ); |
228 | else | 232 | else |
229 | qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); | 233 | qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); |
230 | } | 234 | } |
231 | 235 | ||
232 | void Zaurus::initButtons() | 236 | void Zaurus::initButtons() |
233 | { | 237 | { |
234 | if ( d->m_buttons ) | 238 | if ( d->m_buttons ) |
235 | return; | 239 | return; |
236 | 240 | ||
237 | d->m_buttons = new QValueList <ODeviceButton>; | 241 | d->m_buttons = new QValueList <ODeviceButton>; |
238 | 242 | ||
239 | struct z_button * pz_buttons; | 243 | struct z_button * pz_buttons; |
240 | int buttoncount; | 244 | int buttoncount; |
241 | switch ( d->m_model ) { | 245 | switch ( d->m_model ) { |
242 | case Model_Zaurus_SLC3000: // fallthrough | 246 | case Model_Zaurus_SLC3000: // fallthrough |
243 | case Model_Zaurus_SLC7x0: | 247 | case Model_Zaurus_SLC7x0: |
244 | pz_buttons = z_buttons_c700; | 248 | pz_buttons = z_buttons_c700; |
245 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 249 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
246 | break; | 250 | break; |
247 | default: | 251 | default: |
248 | pz_buttons = z_buttons; | 252 | pz_buttons = z_buttons; |
249 | buttoncount = ARRAY_SIZE(z_buttons); | 253 | buttoncount = ARRAY_SIZE(z_buttons); |
250 | break; | 254 | break; |
251 | } | 255 | } |
252 | 256 | ||
253 | for ( int i = 0; i < buttoncount; i++ ) { | 257 | for ( int i = 0; i < buttoncount; i++ ) { |
254 | struct z_button *zb = pz_buttons + i; | 258 | struct z_button *zb = pz_buttons + i; |
255 | ODeviceButton b; | 259 | ODeviceButton b; |
256 | 260 | ||
257 | b.setKeycode( zb->code ); | 261 | b.setKeycode( zb->code ); |
258 | b.setUserText( QObject::tr( "Button", zb->utext )); | 262 | b.setUserText( QObject::tr( "Button", zb->utext )); |
259 | b.setPixmap( Resource::loadPixmap( zb->pix )); | 263 | b.setPixmap( Resource::loadPixmap( zb->pix )); |
260 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); | 264 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); |
261 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); | 265 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); |
262 | d->m_buttons->append( b ); | 266 | d->m_buttons->append( b ); |
263 | } | 267 | } |
264 | 268 | ||
265 | reloadButtonMapping(); | 269 | reloadButtonMapping(); |
266 | } | 270 | } |
267 | 271 | ||
268 | 272 | ||
269 | 273 | ||
270 | typedef struct sharp_led_status { | 274 | typedef struct sharp_led_status { |
271 | int which; /* select which LED status is wanted. */ | 275 | int which; /* select which LED status is wanted. */ |
272 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 276 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
273 | } sharp_led_status; | 277 | } sharp_led_status; |
274 | 278 | ||
275 | void Zaurus::buzzer( int sound ) | 279 | void Zaurus::buzzer( int sound ) |
276 | { | 280 | { |
277 | #ifndef QT_NO_SOUND | 281 | #ifndef QT_NO_SOUND |
278 | Sound *snd = 0; | 282 | Sound *snd = 0; |
279 | 283 | ||
280 | // All devices except SL5500 have a DSP device | 284 | // All devices except SL5500 have a DSP device |
281 | if ( d->m_model != Model_Zaurus_SL5000 | 285 | if ( d->m_model != Model_Zaurus_SL5000 |
282 | && d->m_model != Model_Zaurus_SL5500 ) { | 286 | && d->m_model != Model_Zaurus_SL5500 ) { |
283 | 287 | ||
284 | switch ( sound ){ | 288 | switch ( sound ){ |
285 | case SHARP_BUZ_TOUCHSOUND: { | 289 | case SHARP_BUZ_TOUCHSOUND: { |
286 | static Sound touch_sound("touchsound"); | 290 | static Sound touch_sound("touchsound"); |
287 | snd = &touch_sound; | 291 | snd = &touch_sound; |
288 | } | 292 | } |
289 | break; | 293 | break; |
290 | case SHARP_BUZ_KEYSOUND: { | 294 | case SHARP_BUZ_KEYSOUND: { |
291 | static Sound key_sound( "keysound" ); | 295 | static Sound key_sound( "keysound" ); |
292 | snd = &key_sound; | 296 | snd = &key_sound; |
293 | } | 297 | } |
294 | break; | 298 | break; |
295 | case SHARP_BUZ_SCHEDULE_ALARM: | 299 | case SHARP_BUZ_SCHEDULE_ALARM: |
296 | default: { | 300 | default: { |
297 | static Sound alarm_sound("alarm"); | 301 | static Sound alarm_sound("alarm"); |
298 | snd = &alarm_sound; | 302 | snd = &alarm_sound; |
299 | } | 303 | } |
300 | break; | 304 | break; |
301 | } | 305 | } |
302 | } | 306 | } |
303 | 307 | ||
304 | // If a soundname is defined, we expect that this device has | 308 | // If a soundname is defined, we expect that this device has |
305 | // sound capabilities.. Otherwise we expect to have the buzzer | 309 | // sound capabilities.. Otherwise we expect to have the buzzer |
306 | // device.. | 310 | // device.. |
307 | if ( snd && snd->isFinished() ){ | 311 | if ( snd && snd->isFinished() ){ |
308 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); | 312 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); |
309 | snd->play(); | 313 | snd->play(); |
310 | } else if( !snd ) { | 314 | } else if( !snd ) { |
311 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 315 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
312 | 316 | ||
313 | if ( fd >= 0 ) { | 317 | if ( fd >= 0 ) { |
314 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 318 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
315 | ::close ( fd ); | 319 | ::close ( fd ); |
316 | } | 320 | } |
317 | 321 | ||
318 | } | 322 | } |
319 | #endif | 323 | #endif |
320 | } | 324 | } |
321 | 325 | ||
322 | 326 | ||
323 | void Zaurus::playAlarmSound() | 327 | void Zaurus::playAlarmSound() |
324 | { | 328 | { |
325 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); | 329 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); |
326 | } | 330 | } |
327 | 331 | ||
328 | void Zaurus::playTouchSound() | 332 | void Zaurus::playTouchSound() |
329 | { | 333 | { |
330 | buzzer( SHARP_BUZ_TOUCHSOUND ); | 334 | buzzer( SHARP_BUZ_TOUCHSOUND ); |
331 | } | 335 | } |
332 | 336 | ||
333 | void Zaurus::playKeySound() | 337 | void Zaurus::playKeySound() |
334 | { | 338 | { |
335 | buzzer( SHARP_BUZ_KEYSOUND ); | 339 | buzzer( SHARP_BUZ_KEYSOUND ); |
336 | } | 340 | } |
337 | 341 | ||
338 | 342 | ||
339 | QValueList <OLed> Zaurus::ledList() const | 343 | QValueList <OLed> Zaurus::ledList() const |
340 | { | 344 | { |
341 | QValueList <OLed> vl; | 345 | QValueList <OLed> vl; |
342 | vl << Led_Mail; | 346 | vl << Led_Mail; |
343 | return vl; | 347 | return vl; |
344 | } | 348 | } |
345 | 349 | ||
346 | QValueList <OLedState> Zaurus::ledStateList( OLed l ) const | 350 | QValueList <OLedState> Zaurus::ledStateList( OLed l ) const |
347 | { | 351 | { |
348 | QValueList <OLedState> vl; | 352 | QValueList <OLedState> vl; |
349 | 353 | ||
350 | if ( l == Led_Mail ) | 354 | if ( l == Led_Mail ) |
351 | vl << Led_Off << Led_On << Led_BlinkSlow; | 355 | vl << Led_Off << Led_On << Led_BlinkSlow; |
352 | return vl; | 356 | return vl; |
353 | } | 357 | } |
354 | 358 | ||
355 | OLedState Zaurus::ledState( OLed which ) const | 359 | OLedState Zaurus::ledState( OLed which ) const |
356 | { | 360 | { |
357 | if ( which == Led_Mail ) | 361 | if ( which == Led_Mail ) |
358 | return m_leds [0]; | 362 | return m_leds [0]; |
359 | else | 363 | else |
360 | return Led_Off; | 364 | return Led_Off; |
361 | } | 365 | } |
362 | 366 | ||
363 | bool Zaurus::setLedState( OLed which, OLedState st ) | 367 | bool Zaurus::setLedState( OLed which, OLedState st ) |
364 | { | 368 | { |
365 | // Currently not supported on non_embedix kernels | 369 | // Currently not supported on non_embedix kernels |
366 | if (!m_embedix) | 370 | if (!m_embedix) |
367 | { | 371 | { |
368 | qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); | 372 | qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); |
369 | return false; | 373 | return false; |
370 | } | 374 | } |
371 | 375 | ||
372 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 376 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
373 | 377 | ||
374 | if ( which == Led_Mail ) { | 378 | if ( which == Led_Mail ) { |
375 | if ( fd >= 0 ) { | 379 | if ( fd >= 0 ) { |
376 | struct sharp_led_status leds; | 380 | struct sharp_led_status leds; |
377 | ::memset ( &leds, 0, sizeof( leds )); | 381 | ::memset ( &leds, 0, sizeof( leds )); |
378 | leds. which = SHARP_LED_MAIL_EXISTS; | 382 | leds. which = SHARP_LED_MAIL_EXISTS; |
379 | bool ok = true; | 383 | bool ok = true; |
380 | 384 | ||
381 | switch ( st ) { | 385 | switch ( st ) { |
382 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 386 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
383 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 387 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
384 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 388 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
385 | default : ok = false; | 389 | default : ok = false; |
386 | } | 390 | } |
387 | 391 | ||
388 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 392 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
389 | m_leds [0] = st; | 393 | m_leds [0] = st; |
390 | return true; | 394 | return true; |
391 | } | 395 | } |
392 | } | 396 | } |
393 | } | 397 | } |
394 | return false; | 398 | return false; |
395 | } | 399 | } |
396 | 400 | ||
397 | int Zaurus::displayBrightnessResolution() const | 401 | int Zaurus::displayBrightnessResolution() const |
398 | { | 402 | { |
399 | int res = 1; | 403 | int res = 1; |
400 | if (m_embedix) | 404 | if (m_embedix) |
401 | { | 405 | { |
402 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); | 406 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); |
403 | if ( fd ) | 407 | if ( fd ) |
404 | { | 408 | { |
405 | int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); | 409 | int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); |
406 | ::close( fd ); | 410 | ::close( fd ); |
407 | return value ? value : res; | 411 | return value ? value : res; |
408 | } | 412 | } |
409 | } | 413 | } |
410 | else | 414 | else |
411 | { | 415 | { |
412 | int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK ); | 416 | int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK ); |
413 | if ( fd ) | 417 | if ( fd ) |
414 | { | 418 | { |
415 | char buf[100]; | 419 | char buf[100]; |
416 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); | 420 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); |
417 | ::close( fd ); | 421 | ::close( fd ); |
418 | } | 422 | } |
419 | } | 423 | } |
420 | return res; | 424 | return res; |
421 | } | 425 | } |
422 | 426 | ||
423 | bool Zaurus::setDisplayBrightness( int bright ) | 427 | bool Zaurus::setDisplayBrightness( int bright ) |
424 | { | 428 | { |
425 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); | 429 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); |
426 | bool res = false; | 430 | bool res = false; |
427 | 431 | ||
428 | if ( bright > 255 ) bright = 255; | 432 | if ( bright > 255 ) bright = 255; |
429 | if ( bright < 0 ) bright = 0; | 433 | if ( bright < 0 ) bright = 0; |
430 | 434 | ||
431 | int numberOfSteps = displayBrightnessResolution(); | 435 | int numberOfSteps = displayBrightnessResolution(); |
432 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; | 436 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; |
433 | 437 | ||
434 | if ( m_embedix ) | 438 | if ( m_embedix ) |
435 | { | 439 | { |
436 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | 440 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
437 | if ( fd ) | 441 | if ( fd ) |
438 | { | 442 | { |
439 | res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); | 443 | res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); |
440 | ::close( fd ); | 444 | ::close( fd ); |
441 | } | 445 | } |
442 | } | 446 | } |
443 | else | 447 | else |
444 | { | 448 | { |
445 | int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK ); | 449 | int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK ); |
446 | if ( fd ) | 450 | if ( fd ) |
447 | { | 451 | { |
448 | char buf[100]; | 452 | char buf[100]; |
449 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); | 453 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); |
450 | res = ( ::write( fd, &buf[0], len ) == 0 ); | 454 | res = ( ::write( fd, &buf[0], len ) == 0 ); |
451 | ::close( fd ); | 455 | ::close( fd ); |
452 | } | 456 | } |
453 | } | 457 | } |
454 | return res; | 458 | return res; |
455 | } | 459 | } |
456 | 460 | ||
457 | bool Zaurus::setDisplayStatus( bool on ) | 461 | bool Zaurus::setDisplayStatus( bool on ) |
458 | { | 462 | { |
459 | bool res = false; | 463 | bool res = false; |
460 | if ( m_embedix ) | 464 | if ( m_embedix ) |
461 | { | 465 | { |
462 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | 466 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
463 | if ( fd ) | 467 | if ( fd ) |
464 | { | 468 | { |
465 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; | 469 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; |
466 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); | 470 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); |
467 | ::close ( fd ); | 471 | ::close ( fd ); |
468 | } | 472 | } |
469 | } | 473 | } |
470 | else | 474 | else |
471 | { | 475 | { |
472 | int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); | 476 | int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); |
473 | if ( fd ) | 477 | if ( fd ) |
474 | { | 478 | { |
475 | char buf[10]; | 479 | char buf[10]; |
476 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; | 480 | buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; |
477 | buf[1] = '\0'; | 481 | buf[1] = '\0'; |
478 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); | 482 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); |
479 | ::close( fd ); | 483 | ::close( fd ); |
480 | } | 484 | } |
481 | } | 485 | } |
482 | return res; | 486 | return res; |
483 | } | 487 | } |
484 | 488 | ||
485 | bool Zaurus::suspend() | ||
486 | { | ||
487 | qDebug("ODevice::suspend"); | ||
488 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | ||
489 | return false; | ||
490 | |||
491 | if ( d->m_model == Model_Unknown ) // better don't suspend on unknown devices | ||
492 | return false; | ||
493 | |||
494 | bool res = false; | ||
495 | ODevice::sendSuspendmsg(); | ||
496 | |||
497 | struct timeval tvs, tvn; | ||
498 | ::gettimeofday ( &tvs, 0 ); | ||
499 | |||
500 | ::sync(); // flush fs caches | ||
501 | res = ( ::system ( "apm --suspend" ) == 0 ); | ||
502 | |||
503 | // This is needed because the apm implementation is asynchronous and we | ||
504 | // can not be sure when exactly the device is really suspended | ||
505 | if ( res ) { | ||
506 | do { // Yes, wait 15 seconds. This APM sucks big time. | ||
507 | ::usleep ( 200 * 1000 ); | ||
508 | ::gettimeofday ( &tvn, 0 ); | ||
509 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); | ||
510 | } | ||
511 | |||
512 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); | ||
513 | return res; | ||
514 | } | ||
515 | |||
516 | |||
517 | Transformation Zaurus::rotation() const | 489 | Transformation Zaurus::rotation() const |
518 | { | 490 | { |
519 | qDebug( "Zaurus::rotation()" ); | 491 | qDebug( "Zaurus::rotation()" ); |
520 | Transformation rot; | 492 | Transformation rot; |
521 | 493 | ||
522 | switch ( d->m_model ) { | 494 | switch ( d->m_model ) { |
523 | case Model_Zaurus_SLC3000: // fallthrough | 495 | case Model_Zaurus_SLC3000: // fallthrough |
524 | case Model_Zaurus_SLC7x0: | 496 | case Model_Zaurus_SLC7x0: |
525 | { | 497 | { |
526 | OHingeStatus hs = readHingeSensor(); | 498 | OHingeStatus hs = readHingeSensor(); |
527 | qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); | 499 | qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); |
528 | 500 | ||
529 | if ( m_embedix ) | 501 | if ( m_embedix ) |
530 | { | 502 | { |
531 | if ( hs == CASE_PORTRAIT ) rot = Rot0; | 503 | if ( hs == CASE_PORTRAIT ) rot = Rot0; |
532 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; | 504 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; |
533 | else rot = Rot270; | 505 | else rot = Rot270; |
534 | } | 506 | } |
535 | else | 507 | else |
536 | { | 508 | { |
537 | if ( hs == CASE_PORTRAIT ) rot = Rot90; | 509 | if ( hs == CASE_PORTRAIT ) rot = Rot90; |
538 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; | 510 | else if ( hs == CASE_UNKNOWN ) rot = Rot0; |
539 | else rot = Rot0; | 511 | else rot = Rot0; |
540 | } | 512 | } |
541 | } | 513 | } |
542 | break; | 514 | break; |
543 | case Model_Zaurus_SL6000: | 515 | case Model_Zaurus_SL6000: |
544 | case Model_Zaurus_SLB600: | 516 | case Model_Zaurus_SLB600: |
545 | case Model_Zaurus_SLA300: | 517 | case Model_Zaurus_SLA300: |
546 | case Model_Zaurus_SL5500: | 518 | case Model_Zaurus_SL5500: |
547 | case Model_Zaurus_SL5000: | 519 | case Model_Zaurus_SL5000: |
548 | default: | 520 | default: |
549 | rot = d->m_rotation; | 521 | rot = d->m_rotation; |
550 | break; | 522 | break; |
551 | } | 523 | } |
552 | 524 | ||
553 | return rot; | 525 | return rot; |
554 | } | 526 | } |
555 | ODirection Zaurus::direction() const | 527 | ODirection Zaurus::direction() const |
556 | { | 528 | { |
557 | ODirection dir; | 529 | ODirection dir; |
558 | 530 | ||
559 | switch ( d->m_model ) { | 531 | switch ( d->m_model ) { |
560 | case Model_Zaurus_SLC3000: // fallthrough | 532 | case Model_Zaurus_SLC3000: // fallthrough |
561 | case Model_Zaurus_SLC7x0: { | 533 | case Model_Zaurus_SLC7x0: { |
562 | OHingeStatus hs = readHingeSensor(); | 534 | OHingeStatus hs = readHingeSensor(); |
563 | if ( hs == CASE_PORTRAIT ) dir = CCW; | 535 | if ( hs == CASE_PORTRAIT ) dir = CCW; |
564 | else if ( hs == CASE_UNKNOWN ) dir = CCW; | 536 | else if ( hs == CASE_UNKNOWN ) dir = CCW; |
565 | else dir = CW; | 537 | else dir = CW; |
566 | } | 538 | } |
567 | break; | 539 | break; |
568 | case Model_Zaurus_SL6000: | 540 | case Model_Zaurus_SL6000: |
569 | case Model_Zaurus_SLA300: | 541 | case Model_Zaurus_SLA300: |
570 | case Model_Zaurus_SLB600: | 542 | case Model_Zaurus_SLB600: |
571 | case Model_Zaurus_SL5500: | 543 | case Model_Zaurus_SL5500: |
572 | case Model_Zaurus_SL5000: | 544 | case Model_Zaurus_SL5000: |
573 | default: dir = d->m_direction; | 545 | default: dir = d->m_direction; |
574 | break; | 546 | break; |
575 | } | 547 | } |
576 | return dir; | 548 | return dir; |
577 | 549 | ||
578 | } | 550 | } |
579 | 551 | ||
580 | bool Zaurus::hasHingeSensor() const | 552 | bool Zaurus::hasHingeSensor() const |
581 | { | 553 | { |
582 | return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; | 554 | return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; |
583 | } | 555 | } |
584 | 556 | ||
585 | OHingeStatus Zaurus::readHingeSensor() const | 557 | OHingeStatus Zaurus::readHingeSensor() const |
586 | { | 558 | { |
587 | if (m_embedix) | 559 | if (m_embedix) |
588 | { | 560 | { |
589 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 561 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
590 | if (handle == -1) | 562 | if (handle == -1) |
591 | { | 563 | { |
592 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror | 564 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror |
593 | return CASE_UNKNOWN; | 565 | return CASE_UNKNOWN; |
594 | } | 566 | } |
595 | else | 567 | else |
596 | { | 568 | { |
597 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 569 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
598 | ::close (handle); | 570 | ::close (handle); |
599 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | 571 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) |
600 | { | 572 | { |
601 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | 573 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); |
602 | return static_cast<OHingeStatus>( retval ); | 574 | return static_cast<OHingeStatus>( retval ); |
603 | } | 575 | } |
604 | else | 576 | else |
605 | { | 577 | { |
606 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 578 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
607 | return CASE_UNKNOWN; | 579 | return CASE_UNKNOWN; |
608 | } | 580 | } |
609 | } | 581 | } |
610 | } | 582 | } |
611 | else | 583 | else |
612 | { | 584 | { |
613 | // corgi keyboard is event source 0 in OZ kernel 2.6 | 585 | // corgi keyboard is event source 0 in OZ kernel 2.6 |
614 | OInputDevice* keyboard = OInputSystem::instance()->device( "event0" ); | 586 | OInputDevice* keyboard = OInputSystem::instance()->device( "event0" ); |
615 | if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP0 ) ) return CASE_LANDSCAPE; | 587 | if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP0 ) ) return CASE_LANDSCAPE; |
616 | else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP1 ) ) return CASE_PORTRAIT; | 588 | else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP1 ) ) return CASE_PORTRAIT; |
617 | else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP2 ) ) return CASE_CLOSED; | 589 | else if ( keyboard && keyboard->isHeld( OInputDevice::Key_KP2 ) ) return CASE_CLOSED; |
618 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 590 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
619 | return CASE_UNKNOWN; | 591 | return CASE_UNKNOWN; |
620 | } | 592 | } |
621 | } | 593 | } |
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h index 80593ce..6e6ca46 100644 --- a/libopie2/opiecore/device/odevice_zaurus.h +++ b/libopie2/opiecore/device/odevice_zaurus.h | |||
@@ -1,140 +1,139 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 4 | =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef ODEVICE_ZAURUS | 30 | #ifndef ODEVICE_ZAURUS |
31 | #define ODEVICE_ZAURUS | 31 | #define ODEVICE_ZAURUS |
32 | 32 | ||
33 | #include <opie2/odevice.h> | 33 | #include "odevice_abstractmobiledevice.h" |
34 | 34 | ||
35 | #ifndef ARRAY_SIZE | 35 | #ifndef ARRAY_SIZE |
36 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | 36 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | // _IO and friends are only defined in kernel headers ... | 39 | // _IO and friends are only defined in kernel headers ... |
40 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 40 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
41 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 41 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
42 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 42 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
43 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 43 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
44 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 44 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
45 | 45 | ||
46 | // Audio | 46 | // Audio |
47 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 47 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
48 | 48 | ||
49 | #define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 49 | #define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
50 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 50 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
51 | 51 | ||
52 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 52 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
53 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 53 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
54 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 54 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
55 | 55 | ||
56 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 56 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
57 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 57 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
58 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 58 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
59 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 59 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
60 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 60 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
61 | 61 | ||
62 | // LED | 62 | // LED |
63 | #define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 63 | #define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
64 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 64 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
65 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 65 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
66 | 66 | ||
67 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 67 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
68 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 68 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
69 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 69 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
70 | 70 | ||
71 | // Rotation and Power Management | 71 | // Rotation and Power Management |
72 | #define SHARP_IOCTL_GET_ROTATION 0x413c | 72 | #define SHARP_IOCTL_GET_ROTATION 0x413c |
73 | 73 | ||
74 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 74 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
75 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 75 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
76 | #define APM_EVT_POWER_BUTTON (1 << 0) | 76 | #define APM_EVT_POWER_BUTTON (1 << 0) |
77 | 77 | ||
78 | // Brightness Embedix | 78 | // Brightness Embedix |
79 | #define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl" | 79 | #define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl" |
80 | #define SHARP_FL_IOCTL_ON 1 | 80 | #define SHARP_FL_IOCTL_ON 1 |
81 | #define SHARP_FL_IOCTL_OFF 2 | 81 | #define SHARP_FL_IOCTL_OFF 2 |
82 | #define SHARP_FL_IOCTL_STEP_CONTRAST 100 | 82 | #define SHARP_FL_IOCTL_STEP_CONTRAST 100 |
83 | #define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101 | 83 | #define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101 |
84 | #define SHARP_FL_IOCTL_GET_STEP 102 | 84 | #define SHARP_FL_IOCTL_GET_STEP 102 |
85 | 85 | ||
86 | // Vesa Standard | 86 | // Vesa Standard |
87 | #define FB_BLANK_UNBLANK 0 | 87 | #define FB_BLANK_UNBLANK 0 |
88 | #define FB_BLANK_POWERDOWN 4 | 88 | #define FB_BLANK_POWERDOWN 4 |
89 | 89 | ||
90 | namespace Opie { | 90 | namespace Opie { |
91 | namespace Core { | 91 | namespace Core { |
92 | namespace Internal { | 92 | namespace Internal { |
93 | 93 | ||
94 | class Zaurus : public ODevice | 94 | class Zaurus : public OAbstractMobileDevice |
95 | { | 95 | { |
96 | protected: | 96 | protected: |
97 | virtual void init(const QString&); | 97 | virtual void init(const QString&); |
98 | virtual void initButtons(); | 98 | virtual void initButtons(); |
99 | 99 | ||
100 | public: | 100 | public: |
101 | virtual bool setDisplayBrightness( int b ); | 101 | virtual bool setDisplayBrightness( int b ); |
102 | virtual bool setDisplayStatus( bool on ); | 102 | virtual bool setDisplayStatus( bool on ); |
103 | virtual int displayBrightnessResolution() const; | 103 | virtual int displayBrightnessResolution() const; |
104 | 104 | ||
105 | virtual void playAlarmSound(); | 105 | virtual void playAlarmSound(); |
106 | virtual void playKeySound(); | 106 | virtual void playKeySound(); |
107 | virtual void playTouchSound(); | 107 | virtual void playTouchSound(); |
108 | 108 | ||
109 | virtual QValueList <OLed> ledList() const; | 109 | virtual QValueList <OLed> ledList() const; |
110 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 110 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
111 | virtual OLedState ledState( OLed led ) const; | 111 | virtual OLedState ledState( OLed led ) const; |
112 | virtual bool setLedState( OLed led, OLedState st ); | 112 | virtual bool setLedState( OLed led, OLedState st ); |
113 | 113 | ||
114 | virtual bool hasHingeSensor() const; | 114 | virtual bool hasHingeSensor() const; |
115 | virtual OHingeStatus readHingeSensor() const; | 115 | virtual OHingeStatus readHingeSensor() const; |
116 | 116 | ||
117 | virtual bool suspend(); | ||
118 | virtual Transformation rotation() const; | 117 | virtual Transformation rotation() const; |
119 | virtual ODirection direction() const; | 118 | virtual ODirection direction() const; |
120 | 119 | ||
121 | protected: | 120 | protected: |
122 | virtual void buzzer( int snd ); | 121 | virtual void buzzer( int snd ); |
123 | 122 | ||
124 | OLedState m_leds[1]; | 123 | OLedState m_leds[1]; |
125 | bool m_embedix; | 124 | bool m_embedix; |
126 | }; | 125 | }; |
127 | 126 | ||
128 | struct z_button { | 127 | struct z_button { |
129 | Qt::Key code; | 128 | Qt::Key code; |
130 | char *utext; | 129 | char *utext; |
131 | char *pix; | 130 | char *pix; |
132 | char *fpressedservice; | 131 | char *fpressedservice; |
133 | char *fpressedaction; | 132 | char *fpressedaction; |
134 | char *fheldservice; | 133 | char *fheldservice; |
135 | char *fheldaction; | 134 | char *fheldaction; |
136 | }; | 135 | }; |
137 | } | 136 | } |
138 | } | 137 | } |
139 | } | 138 | } |
140 | #endif | 139 | #endif |