author | wimpie <wimpie> | 2005-01-04 01:29:55 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-04 01:29:55 (UTC) |
commit | 5199338e990284244b8fe540d3fb4a36b24bae82 (patch) (unidiff) | |
tree | bbd17e6ab0998379a1a032851d27d78bd5db201f | |
parent | 1708efc66ceab63d93960a523e247bcbfafe6e7f (diff) | |
download | opie-5199338e990284244b8fe540d3fb4a36b24bae82.zip opie-5199338e990284244b8fe540d3fb4a36b24bae82.tar.gz opie-5199338e990284244b8fe540d3fb4a36b24bae82.tar.bz2 |
added odevice_genuine for pure INTEL based CPU
-> needed for system dependend applications. being LIKE
-> an IPAQ is not enough
-rw-r--r-- | libopie2/opiecore/device/device.pro | 2 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 8 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice.h | 4 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_genuineintel.cpp | 193 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_genuineintel.h | 84 |
5 files changed, 291 insertions, 0 deletions
diff --git a/libopie2/opiecore/device/device.pro b/libopie2/opiecore/device/device.pro index 2c9e770..9a409e1 100644 --- a/libopie2/opiecore/device/device.pro +++ b/libopie2/opiecore/device/device.pro | |||
@@ -1,20 +1,22 @@ | |||
1 | HEADERS += device/odevice.h \ | 1 | HEADERS += device/odevice.h \ |
2 | device/odevicebutton.h \ | 2 | device/odevicebutton.h \ |
3 | device/odevice_beagle.h \ | 3 | device/odevice_beagle.h \ |
4 | device/odevice_ipaq.h \ | 4 | device/odevice_ipaq.h \ |
5 | device/odevice_jornada.h \ | 5 | device/odevice_jornada.h \ |
6 | device/odevice_ramses.h \ | 6 | device/odevice_ramses.h \ |
7 | device/odevice_simpad.h \ | 7 | device/odevice_simpad.h \ |
8 | device/odevice_zaurus.h \ | 8 | device/odevice_zaurus.h \ |
9 | device/odevice_genuineintel.h \ | ||
9 | device/odevice_yopy.h | 10 | device/odevice_yopy.h |
10 | 11 | ||
11 | SOURCES += device/odevice.cpp \ | 12 | SOURCES += device/odevice.cpp \ |
12 | device/odevicebutton.cpp \ | 13 | device/odevicebutton.cpp \ |
13 | device/odevice_beagle.cpp \ | 14 | device/odevice_beagle.cpp \ |
14 | device/odevice_ipaq.cpp \ | 15 | device/odevice_ipaq.cpp \ |
15 | device/odevice_jornada.cpp\ | 16 | device/odevice_jornada.cpp\ |
16 | device/odevice_ramses.cpp \ | 17 | device/odevice_ramses.cpp \ |
17 | device/odevice_simpad.cpp \ | 18 | device/odevice_simpad.cpp \ |
18 | device/odevice_zaurus.cpp \ | 19 | device/odevice_zaurus.cpp \ |
20 | device/odevice_genuineintel.cpp \ | ||
19 | device/odevice_yopy.cpp | 21 | device/odevice_yopy.cpp |
20 | 22 | ||
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index 39b37cd..a824392 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -1,860 +1,868 @@ | |||
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_beagle.h" | 30 | #include "odevice_beagle.h" |
31 | #include "odevice_ipaq.h" | 31 | #include "odevice_ipaq.h" |
32 | #include "odevice_jornada.h" | 32 | #include "odevice_jornada.h" |
33 | #include "odevice_ramses.h" | 33 | #include "odevice_ramses.h" |
34 | #include "odevice_simpad.h" | 34 | #include "odevice_simpad.h" |
35 | #include "odevice_yopy.h" | 35 | #include "odevice_yopy.h" |
36 | #include "odevice_zaurus.h" | 36 | #include "odevice_zaurus.h" |
37 | #include "odevice_genuineintel.h" | ||
37 | 38 | ||
38 | /* QT */ | 39 | /* QT */ |
39 | #include <qapplication.h> | 40 | #include <qapplication.h> |
40 | #include <qfile.h> | 41 | #include <qfile.h> |
41 | #include <qtextstream.h> | 42 | #include <qtextstream.h> |
42 | #include <qwindowsystem_qws.h> | 43 | #include <qwindowsystem_qws.h> |
43 | 44 | ||
44 | /* OPIE */ | 45 | /* OPIE */ |
45 | #include <qpe/config.h> | 46 | #include <qpe/config.h> |
46 | #include <qpe/resource.h> | 47 | #include <qpe/resource.h> |
47 | #include <qpe/sound.h> | 48 | #include <qpe/sound.h> |
48 | #include <qpe/qcopenvelope_qws.h> | 49 | #include <qpe/qcopenvelope_qws.h> |
49 | #include <qpe/sound.h> | 50 | #include <qpe/sound.h> |
50 | #include <opie2/okeyfilter.h> | 51 | #include <opie2/okeyfilter.h> |
51 | 52 | ||
52 | /* STD */ | 53 | /* STD */ |
53 | #include <fcntl.h> | 54 | #include <fcntl.h> |
54 | #include <math.h> | 55 | #include <math.h> |
55 | #include <stdlib.h> | 56 | #include <stdlib.h> |
56 | #include <signal.h> | 57 | #include <signal.h> |
57 | #include <sys/ioctl.h> | 58 | #include <sys/ioctl.h> |
58 | #include <sys/time.h> | 59 | #include <sys/time.h> |
59 | #include <unistd.h> | 60 | #include <unistd.h> |
60 | #ifndef QT_NO_SOUND | 61 | #ifndef QT_NO_SOUND |
61 | #include <linux/soundcard.h> | 62 | #include <linux/soundcard.h> |
62 | #endif | 63 | #endif |
63 | 64 | ||
64 | namespace Opie { | 65 | namespace Opie { |
65 | namespace Core { | 66 | namespace Core { |
66 | 67 | ||
67 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; | 68 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; |
68 | 69 | ||
69 | 70 | ||
70 | /* STATIC and common implementation */ | 71 | /* STATIC and common implementation */ |
71 | /* EXPORT */ ODistribution distributions[] = { | 72 | /* EXPORT */ ODistribution distributions[] = { |
72 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, | 73 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, |
73 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, | 74 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, |
74 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, | 75 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, |
75 | { System_Unknown, "Linux", "/etc/issue" }, | 76 | { System_Unknown, "Linux", "/etc/issue" }, |
76 | }; | 77 | }; |
77 | 78 | ||
78 | 79 | ||
79 | /* EXPORT */ bool isQWS(){ | 80 | /* EXPORT */ bool isQWS(){ |
80 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; | 81 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; |
81 | } | 82 | } |
82 | 83 | ||
83 | /* EXPORT */ QCString makeChannel ( const char *str ){ | 84 | /* EXPORT */ QCString makeChannel ( const char *str ){ |
84 | if ( str && !::strchr ( str, '/' )) | 85 | if ( str && !::strchr ( str, '/' )) |
85 | return QCString ( "QPE/Application/" ) + str; | 86 | return QCString ( "QPE/Application/" ) + str; |
86 | else | 87 | else |
87 | return str; | 88 | return str; |
88 | } | 89 | } |
89 | 90 | ||
90 | 91 | ||
91 | 92 | ||
92 | /* Now the default implementation of ODevice */ | 93 | /* Now the default implementation of ODevice */ |
93 | 94 | ||
94 | struct default_button default_buttons [] = { | 95 | struct default_button default_buttons [] = { |
95 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 96 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
96 | "devicebuttons/z_calendar", | 97 | "devicebuttons/z_calendar", |
97 | "datebook", "nextView()", | 98 | "datebook", "nextView()", |
98 | "today", "raise()" }, | 99 | "today", "raise()" }, |
99 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 100 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
100 | "devicebuttons/z_contact", | 101 | "devicebuttons/z_contact", |
101 | "addressbook", "raise()", | 102 | "addressbook", "raise()", |
102 | "addressbook", "beamBusinessCard()" }, | 103 | "addressbook", "beamBusinessCard()" }, |
103 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 104 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
104 | "devicebuttons/z_home", | 105 | "devicebuttons/z_home", |
105 | "QPE/Launcher", "home()", | 106 | "QPE/Launcher", "home()", |
106 | "buttonsettings", "raise()" }, | 107 | "buttonsettings", "raise()" }, |
107 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 108 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
108 | "devicebuttons/z_menu", | 109 | "devicebuttons/z_menu", |
109 | "QPE/TaskBar", "toggleMenu()", | 110 | "QPE/TaskBar", "toggleMenu()", |
110 | "QPE/TaskBar", "toggleStartMenu()" }, | 111 | "QPE/TaskBar", "toggleStartMenu()" }, |
111 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 112 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
112 | "devicebuttons/z_mail", | 113 | "devicebuttons/z_mail", |
113 | "opiemail", "raise()", | 114 | "opiemail", "raise()", |
114 | "opiemail", "newMail()" }, | 115 | "opiemail", "newMail()" }, |
115 | }; | 116 | }; |
116 | 117 | ||
117 | ODevice *ODevice::inst() | 118 | ODevice *ODevice::inst() |
118 | { | 119 | { |
119 | static ODevice *dev = 0; | 120 | static ODevice *dev = 0; |
120 | 121 | ||
121 | // rewrite this to only use /proc/cpuinfo or so | 122 | // rewrite this to only use /proc/cpuinfo or so |
122 | QString cpu_info; | 123 | QString cpu_info; |
123 | 124 | ||
124 | if ( !dev ) | 125 | if ( !dev ) |
125 | { | 126 | { |
126 | QFile f( PATH_PROC_CPUINFO ); | 127 | QFile f( PATH_PROC_CPUINFO ); |
127 | if ( f.open( IO_ReadOnly ) ) | 128 | if ( f.open( IO_ReadOnly ) ) |
128 | { | 129 | { |
129 | QTextStream s( &f ); | 130 | QTextStream s( &f ); |
130 | while ( !s.atEnd() ) | 131 | while ( !s.atEnd() ) |
131 | { | 132 | { |
132 | QString line; | 133 | QString line; |
133 | line = s.readLine(); | 134 | line = s.readLine(); |
134 | if ( line.startsWith( "Hardware" ) ) | 135 | if ( line.startsWith( "Hardware" ) ) |
135 | { | 136 | { |
136 | qDebug( "ODevice() - found '%s'", (const char*) line ); | 137 | qDebug( "ODevice() - found '%s'", (const char*) line ); |
137 | cpu_info = line; | 138 | cpu_info = line; |
138 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); | 139 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); |
139 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); | 140 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); |
140 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); | 141 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); |
141 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); | 142 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); |
142 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); | 143 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); |
143 | else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); | 144 | else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); |
144 | else qWarning( "ODevice() - unknown hardware - using default." ); | 145 | else qWarning( "ODevice() - unknown hardware - using default." ); |
145 | break; | 146 | break; |
147 | } else if ( line.startsWith( "vendor_id" ) ) { | ||
148 | qDebug( "ODevice() - found '%s'", (const char*) line ); | ||
149 | cpu_info = line; | ||
150 | if( line.contains( "genuineintel", false ) ) { | ||
151 | dev = new Internal::GenuineIntel(); | ||
152 | break; | ||
153 | } | ||
146 | } | 154 | } |
147 | } | 155 | } |
148 | } | 156 | } |
149 | else | 157 | else |
150 | { | 158 | { |
151 | 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 ); |
152 | } | 160 | } |
153 | if ( !dev ) dev = new ODevice(); | 161 | if ( !dev ) dev = new ODevice(); |
154 | dev->init(cpu_info); | 162 | dev->init(cpu_info); |
155 | } | 163 | } |
156 | return dev; | 164 | return dev; |
157 | } | 165 | } |
158 | 166 | ||
159 | ODevice::ODevice() | 167 | ODevice::ODevice() |
160 | { | 168 | { |
161 | d = new ODeviceData; | 169 | d = new ODeviceData; |
162 | 170 | ||
163 | d->m_modelstr = "Unknown"; | 171 | d->m_modelstr = "Unknown"; |
164 | d->m_model = Model_Unknown; | 172 | d->m_model = Model_Unknown; |
165 | d->m_vendorstr = "Unknown"; | 173 | d->m_vendorstr = "Unknown"; |
166 | d->m_vendor = Vendor_Unknown; | 174 | d->m_vendor = Vendor_Unknown; |
167 | d->m_systemstr = "Unknown"; | 175 | d->m_systemstr = "Unknown"; |
168 | d->m_system = System_Unknown; | 176 | d->m_system = System_Unknown; |
169 | d->m_sysverstr = "0.0"; | 177 | d->m_sysverstr = "0.0"; |
170 | d->m_rotation = Rot0; | 178 | d->m_rotation = Rot0; |
171 | d->m_direction = CW; | 179 | d->m_direction = CW; |
172 | 180 | ||
173 | d->m_holdtime = 1000; // 1000ms | 181 | d->m_holdtime = 1000; // 1000ms |
174 | d->m_buttons = 0; | 182 | d->m_buttons = 0; |
175 | d->m_cpu_frequencies = new QStrList; | 183 | d->m_cpu_frequencies = new QStrList; |
176 | 184 | ||
177 | 185 | ||
178 | /* mixer */ | 186 | /* mixer */ |
179 | d->m_sound = d->m_vol = d->m_mixer = -1; | 187 | d->m_sound = d->m_vol = d->m_mixer = -1; |
180 | 188 | ||
181 | /* System QCopChannel created */ | 189 | /* System QCopChannel created */ |
182 | d->m_initializedButtonQcop = false; | 190 | d->m_initializedButtonQcop = false; |
183 | 191 | ||
184 | // New distribution detection code first checks for legacy distributions, | 192 | // New distribution detection code first checks for legacy distributions, |
185 | // identified by /etc/familiar-version or /etc/oz_version. | 193 | // identified by /etc/familiar-version or /etc/oz_version. |
186 | // Then check for OpenEmbedded and lastly, read /etc/issue | 194 | // Then check for OpenEmbedded and lastly, read /etc/issue |
187 | 195 | ||
188 | for ( unsigned int i = 0; i < sizeof distributions; ++i ) | 196 | for ( unsigned int i = 0; i < sizeof distributions; ++i ) |
189 | { | 197 | { |
190 | if ( QFile::exists( distributions[i].sysvfile ) ) | 198 | if ( QFile::exists( distributions[i].sysvfile ) ) |
191 | { | 199 | { |
192 | d->m_systemstr = distributions[i].sysstr; | 200 | d->m_systemstr = distributions[i].sysstr; |
193 | d->m_system = distributions[i].system; | 201 | d->m_system = distributions[i].system; |
194 | d->m_sysverstr = "<Unknown>"; | 202 | d->m_sysverstr = "<Unknown>"; |
195 | QFile f( distributions[i].sysvfile ); | 203 | QFile f( distributions[i].sysvfile ); |
196 | if ( f.open( IO_ReadOnly ) ) | 204 | if ( f.open( IO_ReadOnly ) ) |
197 | { | 205 | { |
198 | QTextStream ts( &f ); | 206 | QTextStream ts( &f ); |
199 | d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); | 207 | d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); |
200 | } | 208 | } |
201 | break; | 209 | break; |
202 | } | 210 | } |
203 | } | 211 | } |
204 | } | 212 | } |
205 | 213 | ||
206 | void ODevice::systemMessage( const QCString &msg, const QByteArray & ) | 214 | void ODevice::systemMessage( const QCString &msg, const QByteArray & ) |
207 | { | 215 | { |
208 | if ( msg == "deviceButtonMappingChanged()" ) { | 216 | if ( msg == "deviceButtonMappingChanged()" ) { |
209 | reloadButtonMapping(); | 217 | reloadButtonMapping(); |
210 | } | 218 | } |
211 | } | 219 | } |
212 | 220 | ||
213 | void ODevice::init(const QString&) | 221 | void ODevice::init(const QString&) |
214 | { | 222 | { |
215 | } | 223 | } |
216 | 224 | ||
217 | /** | 225 | /** |
218 | * This method initialises the button mapping | 226 | * This method initialises the button mapping |
219 | */ | 227 | */ |
220 | void ODevice::initButtons() | 228 | void ODevice::initButtons() |
221 | { | 229 | { |
222 | if ( d->m_buttons ) | 230 | if ( d->m_buttons ) |
223 | return; | 231 | return; |
224 | 232 | ||
225 | qDebug ( "init Buttons" ); | 233 | qDebug ( "init Buttons" ); |
226 | d->m_buttons = new QValueList <ODeviceButton>; | 234 | d->m_buttons = new QValueList <ODeviceButton>; |
227 | 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++ ) { |
228 | default_button *db = default_buttons + i; | 236 | default_button *db = default_buttons + i; |
229 | ODeviceButton b; | 237 | ODeviceButton b; |
230 | b. setKeycode ( db->code ); | 238 | b. setKeycode ( db->code ); |
231 | b. setUserText ( QObject::tr ( "Button", db->utext )); | 239 | b. setUserText ( QObject::tr ( "Button", db->utext )); |
232 | b. setPixmap ( Resource::loadPixmap ( db->pix )); | 240 | b. setPixmap ( Resource::loadPixmap ( db->pix )); |
233 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); | 241 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); |
234 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); | 242 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); |
235 | d->m_buttons->append ( b ); | 243 | d->m_buttons->append ( b ); |
236 | } | 244 | } |
237 | 245 | ||
238 | reloadButtonMapping(); | 246 | reloadButtonMapping(); |
239 | } | 247 | } |
240 | 248 | ||
241 | ODevice::~ODevice() | 249 | ODevice::~ODevice() |
242 | { | 250 | { |
243 | // we leak m_devicebuttons and m_cpu_frequency | 251 | // we leak m_devicebuttons and m_cpu_frequency |
244 | // but it's a singleton and it is not so importantant | 252 | // but it's a singleton and it is not so importantant |
245 | // -zecke | 253 | // -zecke |
246 | delete d; | 254 | delete d; |
247 | } | 255 | } |
248 | 256 | ||
249 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 257 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
250 | { | 258 | { |
251 | return false; | 259 | return false; |
252 | } | 260 | } |
253 | 261 | ||
254 | //#include <linux/apm_bios.h> | 262 | //#include <linux/apm_bios.h> |
255 | 263 | ||
256 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 264 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
257 | 265 | ||
258 | /** | 266 | /** |
259 | * This method will try to suspend the device | 267 | * This method will try to suspend the device |
260 | * It only works if the user is the QWS Server and the apm application | 268 | * It only works if the user is the QWS Server and the apm application |
261 | * is installed. | 269 | * is installed. |
262 | * It tries to suspend and then waits some time cause some distributions | 270 | * It tries to suspend and then waits some time cause some distributions |
263 | * do have asynchronus apm implementations. | 271 | * do have asynchronus apm implementations. |
264 | * This method will either fail and return false or it'll suspend the | 272 | * This method will either fail and return false or it'll suspend the |
265 | * device and return once the device got woken up | 273 | * device and return once the device got woken up |
266 | * | 274 | * |
267 | * @return if the device got suspended | 275 | * @return if the device got suspended |
268 | */ | 276 | */ |
269 | bool ODevice::suspend() | 277 | bool ODevice::suspend() |
270 | { | 278 | { |
271 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 279 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
272 | return false; | 280 | return false; |
273 | 281 | ||
274 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 282 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
275 | return false; | 283 | return false; |
276 | 284 | ||
277 | bool res = false; | 285 | bool res = false; |
278 | ODevice::sendSuspendmsg(); | 286 | ODevice::sendSuspendmsg(); |
279 | 287 | ||
280 | struct timeval tvs, tvn; | 288 | struct timeval tvs, tvn; |
281 | ::gettimeofday ( &tvs, 0 ); | 289 | ::gettimeofday ( &tvs, 0 ); |
282 | 290 | ||
283 | ::sync(); // flush fs caches | 291 | ::sync(); // flush fs caches |
284 | res = ( ::system ( "apm --suspend" ) == 0 ); | 292 | res = ( ::system ( "apm --suspend" ) == 0 ); |
285 | 293 | ||
286 | // This is needed because the iPAQ apm implementation is asynchronous and we | 294 | // This is needed because the iPAQ apm implementation is asynchronous and we |
287 | // can not be sure when exactly the device is really suspended | 295 | // can not be sure when exactly the device is really suspended |
288 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 296 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
289 | 297 | ||
290 | if ( res ) { | 298 | if ( res ) { |
291 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 299 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
292 | ::usleep ( 200 * 1000 ); | 300 | ::usleep ( 200 * 1000 ); |
293 | ::gettimeofday ( &tvn, 0 ); | 301 | ::gettimeofday ( &tvn, 0 ); |
294 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 302 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
295 | } | 303 | } |
296 | 304 | ||
297 | return res; | 305 | return res; |
298 | } | 306 | } |
299 | 307 | ||
300 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 308 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
301 | 309 | ||
302 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 310 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
303 | 311 | ||
304 | /* VESA Blanking Levels */ | 312 | /* VESA Blanking Levels */ |
305 | #define VESA_NO_BLANKING 0 | 313 | #define VESA_NO_BLANKING 0 |
306 | #define VESA_VSYNC_SUSPEND 1 | 314 | #define VESA_VSYNC_SUSPEND 1 |
307 | #define VESA_HSYNC_SUSPEND 2 | 315 | #define VESA_HSYNC_SUSPEND 2 |
308 | #define VESA_POWERDOWN 3 | 316 | #define VESA_POWERDOWN 3 |
309 | 317 | ||
310 | /** | 318 | /** |
311 | * This sets the display on or off | 319 | * This sets the display on or off |
312 | */ | 320 | */ |
313 | bool ODevice::setDisplayStatus ( bool on ) | 321 | bool ODevice::setDisplayStatus ( bool on ) |
314 | { | 322 | { |
315 | qDebug("ODevice::setDisplayStatus(%d)", on); | 323 | qDebug("ODevice::setDisplayStatus(%d)", on); |
316 | 324 | ||
317 | if ( d->m_model == Model_Unknown ) | 325 | if ( d->m_model == Model_Unknown ) |
318 | return false; | 326 | return false; |
319 | 327 | ||
320 | bool res = false; | 328 | bool res = false; |
321 | int fd; | 329 | int fd; |
322 | 330 | ||
323 | #ifdef QT_QWS_DEVFS | 331 | #ifdef QT_QWS_DEVFS |
324 | if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { | 332 | if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { |
325 | #else | 333 | #else |
326 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 334 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
327 | #endif | 335 | #endif |
328 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 336 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
329 | ::close ( fd ); | 337 | ::close ( fd ); |
330 | } | 338 | } |
331 | return res; | 339 | return res; |
332 | } | 340 | } |
333 | 341 | ||
334 | /** | 342 | /** |
335 | * This sets the display brightness | 343 | * This sets the display brightness |
336 | * | 344 | * |
337 | * @param b The brightness to be set on a scale from 0 to 255 | 345 | * @param b The brightness to be set on a scale from 0 to 255 |
338 | * @return success or failure | 346 | * @return success or failure |
339 | */ | 347 | */ |
340 | bool ODevice::setDisplayBrightness ( int b) | 348 | bool ODevice::setDisplayBrightness ( int b) |
341 | { | 349 | { |
342 | Q_UNUSED( b ) | 350 | Q_UNUSED( b ) |
343 | return false; | 351 | return false; |
344 | } | 352 | } |
345 | 353 | ||
346 | /** | 354 | /** |
347 | * | 355 | * |
348 | * @return Returns the number of steppings on the brightness slider | 356 | * @return Returns the number of steppings on the brightness slider |
349 | * in the Light-'n-Power settings. Values smaller zero and bigger | 357 | * in the Light-'n-Power settings. Values smaller zero and bigger |
350 | * than 255 do not make sense. | 358 | * than 255 do not make sense. |
351 | * | 359 | * |
352 | * \sa QSlider::setLineStep | 360 | * \sa QSlider::setLineStep |
353 | * \sa QSlider::setPageStep | 361 | * \sa QSlider::setPageStep |
354 | */ | 362 | */ |
355 | int ODevice::displayBrightnessResolution() const | 363 | int ODevice::displayBrightnessResolution() const |
356 | { | 364 | { |
357 | return 16; | 365 | return 16; |
358 | } | 366 | } |
359 | 367 | ||
360 | /** | 368 | /** |
361 | * This sets the display contrast | 369 | * This sets the display contrast |
362 | * @param p The contrast to be set on a scale from 0 to 255 | 370 | * @param p The contrast to be set on a scale from 0 to 255 |
363 | * @return success or failure | 371 | * @return success or failure |
364 | */ | 372 | */ |
365 | bool ODevice::setDisplayContrast ( int p) | 373 | bool ODevice::setDisplayContrast ( int p) |
366 | { | 374 | { |
367 | Q_UNUSED( p ) | 375 | Q_UNUSED( p ) |
368 | return false; | 376 | return false; |
369 | } | 377 | } |
370 | 378 | ||
371 | /** | 379 | /** |
372 | * @return return the max value for the brightness settings slider | 380 | * @return return the max value for the brightness settings slider |
373 | * or 0 if the device doesn't support setting of a contrast | 381 | * or 0 if the device doesn't support setting of a contrast |
374 | */ | 382 | */ |
375 | int ODevice::displayContrastResolution() const | 383 | int ODevice::displayContrastResolution() const |
376 | { | 384 | { |
377 | return 0; | 385 | return 0; |
378 | } | 386 | } |
379 | 387 | ||
380 | /** | 388 | /** |
381 | * This returns the vendor as string | 389 | * This returns the vendor as string |
382 | * @return Vendor as QString | 390 | * @return Vendor as QString |
383 | */ | 391 | */ |
384 | QString ODevice::vendorString() const | 392 | QString ODevice::vendorString() const |
385 | { | 393 | { |
386 | return d->m_vendorstr; | 394 | return d->m_vendorstr; |
387 | } | 395 | } |
388 | 396 | ||
389 | /** | 397 | /** |
390 | * This returns the vendor as one of the values of OVendor | 398 | * This returns the vendor as one of the values of OVendor |
391 | * @return OVendor | 399 | * @return OVendor |
392 | */ | 400 | */ |
393 | OVendor ODevice::vendor() const | 401 | OVendor ODevice::vendor() const |
394 | { | 402 | { |
395 | return d->m_vendor; | 403 | return d->m_vendor; |
396 | } | 404 | } |
397 | 405 | ||
398 | /** | 406 | /** |
399 | * This returns the model as a string | 407 | * This returns the model as a string |
400 | * @return A string representing the model | 408 | * @return A string representing the model |
401 | */ | 409 | */ |
402 | QString ODevice::modelString() const | 410 | QString ODevice::modelString() const |
403 | { | 411 | { |
404 | return d->m_modelstr; | 412 | return d->m_modelstr; |
405 | } | 413 | } |
406 | 414 | ||
407 | /** | 415 | /** |
408 | * This does return the OModel used | 416 | * This does return the OModel used |
409 | */ | 417 | */ |
410 | OModel ODevice::model() const | 418 | OModel ODevice::model() const |
411 | { | 419 | { |
412 | return d->m_model; | 420 | return d->m_model; |
413 | } | 421 | } |
414 | 422 | ||
415 | /** | 423 | /** |
416 | * This does return the systen name | 424 | * This does return the systen name |
417 | */ | 425 | */ |
418 | QString ODevice::systemString() const | 426 | QString ODevice::systemString() const |
419 | { | 427 | { |
420 | return d->m_systemstr; | 428 | return d->m_systemstr; |
421 | } | 429 | } |
422 | 430 | ||
423 | /** | 431 | /** |
424 | * Return System as OSystem value | 432 | * Return System as OSystem value |
425 | */ | 433 | */ |
426 | OSystem ODevice::system() const | 434 | OSystem ODevice::system() const |
427 | { | 435 | { |
428 | return d->m_system; | 436 | return d->m_system; |
429 | } | 437 | } |
430 | 438 | ||
431 | /** | 439 | /** |
432 | * @return the version string of the base system | 440 | * @return the version string of the base system |
433 | */ | 441 | */ |
434 | QString ODevice::systemVersionString() const | 442 | QString ODevice::systemVersionString() const |
435 | { | 443 | { |
436 | return d->m_sysverstr; | 444 | return d->m_sysverstr; |
437 | } | 445 | } |
438 | 446 | ||
439 | /** | 447 | /** |
440 | * @return the current Transformation | 448 | * @return the current Transformation |
441 | */ | 449 | */ |
442 | Transformation ODevice::rotation() const | 450 | Transformation ODevice::rotation() const |
443 | { | 451 | { |
444 | return d->m_rotation; | 452 | return d->m_rotation; |
445 | } | 453 | } |
446 | 454 | ||
447 | /** | 455 | /** |
448 | * @return the current rotation direction | 456 | * @return the current rotation direction |
449 | */ | 457 | */ |
450 | ODirection ODevice::direction() const | 458 | ODirection ODevice::direction() const |
451 | { | 459 | { |
452 | return d->m_direction; | 460 | return d->m_direction; |
453 | } | 461 | } |
454 | 462 | ||
455 | /** | 463 | /** |
456 | * This plays an alarm sound | 464 | * This plays an alarm sound |
457 | */ | 465 | */ |
458 | void ODevice::playAlarmSound() | 466 | void ODevice::playAlarmSound() |
459 | { | 467 | { |
460 | #ifndef QT_NO_SOUND | 468 | #ifndef QT_NO_SOUND |
461 | static Sound snd ( "alarm" ); | 469 | static Sound snd ( "alarm" ); |
462 | 470 | ||
463 | if ( snd. isFinished()) | 471 | if ( snd. isFinished()) |
464 | snd. play(); | 472 | snd. play(); |
465 | #endif | 473 | #endif |
466 | } | 474 | } |
467 | 475 | ||
468 | /** | 476 | /** |
469 | * This plays a key sound | 477 | * This plays a key sound |
470 | */ | 478 | */ |
471 | void ODevice::playKeySound() | 479 | void ODevice::playKeySound() |
472 | { | 480 | { |
473 | #ifndef QT_NO_SOUND | 481 | #ifndef QT_NO_SOUND |
474 | static Sound snd ( "keysound" ); | 482 | static Sound snd ( "keysound" ); |
475 | 483 | ||
476 | if ( snd. isFinished()) | 484 | if ( snd. isFinished()) |
477 | snd. play(); | 485 | snd. play(); |
478 | #endif | 486 | #endif |
479 | } | 487 | } |
480 | 488 | ||
481 | /** | 489 | /** |
482 | * This plays a touch sound | 490 | * This plays a touch sound |
483 | */ | 491 | */ |
484 | void ODevice::playTouchSound() | 492 | void ODevice::playTouchSound() |
485 | { | 493 | { |
486 | #ifndef QT_NO_SOUND | 494 | #ifndef QT_NO_SOUND |
487 | static Sound snd ( "touchsound" ); | 495 | static Sound snd ( "touchsound" ); |
488 | 496 | ||
489 | if ( snd. isFinished()) | 497 | if ( snd. isFinished()) |
490 | snd. play(); | 498 | snd. play(); |
491 | #endif | 499 | #endif |
492 | } | 500 | } |
493 | 501 | ||
494 | /** | 502 | /** |
495 | * This method will return a list of leds | 503 | * This method will return a list of leds |
496 | * available on this device | 504 | * available on this device |
497 | * @return a list of LEDs. | 505 | * @return a list of LEDs. |
498 | */ | 506 | */ |
499 | QValueList <OLed> ODevice::ledList() const | 507 | QValueList <OLed> ODevice::ledList() const |
500 | { | 508 | { |
501 | return QValueList <OLed>(); | 509 | return QValueList <OLed>(); |
502 | } | 510 | } |
503 | 511 | ||
504 | /** | 512 | /** |
505 | * This does return the state of the LEDs | 513 | * This does return the state of the LEDs |
506 | */ | 514 | */ |
507 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 515 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
508 | { | 516 | { |
509 | return QValueList <OLedState>(); | 517 | return QValueList <OLedState>(); |
510 | } | 518 | } |
511 | 519 | ||
512 | /** | 520 | /** |
513 | * @return the state for a given OLed | 521 | * @return the state for a given OLed |
514 | */ | 522 | */ |
515 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 523 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
516 | { | 524 | { |
517 | return Led_Off; | 525 | return Led_Off; |
518 | } | 526 | } |
519 | 527 | ||
520 | /** | 528 | /** |
521 | * Set the state for a LED | 529 | * Set the state for a LED |
522 | * @param which Which OLed to use | 530 | * @param which Which OLed to use |
523 | * @param st The state to set | 531 | * @param st The state to set |
524 | * @return success or failure | 532 | * @return success or failure |
525 | */ | 533 | */ |
526 | bool ODevice::setLedState ( OLed which, OLedState st ) | 534 | bool ODevice::setLedState ( OLed which, OLedState st ) |
527 | { | 535 | { |
528 | Q_UNUSED( which ) | 536 | Q_UNUSED( which ) |
529 | Q_UNUSED( st ) | 537 | Q_UNUSED( st ) |
530 | return false; | 538 | return false; |
531 | } | 539 | } |
532 | 540 | ||
533 | /** | 541 | /** |
534 | * @return if the device has a light sensor | 542 | * @return if the device has a light sensor |
535 | */ | 543 | */ |
536 | bool ODevice::hasLightSensor() const | 544 | bool ODevice::hasLightSensor() const |
537 | { | 545 | { |
538 | return false; | 546 | return false; |
539 | } | 547 | } |
540 | 548 | ||
541 | /** | 549 | /** |
542 | * @return a value from the light sensor | 550 | * @return a value from the light sensor |
543 | */ | 551 | */ |
544 | int ODevice::readLightSensor() | 552 | int ODevice::readLightSensor() |
545 | { | 553 | { |
546 | return -1; | 554 | return -1; |
547 | } | 555 | } |
548 | 556 | ||
549 | /** | 557 | /** |
550 | * @return the light sensor resolution | 558 | * @return the light sensor resolution |
551 | */ | 559 | */ |
552 | int ODevice::lightSensorResolution() const | 560 | int ODevice::lightSensorResolution() const |
553 | { | 561 | { |
554 | return 0; | 562 | return 0; |
555 | } | 563 | } |
556 | 564 | ||
557 | /** | 565 | /** |
558 | * @return if the device has a hinge sensor | 566 | * @return if the device has a hinge sensor |
559 | */ | 567 | */ |
560 | bool ODevice::hasHingeSensor() const | 568 | bool ODevice::hasHingeSensor() const |
561 | { | 569 | { |
562 | return false; | 570 | return false; |
563 | } | 571 | } |
564 | 572 | ||
565 | /** | 573 | /** |
566 | * @return a value from the hinge sensor | 574 | * @return a value from the hinge sensor |
567 | */ | 575 | */ |
568 | OHingeStatus ODevice::readHingeSensor() | 576 | OHingeStatus ODevice::readHingeSensor() |
569 | { | 577 | { |
570 | return CASE_UNKNOWN; | 578 | return CASE_UNKNOWN; |
571 | } | 579 | } |
572 | 580 | ||
573 | /** | 581 | /** |
574 | * @return a list with CPU frequencies supported by the hardware | 582 | * @return a list with CPU frequencies supported by the hardware |
575 | */ | 583 | */ |
576 | const QStrList &ODevice::allowedCpuFrequencies() const | 584 | const QStrList &ODevice::allowedCpuFrequencies() const |
577 | { | 585 | { |
578 | return *d->m_cpu_frequencies; | 586 | return *d->m_cpu_frequencies; |
579 | } | 587 | } |
580 | 588 | ||
581 | 589 | ||
582 | /** | 590 | /** |
583 | * Set desired CPU frequency | 591 | * Set desired CPU frequency |
584 | * | 592 | * |
585 | * @param index index into d->m_cpu_frequencies of the frequency to be set | 593 | * @param index index into d->m_cpu_frequencies of the frequency to be set |
586 | */ | 594 | */ |
587 | bool ODevice::setCurrentCpuFrequency(uint index) | 595 | bool ODevice::setCurrentCpuFrequency(uint index) |
588 | { | 596 | { |
589 | if (index >= d->m_cpu_frequencies->count()) | 597 | if (index >= d->m_cpu_frequencies->count()) |
590 | return false; | 598 | return false; |
591 | 599 | ||
592 | char *freq = d->m_cpu_frequencies->at(index); | 600 | char *freq = d->m_cpu_frequencies->at(index); |
593 | qWarning("set freq to %s", freq); | 601 | qWarning("set freq to %s", freq); |
594 | 602 | ||
595 | int fd; | 603 | int fd; |
596 | 604 | ||
597 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { | 605 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { |
598 | char writeCommand[50]; | 606 | char writeCommand[50]; |
599 | const int count = sprintf(writeCommand, "%s\n", freq); | 607 | const int count = sprintf(writeCommand, "%s\n", freq); |
600 | int res = (::write(fd, writeCommand, count) != -1); | 608 | int res = (::write(fd, writeCommand, count) != -1); |
601 | ::close(fd); | 609 | ::close(fd); |
602 | return res; | 610 | return res; |
603 | } | 611 | } |
604 | 612 | ||
605 | return false; | 613 | return false; |
606 | } | 614 | } |
607 | 615 | ||
608 | 616 | ||
609 | /** | 617 | /** |
610 | * @return a list of hardware buttons | 618 | * @return a list of hardware buttons |
611 | */ | 619 | */ |
612 | const QValueList <ODeviceButton> &ODevice::buttons() | 620 | const QValueList <ODeviceButton> &ODevice::buttons() |
613 | { | 621 | { |
614 | initButtons(); | 622 | initButtons(); |
615 | 623 | ||
616 | return *d->m_buttons; | 624 | return *d->m_buttons; |
617 | } | 625 | } |
618 | 626 | ||
619 | /** | 627 | /** |
620 | * @return The amount of time that would count as a hold | 628 | * @return The amount of time that would count as a hold |
621 | */ | 629 | */ |
622 | uint ODevice::buttonHoldTime() const | 630 | uint ODevice::buttonHoldTime() const |
623 | { | 631 | { |
624 | return d->m_holdtime; | 632 | return d->m_holdtime; |
625 | } | 633 | } |
626 | 634 | ||
627 | /** | 635 | /** |
628 | * This method return a ODeviceButton for a key code | 636 | * This method return a ODeviceButton for a key code |
629 | * or 0 if no special hardware button is available for the device | 637 | * or 0 if no special hardware button is available for the device |
630 | * | 638 | * |
631 | * @return The devicebutton or 0l | 639 | * @return The devicebutton or 0l |
632 | * @see ODeviceButton | 640 | * @see ODeviceButton |
633 | */ | 641 | */ |
634 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 642 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
635 | { | 643 | { |
636 | initButtons(); | 644 | initButtons(); |
637 | 645 | ||
638 | for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { | 646 | for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { |
639 | if ( (*it). keycode() == code ) | 647 | if ( (*it). keycode() == code ) |
640 | return &(*it); | 648 | return &(*it); |
641 | } | 649 | } |
642 | return 0; | 650 | return 0; |
643 | } | 651 | } |
644 | 652 | ||
645 | void ODevice::reloadButtonMapping() | 653 | void ODevice::reloadButtonMapping() |
646 | { | 654 | { |
647 | if(!d->m_buttons) | 655 | if(!d->m_buttons) |
648 | initButtons(); | 656 | initButtons(); |
649 | 657 | ||
650 | if(!d->m_initializedButtonQcop) { | 658 | if(!d->m_initializedButtonQcop) { |
651 | QCopChannel *chan = new QCopChannel("QPE/System", this, "ODevice button channel"); | 659 | QCopChannel *chan = new QCopChannel("QPE/System", this, "ODevice button channel"); |
652 | connect(chan,SIGNAL(received(const QCString&,const QByteArray&)), | 660 | connect(chan,SIGNAL(received(const QCString&,const QByteArray&)), |
653 | this,SLOT(systemMessage(const QCString&,const QByteArray&))); | 661 | this,SLOT(systemMessage(const QCString&,const QByteArray&))); |
654 | d->m_initializedButtonQcop = true; | 662 | d->m_initializedButtonQcop = true; |
655 | } | 663 | } |
656 | 664 | ||
657 | Config cfg ( "ButtonSettings" ); | 665 | Config cfg ( "ButtonSettings" ); |
658 | 666 | ||
659 | for ( uint i = 0; i < d->m_buttons->count(); i++ ) { | 667 | for ( uint i = 0; i < d->m_buttons->count(); i++ ) { |
660 | ODeviceButton &b = ( *d->m_buttons ) [i]; | 668 | ODeviceButton &b = ( *d->m_buttons ) [i]; |
661 | QString group = "Button" + QString::number ( i ); | 669 | QString group = "Button" + QString::number ( i ); |
662 | 670 | ||
663 | QCString pch, hch; | 671 | QCString pch, hch; |
664 | QCString pm, hm; | 672 | QCString pm, hm; |
665 | QByteArray pdata, hdata; | 673 | QByteArray pdata, hdata; |
666 | 674 | ||
667 | if ( cfg. hasGroup ( group )) { | 675 | if ( cfg. hasGroup ( group )) { |
668 | cfg. setGroup ( group ); | 676 | cfg. setGroup ( group ); |
669 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); | 677 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); |
670 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); | 678 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); |
671 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 679 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
672 | 680 | ||
673 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); | 681 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); |
674 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); | 682 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); |
675 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 683 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
676 | } | 684 | } |
677 | 685 | ||
678 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 686 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
679 | 687 | ||
680 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 688 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
681 | } | 689 | } |
682 | } | 690 | } |
683 | 691 | ||
684 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 692 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
685 | { | 693 | { |
686 | initButtons(); | 694 | initButtons(); |
687 | 695 | ||
688 | QString mb_chan; | 696 | QString mb_chan; |
689 | 697 | ||
690 | if ( button >= (int) d->m_buttons->count()) | 698 | if ( button >= (int) d->m_buttons->count()) |
691 | return; | 699 | return; |
692 | 700 | ||
693 | ODeviceButton &b = ( *d->m_buttons ) [button]; | 701 | ODeviceButton &b = ( *d->m_buttons ) [button]; |
694 | b. setPressedAction ( action ); | 702 | b. setPressedAction ( action ); |
695 | 703 | ||
696 | mb_chan=b. pressedAction(). channel(); | 704 | mb_chan=b. pressedAction(). channel(); |
697 | 705 | ||
698 | Config buttonFile ( "ButtonSettings" ); | 706 | Config buttonFile ( "ButtonSettings" ); |
699 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 707 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
700 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 708 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
701 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); | 709 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); |
702 | 710 | ||
703 | // buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); | 711 | // buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); |
704 | 712 | ||
705 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 713 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
706 | } | 714 | } |
707 | 715 | ||
708 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 716 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
709 | { | 717 | { |
710 | initButtons(); | 718 | initButtons(); |
711 | 719 | ||
712 | if ( button >= (int) d->m_buttons->count()) | 720 | if ( button >= (int) d->m_buttons->count()) |
713 | return; | 721 | return; |
714 | 722 | ||
715 | ODeviceButton &b = ( *d->m_buttons ) [button]; | 723 | ODeviceButton &b = ( *d->m_buttons ) [button]; |
716 | b. setHeldAction ( action ); | 724 | b. setHeldAction ( action ); |
717 | 725 | ||
718 | Config buttonFile ( "ButtonSettings" ); | 726 | Config buttonFile ( "ButtonSettings" ); |
719 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 727 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
720 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); | 728 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); |
721 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); | 729 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); |
722 | 730 | ||
723 | // buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); | 731 | // buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); |
724 | 732 | ||
725 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 733 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
726 | } | 734 | } |
727 | 735 | ||
728 | /** | 736 | /** |
729 | * @internal | 737 | * @internal |
730 | */ | 738 | */ |
731 | void ODevice::virtual_hook(int, void* ){ | 739 | void ODevice::virtual_hook(int, void* ){ |
732 | 740 | ||
733 | } | 741 | } |
734 | 742 | ||
735 | /** | 743 | /** |
736 | * \brief Send a QCOP Message before suspending | 744 | * \brief Send a QCOP Message before suspending |
737 | * | 745 | * |
738 | * Sends a QCOP message to channel QPE/System | 746 | * Sends a QCOP message to channel QPE/System |
739 | * with the message "aboutToSuspend()" if this | 747 | * with the message "aboutToSuspend()" if this |
740 | * is the windowing server. | 748 | * is the windowing server. |
741 | * | 749 | * |
742 | * Call this in your custom \sa suspend() Method | 750 | * Call this in your custom \sa suspend() Method |
743 | * before going to suspend. | 751 | * before going to suspend. |
744 | * | 752 | * |
745 | */ | 753 | */ |
746 | void ODevice::sendSuspendmsg() | 754 | void ODevice::sendSuspendmsg() |
747 | { | 755 | { |
748 | if ( isQWS() ) | 756 | if ( isQWS() ) |
749 | return; | 757 | return; |
750 | 758 | ||
751 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); | 759 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); |
752 | } | 760 | } |
753 | 761 | ||
754 | /** | 762 | /** |
755 | * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters | 763 | * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters |
756 | * | 764 | * |
757 | * Prepend a QWSServer::KeyboardFilter to the List of Keyboard | 765 | * Prepend a QWSServer::KeyboardFilter to the List of Keyboard |
758 | * Filters. This function is the only way to prepend a KeyFilter. | 766 | * Filters. This function is the only way to prepend a KeyFilter. |
759 | * | 767 | * |
760 | * @param aFilter The KeyFilter to be prepended to the list of filters | 768 | * @param aFilter The KeyFilter to be prepended to the list of filters |
761 | * | 769 | * |
762 | * @see Opie::Core::OKeyFilter | 770 | * @see Opie::Core::OKeyFilter |
763 | * @see Opie::Core::OKeyFilter::inst() | 771 | * @see Opie::Core::OKeyFilter::inst() |
764 | */ | 772 | */ |
765 | void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) | 773 | void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) |
766 | { | 774 | { |
767 | Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); | 775 | Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); |
768 | } | 776 | } |
769 | 777 | ||
770 | /** | 778 | /** |
771 | * \brief Remove the QWSServer::KeyboardFilter in the param from the list | 779 | * \brief Remove the QWSServer::KeyboardFilter in the param from the list |
772 | * | 780 | * |
773 | * Remove the QWSServer::KeyboardFilter \par aFilter from the List | 781 | * Remove the QWSServer::KeyboardFilter \par aFilter from the List |
774 | * of Keyfilters. Call this when you delete the KeyFilter! | 782 | * of Keyfilters. Call this when you delete the KeyFilter! |
775 | * | 783 | * |
776 | * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter | 784 | * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter |
777 | * @see Opie::Core::ODevice::addPreHandler | 785 | * @see Opie::Core::ODevice::addPreHandler |
778 | */ | 786 | */ |
779 | void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) | 787 | void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) |
780 | { | 788 | { |
781 | Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); | 789 | Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); |
782 | } | 790 | } |
783 | 791 | ||
784 | 792 | ||
785 | /** | 793 | /** |
786 | * @internal | 794 | * @internal |
787 | * | 795 | * |
788 | * @see changeMixerForAlarm | 796 | * @see changeMixerForAlarm |
789 | */ | 797 | */ |
790 | void ODevice::playingStopped() { | 798 | void ODevice::playingStopped() { |
791 | if ( sender() ) | 799 | if ( sender() ) |
792 | const_cast<QObject*>(sender())->disconnect( this ); | 800 | const_cast<QObject*>(sender())->disconnect( this ); |
793 | 801 | ||
794 | #ifndef QT_NO_SOUND | 802 | #ifndef QT_NO_SOUND |
795 | if ( d->m_sound >= 0 ) { | 803 | if ( d->m_sound >= 0 ) { |
796 | ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); | 804 | ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); |
797 | ::close ( d->m_sound ); | 805 | ::close ( d->m_sound ); |
798 | } | 806 | } |
799 | #endif | 807 | #endif |
800 | } | 808 | } |
801 | 809 | ||
802 | 810 | ||
803 | /** | 811 | /** |
804 | * \brief Change the Volume for the Alarm and set it back after playing is finished | 812 | * \brief Change the Volume for the Alarm and set it back after playing is finished |
805 | * | 813 | * |
806 | * If you play an Alarm Sound you might want to change the Mixer to | 814 | * If you play an Alarm Sound you might want to change the Mixer to |
807 | * full volume and ignore the user setting. After it \sa Sound::isFinished | 815 | * full volume and ignore the user setting. After it \sa Sound::isFinished |
808 | * you would turn the volume back to the user preference. | 816 | * you would turn the volume back to the user preference. |
809 | * The problem is that we used to enter the event loop while waiting | 817 | * The problem is that we used to enter the event loop while waiting |
810 | * for the sound to be finished triggering all kind of reentrance | 818 | * for the sound to be finished triggering all kind of reentrance |
811 | * problems what a library shouldn't introduce. | 819 | * problems what a library shouldn't introduce. |
812 | * Instead of manually waiting for the sound to be finished use | 820 | * Instead of manually waiting for the sound to be finished use |
813 | * this Method and it will automatically restore the Mixer to | 821 | * this Method and it will automatically restore the Mixer to |
814 | * the user configuration after the sound finished playing. | 822 | * the user configuration after the sound finished playing. |
815 | * | 823 | * |
816 | * Note: The onwership of \param snd is not transfered and playing | 824 | * Note: The onwership of \param snd is not transfered and playing |
817 | * is not started in this method. If 'snd' gets deleted before | 825 | * is not started in this method. If 'snd' gets deleted before |
818 | * playing is finished the volume doesn't get set back to | 826 | * playing is finished the volume doesn't get set back to |
819 | * the user preference! | 827 | * the user preference! |
820 | * | 828 | * |
821 | * \code | 829 | * \code |
822 | * static Sound snd("alarm"); | 830 | * static Sound snd("alarm"); |
823 | * if(!snd.isFinished()) | 831 | * if(!snd.isFinished()) |
824 | * return; | 832 | * return; |
825 | * | 833 | * |
826 | * changeMixerForAlarm( my_channel, "/dev/mixer", &snd ); | 834 | * changeMixerForAlarm( my_channel, "/dev/mixer", &snd ); |
827 | * snd.play() | 835 | * snd.play() |
828 | * \endcode | 836 | * \endcode |
829 | * | 837 | * |
830 | * | 838 | * |
831 | * | 839 | * |
832 | * @param mixer The mixer number/channel to use | 840 | * @param mixer The mixer number/channel to use |
833 | * @param file The file name. If you convert from QString use QFile::encodeName | 841 | * @param file The file name. If you convert from QString use QFile::encodeName |
834 | * @param snd The sound to wait for finishing | 842 | * @param snd The sound to wait for finishing |
835 | * | 843 | * |
836 | */ | 844 | */ |
837 | void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { | 845 | void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { |
838 | #ifndef QT_NO_SOUND | 846 | #ifndef QT_NO_SOUND |
839 | if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { | 847 | if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { |
840 | if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { | 848 | if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { |
841 | Config cfg ( "qpe" ); | 849 | Config cfg ( "qpe" ); |
842 | cfg. setGroup ( "Volume" ); | 850 | cfg. setGroup ( "Volume" ); |
843 | 851 | ||
844 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 852 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
845 | if ( volalarm < 0 ) | 853 | if ( volalarm < 0 ) |
846 | volalarm = 0; | 854 | volalarm = 0; |
847 | else if ( volalarm > 100 ) | 855 | else if ( volalarm > 100 ) |
848 | volalarm = 100; | 856 | volalarm = 100; |
849 | volalarm |= ( volalarm << 8 ); | 857 | volalarm |= ( volalarm << 8 ); |
850 | 858 | ||
851 | if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 ) | 859 | if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 ) |
852 | register_qpe_sound_finished(snd, this, SLOT(playingStopped())); | 860 | register_qpe_sound_finished(snd, this, SLOT(playingStopped())); |
853 | } | 861 | } |
854 | d->m_mixer = mixer; | 862 | d->m_mixer = mixer; |
855 | } | 863 | } |
856 | #endif | 864 | #endif |
857 | } | 865 | } |
858 | 866 | ||
859 | } | 867 | } |
860 | } | 868 | } |
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h index 21fcc3f..93d7d22 100644 --- a/libopie2/opiecore/device/odevice.h +++ b/libopie2/opiecore/device/odevice.h | |||
@@ -1,375 +1,379 @@ | |||
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_H_ | 30 | #ifndef ODEVICE_H_ |
31 | #define ODEVICE_H_ | 31 | #define ODEVICE_H_ |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/odevicebutton.h> | 34 | #include <opie2/odevicebutton.h> |
35 | #include <qpe/qpeapplication.h> /* for Transformation enum.. */ | 35 | #include <qpe/qpeapplication.h> /* for Transformation enum.. */ |
36 | 36 | ||
37 | /* QT */ | 37 | /* QT */ |
38 | #include <qnamespace.h> | 38 | #include <qnamespace.h> |
39 | #include <qobject.h> | 39 | #include <qobject.h> |
40 | #include <qstring.h> | 40 | #include <qstring.h> |
41 | 41 | ||
42 | 42 | ||
43 | #include <qstrlist.h> | 43 | #include <qstrlist.h> |
44 | #include <qwindowsystem_qws.h> | 44 | #include <qwindowsystem_qws.h> |
45 | 45 | ||
46 | 46 | ||
47 | class Sound; | 47 | class Sound; |
48 | 48 | ||
49 | namespace Opie{ | 49 | namespace Opie{ |
50 | namespace Core{ | 50 | namespace Core{ |
51 | 51 | ||
52 | class ODeviceData; | 52 | class ODeviceData; |
53 | /** | 53 | /** |
54 | * The available devices | 54 | * The available devices |
55 | */ | 55 | */ |
56 | enum OModel { | 56 | enum OModel { |
57 | Model_Unknown, // = 0 | 57 | Model_Unknown, // = 0 |
58 | 58 | ||
59 | Model_Series_Mask = 0xff000000, | 59 | Model_Series_Mask = 0xff000000, |
60 | 60 | ||
61 | Model_iPAQ = ( 1 << 24 ), | 61 | Model_iPAQ = ( 1 << 24 ), |
62 | 62 | ||
63 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), | 63 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), |
64 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), | 64 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), |
65 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), | 65 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), |
66 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), | 66 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), |
67 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), | 67 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), |
68 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), | 68 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), |
69 | Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ), | 69 | Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ), |
70 | Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ), | 70 | Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ), |
71 | 71 | ||
72 | Model_Jornada = ( 6 << 24 ), | 72 | Model_Jornada = ( 6 << 24 ), |
73 | Model_Jornada_56x = ( Model_Jornada | 0x000001 ), | 73 | Model_Jornada_56x = ( Model_Jornada | 0x000001 ), |
74 | 74 | ||
75 | Model_Zaurus = ( 2 << 24 ), | 75 | Model_Zaurus = ( 2 << 24 ), |
76 | 76 | ||
77 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), | 77 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), |
78 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), | 78 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), |
79 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), | 79 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), |
80 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), | 80 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), |
81 | Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), | 81 | Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), |
82 | Model_Zaurus_SL6000 = ( Model_Zaurus | 0x000006 ), | 82 | Model_Zaurus_SL6000 = ( Model_Zaurus | 0x000006 ), |
83 | 83 | ||
84 | Model_SIMpad = ( 3 << 24 ), | 84 | Model_SIMpad = ( 3 << 24 ), |
85 | 85 | ||
86 | Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), | 86 | Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), |
87 | Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), | 87 | Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), |
88 | Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), | 88 | Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), |
89 | Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), | 89 | Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), |
90 | Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), | 90 | Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), |
91 | 91 | ||
92 | Model_Ramses = ( 4 << 24 ), | 92 | Model_Ramses = ( 4 << 24 ), |
93 | 93 | ||
94 | Model_Ramses_All = ( Model_Ramses | 0xffffff ), | 94 | Model_Ramses_All = ( Model_Ramses | 0xffffff ), |
95 | Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), | 95 | Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), |
96 | Model_Ramses_MNCIRX = ( Model_Ramses | 0x000002 ), | 96 | Model_Ramses_MNCIRX = ( Model_Ramses | 0x000002 ), |
97 | 97 | ||
98 | Model_Yopy = ( 5 << 24 ), | 98 | Model_Yopy = ( 5 << 24 ), |
99 | 99 | ||
100 | Model_Yopy_All = ( Model_Yopy | 0xffffff ), | 100 | Model_Yopy_All = ( Model_Yopy | 0xffffff ), |
101 | Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), | 101 | Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), |
102 | Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), | 102 | Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), |
103 | Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), | 103 | Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), |
104 | 104 | ||
105 | Model_Beagle = ( 6 << 24 ), | 105 | Model_Beagle = ( 6 << 24 ), |
106 | 106 | ||
107 | Model_Beagle_All = ( Model_Beagle | 0xffffff ), | 107 | Model_Beagle_All = ( Model_Beagle | 0xffffff ), |
108 | Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ), | 108 | Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ), |
109 | 109 | ||
110 | Model_GenuineIntel = ( 7 << 24 ) | ||
111 | |||
110 | }; | 112 | }; |
111 | 113 | ||
112 | /** | 114 | /** |
113 | * The vendor of the device | 115 | * The vendor of the device |
114 | */ | 116 | */ |
115 | enum OVendor { | 117 | enum OVendor { |
116 | Vendor_Unknown, | 118 | Vendor_Unknown, |
117 | 119 | ||
118 | Vendor_HP, | 120 | Vendor_HP, |
119 | Vendor_Sharp, | 121 | Vendor_Sharp, |
120 | Vendor_SIEMENS, | 122 | Vendor_SIEMENS, |
121 | Vendor_MundN, | 123 | Vendor_MundN, |
122 | Vendor_GMate, | 124 | Vendor_GMate, |
123 | Vendor_MasterIA, | 125 | Vendor_MasterIA, |
126 | Vendor_GenuineIntel | ||
124 | }; | 127 | }; |
125 | 128 | ||
126 | /** | 129 | /** |
127 | * The System used | 130 | * The System used |
128 | */ | 131 | */ |
129 | enum OSystem { | 132 | enum OSystem { |
130 | System_Unknown, | 133 | System_Unknown, |
131 | 134 | ||
132 | System_Familiar, | 135 | System_Familiar, |
133 | System_Zaurus, | 136 | System_Zaurus, |
134 | System_OpenZaurus, | 137 | System_OpenZaurus, |
135 | System_Linupy, | 138 | System_Linupy, |
136 | System_OpenEmbedded, | 139 | System_OpenEmbedded, |
140 | System_PC | ||
137 | }; | 141 | }; |
138 | 142 | ||
139 | typedef struct { | 143 | typedef struct { |
140 | OSystem system; | 144 | OSystem system; |
141 | char* sysstr; | 145 | char* sysstr; |
142 | char* sysvfile; | 146 | char* sysvfile; |
143 | } ODistribution; | 147 | } ODistribution; |
144 | 148 | ||
145 | extern ODistribution distributions[]; | 149 | extern ODistribution distributions[]; |
146 | 150 | ||
147 | 151 | ||
148 | enum OLedState { | 152 | enum OLedState { |
149 | Led_Off, | 153 | Led_Off, |
150 | Led_On, | 154 | Led_On, |
151 | Led_BlinkSlow, | 155 | Led_BlinkSlow, |
152 | Led_BlinkFast | 156 | Led_BlinkFast |
153 | }; | 157 | }; |
154 | 158 | ||
155 | enum OLed { | 159 | enum OLed { |
156 | Led_Mail, | 160 | Led_Mail, |
157 | Led_Power, | 161 | Led_Power, |
158 | Led_BlueTooth | 162 | Led_BlueTooth |
159 | }; | 163 | }; |
160 | 164 | ||
161 | enum OHardKey { | 165 | enum OHardKey { |
162 | HardKey_Datebook = Qt::Key_F9, | 166 | HardKey_Datebook = Qt::Key_F9, |
163 | HardKey_Contacts = Qt::Key_F10, | 167 | HardKey_Contacts = Qt::Key_F10, |
164 | HardKey_Menu = Qt::Key_F11, | 168 | HardKey_Menu = Qt::Key_F11, |
165 | HardKey_Home = Qt::Key_F12, | 169 | HardKey_Home = Qt::Key_F12, |
166 | HardKey_Mail = Qt::Key_F13, | 170 | HardKey_Mail = Qt::Key_F13, |
167 | HardKey_Record = Qt::Key_F24, | 171 | HardKey_Record = Qt::Key_F24, |
168 | HardKey_Suspend = Qt::Key_F34, | 172 | HardKey_Suspend = Qt::Key_F34, |
169 | HardKey_Backlight = Qt::Key_F35, | 173 | HardKey_Backlight = Qt::Key_F35, |
170 | HardKey_Action = Qt::Key_F10, | 174 | HardKey_Action = Qt::Key_F10, |
171 | HardKey_OK = Qt::Key_F11, | 175 | HardKey_OK = Qt::Key_F11, |
172 | HardKey_End = Qt::Key_F12, | 176 | HardKey_End = Qt::Key_F12, |
173 | }; | 177 | }; |
174 | 178 | ||
175 | enum ODirection { | 179 | enum ODirection { |
176 | CW = 0, | 180 | CW = 0, |
177 | CCW = 1, | 181 | CCW = 1, |
178 | Flip = 2, | 182 | Flip = 2, |
179 | }; | 183 | }; |
180 | 184 | ||
181 | enum OHingeStatus { | 185 | enum OHingeStatus { |
182 | CASE_CLOSED = 3, | 186 | CASE_CLOSED = 3, |
183 | CASE_PORTRAIT = 2, | 187 | CASE_PORTRAIT = 2, |
184 | CASE_LANDSCAPE = 0, | 188 | CASE_LANDSCAPE = 0, |
185 | CASE_UNKNOWN = 1, | 189 | CASE_UNKNOWN = 1, |
186 | }; | 190 | }; |
187 | 191 | ||
188 | /* default button for qvfb or such | 192 | /* default button for qvfb or such |
189 | * see odevice.cpp for details. | 193 | * see odevice.cpp for details. |
190 | * hint: manage a user defined button for qvfb? | 194 | * hint: manage a user defined button for qvfb? |
191 | * alwin | 195 | * alwin |
192 | */ | 196 | */ |
193 | struct default_button { | 197 | struct default_button { |
194 | Qt::Key code; | 198 | Qt::Key code; |
195 | char *utext; | 199 | char *utext; |
196 | char *pix; | 200 | char *pix; |
197 | char *fpressedservice; | 201 | char *fpressedservice; |
198 | char *fpressedaction; | 202 | char *fpressedaction; |
199 | char *fheldservice; | 203 | char *fheldservice; |
200 | char *fheldaction; | 204 | char *fheldaction; |
201 | }; | 205 | }; |
202 | 206 | ||
203 | /** | 207 | /** |
204 | * A singleton which gives informations about device specefic option | 208 | * A singleton which gives informations about device specefic option |
205 | * like the Hardware used, LEDs, the Base Distribution and | 209 | * like the Hardware used, LEDs, the Base Distribution and |
206 | * hardware key mappings. | 210 | * hardware key mappings. |
207 | * | 211 | * |
208 | * @short A small class for device specefic options | 212 | * @short A small class for device specefic options |
209 | * @see QObject | 213 | * @see QObject |
210 | * @author Robert Griebl | 214 | * @author Robert Griebl |
211 | * @version 1.0 | 215 | * @version 1.0 |
212 | */ | 216 | */ |
213 | class ODevice : public QObject | 217 | class ODevice : public QObject |
214 | { | 218 | { |
215 | Q_OBJECT | 219 | Q_OBJECT |
216 | 220 | ||
217 | private: | 221 | private: |
218 | /* disable copy */ | 222 | /* disable copy */ |
219 | ODevice ( const ODevice & ); | 223 | ODevice ( const ODevice & ); |
220 | 224 | ||
221 | protected: | 225 | protected: |
222 | ODevice(); | 226 | ODevice(); |
223 | virtual void init(const QString&); | 227 | virtual void init(const QString&); |
224 | virtual void initButtons(); | 228 | virtual void initButtons(); |
225 | static void sendSuspendmsg(); | 229 | static void sendSuspendmsg(); |
226 | 230 | ||
227 | ODeviceData *d; | 231 | ODeviceData *d; |
228 | 232 | ||
229 | public: | 233 | public: |
230 | // sandman do we want to allow destructions? -zecke? | 234 | // sandman do we want to allow destructions? -zecke? |
231 | virtual ~ODevice(); | 235 | virtual ~ODevice(); |
232 | 236 | ||
233 | static ODevice *inst(); | 237 | static ODevice *inst(); |
234 | 238 | ||
235 | // information | 239 | // information |
236 | 240 | ||
237 | QString modelString() const; | 241 | QString modelString() const; |
238 | OModel model() const; | 242 | OModel model() const; |
239 | inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } | 243 | inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } |
240 | 244 | ||
241 | QString vendorString() const; | 245 | QString vendorString() const; |
242 | OVendor vendor() const; | 246 | OVendor vendor() const; |
243 | 247 | ||
244 | QString systemString() const; | 248 | QString systemString() const; |
245 | OSystem system() const; | 249 | OSystem system() const; |
246 | 250 | ||
247 | QString systemVersionString() const; | 251 | QString systemVersionString() const; |
248 | 252 | ||
249 | virtual Transformation rotation() const; | 253 | virtual Transformation rotation() const; |
250 | virtual ODirection direction() const; | 254 | virtual ODirection direction() const; |
251 | 255 | ||
252 | // system | 256 | // system |
253 | 257 | ||
254 | virtual bool setSoftSuspend ( bool on ); | 258 | virtual bool setSoftSuspend ( bool on ); |
255 | virtual bool suspend(); | 259 | virtual bool suspend(); |
256 | 260 | ||
257 | virtual bool setDisplayStatus ( bool on ); | 261 | virtual bool setDisplayStatus ( bool on ); |
258 | virtual bool setDisplayBrightness ( int brightness ); | 262 | virtual bool setDisplayBrightness ( int brightness ); |
259 | virtual int displayBrightnessResolution() const; | 263 | virtual int displayBrightnessResolution() const; |
260 | virtual bool setDisplayContrast ( int contrast ); | 264 | virtual bool setDisplayContrast ( int contrast ); |
261 | virtual int displayContrastResolution() const; | 265 | virtual int displayContrastResolution() const; |
262 | 266 | ||
263 | // don't add new virtual methods, use this: | 267 | // don't add new virtual methods, use this: |
264 | // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; | 268 | // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; |
265 | // and in your subclass do overwrite | 269 | // and in your subclass do overwrite |
266 | // protected virtual int virtual_hook(int, void *) | 270 | // protected virtual int virtual_hook(int, void *) |
267 | // which is defined below | 271 | // which is defined below |
268 | 272 | ||
269 | // input / output | 273 | // input / output |
270 | virtual void playAlarmSound(); | 274 | virtual void playAlarmSound(); |
271 | virtual void playKeySound(); | 275 | virtual void playKeySound(); |
272 | virtual void playTouchSound(); | 276 | virtual void playTouchSound(); |
273 | 277 | ||
274 | virtual QValueList <OLed> ledList() const; | 278 | virtual QValueList <OLed> ledList() const; |
275 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 279 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
276 | virtual OLedState ledState ( OLed led ) const; | 280 | virtual OLedState ledState ( OLed led ) const; |
277 | virtual bool setLedState ( OLed led, OLedState st ); | 281 | virtual bool setLedState ( OLed led, OLedState st ); |
278 | 282 | ||
279 | virtual bool hasLightSensor() const; | 283 | virtual bool hasLightSensor() const; |
280 | virtual int readLightSensor(); | 284 | virtual int readLightSensor(); |
281 | virtual int lightSensorResolution() const; | 285 | virtual int lightSensorResolution() const; |
282 | 286 | ||
283 | virtual bool hasHingeSensor() const; | 287 | virtual bool hasHingeSensor() const; |
284 | virtual OHingeStatus readHingeSensor(); | 288 | virtual OHingeStatus readHingeSensor(); |
285 | 289 | ||
286 | const QStrList &allowedCpuFrequencies() const; | 290 | const QStrList &allowedCpuFrequencies() const; |
287 | bool setCurrentCpuFrequency(uint index); | 291 | bool setCurrentCpuFrequency(uint index); |
288 | 292 | ||
289 | /** | 293 | /** |
290 | * Returns the available buttons on this device. The number and location | 294 | * Returns the available buttons on this device. The number and location |
291 | * of buttons will vary depending on the device. Button numbers will be assigned | 295 | * of buttons will vary depending on the device. Button numbers will be assigned |
292 | * by the device manufacturer and will be from most preferred button to least preffered | 296 | * by the device manufacturer and will be from most preferred button to least preffered |
293 | * button. Note that this list only contains "user mappable" buttons. | 297 | * button. Note that this list only contains "user mappable" buttons. |
294 | * | 298 | * |
295 | * @todo Make method const and take care of calling initButtons or make that const too | 299 | * @todo Make method const and take care of calling initButtons or make that const too |
296 | * | 300 | * |
297 | */ | 301 | */ |
298 | const QValueList<ODeviceButton> &buttons(); | 302 | const QValueList<ODeviceButton> &buttons(); |
299 | 303 | ||
300 | /** | 304 | /** |
301 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it | 305 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it |
302 | * returns 0L | 306 | * returns 0L |
303 | */ | 307 | */ |
304 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); | 308 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); |
305 | 309 | ||
306 | /** | 310 | /** |
307 | * Reassigns the pressed action for \a button. To return to the factory | 311 | * Reassigns the pressed action for \a button. To return to the factory |
308 | * default pass an empty string as \a qcopMessage. | 312 | * default pass an empty string as \a qcopMessage. |
309 | */ | 313 | */ |
310 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); | 314 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); |
311 | 315 | ||
312 | /** | 316 | /** |
313 | * Reassigns the held action for \a button. To return to the factory | 317 | * Reassigns the held action for \a button. To return to the factory |
314 | * default pass an empty string as \a qcopMessage. | 318 | * default pass an empty string as \a qcopMessage. |
315 | */ | 319 | */ |
316 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); | 320 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); |
317 | 321 | ||
318 | /** | 322 | /** |
319 | * How long (in ms) you have to press a button for a "hold" action | 323 | * How long (in ms) you have to press a button for a "hold" action |
320 | */ | 324 | */ |
321 | uint buttonHoldTime() const; | 325 | uint buttonHoldTime() const; |
322 | 326 | ||
323 | signals: | 327 | signals: |
324 | void buttonMappingChanged(); | 328 | void buttonMappingChanged(); |
325 | 329 | ||
326 | private slots: | 330 | private slots: |
327 | void systemMessage ( const QCString &, const QByteArray & ); | 331 | void systemMessage ( const QCString &, const QByteArray & ); |
328 | void playingStopped(); | 332 | void playingStopped(); |
329 | 333 | ||
330 | protected: | 334 | protected: |
331 | void addPreHandler(QWSServer::KeyboardFilter*aFilter); | 335 | void addPreHandler(QWSServer::KeyboardFilter*aFilter); |
332 | void remPreHandler(QWSServer::KeyboardFilter*aFilter); | 336 | void remPreHandler(QWSServer::KeyboardFilter*aFilter); |
333 | void reloadButtonMapping(); | 337 | void reloadButtonMapping(); |
334 | void changeMixerForAlarm( int mixer, const char* file, Sound *snd); | 338 | void changeMixerForAlarm( int mixer, const char* file, Sound *snd); |
335 | 339 | ||
336 | /* ugly virtual hook */ | 340 | /* ugly virtual hook */ |
337 | virtual void virtual_hook( int id, void* data ); | 341 | virtual void virtual_hook( int id, void* data ); |
338 | }; | 342 | }; |
339 | 343 | ||
340 | class ODeviceData { | 344 | class ODeviceData { |
341 | 345 | ||
342 | public: | 346 | public: |
343 | QString m_vendorstr; | 347 | QString m_vendorstr; |
344 | OVendor m_vendor; | 348 | OVendor m_vendor; |
345 | 349 | ||
346 | QString m_modelstr; | 350 | QString m_modelstr; |
347 | OModel m_model; | 351 | OModel m_model; |
348 | 352 | ||
349 | QString m_systemstr; | 353 | QString m_systemstr; |
350 | OSystem m_system; | 354 | OSystem m_system; |
351 | 355 | ||
352 | QString m_sysverstr; | 356 | QString m_sysverstr; |
353 | 357 | ||
354 | Transformation m_rotation; | 358 | Transformation m_rotation; |
355 | ODirection m_direction; | 359 | ODirection m_direction; |
356 | 360 | ||
357 | QValueList <ODeviceButton> *m_buttons; | 361 | QValueList <ODeviceButton> *m_buttons; |
358 | uint m_holdtime; | 362 | uint m_holdtime; |
359 | QStrList *m_cpu_frequencies; | 363 | QStrList *m_cpu_frequencies; |
360 | boolm_initializedButtonQcop : 1; | 364 | boolm_initializedButtonQcop : 1; |
361 | 365 | ||
362 | /* values for changeMixerForAlarm */ | 366 | /* values for changeMixerForAlarm */ |
363 | int m_sound, m_vol, m_mixer; | 367 | int m_sound, m_vol, m_mixer; |
364 | }; | 368 | }; |
365 | 369 | ||
366 | extern bool isQWS(); | 370 | extern bool isQWS(); |
367 | extern QCString makeChannel ( const char *str ); | 371 | extern QCString makeChannel ( const char *str ); |
368 | } | 372 | } |
369 | } | 373 | } |
370 | 374 | ||
371 | 375 | ||
372 | 376 | ||
373 | 377 | ||
374 | #endif | 378 | #endif |
375 | 379 | ||
diff --git a/libopie2/opiecore/device/odevice_genuineintel.cpp b/libopie2/opiecore/device/odevice_genuineintel.cpp new file mode 100644 index 0000000..61ba052 --- a/dev/null +++ b/libopie2/opiecore/device/odevice_genuineintel.cpp | |||
@@ -0,0 +1,193 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) 2002,2003,2004 The Opie Team <opie-devel@handhelds.org> | ||
4 | =. | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | |||
30 | #include "odevice_genuineintel.h" | ||
31 | |||
32 | /* QT */ | ||
33 | #include <qapplication.h> | ||
34 | #include <qfile.h> | ||
35 | #include <qtextstream.h> | ||
36 | #include <qwindowsystem_qws.h> | ||
37 | |||
38 | /* OPIE */ | ||
39 | #include <qpe/config.h> | ||
40 | #include <qpe/resource.h> | ||
41 | #include <qpe/sound.h> | ||
42 | #include <qpe/qcopenvelope_qws.h> | ||
43 | #include <opie2/okeyfilter.h> | ||
44 | |||
45 | #ifndef QT_NO_SOUND | ||
46 | #include <linux/soundcard.h> | ||
47 | #endif | ||
48 | |||
49 | using namespace Opie::Core; | ||
50 | using namespace Opie::Core::Internal; | ||
51 | |||
52 | struct gi_button genuineintel_buttons [] = { | ||
53 | { | ||
54 | Qt::Key_F1, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | ||
55 | "devicebuttons/ipaq_calendar", | ||
56 | "datebook", "nextView()", | ||
57 | "today", "raise()" }, | ||
58 | { | ||
59 | Qt::Key_F2, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | ||
60 | "devicebuttons/ipaq_contact", | ||
61 | "addressbook", "raise()", | ||
62 | "addressbook", "beamBusinessCard()" }, | ||
63 | { | ||
64 | Qt::Key_F3, QT_TRANSLATE_NOOP("Button", "Menu Button"), | ||
65 | "devicebuttons/ipaq_menu", | ||
66 | "QPE/TaskBar", "toggleMenu()", | ||
67 | "QPE/TaskBar", "toggleStartMenu()" }, | ||
68 | { | ||
69 | Qt::Key_F4, QT_TRANSLATE_NOOP("Button", "Mail Button"), | ||
70 | "devicebuttons/ipaq_mail", | ||
71 | "opiemail", "raise()", | ||
72 | "opiemail", "newMail()" }, | ||
73 | { | ||
74 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Home Button"), | ||
75 | "devicebuttons/ipaq_home", | ||
76 | "QPE/Launcher", "home()", | ||
77 | "buttonsettings", "raise()" }, | ||
78 | { | ||
79 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Record Button"), | ||
80 | "devicebuttons/ipaq_record", | ||
81 | "QPE/VMemo", "toggleRecord()", | ||
82 | "sound", "raise()" }, | ||
83 | }; | ||
84 | |||
85 | void GenuineIntel::init(const QString& model) | ||
86 | { | ||
87 | d->m_vendorstr = "Intel"; | ||
88 | d->m_vendor = Vendor_GenuineIntel; | ||
89 | |||
90 | QStringList SL = QStringList::split( " ", model ); | ||
91 | |||
92 | d->m_model = Model_GenuineIntel; | ||
93 | d->m_rotation = Rot0; | ||
94 | } | ||
95 | |||
96 | void GenuineIntel::initButtons() | ||
97 | { | ||
98 | if ( d->m_buttons ) | ||
99 | return; | ||
100 | |||
101 | if ( isQWS( ) ) { | ||
102 | addPreHandler(this); | ||
103 | } | ||
104 | |||
105 | d->m_buttons = new QValueList <ODeviceButton>; | ||
106 | |||
107 | for ( uint i = 0; i < ( sizeof( genuineintel_buttons ) / sizeof( gi_button )); i++ ) { | ||
108 | gi_button *ib = genuineintel_buttons + i; | ||
109 | ODeviceButton b; | ||
110 | |||
111 | b. setKeycode ( ib->code ); | ||
112 | b. setUserText ( QObject::tr ( "Button", ib->utext )); | ||
113 | b. setPixmap ( Resource::loadPixmap ( ib->pix )); | ||
114 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); | ||
115 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); | ||
116 | |||
117 | d->m_buttons->append ( b ); | ||
118 | } | ||
119 | reloadButtonMapping(); | ||
120 | } | ||
121 | |||
122 | QValueList <OLed> GenuineIntel::ledList() const | ||
123 | { | ||
124 | QValueList <OLed> vl; | ||
125 | return vl; //none | ||
126 | } | ||
127 | |||
128 | QValueList <OLedState> GenuineIntel::ledStateList ( OLed ) const | ||
129 | { | ||
130 | QValueList <OLedState> vl; | ||
131 | return vl; // none | ||
132 | } | ||
133 | |||
134 | OLedState GenuineIntel::ledState ( OLed ) const | ||
135 | { | ||
136 | return Led_Off; | ||
137 | } | ||
138 | |||
139 | bool GenuineIntel::setLedState ( OLed , OLedState ) | ||
140 | { | ||
141 | return false; | ||
142 | } | ||
143 | |||
144 | |||
145 | bool GenuineIntel::filter ( int /*unicode*/, int , int , bool , bool ) | ||
146 | { | ||
147 | return false; | ||
148 | } | ||
149 | |||
150 | void GenuineIntel::playAlarmSound() | ||
151 | { | ||
152 | #ifndef QT_NO_SOUND | ||
153 | static Sound snd ( "alarm" ); | ||
154 | if(!snd.isFinished()) | ||
155 | return; | ||
156 | |||
157 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); | ||
158 | snd. play(); | ||
159 | #endif | ||
160 | } | ||
161 | |||
162 | |||
163 | bool GenuineIntel::setSoftSuspend ( bool ) | ||
164 | { | ||
165 | return false; | ||
166 | } | ||
167 | |||
168 | |||
169 | bool GenuineIntel::setDisplayBrightness ( int ) | ||
170 | { | ||
171 | return false; | ||
172 | } | ||
173 | |||
174 | int GenuineIntel::displayBrightnessResolution() const | ||
175 | { | ||
176 | return 1; // perhaps to avoid division by zero | ||
177 | } | ||
178 | |||
179 | |||
180 | bool GenuineIntel::hasLightSensor() const | ||
181 | { | ||
182 | return false; | ||
183 | } | ||
184 | |||
185 | int GenuineIntel::readLightSensor() | ||
186 | { | ||
187 | return 0; | ||
188 | } | ||
189 | |||
190 | int GenuineIntel::lightSensorResolution() const | ||
191 | { | ||
192 | return 1; // see above | ||
193 | } | ||
diff --git a/libopie2/opiecore/device/odevice_genuineintel.h b/libopie2/opiecore/device/odevice_genuineintel.h new file mode 100644 index 0000000..52c5fc6 --- a/dev/null +++ b/libopie2/opiecore/device/odevice_genuineintel.h | |||
@@ -0,0 +1,84 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
4 | =. | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | |||
30 | #ifndef ODEVICE_GENUINEINTEL | ||
31 | #define ODEVICE_GENUINEINTEL | ||
32 | |||
33 | #include "odevice.h" | ||
34 | |||
35 | /* QT */ | ||
36 | #include <qwindowsystem_qws.h> | ||
37 | |||
38 | namespace Opie { | ||
39 | namespace Core { | ||
40 | namespace Internal { | ||
41 | |||
42 | class GenuineIntel : public ODevice, public QWSServer::KeyboardFilter | ||
43 | { | ||
44 | |||
45 | protected: | ||
46 | virtual void init(const QString&); | ||
47 | virtual void initButtons(); | ||
48 | |||
49 | public: | ||
50 | virtual bool setSoftSuspend( bool soft ); | ||
51 | |||
52 | virtual bool setDisplayBrightness( int b ); | ||
53 | virtual int displayBrightnessResolution() const; | ||
54 | |||
55 | virtual void playAlarmSound(); | ||
56 | |||
57 | virtual QValueList <OLed> ledList() const; | ||
58 | virtual QValueList <OLedState> ledStateList( OLed led ) const; | ||
59 | virtual OLedState ledState( OLed led ) const; | ||
60 | virtual bool setLedState( OLed led, OLedState st ); | ||
61 | |||
62 | virtual bool hasLightSensor() const; | ||
63 | virtual int readLightSensor(); | ||
64 | virtual int lightSensorResolution() const; | ||
65 | protected: | ||
66 | virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | ||
67 | |||
68 | }; | ||
69 | |||
70 | struct gi_button { | ||
71 | Qt::Key code; | ||
72 | char *utext; | ||
73 | char *pix; | ||
74 | char *fpressedservice; | ||
75 | char *fpressedaction; | ||
76 | char *fheldservice; | ||
77 | char *fheldaction; | ||
78 | }; | ||
79 | |||
80 | } | ||
81 | } | ||
82 | } | ||
83 | |||
84 | #endif | ||