Diffstat (limited to 'libopie2/opiecore/device/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 73 |
1 files changed, 36 insertions, 37 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,149 +1,148 @@ | |||
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 & ))); |