summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-05-23 01:59:47 (UTC)
committer llornkcor <llornkcor>2002-05-23 01:59:47 (UTC)
commitae177d167999f204a968ea21ae4a4a804d939e6d (patch) (unidiff)
treef73cde3f861b8016053d4cdfa5236e2394f45c97
parentb448fc3d97345bbc52ce79fb1901e0a610e9a55c (diff)
downloadopie-ae177d167999f204a968ea21ae4a4a804d939e6d.zip
opie-ae177d167999f204a968ea21ae4a4a804d939e6d.tar.gz
opie-ae177d167999f204a968ea21ae4a4a804d939e6d.tar.bz2
make sound conform to sharps warped sense of conf
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 5f61c0c..cf437da 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -79,214 +79,214 @@
79#include <sys/file.h> 79#include <sys/file.h>
80#include <sys/ioctl.h> 80#include <sys/ioctl.h>
81#include <sys/soundcard.h> 81#include <sys/soundcard.h>
82 82
83// for setBacklight() 83// for setBacklight()
84#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 84#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
85#include <linux/fb.h> 85#include <linux/fb.h>
86#include <sys/types.h> 86#include <sys/types.h>
87#include <sys/stat.h> 87#include <sys/stat.h>
88#endif 88#endif
89#include <stdlib.h> 89#include <stdlib.h>
90 90
91 91
92class QPEApplicationData { 92class QPEApplicationData {
93public: 93public:
94 QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE), 94 QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE),
95 kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE), 95 kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE),
96 forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0), 96 forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0),
97 keep_running(TRUE) 97 keep_running(TRUE)
98 { 98 {
99 qcopq.setAutoDelete(TRUE); 99 qcopq.setAutoDelete(TRUE);
100 } 100 }
101 101
102 int presstimer; 102 int presstimer;
103 QWidget* presswidget; 103 QWidget* presswidget;
104 QPoint presspos; 104 QPoint presspos;
105 bool rightpressed; 105 bool rightpressed;
106 int kbgrabber; 106 int kbgrabber;
107 bool kbregrab; 107 bool kbregrab;
108 bool notbusysent; 108 bool notbusysent;
109 QString appName; 109 QString appName;
110 struct QCopRec { 110 struct QCopRec {
111 QCopRec(const QCString &ch, const QCString &msg, 111 QCopRec(const QCString &ch, const QCString &msg,
112 const QByteArray &d) : 112 const QByteArray &d) :
113 channel(ch), message(msg), data(d) { } 113 channel(ch), message(msg), data(d) { }
114 114
115 QCString channel; 115 QCString channel;
116 QCString message; 116 QCString message;
117 QByteArray data; 117 QByteArray data;
118 }; 118 };
119 bool preloaded; 119 bool preloaded;
120 bool forceshow; 120 bool forceshow;
121 bool nomaximize; 121 bool nomaximize;
122 QWidget* qpe_main_widget; 122 QWidget* qpe_main_widget;
123 bool keep_running; 123 bool keep_running;
124 QList<QCopRec> qcopq; 124 QList<QCopRec> qcopq;
125 125
126 void enqueueQCop(const QCString &ch, const QCString &msg, 126 void enqueueQCop(const QCString &ch, const QCString &msg,
127 const QByteArray &data) 127 const QByteArray &data)
128 { 128 {
129 qcopq.append(new QCopRec(ch,msg,data)); 129 qcopq.append(new QCopRec(ch,msg,data));
130 } 130 }
131 void sendQCopQ() 131 void sendQCopQ()
132 { 132 {
133 QCopRec* r; 133 QCopRec* r;
134 for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it) 134 for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it)
135 QCopChannel::sendLocally(r->channel,r->message,r->data); 135 QCopChannel::sendLocally(r->channel,r->message,r->data);
136 qcopq.clear(); 136 qcopq.clear();
137 } 137 }
138}; 138};
139 139
140class ResourceMimeFactory : public QMimeSourceFactory { 140class ResourceMimeFactory : public QMimeSourceFactory {
141public: 141public:
142 ResourceMimeFactory() 142 ResourceMimeFactory()
143 { 143 {
144 setFilePath( Global::helpPath() ); 144 setFilePath( Global::helpPath() );
145 setExtensionType("html","text/html;charset=UTF-8"); 145 setExtensionType("html","text/html;charset=UTF-8");
146 } 146 }
147 147
148 const QMimeSource* data(const QString& abs_name) const 148 const QMimeSource* data(const QString& abs_name) const
149 { 149 {
150 const QMimeSource* r = QMimeSourceFactory::data(abs_name); 150 const QMimeSource* r = QMimeSourceFactory::data(abs_name);
151 if ( !r ) { 151 if ( !r ) {
152 int sl = abs_name.length(); 152 int sl = abs_name.length();
153 do { 153 do {
154 sl = abs_name.findRev('/',sl-1); 154 sl = abs_name.findRev('/',sl-1);
155 QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name; 155 QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name;
156 int dot = name.findRev('.'); 156 int dot = name.findRev('.');
157 if ( dot >= 0 ) 157 if ( dot >= 0 )
158 name = name.left(dot); 158 name = name.left(dot);
159 QImage img = Resource::loadImage(name); 159 QImage img = Resource::loadImage(name);
160 if ( !img.isNull() ) 160 if ( !img.isNull() )
161 r = new QImageDrag(img); 161 r = new QImageDrag(img);
162 } while (!r && sl>0); 162 } while (!r && sl>0);
163 } 163 }
164 return r; 164 return r;
165 } 165 }
166}; 166};
167 167
168static int muted=0; 168static int muted=0;
169static int micMuted=0; 169static int micMuted=0;
170 170
171static void setVolume(int t=0, int percent=-1) 171static void setVolume(int t=0, int percent=-1)
172{ 172{
173 switch (t) { 173 switch (t) {
174 case 0: { 174 case 0: {
175 Config cfg("Sound"); 175 Config cfg("qpe");
176 cfg.setGroup("System"); 176 cfg.setGroup("Volume");
177 if ( percent < 0 ) 177 if ( percent < 0 )
178 percent = cfg.readNumEntry("Volume",50); 178 percent = cfg.readNumEntry("VolumePercent",50);
179 int fd = 0; 179 int fd = 0;
180 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 180 if ((fd = open("/dev/mixer", O_RDWR))>=0) {
181 int vol = muted ? 0 : percent; 181 int vol = muted ? 0 : percent;
182 // set both channels to same volume 182 // set both channels to same volume
183 vol |= vol << 8; 183 vol |= vol << 8;
184 ioctl(fd, MIXER_WRITE(0), &vol); 184 ioctl(fd, MIXER_WRITE(0), &vol);
185 ::close(fd); 185 ::close(fd);
186 } 186 }
187 } break; 187 } break;
188 } 188 }
189} 189}
190 190
191static void setMic(int t=0, int percent=-1) 191static void setMic(int t=0, int percent=-1)
192{ 192{
193 switch (t) { 193 switch (t) {
194 case 0: { 194 case 0: {
195 Config cfg("Sound"); 195 Config cfg("qpe");
196 cfg.setGroup("System"); 196 cfg.setGroup("Volume");
197 if ( percent < 0 ) 197 if ( percent < 0 )
198 percent = cfg.readNumEntry("Mic",50); 198 percent = cfg.readNumEntry("Mic",50);
199 199
200 int fd = 0; 200 int fd = 0;
201 int mic = micMuted ? 0 : percent; 201 int mic = micMuted ? 0 : percent;
202 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 202 if ((fd = open("/dev/mixer", O_RDWR))>=0) {
203 ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic); 203 ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic);
204 ::close(fd); 204 ::close(fd);
205 } 205 }
206 } break; 206 } break;
207 } 207 }
208} 208}
209 209
210int qpe_sysBrightnessSteps() 210int qpe_sysBrightnessSteps()
211{ 211{
212#if defined(QT_QWS_IPAQ) 212#if defined(QT_QWS_IPAQ)
213 return 255; 213 return 255;
214#elif defined(QT_QWS_EBX) 214#elif defined(QT_QWS_EBX)
215 return 4; 215 return 4;
216#else 216#else
217 return 255; // ? 217 return 255; // ?
218#endif 218#endif
219} 219}
220 220
221 221
222static int& hack(int& i) 222static int& hack(int& i)
223{ 223{
224#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 224#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
225 // These should be created, but aren't in Qt 2.3.0 225 // These should be created, but aren't in Qt 2.3.0
226 (void)new QUtf8Codec; 226 (void)new QUtf8Codec;
227 (void)new QUtf16Codec; 227 (void)new QUtf16Codec;
228#endif 228#endif
229 return i; 229 return i;
230} 230}
231 231
232static bool forced_off = FALSE; 232static bool forced_off = FALSE;
233static int curbl=-1; 233static int curbl=-1;
234 234
235static int backlight() 235static int backlight()
236{ 236{
237 if ( curbl == -1 ) { 237 if ( curbl == -1 ) {
238 // Read from config 238 // Read from config
239 Config config( "qpe" ); 239 Config config( "qpe" );
240 config.setGroup( "Screensaver" ); 240 config.setGroup( "Screensaver" );
241 curbl = config.readNumEntry("Brightness",255); 241 curbl = config.readNumEntry("Brightness",255);
242 } 242 }
243 return curbl; 243 return curbl;
244} 244}
245 245
246static void setBacklight(int bright) 246static void setBacklight(int bright)
247{ 247{
248 if ( bright == -3 ) { 248 if ( bright == -3 ) {
249 // Forced on 249 // Forced on
250 forced_off = FALSE; 250 forced_off = FALSE;
251 bright = -1; 251 bright = -1;
252 } 252 }
253 if ( forced_off && bright != -2 ) 253 if ( forced_off && bright != -2 )
254 return; 254 return;
255 if ( bright == -2 ) { 255 if ( bright == -2 ) {
256 // Toggle between off and on 256 // Toggle between off and on
257 bright = curbl ? 0 : -1; 257 bright = curbl ? 0 : -1;
258 forced_off = !bright; 258 forced_off = !bright;
259 } 259 }
260 if ( bright == -1 ) { 260 if ( bright == -1 ) {
261 // Read from config 261 // Read from config
262 Config config( "qpe" ); 262 Config config( "qpe" );
263 config.setGroup( "Screensaver" ); 263 config.setGroup( "Screensaver" );
264 bright = config.readNumEntry("Brightness",255); 264 bright = config.readNumEntry("Brightness",255);
265 } 265 }
266#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 266#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
267 if ( QFile::exists("/usr/bin/bl") ) { 267 if ( QFile::exists("/usr/bin/bl") ) {
268 QString cmd = "/usr/bin/bl 1 "; 268 QString cmd = "/usr/bin/bl 1 ";
269 cmd += bright<=0 ? "0 " : "1 "; 269 cmd += bright<=0 ? "0 " : "1 ";
270 cmd += QString::number(bright); 270 cmd += QString::number(bright);
271 system(cmd.latin1()); 271 system(cmd.latin1());
272#if defined(QT_QWS_EBX) 272#if defined(QT_QWS_EBX)
273 } else if ( QFile::exists("/dev/fl") ) { 273 } else if ( QFile::exists("/dev/fl") ) {
274#define FL_IOCTL_STEP_CONTRAST 100 274#define FL_IOCTL_STEP_CONTRAST 100
275 int fd = open("/dev/fl", O_WRONLY); 275 int fd = open("/dev/fl", O_WRONLY);
276 if (fd >= 0 ) { 276 if (fd >= 0 ) {
277 int steps = qpe_sysBrightnessSteps(); 277 int steps = qpe_sysBrightnessSteps();
278 int bl = ( bright * steps + 127 ) / 255; 278 int bl = ( bright * steps + 127 ) / 255;
279 if ( bright && !bl ) bl = 1; 279 if ( bright && !bl ) bl = 1;
280 bl = ioctl(fd, FL_IOCTL_STEP_CONTRAST, bl); 280 bl = ioctl(fd, FL_IOCTL_STEP_CONTRAST, bl);
281 close(fd); 281 close(fd);
282 } 282 }
283 } 283 }
284#elif defined(QT_QWS_IPAQ) 284#elif defined(QT_QWS_IPAQ)
285 } else if ( QFile::exists("/dev/ts") || QFile::exists("/dev/h3600_ts") ) { 285 } else if ( QFile::exists("/dev/ts") || QFile::exists("/dev/h3600_ts") ) {
286 typedef struct { 286 typedef struct {
287 unsigned char mode; 287 unsigned char mode;
288 unsigned char pwr; 288 unsigned char pwr;
289 unsigned char brightness; 289 unsigned char brightness;
290 } FLITE_IN; 290 } FLITE_IN;
291# ifndef FLITE_ON 291# ifndef FLITE_ON
292# ifndef _LINUX_IOCTL_H 292# ifndef _LINUX_IOCTL_H