-rw-r--r-- | libopie2/opiecore/device/device.pro | 6 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice.h | 7 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_palm.cpp | 282 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_palm.h | 72 |
5 files changed, 367 insertions, 2 deletions
diff --git a/libopie2/opiecore/device/device.pro b/libopie2/opiecore/device/device.pro index b517032..2fd5ded 100644 --- a/libopie2/opiecore/device/device.pro +++ b/libopie2/opiecore/device/device.pro | |||
@@ -1,30 +1,32 @@ | |||
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_abstractmobiledevice.h \ |
4 | device/odevice_beagle.h \ | 4 | device/odevice_beagle.h \ |
5 | device/odevice_ipaq.h \ | 5 | device/odevice_ipaq.h \ |
6 | device/odevice_jornada.h \ | 6 | device/odevice_jornada.h \ |
7 | device/odevice_ramses.h \ | 7 | device/odevice_ramses.h \ |
8 | device/odevice_simpad.h \ | 8 | device/odevice_simpad.h \ |
9 | device/odevice_zaurus.h \ | 9 | device/odevice_zaurus.h \ |
10 | device/odevice_genuineintel.h \ | 10 | device/odevice_genuineintel.h \ |
11 | device/odevice_yopy.h \ | 11 | device/odevice_yopy.h \ |
12 | device/odevice_mypal.h \ | 12 | device/odevice_mypal.h \ |
13 | device/odevice_htc.h \ | 13 | device/odevice_htc.h \ |
14 | device/odevice_motorola_ezx.h | 14 | device/odevice_motorola_ezx.h \ |
15 | device/odevice_palm.h | ||
15 | 16 | ||
16 | SOURCES += device/odevice.cpp \ | 17 | SOURCES += device/odevice.cpp \ |
17 | device/odevicebutton.cpp \ | 18 | device/odevicebutton.cpp \ |
18 | device/odevice_abstractmobiledevice.cpp \ | 19 | device/odevice_abstractmobiledevice.cpp \ |
19 | device/odevice_beagle.cpp \ | 20 | device/odevice_beagle.cpp \ |
20 | device/odevice_ipaq.cpp \ | 21 | device/odevice_ipaq.cpp \ |
21 | device/odevice_jornada.cpp\ | 22 | device/odevice_jornada.cpp\ |
22 | device/odevice_ramses.cpp \ | 23 | device/odevice_ramses.cpp \ |
23 | device/odevice_simpad.cpp \ | 24 | device/odevice_simpad.cpp \ |
24 | device/odevice_zaurus.cpp \ | 25 | device/odevice_zaurus.cpp \ |
25 | device/odevice_genuineintel.cpp \ | 26 | device/odevice_genuineintel.cpp \ |
26 | device/odevice_yopy.cpp \ | 27 | device/odevice_yopy.cpp \ |
27 | device/odevice_mypal.cpp \ | 28 | device/odevice_mypal.cpp \ |
28 | device/odevice_htc.cpp \ | 29 | device/odevice_htc.cpp \ |
29 | device/odevice_motorola_ezx.cpp | 30 | device/odevice_motorola_ezx.cpp \ |
31 | device/odevice_palm.cpp | ||
30 | 32 | ||
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index 8f5be8b..e4233eb 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -1,246 +1,248 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. (C) 2002-2006 The Opie Team <opie-devel@handhelds.org> | 3 | =. (C) 2002-2006 The Opie Team <opie-devel@handhelds.org> |
4 | .=l. | 4 | .=l. |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; version 2 of the License. | 10 | - . .-<_> .<> Foundation; version 2 of the License. |
11 | ._= =} : | 11 | ._= =} : |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | 30 | ||
31 | #include "odevice_beagle.h" | 31 | #include "odevice_beagle.h" |
32 | #include "odevice_ipaq.h" | 32 | #include "odevice_ipaq.h" |
33 | #include "odevice_mypal.h" | 33 | #include "odevice_mypal.h" |
34 | #include "odevice_jornada.h" | 34 | #include "odevice_jornada.h" |
35 | #include "odevice_ramses.h" | 35 | #include "odevice_ramses.h" |
36 | #include "odevice_simpad.h" | 36 | #include "odevice_simpad.h" |
37 | #include "odevice_yopy.h" | 37 | #include "odevice_yopy.h" |
38 | #include "odevice_zaurus.h" | 38 | #include "odevice_zaurus.h" |
39 | #include "odevice_genuineintel.h" | 39 | #include "odevice_genuineintel.h" |
40 | #include "odevice_htc.h" | 40 | #include "odevice_htc.h" |
41 | #include "odevice_motorola_ezx.h" | 41 | #include "odevice_motorola_ezx.h" |
42 | #include "odevice_palm.h" | ||
42 | 43 | ||
43 | /* QT */ | 44 | /* QT */ |
44 | #include <qapplication.h> | 45 | #include <qapplication.h> |
45 | #include <qfile.h> | 46 | #include <qfile.h> |
46 | #include <qtextstream.h> | 47 | #include <qtextstream.h> |
47 | #include <qwindowsystem_qws.h> | 48 | #include <qwindowsystem_qws.h> |
48 | 49 | ||
49 | /* OPIE */ | 50 | /* OPIE */ |
50 | #include <qpe/config.h> | 51 | #include <qpe/config.h> |
51 | #include <qpe/sound.h> | 52 | #include <qpe/sound.h> |
52 | #include <qpe/qcopenvelope_qws.h> | 53 | #include <qpe/qcopenvelope_qws.h> |
53 | #include <qpe/sound.h> | 54 | #include <qpe/sound.h> |
54 | 55 | ||
55 | #include <opie2/okeyfilter.h> | 56 | #include <opie2/okeyfilter.h> |
56 | #include <opie2/oresource.h> | 57 | #include <opie2/oresource.h> |
57 | 58 | ||
58 | /* STD */ | 59 | /* STD */ |
59 | #include <fcntl.h> | 60 | #include <fcntl.h> |
60 | #include <math.h> | 61 | #include <math.h> |
61 | #include <stdlib.h> | 62 | #include <stdlib.h> |
62 | #include <signal.h> | 63 | #include <signal.h> |
63 | #include <sys/ioctl.h> | 64 | #include <sys/ioctl.h> |
64 | #include <sys/time.h> | 65 | #include <sys/time.h> |
65 | #include <unistd.h> | 66 | #include <unistd.h> |
66 | #ifndef QT_NO_SOUND | 67 | #ifndef QT_NO_SOUND |
67 | #include <linux/soundcard.h> | 68 | #include <linux/soundcard.h> |
68 | #endif | 69 | #endif |
69 | 70 | ||
70 | namespace Opie { | 71 | namespace Opie { |
71 | namespace Core { | 72 | namespace Core { |
72 | 73 | ||
73 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; | 74 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; |
74 | 75 | ||
75 | 76 | ||
76 | /* STATIC and common implementation */ | 77 | /* STATIC and common implementation */ |
77 | /* EXPORT */ ODistribution distributions[] = { | 78 | /* EXPORT */ ODistribution distributions[] = { |
78 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, | 79 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, |
79 | { System_OpenZaurus, "OpenZaurus", "/etc/openzaurus-version" }, | 80 | { System_OpenZaurus, "OpenZaurus", "/etc/openzaurus-version" }, |
80 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, | 81 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, |
81 | { System_Unknown, "Linux", "/etc/issue" }, | 82 | { System_Unknown, "Linux", "/etc/issue" }, |
82 | }; | 83 | }; |
83 | 84 | ||
84 | 85 | ||
85 | /* EXPORT */ bool isQWS(){ | 86 | /* EXPORT */ bool isQWS(){ |
86 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; | 87 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; |
87 | } | 88 | } |
88 | 89 | ||
89 | /* EXPORT */ QCString makeChannel ( const char *str ){ | 90 | /* EXPORT */ QCString makeChannel ( const char *str ){ |
90 | if ( str && !::strchr ( str, '/' )) | 91 | if ( str && !::strchr ( str, '/' )) |
91 | return QCString ( "QPE/Application/" ) + str; | 92 | return QCString ( "QPE/Application/" ) + str; |
92 | else | 93 | else |
93 | return str; | 94 | return str; |
94 | } | 95 | } |
95 | 96 | ||
96 | 97 | ||
97 | 98 | ||
98 | /* Now the default implementation of ODevice */ | 99 | /* Now the default implementation of ODevice */ |
99 | 100 | ||
100 | struct default_button default_buttons [] = { | 101 | struct default_button default_buttons [] = { |
101 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 102 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
102 | "devicebuttons/z_calendar", | 103 | "devicebuttons/z_calendar", |
103 | "datebook", "nextView()", | 104 | "datebook", "nextView()", |
104 | "today", "raise()" }, | 105 | "today", "raise()" }, |
105 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 106 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
106 | "devicebuttons/z_contact", | 107 | "devicebuttons/z_contact", |
107 | "addressbook", "raise()", | 108 | "addressbook", "raise()", |
108 | "addressbook", "beamBusinessCard()" }, | 109 | "addressbook", "beamBusinessCard()" }, |
109 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 110 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
110 | "devicebuttons/z_home", | 111 | "devicebuttons/z_home", |
111 | "QPE/Launcher", "home()", | 112 | "QPE/Launcher", "home()", |
112 | "buttonsettings", "raise()" }, | 113 | "buttonsettings", "raise()" }, |
113 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 114 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
114 | "devicebuttons/z_menu", | 115 | "devicebuttons/z_menu", |
115 | "QPE/TaskBar", "toggleMenu()", | 116 | "QPE/TaskBar", "toggleMenu()", |
116 | "QPE/TaskBar", "toggleStartMenu()" }, | 117 | "QPE/TaskBar", "toggleStartMenu()" }, |
117 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 118 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
118 | "devicebuttons/z_mail", | 119 | "devicebuttons/z_mail", |
119 | "opiemail", "raise()", | 120 | "opiemail", "raise()", |
120 | "opiemail", "newMail()" }, | 121 | "opiemail", "newMail()" }, |
121 | }; | 122 | }; |
122 | 123 | ||
123 | ODevice *ODevice::inst() | 124 | ODevice *ODevice::inst() |
124 | { | 125 | { |
125 | static ODevice *dev = 0; | 126 | static ODevice *dev = 0; |
126 | QString cpu_info; | 127 | QString cpu_info; |
127 | 128 | ||
128 | if ( !dev ) | 129 | if ( !dev ) |
129 | { | 130 | { |
130 | QFile f( PATH_PROC_CPUINFO ); | 131 | QFile f( PATH_PROC_CPUINFO ); |
131 | if ( f.open( IO_ReadOnly ) ) | 132 | if ( f.open( IO_ReadOnly ) ) |
132 | { | 133 | { |
133 | QTextStream s( &f ); | 134 | QTextStream s( &f ); |
134 | while ( !s.atEnd() ) | 135 | while ( !s.atEnd() ) |
135 | { | 136 | { |
136 | QString line; | 137 | QString line; |
137 | line = s.readLine(); | 138 | line = s.readLine(); |
138 | if ( line.startsWith( "Hardware" ) ) | 139 | if ( line.startsWith( "Hardware" ) ) |
139 | { | 140 | { |
140 | qDebug( "ODevice() - found '%s'", (const char*) line ); | 141 | qDebug( "ODevice() - found '%s'", (const char*) line ); |
141 | cpu_info = line; | 142 | cpu_info = line; |
142 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); | 143 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); |
143 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); | 144 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); |
144 | else if ( line.contains( "mypal", false ) ) dev = new Internal::MyPal(); | 145 | else if ( line.contains( "mypal", false ) ) dev = new Internal::MyPal(); |
145 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); | 146 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); |
146 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); | 147 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); |
147 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); | 148 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); |
148 | else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); | 149 | else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); |
149 | else if ( line.contains( "HTC", false ) ) dev = new Internal::HTC(); | 150 | else if ( line.contains( "HTC", false ) ) dev = new Internal::HTC(); |
150 | else if ( line.contains( "Motorola", false ) ) dev = new Internal::Motorola_EZX(); | 151 | else if ( line.contains( "Motorola", false ) ) dev = new Internal::Motorola_EZX(); |
152 | else if ( line.contains( "Palm", false ) ) dev = new Internal::Palm(); | ||
151 | 153 | ||
152 | else qWarning( "ODevice() - unknown hardware - using default." ); | 154 | else qWarning( "ODevice() - unknown hardware - using default." ); |
153 | break; | 155 | break; |
154 | } else if ( line.startsWith( "vendor_id" ) ) { | 156 | } else if ( line.startsWith( "vendor_id" ) ) { |
155 | qDebug( "ODevice() - found '%s'", (const char*) line ); | 157 | qDebug( "ODevice() - found '%s'", (const char*) line ); |
156 | cpu_info = line; | 158 | cpu_info = line; |
157 | if( line.contains( "genuineintel", false ) ) { | 159 | if( line.contains( "genuineintel", false ) ) { |
158 | dev = new Internal::GenuineIntel(); | 160 | dev = new Internal::GenuineIntel(); |
159 | break; | 161 | break; |
160 | } | 162 | } |
161 | } | 163 | } |
162 | } | 164 | } |
163 | } | 165 | } |
164 | else | 166 | else |
165 | { | 167 | { |
166 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); | 168 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); |
167 | } | 169 | } |
168 | if ( !dev ) dev = new ODevice(); | 170 | if ( !dev ) dev = new ODevice(); |
169 | dev->init(cpu_info); | 171 | dev->init(cpu_info); |
170 | } | 172 | } |
171 | return dev; | 173 | return dev; |
172 | } | 174 | } |
173 | 175 | ||
174 | ODevice::ODevice() | 176 | ODevice::ODevice() |
175 | { | 177 | { |
176 | d = new ODeviceData; | 178 | d = new ODeviceData; |
177 | 179 | ||
178 | d->m_modelstr = "Unknown"; | 180 | d->m_modelstr = "Unknown"; |
179 | d->m_model = Model_Unknown; | 181 | d->m_model = Model_Unknown; |
180 | d->m_vendorstr = "Unknown"; | 182 | d->m_vendorstr = "Unknown"; |
181 | d->m_vendor = Vendor_Unknown; | 183 | d->m_vendor = Vendor_Unknown; |
182 | d->m_systemstr = "Unknown"; | 184 | d->m_systemstr = "Unknown"; |
183 | d->m_system = System_Unknown; | 185 | d->m_system = System_Unknown; |
184 | d->m_sysverstr = "0.0"; | 186 | d->m_sysverstr = "0.0"; |
185 | d->m_rotation = Rot0; | 187 | d->m_rotation = Rot0; |
186 | d->m_direction = CW; | 188 | d->m_direction = CW; |
187 | d->m_qteDriver = "Transformed"; | 189 | d->m_qteDriver = "Transformed"; |
188 | 190 | ||
189 | d->m_holdtime = 1000; // 1000ms | 191 | d->m_holdtime = 1000; // 1000ms |
190 | d->m_buttons = 0; | 192 | d->m_buttons = 0; |
191 | d->m_cpu_frequencies = new QStrList; | 193 | d->m_cpu_frequencies = new QStrList; |
192 | 194 | ||
193 | 195 | ||
194 | /* mixer */ | 196 | /* mixer */ |
195 | d->m_sound = d->m_vol = d->m_mixer = -1; | 197 | d->m_sound = d->m_vol = d->m_mixer = -1; |
196 | 198 | ||
197 | /* System QCopChannel created */ | 199 | /* System QCopChannel created */ |
198 | d->m_initializedButtonQcop = false; | 200 | d->m_initializedButtonQcop = false; |
199 | 201 | ||
200 | // New distribution detection code first checks for legacy distributions, | 202 | // New distribution detection code first checks for legacy distributions, |
201 | // identified by /etc/familiar-version or /etc/oz_version. | 203 | // identified by /etc/familiar-version or /etc/oz_version. |
202 | // Then check for OpenEmbedded and lastly, read /etc/issue | 204 | // Then check for OpenEmbedded and lastly, read /etc/issue |
203 | 205 | ||
204 | for ( unsigned int i = 0; i < sizeof(distributions)/sizeof(ODistribution); ++i ) | 206 | for ( unsigned int i = 0; i < sizeof(distributions)/sizeof(ODistribution); ++i ) |
205 | { | 207 | { |
206 | if ( QFile::exists( distributions[i].sysvfile ) ) | 208 | if ( QFile::exists( distributions[i].sysvfile ) ) |
207 | { | 209 | { |
208 | d->m_systemstr = distributions[i].sysstr; | 210 | d->m_systemstr = distributions[i].sysstr; |
209 | d->m_system = distributions[i].system; | 211 | d->m_system = distributions[i].system; |
210 | d->m_sysverstr = "<Unknown>"; | 212 | d->m_sysverstr = "<Unknown>"; |
211 | QFile f( distributions[i].sysvfile ); | 213 | QFile f( distributions[i].sysvfile ); |
212 | if ( f.open( IO_ReadOnly ) ) | 214 | if ( f.open( IO_ReadOnly ) ) |
213 | { | 215 | { |
214 | QTextStream ts( &f ); | 216 | QTextStream ts( &f ); |
215 | d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); | 217 | d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); |
216 | } | 218 | } |
217 | break; | 219 | break; |
218 | } | 220 | } |
219 | } | 221 | } |
220 | } | 222 | } |
221 | 223 | ||
222 | void ODevice::systemMessage( const QCString &msg, const QByteArray & ) | 224 | void ODevice::systemMessage( const QCString &msg, const QByteArray & ) |
223 | { | 225 | { |
224 | if ( msg == "deviceButtonMappingChanged()" ) { | 226 | if ( msg == "deviceButtonMappingChanged()" ) { |
225 | reloadButtonMapping(); | 227 | reloadButtonMapping(); |
226 | } | 228 | } |
227 | } | 229 | } |
228 | 230 | ||
229 | void ODevice::init(const QString&) | 231 | void ODevice::init(const QString&) |
230 | { | 232 | { |
231 | } | 233 | } |
232 | 234 | ||
233 | /** | 235 | /** |
234 | * This method initialises the button mapping | 236 | * This method initialises the button mapping |
235 | */ | 237 | */ |
236 | void ODevice::initButtons() | 238 | void ODevice::initButtons() |
237 | { | 239 | { |
238 | if ( d->m_buttons ) | 240 | if ( d->m_buttons ) |
239 | return; | 241 | return; |
240 | 242 | ||
241 | qDebug ( "init Buttons" ); | 243 | qDebug ( "init Buttons" ); |
242 | d->m_buttons = new QValueList <ODeviceButton>; | 244 | d->m_buttons = new QValueList <ODeviceButton>; |
243 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { | 245 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { |
244 | default_button *db = default_buttons + i; | 246 | default_button *db = default_buttons + i; |
245 | ODeviceButton b; | 247 | ODeviceButton b; |
246 | b. setKeycode ( db->code ); | 248 | b. setKeycode ( db->code ); |
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h index a8362cd..1eb5959 100644 --- a/libopie2/opiecore/device/odevice.h +++ b/libopie2/opiecore/device/odevice.h | |||
@@ -45,210 +45,217 @@ | |||
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 = 0xffff0000, | 59 | Model_Series_Mask = 0xffff0000, |
60 | 60 | ||
61 | Model_iPAQ = ( 1 << 16 ), | 61 | Model_iPAQ = ( 1 << 16 ), |
62 | 62 | ||
63 | Model_iPAQ_All = ( Model_iPAQ | 0xffff ), | 63 | Model_iPAQ_All = ( Model_iPAQ | 0xffff ), |
64 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x0001 ), | 64 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x0001 ), |
65 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x0002 ), | 65 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x0002 ), |
66 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x0003 ), | 66 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x0003 ), |
67 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x0004 ), | 67 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x0004 ), |
68 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x0005 ), | 68 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x0005 ), |
69 | Model_iPAQ_H5xxx = ( Model_iPAQ | 0x0006 ), | 69 | Model_iPAQ_H5xxx = ( Model_iPAQ | 0x0006 ), |
70 | Model_iPAQ_H22xx = ( Model_iPAQ | 0x0007 ), | 70 | Model_iPAQ_H22xx = ( Model_iPAQ | 0x0007 ), |
71 | Model_iPAQ_H191x = ( Model_iPAQ | 0x0008 ), | 71 | Model_iPAQ_H191x = ( Model_iPAQ | 0x0008 ), |
72 | Model_iPAQ_H1940 = ( Model_iPAQ | 0x0009 ), | 72 | Model_iPAQ_H1940 = ( Model_iPAQ | 0x0009 ), |
73 | Model_iPAQ_HX4700 = ( Model_iPAQ | 0x000A ), | 73 | Model_iPAQ_HX4700 = ( Model_iPAQ | 0x000A ), |
74 | Model_iPAQ_H4xxx = ( Model_iPAQ | 0x000b ), | 74 | Model_iPAQ_H4xxx = ( Model_iPAQ | 0x000b ), |
75 | Model_Jornada = ( 6 << 16 ), | 75 | Model_Jornada = ( 6 << 16 ), |
76 | Model_Jornada_56x = ( Model_Jornada | 0x0001 ), | 76 | Model_Jornada_56x = ( Model_Jornada | 0x0001 ), |
77 | Model_Jornada_720 = ( Model_Jornada | 0x0002 ), | 77 | Model_Jornada_720 = ( Model_Jornada | 0x0002 ), |
78 | Model_Jornada_820 = ( Model_Jornada | 0x0003 ), | 78 | Model_Jornada_820 = ( Model_Jornada | 0x0003 ), |
79 | 79 | ||
80 | Model_Zaurus = ( 2 << 16 ), | 80 | Model_Zaurus = ( 2 << 16 ), |
81 | 81 | ||
82 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x0001 ), | 82 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x0001 ), |
83 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x0002 ), | 83 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x0002 ), |
84 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x0003 ), | 84 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x0003 ), |
85 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x0004 ), | 85 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x0004 ), |
86 | Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x0005 ), | 86 | Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x0005 ), |
87 | Model_Zaurus_SL6000 = ( Model_Zaurus | 0x0006 ), | 87 | Model_Zaurus_SL6000 = ( Model_Zaurus | 0x0006 ), |
88 | Model_Zaurus_SLC3000 = ( Model_Zaurus | 0x0007 ), | 88 | Model_Zaurus_SLC3000 = ( Model_Zaurus | 0x0007 ), |
89 | Model_Zaurus_SLC1000 = ( Model_Zaurus | 0x0008 ), | 89 | Model_Zaurus_SLC1000 = ( Model_Zaurus | 0x0008 ), |
90 | Model_Zaurus_SLC3100 = ( Model_Zaurus | 0x0009 ), | 90 | Model_Zaurus_SLC3100 = ( Model_Zaurus | 0x0009 ), |
91 | 91 | ||
92 | Model_SIMpad = ( 3 << 16 ), | 92 | Model_SIMpad = ( 3 << 16 ), |
93 | 93 | ||
94 | Model_SIMpad_All = ( Model_SIMpad | 0xffff ), | 94 | Model_SIMpad_All = ( Model_SIMpad | 0xffff ), |
95 | Model_SIMpad_CL4 = ( Model_SIMpad | 0x0001 ), | 95 | Model_SIMpad_CL4 = ( Model_SIMpad | 0x0001 ), |
96 | Model_SIMpad_SL4 = ( Model_SIMpad | 0x0002 ), | 96 | Model_SIMpad_SL4 = ( Model_SIMpad | 0x0002 ), |
97 | Model_SIMpad_SLC = ( Model_SIMpad | 0x0003 ), | 97 | Model_SIMpad_SLC = ( Model_SIMpad | 0x0003 ), |
98 | Model_SIMpad_TSinus = ( Model_SIMpad | 0x0004 ), | 98 | Model_SIMpad_TSinus = ( Model_SIMpad | 0x0004 ), |
99 | 99 | ||
100 | Model_Ramses = ( 4 << 16 ), | 100 | Model_Ramses = ( 4 << 16 ), |
101 | 101 | ||
102 | Model_Ramses_All = ( Model_Ramses | 0xffff ), | 102 | Model_Ramses_All = ( Model_Ramses | 0xffff ), |
103 | Model_Ramses_MNCI = ( Model_Ramses | 0x0001 ), | 103 | Model_Ramses_MNCI = ( Model_Ramses | 0x0001 ), |
104 | Model_Ramses_MNCIRX = ( Model_Ramses | 0x0002 ), | 104 | Model_Ramses_MNCIRX = ( Model_Ramses | 0x0002 ), |
105 | 105 | ||
106 | Model_Yopy = ( 5 << 16 ), | 106 | Model_Yopy = ( 5 << 16 ), |
107 | 107 | ||
108 | Model_Yopy_All = ( Model_Yopy | 0xffff ), | 108 | Model_Yopy_All = ( Model_Yopy | 0xffff ), |
109 | Model_Yopy_3000 = ( Model_Yopy | 0x0001 ), | 109 | Model_Yopy_3000 = ( Model_Yopy | 0x0001 ), |
110 | Model_Yopy_3500 = ( Model_Yopy | 0x0002 ), | 110 | Model_Yopy_3500 = ( Model_Yopy | 0x0002 ), |
111 | Model_Yopy_3700 = ( Model_Yopy | 0x0003 ), | 111 | Model_Yopy_3700 = ( Model_Yopy | 0x0003 ), |
112 | 112 | ||
113 | Model_Beagle = ( 6 << 16 ), | 113 | Model_Beagle = ( 6 << 16 ), |
114 | 114 | ||
115 | Model_Beagle_All = ( Model_Beagle | 0xffff ), | 115 | Model_Beagle_All = ( Model_Beagle | 0xffff ), |
116 | Model_Beagle_PA100 = ( Model_Beagle | 0x0001 ), | 116 | Model_Beagle_PA100 = ( Model_Beagle | 0x0001 ), |
117 | 117 | ||
118 | Model_GenuineIntel = ( 7 << 16 ), | 118 | Model_GenuineIntel = ( 7 << 16 ), |
119 | 119 | ||
120 | Model_MyPal = ( 8 << 16 ), | 120 | Model_MyPal = ( 8 << 16 ), |
121 | 121 | ||
122 | Model_MyPal_All = ( Model_MyPal | 0xffff ), | 122 | Model_MyPal_All = ( Model_MyPal | 0xffff ), |
123 | Model_MyPal_620 = ( Model_MyPal | 0x0001 ), | 123 | Model_MyPal_620 = ( Model_MyPal | 0x0001 ), |
124 | Model_MyPal_716 = ( Model_MyPal | 0x0002 ), | 124 | Model_MyPal_716 = ( Model_MyPal | 0x0002 ), |
125 | Model_MyPal_730 = ( Model_MyPal | 0x0003 ), | 125 | Model_MyPal_730 = ( Model_MyPal | 0x0003 ), |
126 | 126 | ||
127 | Model_HTC = ( 9 << 16 ), | 127 | Model_HTC = ( 9 << 16 ), |
128 | Model_HTC_All = ( Model_HTC | 0xffff ), | 128 | Model_HTC_All = ( Model_HTC | 0xffff ), |
129 | Model_HTC_Universal = ( Model_HTC | 0x0001 ), | 129 | Model_HTC_Universal = ( Model_HTC | 0x0001 ), |
130 | Model_HTC_Alpine = ( Model_HTC | 0x0002 ), | 130 | Model_HTC_Alpine = ( Model_HTC | 0x0002 ), |
131 | Model_HTC_Apache = ( Model_HTC | 0x0003 ), | 131 | Model_HTC_Apache = ( Model_HTC | 0x0003 ), |
132 | Model_HTC_Beetles = ( Model_HTC | 0x0004 ), | 132 | Model_HTC_Beetles = ( Model_HTC | 0x0004 ), |
133 | Model_HTC_Blueangel = ( Model_HTC | 0x0005 ), | 133 | Model_HTC_Blueangel = ( Model_HTC | 0x0005 ), |
134 | Model_HTC_Himalaya = ( Model_HTC | 0x0006 ), | 134 | Model_HTC_Himalaya = ( Model_HTC | 0x0006 ), |
135 | Model_HTC_Magician = ( Model_HTC | 0x0007 ), | 135 | Model_HTC_Magician = ( Model_HTC | 0x0007 ), |
136 | 136 | ||
137 | Model_Motorola = ( 9 << 17 ), | 137 | Model_Motorola = ( 9 << 17 ), |
138 | Model_Motorola_All = ( Model_Motorola | 0xffff ), | 138 | Model_Motorola_All = ( Model_Motorola | 0xffff ), |
139 | Model_Motorola_EZX = ( Model_Motorola | 0x0001 ), | 139 | Model_Motorola_EZX = ( Model_Motorola | 0x0001 ), |
140 | 140 | ||
141 | Model_Palm = ( 10 << 16), | ||
142 | Model_Palm_All = ( Model_Palm | 0xffff ), | ||
143 | Model_Palm_LD = ( Model_Palm | 0x0001 ), | ||
144 | Model_Palm_TX = ( Model_Palm | 0x0002 ), | ||
145 | Model_Palm_Z72 = ( Model_Palm | 0x0003 ), | ||
146 | |||
141 | }; | 147 | }; |
142 | 148 | ||
143 | /** | 149 | /** |
144 | * The vendor of the device | 150 | * The vendor of the device |
145 | */ | 151 | */ |
146 | enum OVendor { | 152 | enum OVendor { |
147 | Vendor_Unknown, | 153 | Vendor_Unknown, |
148 | 154 | ||
149 | Vendor_HP, | 155 | Vendor_HP, |
150 | Vendor_Sharp, | 156 | Vendor_Sharp, |
151 | Vendor_SIEMENS, | 157 | Vendor_SIEMENS, |
152 | Vendor_MundN, | 158 | Vendor_MundN, |
153 | Vendor_GMate, | 159 | Vendor_GMate, |
154 | Vendor_MasterIA, | 160 | Vendor_MasterIA, |
155 | Vendor_GenuineIntel, | 161 | Vendor_GenuineIntel, |
156 | Vendor_Asus, | 162 | Vendor_Asus, |
157 | Vendor_HTC, | 163 | Vendor_HTC, |
158 | Vendor_Motorola, | 164 | Vendor_Motorola, |
165 | Vendor_Palm, | ||
159 | }; | 166 | }; |
160 | 167 | ||
161 | /** | 168 | /** |
162 | * The System used | 169 | * The System used |
163 | */ | 170 | */ |
164 | enum OSystem { | 171 | enum OSystem { |
165 | System_Unknown, | 172 | System_Unknown, |
166 | 173 | ||
167 | System_Familiar, | 174 | System_Familiar, |
168 | System_Zaurus, | 175 | System_Zaurus, |
169 | System_OpenZaurus, | 176 | System_OpenZaurus, |
170 | System_Linupy, | 177 | System_Linupy, |
171 | System_OpenEmbedded, | 178 | System_OpenEmbedded, |
172 | System_PC, | 179 | System_PC, |
173 | System_OpenEZX, | 180 | System_OpenEZX, |
174 | System_Angstrom, | 181 | System_Angstrom, |
175 | }; | 182 | }; |
176 | 183 | ||
177 | typedef struct { | 184 | typedef struct { |
178 | OSystem system; | 185 | OSystem system; |
179 | char* sysstr; | 186 | char* sysstr; |
180 | char* sysvfile; | 187 | char* sysvfile; |
181 | } ODistribution; | 188 | } ODistribution; |
182 | 189 | ||
183 | extern ODistribution distributions[]; | 190 | extern ODistribution distributions[]; |
184 | 191 | ||
185 | 192 | ||
186 | enum OLedState { | 193 | enum OLedState { |
187 | Led_Off, | 194 | Led_Off, |
188 | Led_On, | 195 | Led_On, |
189 | Led_BlinkSlow, | 196 | Led_BlinkSlow, |
190 | Led_BlinkFast | 197 | Led_BlinkFast |
191 | }; | 198 | }; |
192 | 199 | ||
193 | enum OLed { | 200 | enum OLed { |
194 | Led_Mail, | 201 | Led_Mail, |
195 | Led_Power, | 202 | Led_Power, |
196 | Led_BlueTooth | 203 | Led_BlueTooth |
197 | }; | 204 | }; |
198 | 205 | ||
199 | enum OHardKey { | 206 | enum OHardKey { |
200 | HardKey_Datebook = Qt::Key_F9, | 207 | HardKey_Datebook = Qt::Key_F9, |
201 | HardKey_Contacts = Qt::Key_F10, | 208 | HardKey_Contacts = Qt::Key_F10, |
202 | HardKey_Menu = Qt::Key_F11, | 209 | HardKey_Menu = Qt::Key_F11, |
203 | HardKey_Home = Qt::Key_F12, | 210 | HardKey_Home = Qt::Key_F12, |
204 | HardKey_Mail = Qt::Key_F13, | 211 | HardKey_Mail = Qt::Key_F13, |
205 | HardKey_Record = Qt::Key_F24, | 212 | HardKey_Record = Qt::Key_F24, |
206 | HardKey_Suspend = Qt::Key_F34, | 213 | HardKey_Suspend = Qt::Key_F34, |
207 | HardKey_Backlight = Qt::Key_F35, | 214 | HardKey_Backlight = Qt::Key_F35, |
208 | HardKey_Action = Qt::Key_F10, | 215 | HardKey_Action = Qt::Key_F10, |
209 | HardKey_OK = Qt::Key_F11, | 216 | HardKey_OK = Qt::Key_F11, |
210 | HardKey_End = Qt::Key_F12, | 217 | HardKey_End = Qt::Key_F12, |
211 | }; | 218 | }; |
212 | 219 | ||
213 | enum ODirection { | 220 | enum ODirection { |
214 | CW = 0, | 221 | CW = 0, |
215 | CCW = 1, | 222 | CCW = 1, |
216 | Flip = 2, | 223 | Flip = 2, |
217 | }; | 224 | }; |
218 | 225 | ||
219 | enum OHingeStatus { | 226 | enum OHingeStatus { |
220 | CASE_CLOSED = 3, | 227 | CASE_CLOSED = 3, |
221 | CASE_PORTRAIT = 2, | 228 | CASE_PORTRAIT = 2, |
222 | CASE_LANDSCAPE = 0, | 229 | CASE_LANDSCAPE = 0, |
223 | CASE_UNKNOWN = 1, | 230 | CASE_UNKNOWN = 1, |
224 | }; | 231 | }; |
225 | 232 | ||
226 | /* default button for qvfb or such | 233 | /* default button for qvfb or such |
227 | * see odevice.cpp for details. | 234 | * see odevice.cpp for details. |
228 | * hint: manage a user defined button for qvfb? | 235 | * hint: manage a user defined button for qvfb? |
229 | * alwin | 236 | * alwin |
230 | */ | 237 | */ |
231 | struct default_button { | 238 | struct default_button { |
232 | Qt::Key code; | 239 | Qt::Key code; |
233 | char *utext; | 240 | char *utext; |
234 | char *pix; | 241 | char *pix; |
235 | char *fpressedservice; | 242 | char *fpressedservice; |
236 | char *fpressedaction; | 243 | char *fpressedaction; |
237 | char *fheldservice; | 244 | char *fheldservice; |
238 | char *fheldaction; | 245 | char *fheldaction; |
239 | }; | 246 | }; |
240 | 247 | ||
241 | /** | 248 | /** |
242 | * A singleton which gives informations about device specefic option | 249 | * A singleton which gives informations about device specefic option |
243 | * like the Hardware used, LEDs, the Base Distribution and | 250 | * like the Hardware used, LEDs, the Base Distribution and |
244 | * hardware key mappings. | 251 | * hardware key mappings. |
245 | * | 252 | * |
246 | * @short A small class for device specific options | 253 | * @short A small class for device specific options |
247 | * @see QObject | 254 | * @see QObject |
248 | * @author Robert Griebl | 255 | * @author Robert Griebl |
249 | * @version 1.0 | 256 | * @version 1.0 |
250 | */ | 257 | */ |
251 | class ODevice : public QObject | 258 | class ODevice : public QObject |
252 | { | 259 | { |
253 | Q_OBJECT | 260 | Q_OBJECT |
254 | 261 | ||
diff --git a/libopie2/opiecore/device/odevice_palm.cpp b/libopie2/opiecore/device/odevice_palm.cpp new file mode 100644 index 0000000..76399f8 --- a/dev/null +++ b/libopie2/opiecore/device/odevice_palm.cpp | |||
@@ -0,0 +1,282 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org> | ||
5 | =. | ||
6 | .=l. | ||
7 | .>+-= | ||
8 | _;:, .> :=|. This program is free software; you can | ||
9 | .> <`_, > . <= redistribute it and/or modify it under | ||
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
11 | .="- .-=="i, .._ License as published by the Free Software | ||
12 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
13 | ._= =} : or (at your option) any later version. | ||
14 | .%`+i> _;_. | ||
15 | .i_,=:_. -<s. This program is distributed in the hope that | ||
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
17 | : .. .:, . . . without even the implied warranty of | ||
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | */ | ||
30 | |||
31 | #include "odevice_palm.h" | ||
32 | |||
33 | /* QT */ | ||
34 | #include <qapplication.h> | ||
35 | #include <qfile.h> | ||
36 | #include <qtextstream.h> | ||
37 | #include <qwindowsystem_qws.h> | ||
38 | #include <qgfx_qws.h> | ||
39 | |||
40 | /* OPIE */ | ||
41 | #include <qpe/config.h> | ||
42 | #include <qpe/sound.h> | ||
43 | #include <qpe/qcopenvelope_qws.h> | ||
44 | |||
45 | #include <opie2/okeyfilter.h> | ||
46 | #include <opie2/oresource.h> | ||
47 | |||
48 | /* STD */ | ||
49 | #include <fcntl.h> | ||
50 | #include <math.h> | ||
51 | #include <stdlib.h> | ||
52 | #include <signal.h> | ||
53 | #include <sys/ioctl.h> | ||
54 | #include <sys/time.h> | ||
55 | #include <unistd.h> | ||
56 | #ifndef QT_NO_SOUND | ||
57 | #include <linux/soundcard.h> | ||
58 | #endif | ||
59 | |||
60 | using namespace Opie::Core; | ||
61 | using namespace Opie::Core::Internal; | ||
62 | |||
63 | struct palm_button palm_buttons [] = { | ||
64 | { Model_Palm_TX | Model_Palm_LD | Model_Palm_Z72, | ||
65 | Qt::Key_F9, QT_TRANSLATE_NOOP( "Button", "Home Button" ), | ||
66 | "devicebuttons/palm_home", | ||
67 | "QPE/Launcher", "home()", | ||
68 | "buttonsettings", "raise()" }, | ||
69 | { Model_Palm_TX | Model_Palm_LD | Model_Palm_Z72, | ||
70 | Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Calendar Button" ), | ||
71 | "devicebuttons/palm_calendar", | ||
72 | "datebook", "nextView()", | ||
73 | "today", "raise()" }, | ||
74 | { Model_Palm_TX | Model_Palm_LD | Model_Palm_Z72, | ||
75 | Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "Todo Button" ), | ||
76 | "devicebuttons/palm_todo", | ||
77 | "todolist", "raise()", | ||
78 | "todolist", "create()" }, | ||
79 | { Model_Palm_TX | Model_Palm_LD | Model_Palm_Z72, | ||
80 | Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "Mail Button" ), | ||
81 | "devicebuttons/palm_mail", | ||
82 | "opiemail", "raise()", | ||
83 | "opiemail", "newmail()" }, | ||
84 | { Model_Palm_LD, | ||
85 | Qt::Key_F7, QT_TRANSLATE_NOOP( "Button", "Voice Memo Button" ), | ||
86 | "devicebuttons/palm_voice_memo", | ||
87 | "QPE/TaskBar", "toggleMenu()", | ||
88 | "QPE/TaskBar", "toggleStartMenu()" }, | ||
89 | { Model_Palm_LD, | ||
90 | Qt::Key_F8, QT_TRANSLATE_NOOP( "Button", "Rotate Button" ), | ||
91 | "devicebuttons/palm_rotate", | ||
92 | "QPE/Rotation", "flip()",0}, | ||
93 | }; | ||
94 | |||
95 | void Palm::init(const QString& cpu_info) | ||
96 | { | ||
97 | d->m_vendorstr = "Palm"; | ||
98 | d->m_vendor = Vendor_Palm; | ||
99 | |||
100 | QString model = "unknown"; | ||
101 | |||
102 | int loc = cpu_info.find( ":" ); | ||
103 | if ( loc != -1 ) | ||
104 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | ||
105 | else | ||
106 | model = cpu_info; | ||
107 | |||
108 | if ( model == "Palm LifeDrive" ) { | ||
109 | d->m_modelstr = "Palm LifeDrive"; | ||
110 | d->m_model = Model_Palm_LD; | ||
111 | } | ||
112 | else if ( model == "Palm TX" ) { | ||
113 | d->m_modelstr = "Palm TX"; | ||
114 | d->m_model = Model_Palm_TX; | ||
115 | } | ||
116 | else if ( model == "Palm Zire 72" ) { | ||
117 | d->m_modelstr = "Palm Zire 72"; | ||
118 | d->m_model = Model_Palm_Z72; | ||
119 | } | ||
120 | else | ||
121 | d->m_model = Model_Unknown; | ||
122 | |||
123 | switch ( d->m_model ) | ||
124 | { | ||
125 | case Model_Palm_LD: | ||
126 | case Model_Palm_TX: | ||
127 | case Model_Palm_Z72: | ||
128 | m_backlightdev = "/sys/class/backlight/pxapwm-bl/"; | ||
129 | d->m_rotation = Rot0; | ||
130 | d->m_direction = CCW; | ||
131 | d->m_qteDriver = "Transformed"; | ||
132 | break; | ||
133 | default: | ||
134 | m_backlightdev = ""; | ||
135 | } | ||
136 | |||
137 | } | ||
138 | |||
139 | |||
140 | void Palm::initButtons() | ||
141 | { | ||
142 | |||
143 | if ( d->m_buttons ) | ||
144 | return ; | ||
145 | |||
146 | if ( isQWS( ) ) { | ||
147 | addPreHandler(this); | ||
148 | } | ||
149 | |||
150 | d->m_buttons = new QValueList <ODeviceButton>; | ||
151 | |||
152 | for ( uint i = 0; i < ( sizeof( palm_buttons ) / sizeof( palm_button ) ); i++ ) | ||
153 | { | ||
154 | palm_button *ib = palm_buttons + i; | ||
155 | ODeviceButton b; | ||
156 | |||
157 | if (( ib->model & d->m_model ) == d->m_model ) { | ||
158 | b. setKeycode ( ib->code ); | ||
159 | b. setUserText ( QObject::tr ( "Button", ib->utext )); | ||
160 | b. setPixmap ( OResource::loadPixmap ( ib->pix )); | ||
161 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); | ||
162 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); | ||
163 | |||
164 | d->m_buttons->append ( b ); | ||
165 | } | ||
166 | } | ||
167 | reloadButtonMapping(); | ||
168 | } | ||
169 | |||
170 | |||
171 | bool Palm::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | ||
172 | { | ||
173 | int newkeycode = keycode; | ||
174 | |||
175 | if (qt_screen->transformOrientation() != Rot0){ | ||
176 | |||
177 | switch ( keycode ) { | ||
178 | case Key_Left : | ||
179 | case Key_Right: | ||
180 | case Key_Up : | ||
181 | case Key_Down : | ||
182 | newkeycode = Key_Left + ( keycode - Key_Left + (int) qt_screen->transformOrientation() ) % 4; | ||
183 | default: | ||
184 | break; | ||
185 | } | ||
186 | |||
187 | if (newkeycode!=keycode) { | ||
188 | if ( newkeycode != Key_unknown ) { | ||
189 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | ||
190 | } | ||
191 | return true; | ||
192 | } | ||
193 | |||
194 | } | ||
195 | |||
196 | return false; | ||
197 | } | ||
198 | |||
199 | |||
200 | bool Palm::suspend() | ||
201 | { | ||
202 | // some Palms do not implement their own power management at the moment. | ||
203 | |||
204 | bool res = false; | ||
205 | |||
206 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | ||
207 | return false; | ||
208 | |||
209 | switch ( d->m_model ) { | ||
210 | case Model_Palm_LD: | ||
211 | case Model_Palm_Z72: | ||
212 | { | ||
213 | QCopChannel::send( "QPE/System", "aboutToSuspend()" ); | ||
214 | |||
215 | ::sync(); // flush fs caches | ||
216 | res = ( ::system ( "apm --suspend" ) == 0 ); | ||
217 | |||
218 | QCopChannel::send( "QPE/System", "returnFromSuspend()" ); | ||
219 | } | ||
220 | break; | ||
221 | } | ||
222 | |||
223 | return res; | ||
224 | } | ||
225 | |||
226 | |||
227 | int Palm::displayBrightnessResolution() const | ||
228 | { | ||
229 | int res = 1; | ||
230 | |||
231 | switch ( d->m_model ) | ||
232 | { | ||
233 | case Model_Palm_LD: | ||
234 | case Model_Palm_TX: | ||
235 | case Model_Palm_Z72: | ||
236 | int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); | ||
237 | if ( fd ) | ||
238 | { | ||
239 | char buf[100]; | ||
240 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); | ||
241 | ::close( fd ); | ||
242 | } | ||
243 | break; | ||
244 | |||
245 | default: | ||
246 | res = 1; | ||
247 | } | ||
248 | |||
249 | return res; | ||
250 | } | ||
251 | |||
252 | |||
253 | bool Palm::setDisplayBrightness( int bright ) | ||
254 | { | ||
255 | bool res = false; | ||
256 | |||
257 | if ( bright > 255 ) bright = 255; | ||
258 | if ( bright < 0 ) bright = 0; | ||
259 | |||
260 | int numberOfSteps = displayBrightnessResolution(); | ||
261 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; | ||
262 | |||
263 | switch ( d->m_model ) | ||
264 | { | ||
265 | |||
266 | case Model_Palm_LD: | ||
267 | case Model_Palm_TX: | ||
268 | case Model_Palm_Z72: | ||
269 | int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); | ||
270 | if ( fd ) | ||
271 | { | ||
272 | char buf[100]; | ||
273 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); | ||
274 | res = ( ::write( fd, &buf[0], len ) == 0 ); | ||
275 | ::close( fd ); | ||
276 | } | ||
277 | break; | ||
278 | |||
279 | default: res = false; | ||
280 | } | ||
281 | return res; | ||
282 | } | ||
diff --git a/libopie2/opiecore/device/odevice_palm.h b/libopie2/opiecore/device/odevice_palm.h new file mode 100644 index 0000000..3ce786c --- a/dev/null +++ b/libopie2/opiecore/device/odevice_palm.h | |||
@@ -0,0 +1,72 @@ | |||
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_PALM | ||
31 | #define ODEVICE_PALM | ||
32 | |||
33 | #include "odevice_abstractmobiledevice.h" | ||
34 | |||
35 | namespace Opie { | ||
36 | namespace Core { | ||
37 | namespace Internal { | ||
38 | class Palm : public OAbstractMobileDevice, public QWSServer::KeyboardFilter | ||
39 | { | ||
40 | protected: | ||
41 | |||
42 | virtual void init(const QString&); | ||
43 | virtual void initButtons(); | ||
44 | virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | ||
45 | |||
46 | QString m_backlightdev; | ||
47 | |||
48 | public: | ||
49 | virtual bool suspend(); | ||
50 | |||
51 | virtual bool setDisplayBrightness ( int b ); | ||
52 | virtual int displayBrightnessResolution() const; | ||
53 | |||
54 | }; | ||
55 | |||
56 | struct palm_button | ||
57 | { | ||
58 | uint model; | ||
59 | Qt::Key code; | ||
60 | char *utext; | ||
61 | char *pix; | ||
62 | char *fpressedservice; | ||
63 | char *fpressedaction; | ||
64 | char *fheldservice; | ||
65 | char *fheldaction; | ||
66 | }; | ||
67 | |||
68 | } | ||
69 | } | ||
70 | } | ||
71 | |||
72 | #endif | ||