author | mickeyl <mickeyl> | 2004-01-13 18:32:19 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-01-13 18:32:19 (UTC) |
commit | 061ccf5b9d384b1f24d203e96f1f04ccf1dcf133 (patch) (unidiff) | |
tree | ec1fc064f001edba92e58116cdc35fc909b5cdd6 | |
parent | 59f7fa0a480bf921a67ad42fc1fe018b1be44192 (diff) | |
download | opie-061ccf5b9d384b1f24d203e96f1f04ccf1dcf133.zip opie-061ccf5b9d384b1f24d203e96f1f04ccf1dcf133.tar.gz opie-061ccf5b9d384b1f24d203e96f1f04ccf1dcf133.tar.bz2 |
- rewrite device detection
- cleanup
- split odevice stuff into header and cpp files
- Note for next buildsystem: Don't link all header files but distinguish
between public and private headers, e.g. odevice.h is public while
odevice_ipaq.h is private.
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 73 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice.h | 4 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_ipaq.cpp | 55 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_ipaq.h | 84 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_jornada.cpp | 82 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_jornada.h | 50 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_ramses.cpp | 50 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_ramses.h | 72 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.cpp | 56 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.h | 81 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_yopy.cpp | 239 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_yopy.h | 62 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 103 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.h | 96 | ||||
-rw-r--r-- | libopie2/opiecore/opiecore.pro | 6 |
15 files changed, 602 insertions, 511 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index 0f88c3c..6c8432f 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -1,197 +1,196 @@ | |||
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.h" | 30 | #include "odevice_ipaq.h" |
31 | #include "odevice_jornada.h" | ||
32 | #include "odevice_ramses.h" | ||
33 | #include "odevice_simpad.h" | ||
34 | #include "odevice_yopy.h" | ||
35 | #include "odevice_zaurus.h" | ||
31 | 36 | ||
32 | /* QT */ | 37 | /* QT */ |
33 | #include <qapplication.h> | 38 | #include <qapplication.h> |
34 | #include <qfile.h> | 39 | #include <qfile.h> |
35 | #include <qtextstream.h> | 40 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 41 | #include <qwindowsystem_qws.h> |
37 | 42 | ||
38 | /* OPIE */ | 43 | /* OPIE */ |
39 | #include <qpe/config.h> | 44 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | 45 | #include <qpe/resource.h> |
41 | #include <qpe/sound.h> | 46 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 47 | #include <qpe/qcopenvelope_qws.h> |
43 | 48 | ||
44 | /* STD */ | 49 | /* STD */ |
45 | #include <fcntl.h> | 50 | #include <fcntl.h> |
46 | #include <math.h> | 51 | #include <math.h> |
47 | #include <stdlib.h> | 52 | #include <stdlib.h> |
48 | #include <signal.h> | 53 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 54 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 55 | #include <sys/time.h> |
51 | #include <unistd.h> | 56 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 57 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 58 | #include <linux/soundcard.h> |
54 | #endif | 59 | #endif |
55 | 60 | ||
56 | #ifndef ARRAY_SIZE | 61 | const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; |
57 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | ||
58 | #endif | ||
59 | |||
60 | // _IO and friends are only defined in kernel headers ... | ||
61 | |||
62 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | ||
63 | |||
64 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | ||
65 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | ||
66 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | ||
67 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | ||
68 | 62 | ||
69 | using namespace Opie; | 63 | using namespace Opie; |
70 | 64 | ||
71 | class iPAQ; | ||
72 | class Zaurus; | ||
73 | class SIMpad; | ||
74 | class Ramses; | ||
75 | class Jornada; | ||
76 | |||
77 | ODevice *ODevice::inst() | 65 | ODevice *ODevice::inst() |
78 | { | 66 | { |
79 | static ODevice *dev = 0; | 67 | static ODevice *dev = 0; |
80 | 68 | ||
81 | // rewrite this to only use /proc/devinfo or so | 69 | // rewrite this to only use /proc/cpuinfo or so |
82 | 70 | ||
83 | /* | 71 | if ( !dev ) |
84 | if ( !dev ) { | 72 | { |
85 | if ( QFile::exists ( "/proc/hal/model" )) | 73 | QFile f( PATH_PROC_CPUINFO ); |
86 | dev = new iPAQ(); | 74 | if ( f.open( IO_ReadOnly ) ) |
87 | else if ( Zaurus::isZaurus() ) | 75 | { |
88 | dev = new Zaurus(); | 76 | QTextStream s( &f ); |
89 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) | 77 | while ( !s.atEnd() ) |
90 | dev = new SIMpad(); | 78 | { |
91 | else if ( QFile::exists ( "/proc/sys/board/name" )) | 79 | QString line; |
92 | dev = new Ramses(); | 80 | line = s.readLine(); |
93 | else if ( Yopy::isYopy() ) | 81 | if ( line.startsWith( "Hardware" ) ) |
94 | dev = new Yopy(); | 82 | { |
95 | else if ( Jornada::isJornada() ) | 83 | qDebug( "ODevice() - found '%s'", (const char*) line ); |
96 | dev = new Jornada(); | 84 | if ( line.contains( "sharp", false ) ) dev = new Zaurus(); |
85 | else if ( line.contains( "ipaq", false ) ) dev = new iPAQ(); | ||
86 | else if ( line.contains( "simpad", false ) ) dev = new SIMpad(); | ||
87 | else if ( line.contains( "jornada", false ) ) dev = new Jornada(); | ||
88 | else if ( line.contains( "ramses", false ) ) dev = new Ramses(); | ||
89 | else qWarning( "ODevice() - unknown hardware - using default." ); | ||
90 | break; | ||
91 | } | ||
92 | } | ||
93 | } | ||
97 | else | 94 | else |
98 | dev = new ODevice(); | 95 | { |
96 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default." ); | ||
97 | } | ||
98 | if ( !dev ) dev = new ODevice(); | ||
99 | dev->init(); | 99 | dev->init(); |
100 | } | 100 | } |
101 | */ | ||
102 | return dev; | 101 | return dev; |
103 | } | 102 | } |
104 | 103 | ||
105 | ODevice::ODevice() | 104 | ODevice::ODevice() |
106 | { | 105 | { |
107 | d = new ODeviceData; | 106 | d = new ODeviceData; |
108 | 107 | ||
109 | d->m_modelstr = "Unknown"; | 108 | d->m_modelstr = "Unknown"; |
110 | d->m_model = Model_Unknown; | 109 | d->m_model = Model_Unknown; |
111 | d->m_vendorstr = "Unknown"; | 110 | d->m_vendorstr = "Unknown"; |
112 | d->m_vendor = Vendor_Unknown; | 111 | d->m_vendor = Vendor_Unknown; |
113 | d->m_systemstr = "Unknown"; | 112 | d->m_systemstr = "Unknown"; |
114 | d->m_system = System_Unknown; | 113 | d->m_system = System_Unknown; |
115 | d->m_sysverstr = "0.0"; | 114 | d->m_sysverstr = "0.0"; |
116 | d->m_rotation = Rot0; | 115 | d->m_rotation = Rot0; |
117 | d->m_direction = CW; | 116 | d->m_direction = CW; |
118 | 117 | ||
119 | d->m_holdtime = 1000; // 1000ms | 118 | d->m_holdtime = 1000; // 1000ms |
120 | d->m_buttons = 0; | 119 | d->m_buttons = 0; |
121 | d->m_cpu_frequencies = new QStrList; | 120 | d->m_cpu_frequencies = new QStrList; |
122 | } | 121 | } |
123 | 122 | ||
124 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 123 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
125 | { | 124 | { |
126 | if ( msg == "deviceButtonMappingChanged()" ) { | 125 | if ( msg == "deviceButtonMappingChanged()" ) { |
127 | reloadButtonMapping(); | 126 | reloadButtonMapping(); |
128 | } | 127 | } |
129 | } | 128 | } |
130 | 129 | ||
131 | void ODevice::init() | 130 | void ODevice::init() |
132 | { | 131 | { |
133 | } | 132 | } |
134 | 133 | ||
135 | /** | 134 | /** |
136 | * This method initialises the button mapping | 135 | * This method initialises the button mapping |
137 | */ | 136 | */ |
138 | void ODevice::initButtons() | 137 | void ODevice::initButtons() |
139 | { | 138 | { |
140 | if ( d->m_buttons ) | 139 | if ( d->m_buttons ) |
141 | return; | 140 | return; |
142 | 141 | ||
143 | qDebug ( "init Buttons" ); | 142 | qDebug ( "init Buttons" ); |
144 | d->m_buttons = new QValueList <ODeviceButton>; | 143 | d->m_buttons = new QValueList <ODeviceButton>; |
145 | 144 | ||
146 | reloadButtonMapping(); | 145 | reloadButtonMapping(); |
147 | 146 | ||
148 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 147 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
149 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 148 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
150 | } | 149 | } |
151 | 150 | ||
152 | ODevice::~ODevice() | 151 | ODevice::~ODevice() |
153 | { | 152 | { |
154 | // we leak m_devicebuttons and m_cpu_frequency | 153 | // we leak m_devicebuttons and m_cpu_frequency |
155 | // but it's a singleton and it is not so importantant | 154 | // but it's a singleton and it is not so importantant |
156 | // -zecke | 155 | // -zecke |
157 | delete d; | 156 | delete d; |
158 | } | 157 | } |
159 | 158 | ||
160 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 159 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
161 | { | 160 | { |
162 | return false; | 161 | return false; |
163 | } | 162 | } |
164 | 163 | ||
165 | //#include <linux/apm_bios.h> | 164 | //#include <linux/apm_bios.h> |
166 | 165 | ||
167 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 166 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
168 | 167 | ||
169 | /** | 168 | /** |
170 | * This method will try to suspend the device | 169 | * This method will try to suspend the device |
171 | * It only works if the user is the QWS Server and the apm application | 170 | * It only works if the user is the QWS Server and the apm application |
172 | * is installed. | 171 | * is installed. |
173 | * It tries to suspend and then waits some time cause some distributions | 172 | * It tries to suspend and then waits some time cause some distributions |
174 | * do have asynchronus apm implementations. | 173 | * do have asynchronus apm implementations. |
175 | * This method will either fail and return false or it'll suspend the | 174 | * This method will either fail and return false or it'll suspend the |
176 | * device and return once the device got woken up | 175 | * device and return once the device got woken up |
177 | * | 176 | * |
178 | * @return if the device got suspended | 177 | * @return if the device got suspended |
179 | */ | 178 | */ |
180 | bool ODevice::suspend() | 179 | bool ODevice::suspend() |
181 | { | 180 | { |
182 | qDebug("ODevice::suspend"); | 181 | qDebug("ODevice::suspend"); |
183 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 182 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
184 | return false; | 183 | return false; |
185 | 184 | ||
186 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 185 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
187 | return false; | 186 | return false; |
188 | 187 | ||
189 | bool res = false; | 188 | bool res = false; |
190 | 189 | ||
191 | struct timeval tvs, tvn; | 190 | struct timeval tvs, tvn; |
192 | ::gettimeofday ( &tvs, 0 ); | 191 | ::gettimeofday ( &tvs, 0 ); |
193 | 192 | ||
194 | ::sync(); // flush fs caches | 193 | ::sync(); // flush fs caches |
195 | res = ( ::system ( "apm --suspend" ) == 0 ); | 194 | res = ( ::system ( "apm --suspend" ) == 0 ); |
196 | 195 | ||
197 | // This is needed because the iPAQ apm implementation is asynchronous and we | 196 | // This is needed because the iPAQ apm implementation is asynchronous and we |
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h index bde6411..8ae7ffa 100644 --- a/libopie2/opiecore/device/odevice.h +++ b/libopie2/opiecore/device/odevice.h | |||
@@ -1,138 +1,138 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef ODEVICE_H_ | 30 | #ifndef ODEVICE_H_ |
31 | #define ODEVICE_H_ | 31 | #define ODEVICE_H_ |
32 | 32 | ||
33 | /* OPIE */ | ||
33 | #include <opie2/odevicebutton.h> | 34 | #include <opie2/odevicebutton.h> |
35 | #include <qpe/qpeapplication.h> /* for Transformation enum.. */ | ||
34 | 36 | ||
35 | /* QT */ | 37 | /* QT */ |
36 | #include <qnamespace.h> | 38 | #include <qnamespace.h> |
37 | #include <qobject.h> | 39 | #include <qobject.h> |
38 | #include <qstring.h> | 40 | #include <qstring.h> |
39 | #include <qstrlist.h> | 41 | #include <qstrlist.h> |
40 | 42 | ||
41 | #include <qpe/qpeapplication.h> /* for Transformation enum.. */ | ||
42 | |||
43 | namespace Opie | 43 | namespace Opie |
44 | { | 44 | { |
45 | class ODeviceData; | 45 | class ODeviceData; |
46 | /** | 46 | /** |
47 | * The available devices | 47 | * The available devices |
48 | */ | 48 | */ |
49 | enum OModel { | 49 | enum OModel { |
50 | Model_Unknown, // = 0 | 50 | Model_Unknown, // = 0 |
51 | 51 | ||
52 | Model_Series_Mask = 0xff000000, | 52 | Model_Series_Mask = 0xff000000, |
53 | 53 | ||
54 | Model_iPAQ = ( 1 << 24 ), | 54 | Model_iPAQ = ( 1 << 24 ), |
55 | 55 | ||
56 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), | 56 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), |
57 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), | 57 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), |
58 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), | 58 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), |
59 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), | 59 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), |
60 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), | 60 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), |
61 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), | 61 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), |
62 | Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000011 ), | 62 | Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000011 ), |
63 | 63 | ||
64 | Model_Jornada = ( 6 << 24 ), | 64 | Model_Jornada = ( 6 << 24 ), |
65 | Model_Jornada_56x = ( Model_Jornada | 0x000001 ), | 65 | Model_Jornada_56x = ( Model_Jornada | 0x000001 ), |
66 | 66 | ||
67 | Model_Zaurus = ( 2 << 24 ), | 67 | Model_Zaurus = ( 2 << 24 ), |
68 | 68 | ||
69 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), | 69 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), |
70 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), | 70 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), |
71 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), | 71 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), |
72 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), | 72 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), |
73 | Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), | 73 | Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), |
74 | 74 | ||
75 | Model_SIMpad = ( 3 << 24 ), | 75 | Model_SIMpad = ( 3 << 24 ), |
76 | 76 | ||
77 | Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), | 77 | Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), |
78 | Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), | 78 | Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), |
79 | Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), | 79 | Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), |
80 | Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), | 80 | Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), |
81 | Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), | 81 | Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), |
82 | 82 | ||
83 | Model_Ramses = ( 4 << 24 ), | 83 | Model_Ramses = ( 4 << 24 ), |
84 | 84 | ||
85 | Model_Ramses_All = ( Model_Ramses | 0xffffff ), | 85 | Model_Ramses_All = ( Model_Ramses | 0xffffff ), |
86 | Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), | 86 | Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), |
87 | 87 | ||
88 | Model_Yopy = ( 5 << 24 ), | 88 | Model_Yopy = ( 5 << 24 ), |
89 | 89 | ||
90 | Model_Yopy_All = ( Model_Yopy | 0xffffff ), | 90 | Model_Yopy_All = ( Model_Yopy | 0xffffff ), |
91 | Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), | 91 | Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), |
92 | Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), | 92 | Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), |
93 | Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), | 93 | Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), |
94 | 94 | ||
95 | }; | 95 | }; |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * The vendor of the device | 98 | * The vendor of the device |
99 | */ | 99 | */ |
100 | enum OVendor { | 100 | enum OVendor { |
101 | Vendor_Unknown, | 101 | Vendor_Unknown, |
102 | 102 | ||
103 | Vendor_HP, | 103 | Vendor_HP, |
104 | Vendor_Sharp, | 104 | Vendor_Sharp, |
105 | Vendor_SIEMENS, | 105 | Vendor_SIEMENS, |
106 | Vendor_MundN, | 106 | Vendor_MundN, |
107 | Vendor_GMate, | 107 | Vendor_GMate, |
108 | }; | 108 | }; |
109 | 109 | ||
110 | /** | 110 | /** |
111 | * The System used | 111 | * The System used |
112 | */ | 112 | */ |
113 | enum OSystem { | 113 | enum OSystem { |
114 | System_Unknown, | 114 | System_Unknown, |
115 | 115 | ||
116 | System_Familiar, | 116 | System_Familiar, |
117 | System_Zaurus, | 117 | System_Zaurus, |
118 | System_OpenZaurus, | 118 | System_OpenZaurus, |
119 | System_Linupy, | 119 | System_Linupy, |
120 | }; | 120 | }; |
121 | 121 | ||
122 | enum OLedState { | 122 | enum OLedState { |
123 | Led_Off, | 123 | Led_Off, |
124 | Led_On, | 124 | Led_On, |
125 | Led_BlinkSlow, | 125 | Led_BlinkSlow, |
126 | Led_BlinkFast | 126 | Led_BlinkFast |
127 | }; | 127 | }; |
128 | 128 | ||
129 | enum OLed { | 129 | enum OLed { |
130 | Led_Mail, | 130 | Led_Mail, |
131 | Led_Power, | 131 | Led_Power, |
132 | Led_BlueTooth | 132 | Led_BlueTooth |
133 | }; | 133 | }; |
134 | 134 | ||
135 | enum OHardKey { | 135 | enum OHardKey { |
136 | HardKey_Datebook = Qt::Key_F9, | 136 | HardKey_Datebook = Qt::Key_F9, |
137 | HardKey_Contacts = Qt::Key_F10, | 137 | HardKey_Contacts = Qt::Key_F10, |
138 | HardKey_Menu = Qt::Key_F11, | 138 | HardKey_Menu = Qt::Key_F11, |
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp index d928806..d68bce1 100644 --- a/libopie2/opiecore/device/odevice_ipaq.cpp +++ b/libopie2/opiecore/device/odevice_ipaq.cpp | |||
@@ -1,225 +1,176 @@ | |||
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.h" | 30 | #include "odevice_ipaq.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | 43 | ||
44 | /* STD */ | 44 | /* STD */ |
45 | #include <fcntl.h> | 45 | #include <fcntl.h> |
46 | #include <math.h> | 46 | #include <math.h> |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> |
48 | #include <signal.h> | 48 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 50 | #include <sys/time.h> |
51 | #include <unistd.h> | 51 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 52 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 53 | #include <linux/soundcard.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | #ifndef ARRAY_SIZE | 56 | /* KERNEL */ |
57 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | ||
58 | #endif | ||
59 | |||
60 | // _IO and friends are only defined in kernel headers ... | ||
61 | |||
62 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 57 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
63 | 58 | ||
64 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 59 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
65 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 60 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
66 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 61 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
67 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 62 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
68 | 63 | ||
69 | typedef struct { | 64 | typedef struct { |
70 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 65 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
71 | unsigned char TotalTime; /* Units of 5 seconds */ | 66 | unsigned char TotalTime; /* Units of 5 seconds */ |
72 | unsigned char OnTime; /* units of 100m/s */ | 67 | unsigned char OnTime; /* units of 100m/s */ |
73 | unsigned char OffTime; /* units of 100m/s */ | 68 | unsigned char OffTime; /* units of 100m/s */ |
74 | } LED_IN; | 69 | } LED_IN; |
75 | 70 | ||
76 | typedef struct { | 71 | typedef struct { |
77 | unsigned char mode; | 72 | unsigned char mode; |
78 | unsigned char pwr; | 73 | unsigned char pwr; |
79 | unsigned char brightness; | 74 | unsigned char brightness; |
80 | } FLITE_IN; | 75 | } FLITE_IN; |
81 | 76 | ||
82 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 77 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
83 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 78 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
84 | 79 | ||
85 | using namespace Opie; | 80 | struct i_button ipaq_buttons [] = { |
86 | |||
87 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter | ||
88 | { | ||
89 | |||
90 | protected: | ||
91 | virtual void init(); | ||
92 | virtual void initButtons(); | ||
93 | |||
94 | public: | ||
95 | virtual bool setSoftSuspend( bool soft ); | ||
96 | |||
97 | virtual bool setDisplayBrightness( int b ); | ||
98 | virtual int displayBrightnessResolution() const; | ||
99 | |||
100 | virtual void alarmSound(); | ||
101 | |||
102 | virtual QValueList <OLed> ledList() const; | ||
103 | virtual QValueList <OLedState> ledStateList( OLed led ) const; | ||
104 | virtual OLedState ledState( OLed led ) const; | ||
105 | virtual bool setLedState( OLed led, OLedState st ); | ||
106 | |||
107 | virtual bool hasLightSensor() const; | ||
108 | virtual int readLightSensor(); | ||
109 | virtual int lightSensorResolution() const; | ||
110 | |||
111 | protected: | ||
112 | virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | ||
113 | virtual void timerEvent( QTimerEvent *te ); | ||
114 | |||
115 | int m_power_timer; | ||
116 | |||
117 | OLedState m_leds [2]; | ||
118 | }; | ||
119 | |||
120 | struct i_button { | ||
121 | uint model; | ||
122 | Qt::Key code; | ||
123 | char *utext; | ||
124 | char *pix; | ||
125 | char *fpressedservice; | ||
126 | char *fpressedaction; | ||
127 | char *fheldservice; | ||
128 | char *fheldaction; | ||
129 | } ipaq_buttons [] = { | ||
130 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 81 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
131 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 82 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
132 | "devicebuttons/ipaq_calendar", | 83 | "devicebuttons/ipaq_calendar", |
133 | "datebook", "nextView()", | 84 | "datebook", "nextView()", |
134 | "today", "raise()" }, | 85 | "today", "raise()" }, |
135 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 86 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
136 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 87 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
137 | "devicebuttons/ipaq_contact", | 88 | "devicebuttons/ipaq_contact", |
138 | "addressbook", "raise()", | 89 | "addressbook", "raise()", |
139 | "addressbook", "beamBusinessCard()" }, | 90 | "addressbook", "beamBusinessCard()" }, |
140 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, | 91 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, |
141 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 92 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
142 | "devicebuttons/ipaq_menu", | 93 | "devicebuttons/ipaq_menu", |
143 | "QPE/TaskBar", "toggleMenu()", | 94 | "QPE/TaskBar", "toggleMenu()", |
144 | "QPE/TaskBar", "toggleStartMenu()" }, | 95 | "QPE/TaskBar", "toggleStartMenu()" }, |
145 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 96 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
146 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 97 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
147 | "devicebuttons/ipaq_mail", | 98 | "devicebuttons/ipaq_mail", |
148 | "mail", "raise()", | 99 | "mail", "raise()", |
149 | "mail", "newMail()" }, | 100 | "mail", "newMail()" }, |
150 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 101 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
151 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 102 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
152 | "devicebuttons/ipaq_home", | 103 | "devicebuttons/ipaq_home", |
153 | "QPE/Launcher", "home()", | 104 | "QPE/Launcher", "home()", |
154 | "buttonsettings", "raise()" }, | 105 | "buttonsettings", "raise()" }, |
155 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, | 106 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, |
156 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), | 107 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), |
157 | "devicebuttons/ipaq_record", | 108 | "devicebuttons/ipaq_record", |
158 | "QPE/VMemo", "toggleRecord()", | 109 | "QPE/VMemo", "toggleRecord()", |
159 | "sound", "raise()" }, | 110 | "sound", "raise()" }, |
160 | }; | 111 | }; |
161 | 112 | ||
162 | void iPAQ::init() | 113 | void iPAQ::init() |
163 | { | 114 | { |
164 | d->m_vendorstr = "HP"; | 115 | d->m_vendorstr = "HP"; |
165 | d->m_vendor = Vendor_HP; | 116 | d->m_vendor = Vendor_HP; |
166 | 117 | ||
167 | QFile f ( "/proc/hal/model" ); | 118 | QFile f ( "/proc/hal/model" ); |
168 | 119 | ||
169 | if ( f. open ( IO_ReadOnly )) { | 120 | if ( f. open ( IO_ReadOnly )) { |
170 | QTextStream ts ( &f ); | 121 | QTextStream ts ( &f ); |
171 | 122 | ||
172 | d->m_modelstr = "H" + ts. readLine(); | 123 | d->m_modelstr = "H" + ts. readLine(); |
173 | 124 | ||
174 | if ( d->m_modelstr == "H3100" ) | 125 | if ( d->m_modelstr == "H3100" ) |
175 | d->m_model = Model_iPAQ_H31xx; | 126 | d->m_model = Model_iPAQ_H31xx; |
176 | else if ( d->m_modelstr == "H3600" ) | 127 | else if ( d->m_modelstr == "H3600" ) |
177 | d->m_model = Model_iPAQ_H36xx; | 128 | d->m_model = Model_iPAQ_H36xx; |
178 | else if ( d->m_modelstr == "H3700" ) | 129 | else if ( d->m_modelstr == "H3700" ) |
179 | d->m_model = Model_iPAQ_H37xx; | 130 | d->m_model = Model_iPAQ_H37xx; |
180 | else if ( d->m_modelstr == "H3800" ) | 131 | else if ( d->m_modelstr == "H3800" ) |
181 | d->m_model = Model_iPAQ_H38xx; | 132 | d->m_model = Model_iPAQ_H38xx; |
182 | else if ( d->m_modelstr == "H3900" ) | 133 | else if ( d->m_modelstr == "H3900" ) |
183 | d->m_model = Model_iPAQ_H39xx; | 134 | d->m_model = Model_iPAQ_H39xx; |
184 | else if ( d->m_modelstr == "H5400" ) | 135 | else if ( d->m_modelstr == "H5400" ) |
185 | d->m_model = Model_iPAQ_H5xxx; | 136 | d->m_model = Model_iPAQ_H5xxx; |
186 | else | 137 | else |
187 | d->m_model = Model_Unknown; | 138 | d->m_model = Model_Unknown; |
188 | 139 | ||
189 | f. close(); | 140 | f. close(); |
190 | } | 141 | } |
191 | 142 | ||
192 | switch ( d->m_model ) { | 143 | switch ( d->m_model ) { |
193 | case Model_iPAQ_H31xx: | 144 | case Model_iPAQ_H31xx: |
194 | case Model_iPAQ_H38xx: | 145 | case Model_iPAQ_H38xx: |
195 | d->m_rotation = Rot90; | 146 | d->m_rotation = Rot90; |
196 | break; | 147 | break; |
197 | case Model_iPAQ_H36xx: | 148 | case Model_iPAQ_H36xx: |
198 | case Model_iPAQ_H37xx: | 149 | case Model_iPAQ_H37xx: |
199 | case Model_iPAQ_H39xx: | 150 | case Model_iPAQ_H39xx: |
200 | 151 | ||
201 | default: | 152 | default: |
202 | d->m_rotation = Rot270; | 153 | d->m_rotation = Rot270; |
203 | break; | 154 | break; |
204 | case Model_iPAQ_H5xxx: | 155 | case Model_iPAQ_H5xxx: |
205 | d->m_rotation = Rot0; | 156 | d->m_rotation = Rot0; |
206 | } | 157 | } |
207 | 158 | ||
208 | f. setName ( "/etc/familiar-version" ); | 159 | f. setName ( "/etc/familiar-version" ); |
209 | if ( f. open ( IO_ReadOnly )) { | 160 | if ( f. open ( IO_ReadOnly )) { |
210 | d->m_systemstr = "Familiar"; | 161 | d->m_systemstr = "Familiar"; |
211 | d->m_system = System_Familiar; | 162 | d->m_system = System_Familiar; |
212 | 163 | ||
213 | QTextStream ts ( &f ); | 164 | QTextStream ts ( &f ); |
214 | d->m_sysverstr = ts. readLine(). mid ( 10 ); | 165 | d->m_sysverstr = ts. readLine(). mid ( 10 ); |
215 | 166 | ||
216 | f. close(); | 167 | f. close(); |
217 | } else { | 168 | } else { |
218 | f. setName ( "/etc/oz_version" ); | 169 | f. setName ( "/etc/oz_version" ); |
219 | 170 | ||
220 | if ( f. open ( IO_ReadOnly )) { | 171 | if ( f. open ( IO_ReadOnly )) { |
221 | d->m_systemstr = "OpenEmbedded/iPaq"; | 172 | d->m_systemstr = "OpenEmbedded/iPaq"; |
222 | d->m_system = System_Familiar; | 173 | d->m_system = System_Familiar; |
223 | 174 | ||
224 | QTextStream ts ( &f ); | 175 | QTextStream ts ( &f ); |
225 | ts.setDevice ( &f ); | 176 | ts.setDevice ( &f ); |
diff --git a/libopie2/opiecore/device/odevice_ipaq.h b/libopie2/opiecore/device/odevice_ipaq.h new file mode 100644 index 0000000..baf7215 --- a/dev/null +++ b/libopie2/opiecore/device/odevice_ipaq.h | |||
@@ -0,0 +1,84 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
4 | =. | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | |||
30 | #ifndef ODEVICE_IPAQ | ||
31 | #define ODEVICE_IPAQ | ||
32 | |||
33 | #include "odevice.h" | ||
34 | |||
35 | /* QT */ | ||
36 | #include <qwindowsystem_qws.h> | ||
37 | |||
38 | using namespace Opie; | ||
39 | |||
40 | class iPAQ : public ODevice, public QWSServer::KeyboardFilter | ||
41 | { | ||
42 | |||
43 | protected: | ||
44 | virtual void init(); | ||
45 | virtual void initButtons(); | ||
46 | |||
47 | public: | ||
48 | virtual bool setSoftSuspend( bool soft ); | ||
49 | |||
50 | virtual bool setDisplayBrightness( int b ); | ||
51 | virtual int displayBrightnessResolution() const; | ||
52 | |||
53 | virtual void alarmSound(); | ||
54 | |||
55 | virtual QValueList <OLed> ledList() const; | ||
56 | virtual QValueList <OLedState> ledStateList( OLed led ) const; | ||
57 | virtual OLedState ledState( OLed led ) const; | ||
58 | virtual bool setLedState( OLed led, OLedState st ); | ||
59 | |||
60 | virtual bool hasLightSensor() const; | ||
61 | virtual int readLightSensor(); | ||
62 | virtual int lightSensorResolution() const; | ||
63 | |||
64 | protected: | ||
65 | virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | ||
66 | virtual void timerEvent( QTimerEvent *te ); | ||
67 | |||
68 | int m_power_timer; | ||
69 | |||
70 | OLedState m_leds [2]; | ||
71 | }; | ||
72 | |||
73 | struct i_button { | ||
74 | uint model; | ||
75 | Qt::Key code; | ||
76 | char *utext; | ||
77 | char *pix; | ||
78 | char *fpressedservice; | ||
79 | char *fpressedaction; | ||
80 | char *fheldservice; | ||
81 | char *fheldaction; | ||
82 | }; | ||
83 | |||
84 | #endif | ||
diff --git a/libopie2/opiecore/device/odevice_jornada.cpp b/libopie2/opiecore/device/odevice_jornada.cpp index bcd03ed..37bd6e9 100644 --- a/libopie2/opiecore/device/odevice_jornada.cpp +++ b/libopie2/opiecore/device/odevice_jornada.cpp | |||
@@ -1,214 +1,150 @@ | |||
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.h" | 30 | #include "odevice_jornada.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | 43 | ||
44 | /* STD */ | 44 | /* STD */ |
45 | #include <fcntl.h> | 45 | #include <fcntl.h> |
46 | #include <math.h> | 46 | #include <math.h> |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> |
48 | #include <signal.h> | 48 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 50 | #include <sys/time.h> |
51 | #include <unistd.h> | 51 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 52 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 53 | #include <linux/soundcard.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | #ifndef ARRAY_SIZE | 56 | /* KERNEL */ |
57 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | ||
58 | #endif | ||
59 | |||
60 | // _IO and friends are only defined in kernel headers ... | ||
61 | |||
62 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 57 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
63 | 58 | ||
64 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 59 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
65 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 60 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
66 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 61 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
67 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 62 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
68 | 63 | ||
69 | typedef struct { | 64 | typedef struct { |
70 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 65 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
71 | unsigned char TotalTime; /* Units of 5 seconds */ | 66 | unsigned char TotalTime; /* Units of 5 seconds */ |
72 | unsigned char OnTime; /* units of 100m/s */ | 67 | unsigned char OnTime; /* units of 100m/s */ |
73 | unsigned char OffTime; /* units of 100m/s */ | 68 | unsigned char OffTime; /* units of 100m/s */ |
74 | } LED_IN; | 69 | } LED_IN; |
75 | 70 | ||
76 | typedef struct { | 71 | typedef struct { |
77 | unsigned char mode; | 72 | unsigned char mode; |
78 | unsigned char pwr; | 73 | unsigned char pwr; |
79 | unsigned char brightness; | 74 | unsigned char brightness; |
80 | } FLITE_IN; | 75 | } FLITE_IN; |
81 | 76 | ||
82 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 77 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
83 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 78 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
84 | 79 | ||
85 | using namespace Opie; | 80 | using namespace Opie; |
86 | 81 | ||
87 | class Jornada : public ODevice | ||
88 | { | ||
89 | |||
90 | protected: | ||
91 | virtual void init(); | ||
92 | |||
93 | public: | ||
94 | virtual bool setSoftSuspend ( bool soft ); | ||
95 | virtual bool setDisplayBrightness ( int b ); | ||
96 | virtual int displayBrightnessResolution() const; | ||
97 | static bool isJornada(); | ||
98 | }; | ||
99 | |||
100 | |||
101 | bool Jornada::isJornada() | ||
102 | { | ||
103 | QFile f( "/proc/cpuinfo" ); | ||
104 | if ( f. open ( IO_ReadOnly ) ) { | ||
105 | QTextStream ts ( &f ); | ||
106 | QString line; | ||
107 | while( line = ts. readLine() ) { | ||
108 | if ( line. left ( 8 ) == "Hardware" ) { | ||
109 | int loc = line. find ( ":" ); | ||
110 | if ( loc != -1 ) { | ||
111 | QString model = line.mid( loc + 2 ).simplifyWhiteSpace( ); | ||
112 | return ( model == "HP Jornada 56x" ); | ||
113 | } | ||
114 | } | ||
115 | } | ||
116 | } | ||
117 | return false; | ||
118 | } | ||
119 | |||
120 | void Jornada::init() | 82 | void Jornada::init() |
121 | { | 83 | { |
122 | d->m_vendorstr = "HP"; | 84 | d->m_vendorstr = "HP"; |
123 | d->m_vendor = Vendor_HP; | 85 | d->m_vendor = Vendor_HP; |
124 | d->m_modelstr = "Jornada 56x"; | 86 | d->m_modelstr = "Jornada 56x"; |
125 | d->m_model = Model_Jornada_56x; | 87 | d->m_model = Model_Jornada_56x; |
126 | d->m_systemstr = "Familiar"; | 88 | d->m_systemstr = "Familiar"; |
127 | d->m_system = System_Familiar; | 89 | d->m_system = System_Familiar; |
128 | d->m_rotation = Rot0; | 90 | d->m_rotation = Rot0; |
129 | 91 | ||
130 | QFile f ( "/etc/familiar-version" ); | 92 | QFile f ( "/etc/familiar-version" ); |
131 | f. setName ( "/etc/familiar-version" ); | 93 | f.setName ( "/etc/familiar-version" ); |
132 | if ( f. open ( IO_ReadOnly )) { | 94 | if ( f.open ( IO_ReadOnly )) { |
133 | 95 | ||
134 | QTextStream ts ( &f ); | 96 | QTextStream ts ( &f ); |
135 | d->m_sysverstr = ts. readLine(). mid ( 10 ); | 97 | d->m_sysverstr = ts.readLine().mid( 10 ); |
136 | 98 | ||
137 | f. close(); | 99 | f. close(); |
138 | } | 100 | } |
139 | } | 101 | } |
140 | 102 | ||
141 | #if 0 | ||
142 | void Jornada::initButtons() | ||
143 | { | ||
144 | if ( d->m_buttons ) | ||
145 | return; | ||
146 | |||
147 | // Simulation uses iPAQ 3660 device buttons | ||
148 | |||
149 | qDebug ( "init Buttons" ); | ||
150 | d->m_buttons = new QValueList <ODeviceButton>; | ||
151 | |||
152 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | ||
153 | i_button *ib = ipaq_buttons + i; | ||
154 | ODeviceButton b; | ||
155 | |||
156 | if (( ib->model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | ||
157 | b. setKeycode ( ib->code ); | ||
158 | b. setUserText ( QObject::tr ( "Button", ib->utext )); | ||
159 | b. setPixmap ( Resource::loadPixmap ( ib->pix )); | ||
160 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); | ||
161 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); | ||
162 | d->m_buttons->append ( b ); | ||
163 | } | ||
164 | } | ||
165 | reloadButtonMapping(); | ||
166 | |||
167 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | ||
168 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | ||
169 | } | ||
170 | #endif | ||
171 | 103 | ||
172 | int Jornada::displayBrightnessResolution() const | 104 | int Jornada::displayBrightnessResolution() const |
173 | { | 105 | { |
106 | return 0; | ||
174 | } | 107 | } |
175 | 108 | ||
109 | |||
176 | bool Jornada::setDisplayBrightness( int bright ) | 110 | bool Jornada::setDisplayBrightness( int bright ) |
177 | { | 111 | { |
178 | bool res = false; | 112 | bool res = false; |
179 | int fd; | 113 | int fd; |
180 | 114 | ||
181 | if ( bright > 255 ) | 115 | if ( bright > 255 ) |
182 | bright = 255; | 116 | bright = 255; |
183 | if ( bright < 0 ) | 117 | if ( bright < 0 ) |
184 | bright = 0; | 118 | bright = 0; |
185 | 119 | ||
186 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 120 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
187 | FLITE_IN bl; | 121 | FLITE_IN bl; |
188 | bl. mode = 1; | 122 | bl. mode = 1; |
189 | bl. pwr = bright ? 1 : 0; | 123 | bl. pwr = bright ? 1 : 0; |
190 | bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; | 124 | bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; |
191 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 125 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
192 | ::close ( fd ); | 126 | ::close ( fd ); |
193 | } | 127 | } |
194 | return res; | 128 | return res; |
195 | } | 129 | } |
196 | 130 | ||
131 | |||
197 | bool Jornada::setSoftSuspend( bool soft ) | 132 | bool Jornada::setSoftSuspend( bool soft ) |
198 | { | 133 | { |
199 | bool res = false; | 134 | bool res = false; |
200 | int fd; | 135 | int fd; |
201 | 136 | ||
202 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 137 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
203 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 138 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
204 | res = true; | 139 | res = true; |
205 | else | 140 | else |
206 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 141 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
207 | 142 | ||
208 | ::close ( fd ); | 143 | ::close ( fd ); |
209 | } | 144 | } |
210 | else | 145 | else |
211 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 146 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
212 | 147 | ||
213 | return res; | 148 | return res; |
214 | } | 149 | } |
150 | |||
diff --git a/libopie2/opiecore/device/odevice_jornada.h b/libopie2/opiecore/device/odevice_jornada.h new file mode 100644 index 0000000..59be8da --- a/dev/null +++ b/libopie2/opiecore/device/odevice_jornada.h | |||
@@ -0,0 +1,50 @@ | |||
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_JORNADA | ||
31 | #define ODEVICE_JORNADA | ||
32 | |||
33 | #include <opie2/odevice.h> | ||
34 | |||
35 | using namespace Opie; | ||
36 | |||
37 | class Jornada : public ODevice | ||
38 | { | ||
39 | |||
40 | protected: | ||
41 | virtual void init(); | ||
42 | |||
43 | public: | ||
44 | virtual bool setSoftSuspend ( bool soft ); | ||
45 | virtual bool setDisplayBrightness ( int b ); | ||
46 | virtual int displayBrightnessResolution() const; | ||
47 | }; | ||
48 | |||
49 | #endif | ||
50 | |||
diff --git a/libopie2/opiecore/device/odevice_ramses.cpp b/libopie2/opiecore/device/odevice_ramses.cpp index a90c3a0..5bcf6a9 100644 --- a/libopie2/opiecore/device/odevice_ramses.cpp +++ b/libopie2/opiecore/device/odevice_ramses.cpp | |||
@@ -1,198 +1,152 @@ | |||
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.h" | 30 | #include "odevice_ramses.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | 43 | ||
44 | /* STD */ | 44 | /* STD */ |
45 | #include <fcntl.h> | 45 | #include <fcntl.h> |
46 | #include <math.h> | 46 | #include <math.h> |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> |
48 | #include <signal.h> | 48 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 50 | #include <sys/time.h> |
51 | #include <unistd.h> | 51 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 52 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 53 | #include <linux/soundcard.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | #ifndef ARRAY_SIZE | 56 | struct r_button ramses_buttons [] = { |
57 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | ||
58 | #endif | ||
59 | |||
60 | // _IO and friends are only defined in kernel headers ... | ||
61 | |||
62 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | ||
63 | |||
64 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | ||
65 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | ||
66 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | ||
67 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | ||
68 | |||
69 | using namespace Opie; | ||
70 | |||
71 | class Ramses : public ODevice, public QWSServer::KeyboardFilter | ||
72 | { | ||
73 | protected: | ||
74 | virtual void init(); | ||
75 | |||
76 | public: | ||
77 | virtual bool setSoftSuspend( bool soft ); | ||
78 | virtual bool suspend(); | ||
79 | |||
80 | virtual bool setDisplayStatus( bool on ); | ||
81 | virtual bool setDisplayBrightness( int b ); | ||
82 | virtual int displayBrightnessResolution() const; | ||
83 | virtual bool setDisplayContrast( int b ); | ||
84 | virtual int displayContrastResolution() const; | ||
85 | |||
86 | protected: | ||
87 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | ||
88 | virtual void timerEvent ( QTimerEvent *te ); | ||
89 | |||
90 | int m_power_timer; | ||
91 | }; | ||
92 | |||
93 | struct r_button { | ||
94 | uint model; | ||
95 | Qt::Key code; | ||
96 | char *utext; | ||
97 | char *pix; | ||
98 | char *fpressedservice; | ||
99 | char *fpressedaction; | ||
100 | char *fheldservice; | ||
101 | char *fheldaction; | ||
102 | } ramses_buttons [] = { | ||
103 | { Model_Ramses_MNCI, | 57 | { Model_Ramses_MNCI, |
104 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 58 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
105 | "devicebuttons/z_menu", | 59 | "devicebuttons/z_menu", |
106 | "QPE/TaskBar", "toggleMenu()", | 60 | "QPE/TaskBar", "toggleMenu()", |
107 | "QPE/TaskBar", "toggleStartMenu()" }, | 61 | "QPE/TaskBar", "toggleStartMenu()" }, |
108 | { Model_Ramses_MNCI, | 62 | { Model_Ramses_MNCI, |
109 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 63 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
110 | "devicebuttons/ipaq_home", | 64 | "devicebuttons/ipaq_home", |
111 | "QPE/Launcher", "home()", | 65 | "QPE/Launcher", "home()", |
112 | "buttonsettings", "raise()" }, | 66 | "buttonsettings", "raise()" }, |
113 | }; | 67 | }; |
114 | 68 | ||
115 | void Ramses::init() | 69 | void Ramses::init() |
116 | { | 70 | { |
117 | d->m_vendorstr = "M und N"; | 71 | d->m_vendorstr = "M und N"; |
118 | d->m_vendor = Vendor_MundN; | 72 | d->m_vendor = Vendor_MundN; |
119 | 73 | ||
120 | QFile f("/proc/sys/board/ramses"); | 74 | QFile f("/proc/sys/board/ramses"); |
121 | 75 | ||
122 | d->m_modelstr = "Ramses"; | 76 | d->m_modelstr = "Ramses"; |
123 | d->m_model = Model_Ramses_MNCI; | 77 | d->m_model = Model_Ramses_MNCI; |
124 | 78 | ||
125 | d->m_rotation = Rot0; | 79 | d->m_rotation = Rot0; |
126 | d->m_holdtime = 1000; | 80 | d->m_holdtime = 1000; |
127 | 81 | ||
128 | f.setName("/etc/oz_version"); | 82 | f.setName("/etc/oz_version"); |
129 | 83 | ||
130 | if (f.open(IO_ReadOnly)) { | 84 | if (f.open(IO_ReadOnly)) { |
131 | d->m_systemstr = "OpenEmbedded/Ramses"; | 85 | d->m_systemstr = "OpenEmbedded/Ramses"; |
132 | d->m_system = System_OpenZaurus; | 86 | d->m_system = System_OpenZaurus; |
133 | 87 | ||
134 | QTextStream ts(&f); | 88 | QTextStream ts(&f); |
135 | ts.setDevice(&f); | 89 | ts.setDevice(&f); |
136 | d->m_sysverstr = ts.readLine(); | 90 | d->m_sysverstr = ts.readLine(); |
137 | f.close(); | 91 | f.close(); |
138 | } | 92 | } |
139 | 93 | ||
140 | m_power_timer = 0; | 94 | m_power_timer = 0; |
141 | 95 | ||
142 | #ifdef QT_QWS_ALLOW_OVERCLOCK | 96 | #ifdef QT_QWS_ALLOW_OVERCLOCK |
143 | #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** | 97 | #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** |
144 | #define OC(x...) x | 98 | #define OC(x...) x |
145 | #else | 99 | #else |
146 | #define OC(x...) | 100 | #define OC(x...) |
147 | #endif | 101 | #endif |
148 | 102 | ||
149 | // This table is true for a Intel XScale PXA 255 | 103 | // This table is true for a Intel XScale PXA 255 |
150 | 104 | ||
151 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 | 105 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 |
152 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem | 106 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem |
153 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 | 107 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 |
154 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem | 108 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem |
155 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 | 109 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 |
156 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem | 110 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem |
157 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 | 111 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 |
158 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 | 112 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 |
159 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus | 113 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus |
160 | 114 | ||
161 | } | 115 | } |
162 | 116 | ||
163 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) | 117 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) |
164 | { | 118 | { |
165 | Q_UNUSED( keycode ); | 119 | Q_UNUSED( keycode ); |
166 | Q_UNUSED( modifiers ); | 120 | Q_UNUSED( modifiers ); |
167 | Q_UNUSED( isPress ); | 121 | Q_UNUSED( isPress ); |
168 | Q_UNUSED( autoRepeat ); | 122 | Q_UNUSED( autoRepeat ); |
169 | return false; | 123 | return false; |
170 | } | 124 | } |
171 | 125 | ||
172 | void Ramses::timerEvent(QTimerEvent *) | 126 | void Ramses::timerEvent(QTimerEvent *) |
173 | { | 127 | { |
174 | killTimer(m_power_timer); | 128 | killTimer(m_power_timer); |
175 | m_power_timer = 0; | 129 | m_power_timer = 0; |
176 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); | 130 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); |
177 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); | 131 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); |
178 | } | 132 | } |
179 | 133 | ||
180 | 134 | ||
181 | bool Ramses::setSoftSuspend(bool soft) | 135 | bool Ramses::setSoftSuspend(bool soft) |
182 | { | 136 | { |
183 | qDebug("Ramses::setSoftSuspend(%d)", soft); | 137 | qDebug("Ramses::setSoftSuspend(%d)", soft); |
184 | #if 0 | 138 | #if 0 |
185 | bool res = false; | 139 | bool res = false; |
186 | int fd; | 140 | int fd; |
187 | 141 | ||
188 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || | 142 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || |
189 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { | 143 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { |
190 | 144 | ||
191 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources | 145 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources |
192 | 146 | ||
193 | if (sources >= 0) { | 147 | if (sources >= 0) { |
194 | if (soft) | 148 | if (soft) |
195 | sources &= ~APM_EVT_POWER_BUTTON; | 149 | sources &= ~APM_EVT_POWER_BUTTON; |
196 | else | 150 | else |
197 | sources |= APM_EVT_POWER_BUTTON; | 151 | sources |= APM_EVT_POWER_BUTTON; |
198 | 152 | ||
diff --git a/libopie2/opiecore/device/odevice_ramses.h b/libopie2/opiecore/device/odevice_ramses.h new file mode 100644 index 0000000..1b660ab --- a/dev/null +++ b/libopie2/opiecore/device/odevice_ramses.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_RAMSES | ||
31 | #define ODEVICE_RAMSES | ||
32 | |||
33 | #include <opie2/odevice.h> | ||
34 | /* QT */ | ||
35 | #include <qwindowsystem_qws.h> | ||
36 | |||
37 | using namespace Opie; | ||
38 | |||
39 | class Ramses : public ODevice, public QWSServer::KeyboardFilter | ||
40 | { | ||
41 | protected: | ||
42 | virtual void init(); | ||
43 | |||
44 | public: | ||
45 | virtual bool setSoftSuspend( bool soft ); | ||
46 | virtual bool suspend(); | ||
47 | |||
48 | virtual bool setDisplayStatus( bool on ); | ||
49 | virtual bool setDisplayBrightness( int b ); | ||
50 | virtual int displayBrightnessResolution() const; | ||
51 | virtual bool setDisplayContrast( int b ); | ||
52 | virtual int displayContrastResolution() const; | ||
53 | |||
54 | protected: | ||
55 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | ||
56 | virtual void timerEvent ( QTimerEvent *te ); | ||
57 | |||
58 | int m_power_timer; | ||
59 | }; | ||
60 | |||
61 | struct r_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 | #endif | ||
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp index 82dce10..a2cd419 100644 --- a/libopie2/opiecore/device/odevice_simpad.cpp +++ b/libopie2/opiecore/device/odevice_simpad.cpp | |||
@@ -1,206 +1,154 @@ | |||
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.h" | 30 | #include "odevice_simpad.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | 43 | ||
44 | /* STD */ | 44 | /* STD */ |
45 | #include <fcntl.h> | 45 | #include <fcntl.h> |
46 | #include <math.h> | 46 | #include <math.h> |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> |
48 | #include <signal.h> | 48 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 50 | #include <sys/time.h> |
51 | #include <unistd.h> | 51 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 52 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 53 | #include <linux/soundcard.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | #ifndef ARRAY_SIZE | ||
57 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | ||
58 | #endif | ||
59 | |||
60 | // _IO and friends are only defined in kernel headers ... | ||
61 | |||
62 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | ||
63 | |||
64 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | ||
65 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | ||
66 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | ||
67 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | ||
68 | |||
69 | using namespace Opie; | 56 | using namespace Opie; |
70 | 57 | ||
71 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter | 58 | struct s_button simpad_buttons [] = { |
72 | { | ||
73 | protected: | ||
74 | virtual void init(); | ||
75 | virtual void initButtons(); | ||
76 | |||
77 | public: | ||
78 | virtual bool setSoftSuspend( bool soft ); | ||
79 | virtual bool suspend(); | ||
80 | |||
81 | virtual bool setDisplayStatus( bool on ); | ||
82 | virtual bool setDisplayBrightness( int b ); | ||
83 | virtual int displayBrightnessResolution() const; | ||
84 | |||
85 | virtual void alarmSound(); | ||
86 | |||
87 | virtual QValueList <OLed> ledList() const; | ||
88 | virtual QValueList <OLedState> ledStateList( OLed led ) const; | ||
89 | virtual OLedState ledState( OLed led ) const; | ||
90 | virtual bool setLedState( OLed led, OLedState st ); | ||
91 | |||
92 | protected: | ||
93 | virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | ||
94 | virtual void timerEvent( QTimerEvent *te ); | ||
95 | |||
96 | int m_power_timer; | ||
97 | |||
98 | OLedState m_leds [1]; | ||
99 | }; | ||
100 | |||
101 | struct s_button { | ||
102 | uint model; | ||
103 | Qt::Key code; | ||
104 | char *utext; | ||
105 | char *pix; | ||
106 | char *fpressedservice; | ||
107 | char *fpressedaction; | ||
108 | char *fheldservice; | ||
109 | char *fheldaction; | ||
110 | } simpad_buttons [] = { | ||
111 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 59 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
112 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), | 60 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), |
113 | "devicebuttons/simpad_lower_up", | 61 | "devicebuttons/simpad_lower_up", |
114 | "datebook", "nextView()", | 62 | "datebook", "nextView()", |
115 | "today", "raise()" }, | 63 | "today", "raise()" }, |
116 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 64 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
117 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), | 65 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), |
118 | "devicebuttons/simpad_lower_down", | 66 | "devicebuttons/simpad_lower_down", |
119 | "addressbook", "raise()", | 67 | "addressbook", "raise()", |
120 | "addressbook", "beamBusinessCard()" }, | 68 | "addressbook", "beamBusinessCard()" }, |
121 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 69 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
122 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), | 70 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), |
123 | "devicebuttons/simpad_lower_right", | 71 | "devicebuttons/simpad_lower_right", |
124 | "QPE/TaskBar", "toggleMenu()", | 72 | "QPE/TaskBar", "toggleMenu()", |
125 | "QPE/TaskBar", "toggleStartMenu()" }, | 73 | "QPE/TaskBar", "toggleStartMenu()" }, |
126 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 74 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
127 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), | 75 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), |
128 | "devicebuttons/simpad_lower_left", | 76 | "devicebuttons/simpad_lower_left", |
129 | "mail", "raise()", | 77 | "mail", "raise()", |
130 | "mail", "newMail()" }, | 78 | "mail", "newMail()" }, |
131 | 79 | ||
132 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 80 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
133 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), | 81 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), |
134 | "devicebuttons/simpad_upper_up", | 82 | "devicebuttons/simpad_upper_up", |
135 | "QPE/Launcher", "home()", | 83 | "QPE/Launcher", "home()", |
136 | "buttonsettings", "raise()" }, | 84 | "buttonsettings", "raise()" }, |
137 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 85 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
138 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), | 86 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), |
139 | "devicebuttons/simpad_upper_down", | 87 | "devicebuttons/simpad_upper_down", |
140 | "addressbook", "raise()", | 88 | "addressbook", "raise()", |
141 | "addressbook", "beamBusinessCard()" }, | 89 | "addressbook", "beamBusinessCard()" }, |
142 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 90 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
143 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), | 91 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), |
144 | "devicebuttons/simpad_upper_right", | 92 | "devicebuttons/simpad_upper_right", |
145 | "QPE/TaskBar", "toggleMenu()", | 93 | "QPE/TaskBar", "toggleMenu()", |
146 | "QPE/TaskBar", "toggleStartMenu()" }, | 94 | "QPE/TaskBar", "toggleStartMenu()" }, |
147 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 95 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
148 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), | 96 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), |
149 | "devicebuttons/simpad_upper_left", | 97 | "devicebuttons/simpad_upper_left", |
150 | "QPE/Rotation", "flip()", | 98 | "QPE/Rotation", "flip()", |
151 | "QPE/Rotation", "flip()" }, | 99 | "QPE/Rotation", "flip()" }, |
152 | /* | 100 | /* |
153 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 101 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
154 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 102 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
155 | "devicebuttons/simpad_lower_upper", | 103 | "devicebuttons/simpad_lower_upper", |
156 | "QPE/Launcher", "home()", | 104 | "QPE/Launcher", "home()", |
157 | "buttonsettings", "raise()" }, | 105 | "buttonsettings", "raise()" }, |
158 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 106 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
159 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 107 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
160 | "devicebuttons/simpad_upper_lower", | 108 | "devicebuttons/simpad_upper_lower", |
161 | "QPE/Launcher", "home()", | 109 | "QPE/Launcher", "home()", |
162 | "buttonsettings", "raise()" }, | 110 | "buttonsettings", "raise()" }, |
163 | */ | 111 | */ |
164 | }; | 112 | }; |
165 | 113 | ||
166 | void SIMpad::init() | 114 | void SIMpad::init() |
167 | { | 115 | { |
168 | d->m_vendorstr = "SIEMENS"; | 116 | d->m_vendorstr = "SIEMENS"; |
169 | d->m_vendor = Vendor_SIEMENS; | 117 | d->m_vendor = Vendor_SIEMENS; |
170 | 118 | ||
171 | QFile f ( "/proc/hal/model" ); | 119 | QFile f ( "/proc/hal/model" ); |
172 | 120 | ||
173 | //TODO Implement model checking | 121 | //TODO Implement model checking |
174 | //FIXME For now we assume an SL4 | 122 | //FIXME For now we assume an SL4 |
175 | 123 | ||
176 | d->m_modelstr = "SL4"; | 124 | d->m_modelstr = "SL4"; |
177 | d->m_model = Model_SIMpad_SL4; | 125 | d->m_model = Model_SIMpad_SL4; |
178 | 126 | ||
179 | switch ( d->m_model ) { | 127 | switch ( d->m_model ) { |
180 | default: | 128 | default: |
181 | d->m_rotation = Rot0; | 129 | d->m_rotation = Rot0; |
182 | d->m_direction = CCW; | 130 | d->m_direction = CCW; |
183 | d->m_holdtime = 1000; // 1000ms | 131 | d->m_holdtime = 1000; // 1000ms |
184 | 132 | ||
185 | break; | 133 | break; |
186 | } | 134 | } |
187 | 135 | ||
188 | f. setName ( "/etc/familiar-version" ); | 136 | f. setName ( "/etc/familiar-version" ); |
189 | if ( f. open ( IO_ReadOnly )) { | 137 | if ( f. open ( IO_ReadOnly )) { |
190 | d->m_systemstr = "Familiar"; | 138 | d->m_systemstr = "Familiar"; |
191 | d->m_system = System_Familiar; | 139 | d->m_system = System_Familiar; |
192 | 140 | ||
193 | QTextStream ts ( &f ); | 141 | QTextStream ts ( &f ); |
194 | d->m_sysverstr = ts. readLine(). mid ( 10 ); | 142 | d->m_sysverstr = ts. readLine(). mid ( 10 ); |
195 | 143 | ||
196 | f. close(); | 144 | f. close(); |
197 | } else { | 145 | } else { |
198 | f. setName ( "/etc/oz_version" ); | 146 | f. setName ( "/etc/oz_version" ); |
199 | 147 | ||
200 | if ( f. open ( IO_ReadOnly )) { | 148 | if ( f. open ( IO_ReadOnly )) { |
201 | d->m_systemstr = "OpenEmbedded/SIMpad"; | 149 | d->m_systemstr = "OpenEmbedded/SIMpad"; |
202 | d->m_system = System_OpenZaurus; | 150 | d->m_system = System_OpenZaurus; |
203 | 151 | ||
204 | QTextStream ts ( &f ); | 152 | QTextStream ts ( &f ); |
205 | ts.setDevice ( &f ); | 153 | ts.setDevice ( &f ); |
206 | d->m_sysverstr = ts. readLine(); | 154 | d->m_sysverstr = ts. readLine(); |
diff --git a/libopie2/opiecore/device/odevice_simpad.h b/libopie2/opiecore/device/odevice_simpad.h new file mode 100644 index 0000000..615effc --- a/dev/null +++ b/libopie2/opiecore/device/odevice_simpad.h | |||
@@ -0,0 +1,81 @@ | |||
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_SIMPAD | ||
31 | #define ODEVICE_SIMPAD | ||
32 | |||
33 | #include <opie2/odevice.h> | ||
34 | |||
35 | /* QT */ | ||
36 | #include <qwindowsystem_qws.h> | ||
37 | |||
38 | using namespace Opie; | ||
39 | |||
40 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter | ||
41 | { | ||
42 | protected: | ||
43 | virtual void init(); | ||
44 | virtual void initButtons(); | ||
45 | |||
46 | public: | ||
47 | virtual bool setSoftSuspend( bool soft ); | ||
48 | virtual bool suspend(); | ||
49 | |||
50 | virtual bool setDisplayStatus( bool on ); | ||
51 | virtual bool setDisplayBrightness( int b ); | ||
52 | virtual int displayBrightnessResolution() const; | ||
53 | |||
54 | virtual void alarmSound(); | ||
55 | |||
56 | virtual QValueList <OLed> ledList() const; | ||
57 | virtual QValueList <OLedState> ledStateList( OLed led ) const; | ||
58 | virtual OLedState ledState( OLed led ) const; | ||
59 | virtual bool setLedState( OLed led, OLedState st ); | ||
60 | |||
61 | protected: | ||
62 | virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | ||
63 | virtual void timerEvent( QTimerEvent *te ); | ||
64 | |||
65 | int m_power_timer; | ||
66 | |||
67 | OLedState m_leds [1]; | ||
68 | }; | ||
69 | |||
70 | struct s_button { | ||
71 | uint model; | ||
72 | Qt::Key code; | ||
73 | char *utext; | ||
74 | char *pix; | ||
75 | char *fpressedservice; | ||
76 | char *fpressedaction; | ||
77 | char *fheldservice; | ||
78 | char *fheldaction; | ||
79 | }; | ||
80 | |||
81 | #endif | ||
diff --git a/libopie2/opiecore/device/odevice_yopy.cpp b/libopie2/opiecore/device/odevice_yopy.cpp index 9d0cdeb..a76f90b 100644 --- a/libopie2/opiecore/device/odevice_yopy.cpp +++ b/libopie2/opiecore/device/odevice_yopy.cpp | |||
@@ -1,212 +1,163 @@ | |||
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.h" | 30 | #include "odevice_yopy.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | 43 | ||
44 | /* STD */ | 44 | /* STD */ |
45 | #include <fcntl.h> | 45 | #include <fcntl.h> |
46 | #include <math.h> | 46 | #include <math.h> |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> |
48 | #include <signal.h> | 48 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 50 | #include <sys/time.h> |
51 | #include <unistd.h> | 51 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 52 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 53 | #include <linux/soundcard.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | #ifndef ARRAY_SIZE | ||
57 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | ||
58 | #endif | ||
59 | |||
60 | // _IO and friends are only defined in kernel headers ... | ||
61 | |||
62 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | ||
63 | |||
64 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | ||
65 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | ||
66 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | ||
67 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | ||
68 | |||
69 | using namespace Opie; | 56 | using namespace Opie; |
70 | 57 | ||
71 | class Yopy : public ODevice | 58 | struct yopy_button yopy_buttons [] = { |
72 | { | 59 | { Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Action Button" ), |
73 | protected: | 60 | "devicebuttons/yopy_action", |
74 | 61 | "datebook", "nextView()", | |
75 | virtual void init(); | 62 | "today", "raise()" }, |
76 | virtual void initButtons(); | 63 | { Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "OK Button" ), |
77 | 64 | "devicebuttons/yopy_ok", | |
78 | public: | 65 | "addressbook", "raise()", |
79 | virtual bool suspend(); | 66 | "addressbook", "beamBusinessCard()" }, |
80 | 67 | { Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "End Button" ), | |
81 | virtual bool setDisplayBrightness ( int b ); | 68 | "devicebuttons/yopy_end", |
82 | virtual int displayBrightnessResolution() const; | 69 | "QPE/Launcher", "home()", |
83 | 70 | "buttonsettings", "raise()" }, | |
84 | static bool isYopy(); | ||
85 | }; | 71 | }; |
86 | 72 | ||
87 | struct yopy_button { | 73 | void Yopy::init() |
88 | Qt::Key code; | ||
89 | char *utext; | ||
90 | char *pix; | ||
91 | char *fpressedservice; | ||
92 | char *fpressedaction; | ||
93 | char *fheldservice; | ||
94 | char *fheldaction; | ||
95 | } yopy_buttons [] = { | ||
96 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), | ||
97 | "devicebuttons/yopy_action", | ||
98 | "datebook", "nextView()", | ||
99 | "today", "raise()" }, | ||
100 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), | ||
101 | "devicebuttons/yopy_ok", | ||
102 | "addressbook", "raise()", | ||
103 | "addressbook", "beamBusinessCard()" }, | ||
104 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), | ||
105 | "devicebuttons/yopy_end", | ||
106 | "QPE/Launcher", "home()", | ||
107 | "buttonsettings", "raise()" }, | ||
108 | }; | ||
109 | |||
110 | bool Yopy::isYopy() | ||
111 | { | 74 | { |
112 | QFile f( "/proc/cpuinfo" ); | 75 | d->m_vendorstr = "G.Mate"; |
113 | if ( f. open ( IO_ReadOnly ) ) { | 76 | d->m_vendor = Vendor_GMate; |
114 | QTextStream ts ( &f ); | 77 | d->m_modelstr = "Yopy3700"; |
115 | QString line; | 78 | d->m_model = Model_Yopy_3700; |
116 | while( line = ts. readLine() ) { | 79 | d->m_rotation = Rot0; |
117 | if ( line. left ( 8 ) == "Hardware" ) { | 80 | |
118 | int loc = line. find ( ":" ); | 81 | d->m_systemstr = "Linupy"; |
119 | if ( loc != -1 ) { | 82 | d->m_system = System_Linupy; |
120 | QString model = | 83 | |
121 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 84 | QFile f ( "/etc/issue" ); |
122 | return ( model == "Yopy" ); | 85 | if ( f. open ( IO_ReadOnly ) ) |
123 | } | 86 | { |
124 | } | 87 | QTextStream ts ( &f ); |
88 | ts.readLine(); | ||
89 | d->m_sysverstr = ts. readLine(); | ||
90 | f. close(); | ||
125 | } | 91 | } |
126 | } | 92 | } |
127 | return false; | ||
128 | } | ||
129 | 93 | ||
130 | void Yopy::init() | ||
131 | { | ||
132 | d->m_vendorstr = "G.Mate"; | ||
133 | d->m_vendor = Vendor_GMate; | ||
134 | d->m_modelstr = "Yopy3700"; | ||
135 | d->m_model = Model_Yopy_3700; | ||
136 | d->m_rotation = Rot0; | ||
137 | |||
138 | d->m_systemstr = "Linupy"; | ||
139 | d->m_system = System_Linupy; | ||
140 | |||
141 | QFile f ( "/etc/issue" ); | ||
142 | if ( f. open ( IO_ReadOnly )) { | ||
143 | QTextStream ts ( &f ); | ||
144 | ts.readLine(); | ||
145 | d->m_sysverstr = ts. readLine(); | ||
146 | f. close(); | ||
147 | } | ||
148 | } | ||
149 | 94 | ||
150 | void Yopy::initButtons() | 95 | void Yopy::initButtons() |
151 | { | 96 | { |
152 | if ( d->m_buttons ) | 97 | if ( d->m_buttons ) |
153 | return; | 98 | return ; |
154 | 99 | ||
155 | d->m_buttons = new QValueList <ODeviceButton>; | 100 | d->m_buttons = new QValueList <ODeviceButton>; |
156 | 101 | ||
157 | for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { | 102 | for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ ) |
103 | { | ||
158 | 104 | ||
159 | yopy_button *ib = yopy_buttons + i; | 105 | yopy_button *ib = yopy_buttons + i; |
160 | 106 | ||
161 | ODeviceButton b; | 107 | ODeviceButton b; |
162 | 108 | ||
163 | b. setKeycode ( ib->code ); | 109 | b. setKeycode ( ib->code ); |
164 | b. setUserText ( QObject::tr ( "Button", ib->utext )); | 110 | b. setUserText ( QObject::tr ( "Button", ib->utext ) ); |
165 | b. setPixmap ( Resource::loadPixmap ( ib->pix )); | 111 | b. setPixmap ( Resource::loadPixmap ( ib->pix ) ); |
166 | b. setFactoryPresetPressedAction | 112 | b. setFactoryPresetPressedAction |
167 | (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); | 113 | ( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) ); |
168 | b. setFactoryPresetHeldAction | 114 | b. setFactoryPresetHeldAction |
169 | (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); | 115 | ( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) ); |
170 | 116 | ||
171 | d->m_buttons->append ( b ); | 117 | d->m_buttons->append ( b ); |
172 | } | 118 | } |
173 | reloadButtonMapping(); | 119 | reloadButtonMapping(); |
174 | 120 | ||
175 | QCopChannel *sysch = new QCopChannel("QPE/System", this); | 121 | QCopChannel *sysch = new QCopChannel( "QPE/System", this ); |
176 | connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), | 122 | connect( sysch, SIGNAL( received( const QCString &, const QByteArray & ) ), |
177 | this, SLOT(systemMessage(const QCString &, const QByteArray & ))); | 123 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); |
178 | } | 124 | } |
179 | 125 | ||
126 | |||
180 | bool Yopy::suspend() | 127 | bool Yopy::suspend() |
181 | { | 128 | { |
182 | /* Opie for Yopy does not implement its own power management at the | 129 | /* Opie for Yopy does not implement its own power management at the |
183 | moment. The public version runs parallel to X, and relies on the | 130 | moment. The public version runs parallel to X, and relies on the |
184 | existing power management features. */ | 131 | existing power management features. */ |
185 | return false; | 132 | return false; |
186 | } | 133 | } |
187 | 134 | ||
188 | bool Yopy::setDisplayBrightness(int bright) | 135 | |
136 | bool Yopy::setDisplayBrightness( int bright ) | ||
189 | { | 137 | { |
190 | /* The code here works, but is disabled as the current version runs | 138 | /* The code here works, but is disabled as the current version runs |
191 | parallel to X, and relies on the existing backlight demon. */ | 139 | parallel to X, and relies on the existing backlight demon. */ |
192 | #if 0 | 140 | #if 0 |
193 | if ( QFile::exists("/proc/sys/pm/light") ) { | 141 | if ( QFile::exists( "/proc/sys/pm/light" ) ) |
194 | int fd = ::open("/proc/sys/pm/light", O_WRONLY); | 142 | { |
195 | if (fd >= 0 ) { | 143 | int fd = ::open( "/proc/sys/pm/light", O_WRONLY ); |
196 | if (bright) | 144 | if ( fd >= 0 ) |
197 | ::write(fd, "1\n", 2); | 145 | { |
198 | else | 146 | if ( bright ) |
199 | ::write(fd, "0\n", 2); | 147 | ::write( fd, "1\n", 2 ); |
200 | ::close(fd); | 148 | else |
201 | return true; | 149 | ::write( fd, "0\n", 2 ); |
150 | ::close( fd ); | ||
151 | return true; | ||
152 | } | ||
202 | } | 153 | } |
203 | } | ||
204 | #endif | 154 | #endif |
205 | return false; | 155 | return false; |
206 | } | 156 | } |
207 | 157 | ||
158 | |||
208 | int Yopy::displayBrightnessResolution() const | 159 | int Yopy::displayBrightnessResolution() const |
209 | { | 160 | { |
210 | return 2; | 161 | return 2; |
211 | } | 162 | } |
212 | 163 | ||
diff --git a/libopie2/opiecore/device/odevice_yopy.h b/libopie2/opiecore/device/odevice_yopy.h new file mode 100644 index 0000000..be8f62c --- a/dev/null +++ b/libopie2/opiecore/device/odevice_yopy.h | |||
@@ -0,0 +1,62 @@ | |||
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_YOPY | ||
31 | #define ODEVICE_YOPY | ||
32 | |||
33 | #include <opie2/odevice.h> | ||
34 | |||
35 | using namespace Opie; | ||
36 | |||
37 | class Yopy : public ODevice | ||
38 | { | ||
39 | protected: | ||
40 | |||
41 | virtual void init(); | ||
42 | virtual void initButtons(); | ||
43 | |||
44 | public: | ||
45 | virtual bool suspend(); | ||
46 | |||
47 | virtual bool setDisplayBrightness ( int b ); | ||
48 | virtual int displayBrightnessResolution() const; | ||
49 | }; | ||
50 | |||
51 | struct yopy_button | ||
52 | { | ||
53 | Qt::Key code; | ||
54 | char *utext; | ||
55 | char *pix; | ||
56 | char *fpressedservice; | ||
57 | char *fpressedaction; | ||
58 | char *fheldservice; | ||
59 | char *fheldaction; | ||
60 | }; | ||
61 | |||
62 | #endif | ||
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index a6e8b82..78bc62e 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -1,311 +1,212 @@ | |||
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.h" | 30 | #include "odevice_zaurus.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | 43 | ||
44 | /* STD */ | 44 | /* STD */ |
45 | #include <fcntl.h> | 45 | #include <fcntl.h> |
46 | #include <math.h> | 46 | #include <math.h> |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> |
48 | #include <signal.h> | 48 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 50 | #include <sys/time.h> |
51 | #include <unistd.h> | 51 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 52 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 53 | #include <linux/soundcard.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | #ifndef ARRAY_SIZE | ||
57 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | ||
58 | #endif | ||
59 | |||
60 | // _IO and friends are only defined in kernel headers ... | ||
61 | |||
62 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | ||
63 | |||
64 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | ||
65 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | ||
66 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | ||
67 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | ||
68 | |||
69 | using namespace Opie; | 56 | using namespace Opie; |
70 | 57 | ||
71 | class Zaurus : public ODevice | 58 | struct z_button z_buttons [] = { |
72 | { | ||
73 | |||
74 | protected: | ||
75 | virtual void init(); | ||
76 | virtual void initButtons(); | ||
77 | |||
78 | public: | ||
79 | virtual bool setSoftSuspend ( bool soft ); | ||
80 | |||
81 | virtual bool setDisplayBrightness ( int b ); | ||
82 | virtual int displayBrightnessResolution() const; | ||
83 | |||
84 | virtual void alarmSound(); | ||
85 | virtual void keySound(); | ||
86 | virtual void touchSound(); | ||
87 | |||
88 | virtual QValueList <OLed> ledList() const; | ||
89 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | ||
90 | virtual OLedState ledState( OLed led ) const; | ||
91 | virtual bool setLedState( OLed led, OLedState st ); | ||
92 | |||
93 | virtual bool hasHingeSensor() const; | ||
94 | virtual OHingeStatus readHingeSensor(); | ||
95 | |||
96 | static bool isZaurus(); | ||
97 | |||
98 | virtual bool suspend(); | ||
99 | virtual Transformation rotation() const; | ||
100 | virtual ODirection direction() const; | ||
101 | |||
102 | protected: | ||
103 | virtual void buzzer ( int snd ); | ||
104 | |||
105 | OLedState m_leds [1]; | ||
106 | bool m_embedix; | ||
107 | }; | ||
108 | |||
109 | struct z_button { | ||
110 | Qt::Key code; | ||
111 | char *utext; | ||
112 | char *pix; | ||
113 | char *fpressedservice; | ||
114 | char *fpressedaction; | ||
115 | char *fheldservice; | ||
116 | char *fheldaction; | ||
117 | } z_buttons [] = { | ||
118 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 59 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
119 | "devicebuttons/z_calendar", | 60 | "devicebuttons/z_calendar", |
120 | "datebook", "nextView()", | 61 | "datebook", "nextView()", |
121 | "today", "raise()" }, | 62 | "today", "raise()" }, |
122 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 63 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
123 | "devicebuttons/z_contact", | 64 | "devicebuttons/z_contact", |
124 | "addressbook", "raise()", | 65 | "addressbook", "raise()", |
125 | "addressbook", "beamBusinessCard()" }, | 66 | "addressbook", "beamBusinessCard()" }, |
126 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 67 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
127 | "devicebuttons/z_home", | 68 | "devicebuttons/z_home", |
128 | "QPE/Launcher", "home()", | 69 | "QPE/Launcher", "home()", |
129 | "buttonsettings", "raise()" }, | 70 | "buttonsettings", "raise()" }, |
130 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 71 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
131 | "devicebuttons/z_menu", | 72 | "devicebuttons/z_menu", |
132 | "QPE/TaskBar", "toggleMenu()", | 73 | "QPE/TaskBar", "toggleMenu()", |
133 | "QPE/TaskBar", "toggleStartMenu()" }, | 74 | "QPE/TaskBar", "toggleStartMenu()" }, |
134 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 75 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
135 | "devicebuttons/z_mail", | 76 | "devicebuttons/z_mail", |
136 | "mail", "raise()", | 77 | "mail", "raise()", |
137 | "mail", "newMail()" }, | 78 | "mail", "newMail()" }, |
138 | }; | 79 | }; |
139 | 80 | ||
140 | struct z_button z_buttons_c700 [] = { | 81 | struct z_button z_buttons_c700 [] = { |
141 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 82 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
142 | "devicebuttons/z_calendar", | 83 | "devicebuttons/z_calendar", |
143 | "datebook", "nextView()", | 84 | "datebook", "nextView()", |
144 | "today", "raise()" }, | 85 | "today", "raise()" }, |
145 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 86 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
146 | "devicebuttons/z_contact", | 87 | "devicebuttons/z_contact", |
147 | "addressbook", "raise()", | 88 | "addressbook", "raise()", |
148 | "addressbook", "beamBusinessCard()" }, | 89 | "addressbook", "beamBusinessCard()" }, |
149 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 90 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
150 | "devicebuttons/z_home", | 91 | "devicebuttons/z_home", |
151 | "QPE/Launcher", "home()", | 92 | "QPE/Launcher", "home()", |
152 | "buttonsettings", "raise()" }, | 93 | "buttonsettings", "raise()" }, |
153 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 94 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
154 | "devicebuttons/z_menu", | 95 | "devicebuttons/z_menu", |
155 | "QPE/TaskBar", "toggleMenu()", | 96 | "QPE/TaskBar", "toggleMenu()", |
156 | "QPE/TaskBar", "toggleStartMenu()" }, | 97 | "QPE/TaskBar", "toggleStartMenu()" }, |
157 | { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), | 98 | { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), |
158 | "devicebuttons/z_hinge", | 99 | "devicebuttons/z_hinge", |
159 | "QPE/Rotation", "rotateDefault()", | 100 | "QPE/Rotation", "rotateDefault()", |
160 | "QPE/Dummy", "doNothing()" }, | 101 | "QPE/Dummy", "doNothing()" }, |
161 | }; | 102 | }; |
162 | 103 | ||
163 | // Check whether this device is the sharp zaurus.. | ||
164 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus | 104 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus |
165 | // class up into individual classes. We need three classes | 105 | // class up into individual classes. We need three classes |
166 | // | 106 | // |
167 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) | 107 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) |
168 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) | 108 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) |
169 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) | 109 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) |
170 | // | 110 | // |
171 | // Only question right now is: Do we really need to do it? Because as soon | 111 | // Only question right now is: Do we really need to do it? Because as soon |
172 | // as the OpenZaurus kernel is ready, there will be a unified interface for all | 112 | // as the OpenZaurus kernel is ready, there will be a unified interface for all |
173 | // Zaurus models (concerning apm, backlight, buttons, etc.) | 113 | // Zaurus models (concerning apm, backlight, buttons, etc.) |
174 | // | 114 | // |
175 | // Comments? - mickeyl. | 115 | // Comments? - mickeyl. |
176 | 116 | ||
177 | bool Zaurus::isZaurus() | ||
178 | { | ||
179 | |||
180 | // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! | ||
181 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ | ||
182 | return true; | ||
183 | } | ||
184 | |||
185 | // On non-embedix kernels, we have to look closer. | ||
186 | bool is_zaurus = false; | ||
187 | QFile f ( "/proc/cpuinfo" ); | ||
188 | if ( f. open ( IO_ReadOnly ) ) { | ||
189 | QString model; | ||
190 | QFile f ( "/proc/cpuinfo" ); | ||
191 | |||
192 | QTextStream ts ( &f ); | ||
193 | QString line; | ||
194 | while( line = ts. readLine() ) { | ||
195 | if ( line. left ( 8 ) == "Hardware" ) | ||
196 | break; | ||
197 | } | ||
198 | int loc = line. find ( ":" ); | ||
199 | if ( loc != -1 ) | ||
200 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | ||
201 | |||
202 | if ( model == "Sharp-Collie" | ||
203 | || model == "Collie" | ||
204 | || model == "SHARP Corgi" | ||
205 | || model == "SHARP Shepherd" | ||
206 | || model == "SHARP Poodle" | ||
207 | || model == "SHARP Husky" | ||
208 | ) | ||
209 | is_zaurus = true; | ||
210 | |||
211 | } | ||
212 | return is_zaurus; | ||
213 | } | ||
214 | |||
215 | |||
216 | void Zaurus::init() | 117 | void Zaurus::init() |
217 | { | 118 | { |
218 | d->m_vendorstr = "Sharp"; | 119 | d->m_vendorstr = "Sharp"; |
219 | d->m_vendor = Vendor_Sharp; | 120 | d->m_vendor = Vendor_Sharp; |
220 | m_embedix = true; // Not openzaurus means: It has an embedix kernel ! | 121 | m_embedix = true; // Not openzaurus means: It has an embedix kernel ! |
221 | 122 | ||
222 | // QFile f ( "/proc/filesystems" ); | 123 | // QFile f ( "/proc/filesystems" ); |
223 | QString model; | 124 | QString model; |
224 | 125 | ||
225 | // It isn't a good idea to check the system configuration to | 126 | // It isn't a good idea to check the system configuration to |
226 | // detect the distribution ! | 127 | // detect the distribution ! |
227 | // Otherwise it may happen that any other distribution is detected as openzaurus, just | 128 | // Otherwise it may happen that any other distribution is detected as openzaurus, just |
228 | // because it uses a jffs2 filesystem.. | 129 | // because it uses a jffs2 filesystem.. |
229 | // (eilers) | 130 | // (eilers) |
230 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read(). find ( "\tjffs2\n" ) >= 0 )) { | 131 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read(). find ( "\tjffs2\n" ) >= 0 )) { |
231 | QFile f ("/etc/oz_version"); | 132 | QFile f ("/etc/oz_version"); |
232 | if ( f.exists() ){ | 133 | if ( f.exists() ){ |
233 | d->m_vendorstr = "OpenZaurus Team"; | 134 | d->m_vendorstr = "OpenZaurus Team"; |
234 | d->m_systemstr = "OpenZaurus"; | 135 | d->m_systemstr = "OpenZaurus"; |
235 | d->m_system = System_OpenZaurus; | 136 | d->m_system = System_OpenZaurus; |
236 | 137 | ||
237 | if ( f. open ( IO_ReadOnly )) { | 138 | if ( f. open ( IO_ReadOnly )) { |
238 | QTextStream ts ( &f ); | 139 | QTextStream ts ( &f ); |
239 | d->m_sysverstr = ts. readLine();//. mid ( 10 ); | 140 | d->m_sysverstr = ts. readLine();//. mid ( 10 ); |
240 | f. close(); | 141 | f. close(); |
241 | } | 142 | } |
242 | 143 | ||
243 | // Openzaurus sometimes uses the embedix kernel! | 144 | // Openzaurus sometimes uses the embedix kernel! |
244 | // => Check whether this is an embedix kernel | 145 | // => Check whether this is an embedix kernel |
245 | FILE *uname = popen("uname -r", "r"); | 146 | FILE *uname = popen("uname -r", "r"); |
246 | QString line; | 147 | QString line; |
247 | if ( f.open(IO_ReadOnly, uname) ) { | 148 | if ( f.open(IO_ReadOnly, uname) ) { |
248 | QTextStream ts ( &f ); | 149 | QTextStream ts ( &f ); |
249 | line = ts. readLine(); | 150 | line = ts. readLine(); |
250 | int loc = line. find ( "embedix" ); | 151 | int loc = line. find ( "embedix" ); |
251 | if ( loc != -1 ) | 152 | if ( loc != -1 ) |
252 | m_embedix = true; | 153 | m_embedix = true; |
253 | else | 154 | else |
254 | m_embedix = false; | 155 | m_embedix = false; |
255 | f. close(); | 156 | f. close(); |
256 | } | 157 | } |
257 | pclose(uname); | 158 | pclose(uname); |
258 | } | 159 | } |
259 | else { | 160 | else { |
260 | d->m_systemstr = "Zaurus"; | 161 | d->m_systemstr = "Zaurus"; |
261 | d->m_system = System_Zaurus; | 162 | d->m_system = System_Zaurus; |
262 | } | 163 | } |
263 | 164 | ||
264 | f. setName ( "/proc/cpuinfo" ); | 165 | f. setName ( "/proc/cpuinfo" ); |
265 | if ( f. open ( IO_ReadOnly ) ) { | 166 | if ( f. open ( IO_ReadOnly ) ) { |
266 | QTextStream ts ( &f ); | 167 | QTextStream ts ( &f ); |
267 | QString line; | 168 | QString line; |
268 | while( line = ts. readLine() ) { | 169 | while( line = ts. readLine() ) { |
269 | if ( line. left ( 8 ) == "Hardware" ) | 170 | if ( line. left ( 8 ) == "Hardware" ) |
270 | break; | 171 | break; |
271 | } | 172 | } |
272 | int loc = line. find ( ":" ); | 173 | int loc = line. find ( ":" ); |
273 | if ( loc != -1 ) | 174 | if ( loc != -1 ) |
274 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 175 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
275 | } | 176 | } |
276 | 177 | ||
277 | if ( model == "SHARP Corgi" ) { | 178 | if ( model == "SHARP Corgi" ) { |
278 | d->m_model = Model_Zaurus_SLC7x0; | 179 | d->m_model = Model_Zaurus_SLC7x0; |
279 | d->m_modelstr = "Zaurus SL-C700"; | 180 | d->m_modelstr = "Zaurus SL-C700"; |
280 | } else if ( model == "SHARP Shepherd" ) { | 181 | } else if ( model == "SHARP Shepherd" ) { |
281 | d->m_model = Model_Zaurus_SLC7x0; | 182 | d->m_model = Model_Zaurus_SLC7x0; |
282 | d->m_modelstr = "Zaurus SL-C750"; | 183 | d->m_modelstr = "Zaurus SL-C750"; |
283 | } else if ( model == "SHARP Husky" ) { | 184 | } else if ( model == "SHARP Husky" ) { |
284 | d->m_model = Model_Zaurus_SLC7x0; | 185 | d->m_model = Model_Zaurus_SLC7x0; |
285 | d->m_modelstr = "Zaurus SL-C760"; | 186 | d->m_modelstr = "Zaurus SL-C760"; |
286 | } else if ( model == "SHARP Poodle" ) { | 187 | } else if ( model == "SHARP Poodle" ) { |
287 | d->m_model = Model_Zaurus_SLB600; | 188 | d->m_model = Model_Zaurus_SLB600; |
288 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; | 189 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; |
289 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 190 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
290 | d->m_model = Model_Zaurus_SL5500; | 191 | d->m_model = Model_Zaurus_SL5500; |
291 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 192 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
292 | } else { | 193 | } else { |
293 | d->m_model = Model_Zaurus_SL5500; | 194 | d->m_model = Model_Zaurus_SL5500; |
294 | d->m_modelstr = "Zaurus (Model unknown)"; | 195 | d->m_modelstr = "Zaurus (Model unknown)"; |
295 | } | 196 | } |
296 | 197 | ||
297 | bool flipstate = false; | 198 | bool flipstate = false; |
298 | switch ( d->m_model ) { | 199 | switch ( d->m_model ) { |
299 | case Model_Zaurus_SLA300: | 200 | case Model_Zaurus_SLA300: |
300 | d->m_rotation = Rot0; | 201 | d->m_rotation = Rot0; |
301 | break; | 202 | break; |
302 | case Model_Zaurus_SLC7x0: | 203 | case Model_Zaurus_SLC7x0: |
303 | d->m_rotation = rotation(); | 204 | d->m_rotation = rotation(); |
304 | d->m_direction = direction(); | 205 | d->m_direction = direction(); |
305 | break; | 206 | break; |
306 | case Model_Zaurus_SLB600: | 207 | case Model_Zaurus_SLB600: |
307 | case Model_Zaurus_SL5500: | 208 | case Model_Zaurus_SL5500: |
308 | case Model_Zaurus_SL5000: | 209 | case Model_Zaurus_SL5000: |
309 | default: | 210 | default: |
310 | d->m_rotation = Rot270; | 211 | d->m_rotation = Rot270; |
311 | break; | 212 | break; |
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h new file mode 100644 index 0000000..c07fe07 --- a/dev/null +++ b/libopie2/opiecore/device/odevice_zaurus.h | |||
@@ -0,0 +1,96 @@ | |||
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_ZAURUS | ||
31 | #define ODEVICE_ZAURUS | ||
32 | |||
33 | #include <opie2/odevice.h> | ||
34 | |||
35 | #ifndef ARRAY_SIZE | ||
36 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | ||
37 | #endif | ||
38 | |||
39 | // _IO and friends are only defined in kernel headers ... | ||
40 | |||
41 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | ||
42 | |||
43 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | ||
44 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | ||
45 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | ||
46 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | ||
47 | |||
48 | using namespace Opie; | ||
49 | |||
50 | class Zaurus : public ODevice | ||
51 | { | ||
52 | |||
53 | protected: | ||
54 | virtual void init(); | ||
55 | virtual void initButtons(); | ||
56 | |||
57 | public: | ||
58 | virtual bool setSoftSuspend ( bool soft ); | ||
59 | |||
60 | virtual bool setDisplayBrightness ( int b ); | ||
61 | virtual int displayBrightnessResolution() const; | ||
62 | |||
63 | virtual void alarmSound(); | ||
64 | virtual void keySound(); | ||
65 | virtual void touchSound(); | ||
66 | |||
67 | virtual QValueList <OLed> ledList() const; | ||
68 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | ||
69 | virtual OLedState ledState( OLed led ) const; | ||
70 | virtual bool setLedState( OLed led, OLedState st ); | ||
71 | |||
72 | virtual bool hasHingeSensor() const; | ||
73 | virtual OHingeStatus readHingeSensor(); | ||
74 | |||
75 | virtual bool suspend(); | ||
76 | virtual Transformation rotation() const; | ||
77 | virtual ODirection direction() const; | ||
78 | |||
79 | protected: | ||
80 | virtual void buzzer ( int snd ); | ||
81 | |||
82 | OLedState m_leds [1]; | ||
83 | bool m_embedix; | ||
84 | }; | ||
85 | |||
86 | struct z_button { | ||
87 | Qt::Key code; | ||
88 | char *utext; | ||
89 | char *pix; | ||
90 | char *fpressedservice; | ||
91 | char *fpressedaction; | ||
92 | char *fheldservice; | ||
93 | char *fheldaction; | ||
94 | }; | ||
95 | |||
96 | #endif | ||
diff --git a/libopie2/opiecore/opiecore.pro b/libopie2/opiecore/opiecore.pro index 97e8146..98d315f 100644 --- a/libopie2/opiecore/opiecore.pro +++ b/libopie2/opiecore/opiecore.pro | |||
@@ -1,49 +1,55 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on debug | 2 | CONFIG += qt warn_on debug |
3 | DESTDIR = $(OPIEDIR)/lib | 3 | DESTDIR = $(OPIEDIR)/lib |
4 | HEADERS = oapplication.h \ | 4 | HEADERS = oapplication.h \ |
5 | oconfig.h \ | 5 | oconfig.h \ |
6 | odebug.h \ | 6 | odebug.h \ |
7 | odevice.h \ | 7 | odevice.h \ |
8 | odevicebutton.h \ | 8 | odevicebutton.h \ |
9 | odevice_ipaq.h \ | ||
10 | odevice_jornada.h \ | ||
11 | odevice_ramses.h \ | ||
12 | odevice_simpad.h \ | ||
13 | odevice_zaurus.h \ | ||
14 | odevice_yopy.h \ | ||
9 | oglobal.h \ | 15 | oglobal.h \ |
10 | oglobalsettings.h \ | 16 | oglobalsettings.h \ |
11 | oprocess.h \ | 17 | oprocess.h \ |
12 | oprocctrl.h \ | 18 | oprocctrl.h \ |
13 | ostorageinfo.h | 19 | ostorageinfo.h |
14 | 20 | ||
15 | SOURCES = oapplication.cpp \ | 21 | SOURCES = oapplication.cpp \ |
16 | oconfig.cpp \ | 22 | oconfig.cpp \ |
17 | odebug.cpp \ | 23 | odebug.cpp \ |
18 | odevice.cpp \ | 24 | odevice.cpp \ |
19 | odevicebutton.cpp \ | 25 | odevicebutton.cpp \ |
20 | odevice_ipaq.cpp \ | 26 | odevice_ipaq.cpp \ |
21 | odevice_jornada.cpp \ | 27 | odevice_jornada.cpp \ |
22 | odevice_ramses.cpp \ | 28 | odevice_ramses.cpp \ |
23 | odevice_simpad.cpp \ | 29 | odevice_simpad.cpp \ |
24 | odevice_zaurus.cpp \ | 30 | odevice_zaurus.cpp \ |
25 | odevice_yopy.cpp \ | 31 | odevice_yopy.cpp \ |
26 | oglobal.cpp \ | 32 | oglobal.cpp \ |
27 | oglobalsettings.cpp \ | 33 | oglobalsettings.cpp \ |
28 | oprocess.cpp \ | 34 | oprocess.cpp \ |
29 | oprocctrl.cpp \ | 35 | oprocctrl.cpp \ |
30 | ostorageinfo.cpp | 36 | ostorageinfo.cpp |
31 | 37 | ||
32 | INTERFACES = | 38 | INTERFACES = |
33 | TARGET = opiecore2 | 39 | TARGET = opiecore2 |
34 | VERSION = 1.8.3 | 40 | VERSION = 1.8.3 |
35 | INCLUDEPATH += $(OPIEDIR)/include | 41 | INCLUDEPATH += $(OPIEDIR)/include |
36 | DEPENDPATH += $(OPIEDIR)/include | 42 | DEPENDPATH += $(OPIEDIR)/include |
37 | MOC_DIR = moc | 43 | MOC_DIR = moc |
38 | OBJECTS_DIR = obj | 44 | OBJECTS_DIR = obj |
39 | 45 | ||
40 | 46 | ||
41 | !contains( platform, x11 ) { | 47 | !contains( platform, x11 ) { |
42 | LIBS = -lqpe | 48 | LIBS = -lqpe |
43 | include ( $(OPIEDIR)/include.pro ) | 49 | include ( $(OPIEDIR)/include.pro ) |
44 | } | 50 | } |
45 | 51 | ||
46 | contains( platform, x11 ) { | 52 | contains( platform, x11 ) { |
47 | LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib | 53 | LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib |
48 | } | 54 | } |
49 | 55 | ||