author | zecke <zecke> | 2004-09-17 21:51:47 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-17 21:51:47 (UTC) |
commit | 5a0986abc76a695a4262b75219a29ea983cf19c8 (patch) (unidiff) | |
tree | 3e5a98bce5f07fc6c7edf9dc8b26aee5ec2098cc | |
parent | a7d6af0d9a4f06dc5e27844f74212806387ce218 (diff) | |
download | opie-5a0986abc76a695a4262b75219a29ea983cf19c8.zip opie-5a0986abc76a695a4262b75219a29ea983cf19c8.tar.gz opie-5a0986abc76a695a4262b75219a29ea983cf19c8.tar.bz2 |
First untested support for the beagle from MasterIA
-rw-r--r-- | libopie2/opiecore/device/device.pro | 6 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 3 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_beagle.cpp | 156 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_beagle.h | 62 |
4 files changed, 225 insertions, 2 deletions
diff --git a/libopie2/opiecore/device/device.pro b/libopie2/opiecore/device/device.pro index 946bff1..87a3fd8 100644 --- a/libopie2/opiecore/device/device.pro +++ b/libopie2/opiecore/device/device.pro | |||
@@ -1,19 +1,23 @@ | |||
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_ipaq.h \ | 4 | device/odevice_ipaq.h \ |
4 | device/odevice_jornada.h \ | 5 | device/odevice_jornada.h \ |
5 | device/odevice_ramses.h \ | 6 | device/odevice_ramses.h \ |
6 | device/odevice_simpad.h \ | 7 | device/odevice_simpad.h \ |
7 | device/odevice_zaurus.h \ | 8 | device/odevice_zaurus.h \ |
8 | device/odevice_yopy.h \ | 9 | device/odevice_yopy.h \ |
10 | device/odevice_beagle.h | ||
9 | 11 | ||
10 | SOURCES += device/odevice.cpp \ | 12 | SOURCES += device/odevice.cpp \ |
11 | device/odevicebutton.cpp \ | 13 | device/odevicebutton.cpp \ |
14 | device/odevice_beagle.cpp \ | ||
12 | device/odevice_ipaq.cpp \ | 15 | device/odevice_ipaq.cpp \ |
13 | device/odevice_jornada.cpp\ | 16 | device/odevice_jornada.cpp\ |
14 | device/odevice_ramses.cpp \ | 17 | device/odevice_ramses.cpp \ |
15 | device/odevice_simpad.cpp \ | 18 | device/odevice_simpad.cpp \ |
16 | device/odevice_zaurus.cpp \ | 19 | device/odevice_zaurus.cpp \ |
17 | device/odevice_yopy.cpp \ | 20 | device/odevice_yopy.cpp |
21 | |||
18 | 22 | ||
19 | 23 | ||
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index 2355621..2b10034 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -1,653 +1,654 @@ | |||
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_ipaq.h" | 31 | #include "odevice_ipaq.h" |
31 | #include "odevice_jornada.h" | 32 | #include "odevice_jornada.h" |
32 | #include "odevice_ramses.h" | 33 | #include "odevice_ramses.h" |
33 | #include "odevice_simpad.h" | 34 | #include "odevice_simpad.h" |
34 | #include "odevice_yopy.h" | 35 | #include "odevice_yopy.h" |
35 | #include "odevice_zaurus.h" | 36 | #include "odevice_zaurus.h" |
36 | 37 | ||
37 | /* QT */ | 38 | /* QT */ |
38 | #include <qapplication.h> | 39 | #include <qapplication.h> |
39 | #include <qfile.h> | 40 | #include <qfile.h> |
40 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
41 | #include <qwindowsystem_qws.h> | 42 | #include <qwindowsystem_qws.h> |
42 | 43 | ||
43 | /* OPIE */ | 44 | /* OPIE */ |
44 | #include <qpe/config.h> | 45 | #include <qpe/config.h> |
45 | #include <qpe/resource.h> | 46 | #include <qpe/resource.h> |
46 | #include <qpe/sound.h> | 47 | #include <qpe/sound.h> |
47 | #include <qpe/qcopenvelope_qws.h> | 48 | #include <qpe/qcopenvelope_qws.h> |
48 | #include <qpe/sound.h> | 49 | #include <qpe/sound.h> |
49 | #include <opie2/okeyfilter.h> | 50 | #include <opie2/okeyfilter.h> |
50 | 51 | ||
51 | /* STD */ | 52 | /* STD */ |
52 | #include <fcntl.h> | 53 | #include <fcntl.h> |
53 | #include <math.h> | 54 | #include <math.h> |
54 | #include <stdlib.h> | 55 | #include <stdlib.h> |
55 | #include <signal.h> | 56 | #include <signal.h> |
56 | #include <sys/ioctl.h> | 57 | #include <sys/ioctl.h> |
57 | #include <sys/time.h> | 58 | #include <sys/time.h> |
58 | #include <unistd.h> | 59 | #include <unistd.h> |
59 | #ifndef QT_NO_SOUND | 60 | #ifndef QT_NO_SOUND |
60 | #include <linux/soundcard.h> | 61 | #include <linux/soundcard.h> |
61 | #endif | 62 | #endif |
62 | 63 | ||
63 | namespace Opie { | 64 | namespace Opie { |
64 | namespace Core { | 65 | namespace Core { |
65 | 66 | ||
66 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; | 67 | static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; |
67 | 68 | ||
68 | 69 | ||
69 | /* STATIC and common implementation */ | 70 | /* STATIC and common implementation */ |
70 | /* EXPORT */ ODistribution distributions[] = { | 71 | /* EXPORT */ ODistribution distributions[] = { |
71 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, | 72 | { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, |
72 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, | 73 | { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, |
73 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, | 74 | { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, |
74 | { System_Unknown, "Linux", "/etc/issue" }, | 75 | { System_Unknown, "Linux", "/etc/issue" }, |
75 | }; | 76 | }; |
76 | 77 | ||
77 | 78 | ||
78 | /* EXPORT */ bool isQWS(){ | 79 | /* EXPORT */ bool isQWS(){ |
79 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; | 80 | return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; |
80 | } | 81 | } |
81 | 82 | ||
82 | /* EXPORT */ QCString makeChannel ( const char *str ){ | 83 | /* EXPORT */ QCString makeChannel ( const char *str ){ |
83 | if ( str && !::strchr ( str, '/' )) | 84 | if ( str && !::strchr ( str, '/' )) |
84 | return QCString ( "QPE/Application/" ) + str; | 85 | return QCString ( "QPE/Application/" ) + str; |
85 | else | 86 | else |
86 | return str; | 87 | return str; |
87 | } | 88 | } |
88 | 89 | ||
89 | 90 | ||
90 | 91 | ||
91 | /* Now the default implementation of ODevice */ | 92 | /* Now the default implementation of ODevice */ |
92 | 93 | ||
93 | struct default_button default_buttons [] = { | 94 | struct default_button default_buttons [] = { |
94 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 95 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
95 | "devicebuttons/z_calendar", | 96 | "devicebuttons/z_calendar", |
96 | "datebook", "nextView()", | 97 | "datebook", "nextView()", |
97 | "today", "raise()" }, | 98 | "today", "raise()" }, |
98 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 99 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
99 | "devicebuttons/z_contact", | 100 | "devicebuttons/z_contact", |
100 | "addressbook", "raise()", | 101 | "addressbook", "raise()", |
101 | "addressbook", "beamBusinessCard()" }, | 102 | "addressbook", "beamBusinessCard()" }, |
102 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 103 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
103 | "devicebuttons/z_home", | 104 | "devicebuttons/z_home", |
104 | "QPE/Launcher", "home()", | 105 | "QPE/Launcher", "home()", |
105 | "buttonsettings", "raise()" }, | 106 | "buttonsettings", "raise()" }, |
106 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 107 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
107 | "devicebuttons/z_menu", | 108 | "devicebuttons/z_menu", |
108 | "QPE/TaskBar", "toggleMenu()", | 109 | "QPE/TaskBar", "toggleMenu()", |
109 | "QPE/TaskBar", "toggleStartMenu()" }, | 110 | "QPE/TaskBar", "toggleStartMenu()" }, |
110 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 111 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
111 | "devicebuttons/z_mail", | 112 | "devicebuttons/z_mail", |
112 | "opiemail", "raise()", | 113 | "opiemail", "raise()", |
113 | "opiemail", "newMail()" }, | 114 | "opiemail", "newMail()" }, |
114 | }; | 115 | }; |
115 | 116 | ||
116 | ODevice *ODevice::inst() | 117 | ODevice *ODevice::inst() |
117 | { | 118 | { |
118 | static ODevice *dev = 0; | 119 | static ODevice *dev = 0; |
119 | 120 | ||
120 | // rewrite this to only use /proc/cpuinfo or so | 121 | // rewrite this to only use /proc/cpuinfo or so |
121 | QString cpu_info; | 122 | QString cpu_info; |
122 | 123 | ||
123 | if ( !dev ) | 124 | if ( !dev ) |
124 | { | 125 | { |
125 | QFile f( PATH_PROC_CPUINFO ); | 126 | QFile f( PATH_PROC_CPUINFO ); |
126 | if ( f.open( IO_ReadOnly ) ) | 127 | if ( f.open( IO_ReadOnly ) ) |
127 | { | 128 | { |
128 | QTextStream s( &f ); | 129 | QTextStream s( &f ); |
129 | while ( !s.atEnd() ) | 130 | while ( !s.atEnd() ) |
130 | { | 131 | { |
131 | QString line; | 132 | QString line; |
132 | line = s.readLine(); | 133 | line = s.readLine(); |
133 | if ( line.startsWith( "Hardware" ) ) | 134 | if ( line.startsWith( "Hardware" ) ) |
134 | { | 135 | { |
135 | qDebug( "ODevice() - found '%s'", (const char*) line ); | 136 | qDebug( "ODevice() - found '%s'", (const char*) line ); |
136 | cpu_info = line; | 137 | cpu_info = line; |
137 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); | 138 | if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); |
138 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); | 139 | else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); |
139 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); | 140 | else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); |
140 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); | 141 | else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); |
141 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); | 142 | else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); |
143 | else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); | ||
142 | else qWarning( "ODevice() - unknown hardware - using default." ); | 144 | else qWarning( "ODevice() - unknown hardware - using default." ); |
143 | break; | 145 | break; |
144 | } | 146 | } |
145 | } | 147 | } |
146 | } | 148 | } |
147 | else | 149 | else |
148 | { | 150 | { |
149 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); | 151 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); |
150 | } | 152 | } |
151 | if ( !dev ) dev = new ODevice(); | 153 | if ( !dev ) dev = new ODevice(); |
152 | dev->init(cpu_info); | 154 | dev->init(cpu_info); |
153 | } | 155 | } |
154 | return dev; | 156 | return dev; |
155 | } | 157 | } |
156 | 158 | ||
157 | ODevice::ODevice() | 159 | ODevice::ODevice() |
158 | { | 160 | { |
159 | d = new ODeviceData; | 161 | d = new ODeviceData; |
160 | 162 | ||
161 | d->m_modelstr = "Unknown"; | 163 | d->m_modelstr = "Unknown"; |
162 | d->m_model = Model_Unknown; | 164 | d->m_model = Model_Unknown; |
163 | d->m_vendorstr = "Unknown"; | 165 | d->m_vendorstr = "Unknown"; |
164 | d->m_vendor = Vendor_Unknown; | 166 | d->m_vendor = Vendor_Unknown; |
165 | d->m_systemstr = "Unknown"; | 167 | d->m_systemstr = "Unknown"; |
166 | d->m_system = System_Unknown; | 168 | d->m_system = System_Unknown; |
167 | d->m_sysverstr = "0.0"; | 169 | d->m_sysverstr = "0.0"; |
168 | d->m_rotation = Rot0; | 170 | d->m_rotation = Rot0; |
169 | d->m_direction = CW; | 171 | d->m_direction = CW; |
170 | 172 | ||
171 | d->m_holdtime = 1000; // 1000ms | 173 | d->m_holdtime = 1000; // 1000ms |
172 | d->m_buttons = 0; | 174 | d->m_buttons = 0; |
173 | d->m_cpu_frequencies = new QStrList; | 175 | d->m_cpu_frequencies = new QStrList; |
174 | 176 | ||
175 | 177 | ||
176 | /* mixer */ | 178 | /* mixer */ |
177 | d->m_sound = d->m_vol = d->m_mixer = -1; | 179 | d->m_sound = d->m_vol = d->m_mixer = -1; |
178 | 180 | ||
179 | // New distribution detection code first checks for legacy distributions, | 181 | // New distribution detection code first checks for legacy distributions, |
180 | // identified by /etc/familiar-version or /etc/oz_version. | 182 | // identified by /etc/familiar-version or /etc/oz_version. |
181 | // Then check for OpenEmbedded and lastly, read /etc/issue | 183 | // Then check for OpenEmbedded and lastly, read /etc/issue |
182 | 184 | ||
183 | for ( unsigned int i = 0; i < sizeof distributions; ++i ) | 185 | for ( unsigned int i = 0; i < sizeof distributions; ++i ) |
184 | { | 186 | { |
185 | if ( QFile::exists( distributions[i].sysvfile ) ) | 187 | if ( QFile::exists( distributions[i].sysvfile ) ) |
186 | { | 188 | { |
187 | d->m_systemstr = distributions[i].sysstr; | 189 | d->m_systemstr = distributions[i].sysstr; |
188 | d->m_system = distributions[i].system; | 190 | d->m_system = distributions[i].system; |
189 | d->m_sysverstr = "<Unknown>"; | 191 | d->m_sysverstr = "<Unknown>"; |
190 | QFile f( distributions[i].sysvfile ); | 192 | QFile f( distributions[i].sysvfile ); |
191 | if ( f.open( IO_ReadOnly ) ) | 193 | if ( f.open( IO_ReadOnly ) ) |
192 | { | 194 | { |
193 | QTextStream ts( &f ); | 195 | QTextStream ts( &f ); |
194 | d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); | 196 | d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); |
195 | } | 197 | } |
196 | break; | 198 | break; |
197 | } | 199 | } |
198 | } | 200 | } |
199 | } | 201 | } |
200 | 202 | ||
201 | void ODevice::systemMessage( const QCString &msg, const QByteArray & ) | 203 | void ODevice::systemMessage( const QCString &msg, const QByteArray & ) |
202 | { | 204 | { |
203 | if ( msg == "deviceButtonMappingChanged()" ) { | 205 | if ( msg == "deviceButtonMappingChanged()" ) { |
204 | reloadButtonMapping(); | 206 | reloadButtonMapping(); |
205 | } | 207 | } |
206 | } | 208 | } |
207 | 209 | ||
208 | void ODevice::init(const QString&) | 210 | void ODevice::init(const QString&) |
209 | { | 211 | { |
210 | } | 212 | } |
211 | 213 | ||
212 | /** | 214 | /** |
213 | * This method initialises the button mapping | 215 | * This method initialises the button mapping |
214 | */ | 216 | */ |
215 | void ODevice::initButtons() | 217 | void ODevice::initButtons() |
216 | { | 218 | { |
217 | if ( d->m_buttons ) | 219 | if ( d->m_buttons ) |
218 | return; | 220 | return; |
219 | 221 | ||
220 | qDebug ( "init Buttons" ); | 222 | qDebug ( "init Buttons" ); |
221 | d->m_buttons = new QValueList <ODeviceButton>; | 223 | d->m_buttons = new QValueList <ODeviceButton>; |
222 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { | 224 | for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { |
223 | default_button *db = default_buttons + i; | 225 | default_button *db = default_buttons + i; |
224 | ODeviceButton b; | 226 | ODeviceButton b; |
225 | b. setKeycode ( db->code ); | 227 | b. setKeycode ( db->code ); |
226 | b. setUserText ( QObject::tr ( "Button", db->utext )); | 228 | b. setUserText ( QObject::tr ( "Button", db->utext )); |
227 | b. setPixmap ( Resource::loadPixmap ( db->pix )); | 229 | b. setPixmap ( Resource::loadPixmap ( db->pix )); |
228 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); | 230 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); |
229 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); | 231 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); |
230 | d->m_buttons->append ( b ); | 232 | d->m_buttons->append ( b ); |
231 | } | 233 | } |
232 | 234 | ||
233 | reloadButtonMapping(); | 235 | reloadButtonMapping(); |
234 | 236 | ||
235 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 237 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
236 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 238 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
237 | } | 239 | } |
238 | 240 | ||
239 | ODevice::~ODevice() | 241 | ODevice::~ODevice() |
240 | { | 242 | { |
241 | // we leak m_devicebuttons and m_cpu_frequency | 243 | // we leak m_devicebuttons and m_cpu_frequency |
242 | // but it's a singleton and it is not so importantant | 244 | // but it's a singleton and it is not so importantant |
243 | // -zecke | 245 | // -zecke |
244 | delete d; | 246 | delete d; |
245 | } | 247 | } |
246 | 248 | ||
247 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 249 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
248 | { | 250 | { |
249 | return false; | 251 | return false; |
250 | } | 252 | } |
251 | 253 | ||
252 | //#include <linux/apm_bios.h> | 254 | //#include <linux/apm_bios.h> |
253 | 255 | ||
254 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 256 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
255 | 257 | ||
256 | /** | 258 | /** |
257 | * This method will try to suspend the device | 259 | * This method will try to suspend the device |
258 | * It only works if the user is the QWS Server and the apm application | 260 | * It only works if the user is the QWS Server and the apm application |
259 | * is installed. | 261 | * is installed. |
260 | * It tries to suspend and then waits some time cause some distributions | 262 | * It tries to suspend and then waits some time cause some distributions |
261 | * do have asynchronus apm implementations. | 263 | * do have asynchronus apm implementations. |
262 | * This method will either fail and return false or it'll suspend the | 264 | * This method will either fail and return false or it'll suspend the |
263 | * device and return once the device got woken up | 265 | * device and return once the device got woken up |
264 | * | 266 | * |
265 | * @return if the device got suspended | 267 | * @return if the device got suspended |
266 | */ | 268 | */ |
267 | bool ODevice::suspend() | 269 | bool ODevice::suspend() |
268 | { | 270 | { |
269 | qDebug("ODevice::suspend"); | ||
270 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 271 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
271 | return false; | 272 | return false; |
272 | 273 | ||
273 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 274 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
274 | return false; | 275 | return false; |
275 | 276 | ||
276 | bool res = false; | 277 | bool res = false; |
277 | ODevice::sendSuspendmsg(); | 278 | ODevice::sendSuspendmsg(); |
278 | 279 | ||
279 | struct timeval tvs, tvn; | 280 | struct timeval tvs, tvn; |
280 | ::gettimeofday ( &tvs, 0 ); | 281 | ::gettimeofday ( &tvs, 0 ); |
281 | 282 | ||
282 | ::sync(); // flush fs caches | 283 | ::sync(); // flush fs caches |
283 | res = ( ::system ( "apm --suspend" ) == 0 ); | 284 | res = ( ::system ( "apm --suspend" ) == 0 ); |
284 | 285 | ||
285 | // This is needed because the iPAQ apm implementation is asynchronous and we | 286 | // This is needed because the iPAQ apm implementation is asynchronous and we |
286 | // can not be sure when exactly the device is really suspended | 287 | // can not be sure when exactly the device is really suspended |
287 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 288 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
288 | 289 | ||
289 | if ( res ) { | 290 | if ( res ) { |
290 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 291 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
291 | ::usleep ( 200 * 1000 ); | 292 | ::usleep ( 200 * 1000 ); |
292 | ::gettimeofday ( &tvn, 0 ); | 293 | ::gettimeofday ( &tvn, 0 ); |
293 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 294 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
294 | } | 295 | } |
295 | 296 | ||
296 | return res; | 297 | return res; |
297 | } | 298 | } |
298 | 299 | ||
299 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 300 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
300 | 301 | ||
301 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 302 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
302 | 303 | ||
303 | /* VESA Blanking Levels */ | 304 | /* VESA Blanking Levels */ |
304 | #define VESA_NO_BLANKING 0 | 305 | #define VESA_NO_BLANKING 0 |
305 | #define VESA_VSYNC_SUSPEND 1 | 306 | #define VESA_VSYNC_SUSPEND 1 |
306 | #define VESA_HSYNC_SUSPEND 2 | 307 | #define VESA_HSYNC_SUSPEND 2 |
307 | #define VESA_POWERDOWN 3 | 308 | #define VESA_POWERDOWN 3 |
308 | 309 | ||
309 | /** | 310 | /** |
310 | * This sets the display on or off | 311 | * This sets the display on or off |
311 | */ | 312 | */ |
312 | bool ODevice::setDisplayStatus ( bool on ) | 313 | bool ODevice::setDisplayStatus ( bool on ) |
313 | { | 314 | { |
314 | qDebug("ODevice::setDisplayStatus(%d)", on); | 315 | qDebug("ODevice::setDisplayStatus(%d)", on); |
315 | 316 | ||
316 | if ( d->m_model == Model_Unknown ) | 317 | if ( d->m_model == Model_Unknown ) |
317 | return false; | 318 | return false; |
318 | 319 | ||
319 | bool res = false; | 320 | bool res = false; |
320 | int fd; | 321 | int fd; |
321 | 322 | ||
322 | #ifdef QT_QWS_DEVFS | 323 | #ifdef QT_QWS_DEVFS |
323 | if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { | 324 | if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { |
324 | #else | 325 | #else |
325 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 326 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
326 | #endif | 327 | #endif |
327 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 328 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
328 | ::close ( fd ); | 329 | ::close ( fd ); |
329 | } | 330 | } |
330 | return res; | 331 | return res; |
331 | } | 332 | } |
332 | 333 | ||
333 | /** | 334 | /** |
334 | * This sets the display brightness | 335 | * This sets the display brightness |
335 | * | 336 | * |
336 | * @param p The brightness to be set on a scale from 0 to 255 | 337 | * @param p The brightness to be set on a scale from 0 to 255 |
337 | * @return success or failure | 338 | * @return success or failure |
338 | */ | 339 | */ |
339 | bool ODevice::setDisplayBrightness ( int p) | 340 | bool ODevice::setDisplayBrightness ( int p) |
340 | { | 341 | { |
341 | Q_UNUSED( p ) | 342 | Q_UNUSED( p ) |
342 | return false; | 343 | return false; |
343 | } | 344 | } |
344 | 345 | ||
345 | /** | 346 | /** |
346 | * @return returns the number of steppings on the brightness slider | 347 | * @return returns the number of steppings on the brightness slider |
347 | * in the Light-'n-Power settings. | 348 | * in the Light-'n-Power settings. |
348 | */ | 349 | */ |
349 | int ODevice::displayBrightnessResolution() const | 350 | int ODevice::displayBrightnessResolution() const |
350 | { | 351 | { |
351 | return 16; | 352 | return 16; |
352 | } | 353 | } |
353 | 354 | ||
354 | /** | 355 | /** |
355 | * This sets the display contrast | 356 | * This sets the display contrast |
356 | * @param p The contrast to be set on a scale from 0 to 255 | 357 | * @param p The contrast to be set on a scale from 0 to 255 |
357 | * @return success or failure | 358 | * @return success or failure |
358 | */ | 359 | */ |
359 | bool ODevice::setDisplayContrast ( int p) | 360 | bool ODevice::setDisplayContrast ( int p) |
360 | { | 361 | { |
361 | Q_UNUSED( p ) | 362 | Q_UNUSED( p ) |
362 | return false; | 363 | return false; |
363 | } | 364 | } |
364 | 365 | ||
365 | /** | 366 | /** |
366 | * @return return the max value for the brightness settings slider | 367 | * @return return the max value for the brightness settings slider |
367 | * or 0 if the device doesn't support setting of a contrast | 368 | * or 0 if the device doesn't support setting of a contrast |
368 | */ | 369 | */ |
369 | int ODevice::displayContrastResolution() const | 370 | int ODevice::displayContrastResolution() const |
370 | { | 371 | { |
371 | return 0; | 372 | return 0; |
372 | } | 373 | } |
373 | 374 | ||
374 | /** | 375 | /** |
375 | * This returns the vendor as string | 376 | * This returns the vendor as string |
376 | * @return Vendor as QString | 377 | * @return Vendor as QString |
377 | */ | 378 | */ |
378 | QString ODevice::vendorString() const | 379 | QString ODevice::vendorString() const |
379 | { | 380 | { |
380 | return d->m_vendorstr; | 381 | return d->m_vendorstr; |
381 | } | 382 | } |
382 | 383 | ||
383 | /** | 384 | /** |
384 | * This returns the vendor as one of the values of OVendor | 385 | * This returns the vendor as one of the values of OVendor |
385 | * @return OVendor | 386 | * @return OVendor |
386 | */ | 387 | */ |
387 | OVendor ODevice::vendor() const | 388 | OVendor ODevice::vendor() const |
388 | { | 389 | { |
389 | return d->m_vendor; | 390 | return d->m_vendor; |
390 | } | 391 | } |
391 | 392 | ||
392 | /** | 393 | /** |
393 | * This returns the model as a string | 394 | * This returns the model as a string |
394 | * @return A string representing the model | 395 | * @return A string representing the model |
395 | */ | 396 | */ |
396 | QString ODevice::modelString() const | 397 | QString ODevice::modelString() const |
397 | { | 398 | { |
398 | return d->m_modelstr; | 399 | return d->m_modelstr; |
399 | } | 400 | } |
400 | 401 | ||
401 | /** | 402 | /** |
402 | * This does return the OModel used | 403 | * This does return the OModel used |
403 | */ | 404 | */ |
404 | OModel ODevice::model() const | 405 | OModel ODevice::model() const |
405 | { | 406 | { |
406 | return d->m_model; | 407 | return d->m_model; |
407 | } | 408 | } |
408 | 409 | ||
409 | /** | 410 | /** |
410 | * This does return the systen name | 411 | * This does return the systen name |
411 | */ | 412 | */ |
412 | QString ODevice::systemString() const | 413 | QString ODevice::systemString() const |
413 | { | 414 | { |
414 | return d->m_systemstr; | 415 | return d->m_systemstr; |
415 | } | 416 | } |
416 | 417 | ||
417 | /** | 418 | /** |
418 | * Return System as OSystem value | 419 | * Return System as OSystem value |
419 | */ | 420 | */ |
420 | OSystem ODevice::system() const | 421 | OSystem ODevice::system() const |
421 | { | 422 | { |
422 | return d->m_system; | 423 | return d->m_system; |
423 | } | 424 | } |
424 | 425 | ||
425 | /** | 426 | /** |
426 | * @return the version string of the base system | 427 | * @return the version string of the base system |
427 | */ | 428 | */ |
428 | QString ODevice::systemVersionString() const | 429 | QString ODevice::systemVersionString() const |
429 | { | 430 | { |
430 | return d->m_sysverstr; | 431 | return d->m_sysverstr; |
431 | } | 432 | } |
432 | 433 | ||
433 | /** | 434 | /** |
434 | * @return the current Transformation | 435 | * @return the current Transformation |
435 | */ | 436 | */ |
436 | Transformation ODevice::rotation() const | 437 | Transformation ODevice::rotation() const |
437 | { | 438 | { |
438 | return d->m_rotation; | 439 | return d->m_rotation; |
439 | } | 440 | } |
440 | 441 | ||
441 | /** | 442 | /** |
442 | * @return the current rotation direction | 443 | * @return the current rotation direction |
443 | */ | 444 | */ |
444 | ODirection ODevice::direction() const | 445 | ODirection ODevice::direction() const |
445 | { | 446 | { |
446 | return d->m_direction; | 447 | return d->m_direction; |
447 | } | 448 | } |
448 | 449 | ||
449 | /** | 450 | /** |
450 | * This plays an alarm sound | 451 | * This plays an alarm sound |
451 | */ | 452 | */ |
452 | void ODevice::playAlarmSound() | 453 | void ODevice::playAlarmSound() |
453 | { | 454 | { |
454 | #ifndef QT_NO_SOUND | 455 | #ifndef QT_NO_SOUND |
455 | static Sound snd ( "alarm" ); | 456 | static Sound snd ( "alarm" ); |
456 | 457 | ||
457 | if ( snd. isFinished()) | 458 | if ( snd. isFinished()) |
458 | snd. play(); | 459 | snd. play(); |
459 | #endif | 460 | #endif |
460 | } | 461 | } |
461 | 462 | ||
462 | /** | 463 | /** |
463 | * This plays a key sound | 464 | * This plays a key sound |
464 | */ | 465 | */ |
465 | void ODevice::playKeySound() | 466 | void ODevice::playKeySound() |
466 | { | 467 | { |
467 | #ifndef QT_NO_SOUND | 468 | #ifndef QT_NO_SOUND |
468 | static Sound snd ( "keysound" ); | 469 | static Sound snd ( "keysound" ); |
469 | 470 | ||
470 | if ( snd. isFinished()) | 471 | if ( snd. isFinished()) |
471 | snd. play(); | 472 | snd. play(); |
472 | #endif | 473 | #endif |
473 | } | 474 | } |
474 | 475 | ||
475 | /** | 476 | /** |
476 | * This plays a touch sound | 477 | * This plays a touch sound |
477 | */ | 478 | */ |
478 | void ODevice::playTouchSound() | 479 | void ODevice::playTouchSound() |
479 | { | 480 | { |
480 | #ifndef QT_NO_SOUND | 481 | #ifndef QT_NO_SOUND |
481 | static Sound snd ( "touchsound" ); | 482 | static Sound snd ( "touchsound" ); |
482 | 483 | ||
483 | if ( snd. isFinished()) | 484 | if ( snd. isFinished()) |
484 | snd. play(); | 485 | snd. play(); |
485 | #endif | 486 | #endif |
486 | } | 487 | } |
487 | 488 | ||
488 | /** | 489 | /** |
489 | * This method will return a list of leds | 490 | * This method will return a list of leds |
490 | * available on this device | 491 | * available on this device |
491 | * @return a list of LEDs. | 492 | * @return a list of LEDs. |
492 | */ | 493 | */ |
493 | QValueList <OLed> ODevice::ledList() const | 494 | QValueList <OLed> ODevice::ledList() const |
494 | { | 495 | { |
495 | return QValueList <OLed>(); | 496 | return QValueList <OLed>(); |
496 | } | 497 | } |
497 | 498 | ||
498 | /** | 499 | /** |
499 | * This does return the state of the LEDs | 500 | * This does return the state of the LEDs |
500 | */ | 501 | */ |
501 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 502 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
502 | { | 503 | { |
503 | return QValueList <OLedState>(); | 504 | return QValueList <OLedState>(); |
504 | } | 505 | } |
505 | 506 | ||
506 | /** | 507 | /** |
507 | * @return the state for a given OLed | 508 | * @return the state for a given OLed |
508 | */ | 509 | */ |
509 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 510 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
510 | { | 511 | { |
511 | return Led_Off; | 512 | return Led_Off; |
512 | } | 513 | } |
513 | 514 | ||
514 | /** | 515 | /** |
515 | * Set the state for a LED | 516 | * Set the state for a LED |
516 | * @param which Which OLed to use | 517 | * @param which Which OLed to use |
517 | * @param st The state to set | 518 | * @param st The state to set |
518 | * @return success or failure | 519 | * @return success or failure |
519 | */ | 520 | */ |
520 | bool ODevice::setLedState ( OLed which, OLedState st ) | 521 | bool ODevice::setLedState ( OLed which, OLedState st ) |
521 | { | 522 | { |
522 | Q_UNUSED( which ) | 523 | Q_UNUSED( which ) |
523 | Q_UNUSED( st ) | 524 | Q_UNUSED( st ) |
524 | return false; | 525 | return false; |
525 | } | 526 | } |
526 | 527 | ||
527 | /** | 528 | /** |
528 | * @return if the device has a light sensor | 529 | * @return if the device has a light sensor |
529 | */ | 530 | */ |
530 | bool ODevice::hasLightSensor() const | 531 | bool ODevice::hasLightSensor() const |
531 | { | 532 | { |
532 | return false; | 533 | return false; |
533 | } | 534 | } |
534 | 535 | ||
535 | /** | 536 | /** |
536 | * @return a value from the light sensor | 537 | * @return a value from the light sensor |
537 | */ | 538 | */ |
538 | int ODevice::readLightSensor() | 539 | int ODevice::readLightSensor() |
539 | { | 540 | { |
540 | return -1; | 541 | return -1; |
541 | } | 542 | } |
542 | 543 | ||
543 | /** | 544 | /** |
544 | * @return the light sensor resolution | 545 | * @return the light sensor resolution |
545 | */ | 546 | */ |
546 | int ODevice::lightSensorResolution() const | 547 | int ODevice::lightSensorResolution() const |
547 | { | 548 | { |
548 | return 0; | 549 | return 0; |
549 | } | 550 | } |
550 | 551 | ||
551 | /** | 552 | /** |
552 | * @return if the device has a hinge sensor | 553 | * @return if the device has a hinge sensor |
553 | */ | 554 | */ |
554 | bool ODevice::hasHingeSensor() const | 555 | bool ODevice::hasHingeSensor() const |
555 | { | 556 | { |
556 | return false; | 557 | return false; |
557 | } | 558 | } |
558 | 559 | ||
559 | /** | 560 | /** |
560 | * @return a value from the hinge sensor | 561 | * @return a value from the hinge sensor |
561 | */ | 562 | */ |
562 | OHingeStatus ODevice::readHingeSensor() | 563 | OHingeStatus ODevice::readHingeSensor() |
563 | { | 564 | { |
564 | return CASE_UNKNOWN; | 565 | return CASE_UNKNOWN; |
565 | } | 566 | } |
566 | 567 | ||
567 | /** | 568 | /** |
568 | * @return a list with CPU frequencies supported by the hardware | 569 | * @return a list with CPU frequencies supported by the hardware |
569 | */ | 570 | */ |
570 | const QStrList &ODevice::allowedCpuFrequencies() const | 571 | const QStrList &ODevice::allowedCpuFrequencies() const |
571 | { | 572 | { |
572 | return *d->m_cpu_frequencies; | 573 | return *d->m_cpu_frequencies; |
573 | } | 574 | } |
574 | 575 | ||
575 | 576 | ||
576 | /** | 577 | /** |
577 | * Set desired CPU frequency | 578 | * Set desired CPU frequency |
578 | * | 579 | * |
579 | * @param index index into d->m_cpu_frequencies of the frequency to be set | 580 | * @param index index into d->m_cpu_frequencies of the frequency to be set |
580 | */ | 581 | */ |
581 | bool ODevice::setCurrentCpuFrequency(uint index) | 582 | bool ODevice::setCurrentCpuFrequency(uint index) |
582 | { | 583 | { |
583 | if (index >= d->m_cpu_frequencies->count()) | 584 | if (index >= d->m_cpu_frequencies->count()) |
584 | return false; | 585 | return false; |
585 | 586 | ||
586 | char *freq = d->m_cpu_frequencies->at(index); | 587 | char *freq = d->m_cpu_frequencies->at(index); |
587 | qWarning("set freq to %s", freq); | 588 | qWarning("set freq to %s", freq); |
588 | 589 | ||
589 | int fd; | 590 | int fd; |
590 | 591 | ||
591 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { | 592 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { |
592 | char writeCommand[50]; | 593 | char writeCommand[50]; |
593 | const int count = sprintf(writeCommand, "%s\n", freq); | 594 | const int count = sprintf(writeCommand, "%s\n", freq); |
594 | int res = (::write(fd, writeCommand, count) != -1); | 595 | int res = (::write(fd, writeCommand, count) != -1); |
595 | ::close(fd); | 596 | ::close(fd); |
596 | return res; | 597 | return res; |
597 | } | 598 | } |
598 | 599 | ||
599 | return false; | 600 | return false; |
600 | } | 601 | } |
601 | 602 | ||
602 | 603 | ||
603 | /** | 604 | /** |
604 | * @return a list of hardware buttons | 605 | * @return a list of hardware buttons |
605 | */ | 606 | */ |
606 | const QValueList <ODeviceButton> &ODevice::buttons() | 607 | const QValueList <ODeviceButton> &ODevice::buttons() |
607 | { | 608 | { |
608 | initButtons(); | 609 | initButtons(); |
609 | 610 | ||
610 | return *d->m_buttons; | 611 | return *d->m_buttons; |
611 | } | 612 | } |
612 | 613 | ||
613 | /** | 614 | /** |
614 | * @return The amount of time that would count as a hold | 615 | * @return The amount of time that would count as a hold |
615 | */ | 616 | */ |
616 | uint ODevice::buttonHoldTime() const | 617 | uint ODevice::buttonHoldTime() const |
617 | { | 618 | { |
618 | return d->m_holdtime; | 619 | return d->m_holdtime; |
619 | } | 620 | } |
620 | 621 | ||
621 | /** | 622 | /** |
622 | * This method return a ODeviceButton for a key code | 623 | * This method return a ODeviceButton for a key code |
623 | * or 0 if no special hardware button is available for the device | 624 | * or 0 if no special hardware button is available for the device |
624 | * | 625 | * |
625 | * @return The devicebutton or 0l | 626 | * @return The devicebutton or 0l |
626 | * @see ODeviceButton | 627 | * @see ODeviceButton |
627 | */ | 628 | */ |
628 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 629 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
629 | { | 630 | { |
630 | initButtons(); | 631 | initButtons(); |
631 | 632 | ||
632 | for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { | 633 | for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { |
633 | if ( (*it). keycode() == code ) | 634 | if ( (*it). keycode() == code ) |
634 | return &(*it); | 635 | return &(*it); |
635 | } | 636 | } |
636 | return 0; | 637 | return 0; |
637 | } | 638 | } |
638 | 639 | ||
639 | void ODevice::reloadButtonMapping() | 640 | void ODevice::reloadButtonMapping() |
640 | { | 641 | { |
641 | initButtons(); | 642 | initButtons(); |
642 | 643 | ||
643 | Config cfg ( "ButtonSettings" ); | 644 | Config cfg ( "ButtonSettings" ); |
644 | 645 | ||
645 | for ( uint i = 0; i < d->m_buttons->count(); i++ ) { | 646 | for ( uint i = 0; i < d->m_buttons->count(); i++ ) { |
646 | ODeviceButton &b = ( *d->m_buttons ) [i]; | 647 | ODeviceButton &b = ( *d->m_buttons ) [i]; |
647 | QString group = "Button" + QString::number ( i ); | 648 | QString group = "Button" + QString::number ( i ); |
648 | 649 | ||
649 | QCString pch, hch; | 650 | QCString pch, hch; |
650 | QCString pm, hm; | 651 | QCString pm, hm; |
651 | QByteArray pdata, hdata; | 652 | QByteArray pdata, hdata; |
652 | 653 | ||
653 | if ( cfg. hasGroup ( group )) { | 654 | if ( cfg. hasGroup ( group )) { |
diff --git a/libopie2/opiecore/device/odevice_beagle.cpp b/libopie2/opiecore/device/odevice_beagle.cpp new file mode 100644 index 0000000..9cf640a --- a/dev/null +++ b/libopie2/opiecore/device/odevice_beagle.cpp | |||
@@ -0,0 +1,156 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) 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 "odevicebutton.h" | ||
31 | #include "odevice_beagle.h" | ||
32 | |||
33 | #include <qpe/resource.h> | ||
34 | |||
35 | #include <sys/types.h> | ||
36 | #include <sys/ioctl.h> | ||
37 | #include <fcntl.h> | ||
38 | #include <unistd.h> | ||
39 | |||
40 | |||
41 | |||
42 | #define _SA1100_FL_IOCTL_ON 1 | ||
43 | #define _SA1100_FL_IOCTL_OFF 2 | ||
44 | #define _SA1100_FL_IOCTL_INTENSITY3 | ||
45 | #define _SA1100_FL_IOCTL_BACKLIGHT 4 | ||
46 | #define _SA1100_FL_IOCTL_CONTRAST5 | ||
47 | #define _SA1100_FL_IOCTL_GET_BACKLIGHT 6 | ||
48 | #define _SA1100_FL_IOCTL_GET_CONTRAST 7 | ||
49 | // added by Sean Hsieh | ||
50 | #define _SA1100_FL_IOCTL_PWR_TOGGLE 8 | ||
51 | #define _SA1100_FL_IOCTL_AUTOLIGHT 10 | ||
52 | |||
53 | #define FL_MAJOR 60 | ||
54 | #define FL_NAME "sa1100-fl" | ||
55 | #define FL_FILE "/dev/sa1100-fl" | ||
56 | |||
57 | namespace Opie { | ||
58 | namespace Core { | ||
59 | namespace Internal { | ||
60 | |||
61 | struct b_button { | ||
62 | uint model; | ||
63 | Qt::Key code; | ||
64 | char *utext; | ||
65 | char *pix; | ||
66 | char *fpressedservice; | ||
67 | char *fpressedaction; | ||
68 | char *fheldservice; | ||
69 | char *fheldaction; | ||
70 | }; | ||
71 | |||
72 | struct b_button beagle_buttons [] = { | ||
73 | { Model_Beagle_PA100, | ||
74 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | ||
75 | "devicebuttons/beagle_calendar", | ||
76 | "datebook", "nextView()", | ||
77 | "today", "raise()" }, | ||
78 | { Model_Beagle_PA100, | ||
79 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | ||
80 | "devicebuttons/beagle_contact", | ||
81 | "addressbook", "raise()", | ||
82 | "addressbook", "beamBusinessCard()" }, | ||
83 | { Model_Beagle_PA100, | ||
84 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"), | ||
85 | "devicebuttons/beagle_todo", | ||
86 | "todolist", "raise()", | ||
87 | "QPE/TaskBar", "toggleMenu()" }, | ||
88 | { Model_Beagle_PA100, | ||
89 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | ||
90 | "devicebuttons/beagle_home", | ||
91 | "QPE/Launcher", "home()", | ||
92 | "buttonsettings", "raise()" }, | ||
93 | }; | ||
94 | |||
95 | |||
96 | Beagle::Beagle() | ||
97 | { | ||
98 | qWarning( "Created Beagle" ); | ||
99 | } | ||
100 | Beagle::~Beagle() {} | ||
101 | |||
102 | void Beagle::init( const QString&) { | ||
103 | /* | ||
104 | * No other assabat model yet | ||
105 | */ | ||
106 | d->m_vendorstr = "Tradesquare.NL"; | ||
107 | d->m_vendor = Vendor_MasterIA; | ||
108 | d->m_modelstr = "Tuxpda 1"; | ||
109 | d->m_rotation = Rot0; | ||
110 | } | ||
111 | |||
112 | void Beagle::initButtons() { | ||
113 | if ( d->m_buttons ) | ||
114 | return; | ||
115 | |||
116 | d->m_buttons = new QValueList<ODeviceButton>; | ||
117 | uint length = sizeof( beagle_buttons )/ sizeof( b_button ); | ||
118 | for ( uint i = 0; i < length; ++i ) { | ||
119 | b_button *bb = &beagle_buttons[i]; | ||
120 | ODeviceButton b; | ||
121 | b.setKeycode( bb->code ); | ||
122 | b.setUserText( QObject::tr( "Button", bb->utext ) ); | ||
123 | b.setPixmap( Resource::loadPixmap( bb->pix ) ); | ||
124 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel( bb->fpressedservice ), bb->fpressedaction ) ); | ||
125 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel( bb->fheldservice ), bb->fheldaction ) ); | ||
126 | d->m_buttons->append( b ); | ||
127 | } | ||
128 | |||
129 | reloadButtonMapping(); | ||
130 | } | ||
131 | |||
132 | bool Beagle::setDisplayStatus( bool on ) { | ||
133 | int fd = ::open(FL_FILE, O_WRONLY); | ||
134 | |||
135 | if ( fd < 0 ) | ||
136 | return false; | ||
137 | |||
138 | return ( ::ioctl(fd, on ? _SA1100_FL_IOCTL_ON : _SA1100_FL_IOCTL_OFF, 0 ) == -1 ); | ||
139 | } | ||
140 | |||
141 | int Beagle::displayBrightnessResolution()const { | ||
142 | return 100; | ||
143 | } | ||
144 | |||
145 | bool Beagle::setDisplayBrightness( int brightness ) { | ||
146 | int fd = ::open(FL_FILE, O_WRONLY); | ||
147 | |||
148 | if ( fd < 0 ) | ||
149 | return false; | ||
150 | |||
151 | return ( ::ioctl(fd, _SA1100_FL_IOCTL_INTENSITY, brightness%101 ) == 0 ); | ||
152 | } | ||
153 | |||
154 | } | ||
155 | } | ||
156 | } | ||
diff --git a/libopie2/opiecore/device/odevice_beagle.h b/libopie2/opiecore/device/odevice_beagle.h new file mode 100644 index 0000000..1626330 --- a/dev/null +++ b/libopie2/opiecore/device/odevice_beagle.h | |||
@@ -0,0 +1,62 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) 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 | #ifndef OPIE_CORE_DEVICE_BEAGLE_H | ||
31 | #define OPIE_CORE_DEVICE_BEAGLE_H | ||
32 | |||
33 | #include "odevice.h" | ||
34 | |||
35 | namespace Opie { | ||
36 | namespace Core { | ||
37 | namespace Internal { | ||
38 | class Beagle : public ODevice { | ||
39 | Q_OBJECT | ||
40 | public: | ||
41 | Beagle(); | ||
42 | ~Beagle(); | ||
43 | |||
44 | //@{ | ||
45 | void init( const QString& init ); | ||
46 | void initButtons(); | ||
47 | //@} | ||
48 | |||
49 | |||
50 | //@{ | ||
51 | bool setDisplayStatus( bool on ); | ||
52 | int displayBrightnessResolution()const; | ||
53 | bool setDisplayBrightness( int brightness ); | ||
54 | //@} | ||
55 | |||
56 | }; | ||
57 | } | ||
58 | } | ||
59 | } | ||
60 | |||
61 | |||
62 | #endif | ||