summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_mypal.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/libopie2/opiecore/device/odevice_mypal.cpp b/libopie2/opiecore/device/odevice_mypal.cpp
index 208be46..73b31cb 100644
--- a/libopie2/opiecore/device/odevice_mypal.cpp
+++ b/libopie2/opiecore/device/odevice_mypal.cpp
@@ -1,268 +1,268 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> 3 =. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; version 2 of the License. 10 - .   .-<_>     .<> Foundation; version 2 of the License.
11     ._= =}       : 11     ._= =}       :
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30#include "odevice_mypal.h" 30#include "odevice_mypal.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qdir.h> 34#include <qdir.h>
35#include <qfile.h> 35#include <qfile.h>
36#include <qtextstream.h> 36#include <qtextstream.h>
37#include <qwindowsystem_qws.h> 37#include <qwindowsystem_qws.h>
38 38
39/* OPIE */ 39/* OPIE */
40#include <qpe/config.h> 40#include <qpe/config.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#include <opie2/okeyfilter.h> 44#include <opie2/okeyfilter.h>
45#include <opie2/oresource.h> 45#include <opie2/oresource.h>
46 46
47/* STD */ 47/* STD */
48#include <fcntl.h> 48#include <fcntl.h>
49#include <math.h> 49#include <math.h>
50#include <stdlib.h> 50#include <stdlib.h>
51#include <signal.h> 51#include <signal.h>
52#include <sys/ioctl.h> 52#include <sys/ioctl.h>
53#include <sys/time.h> 53#include <sys/time.h>
54#include <unistd.h> 54#include <unistd.h>
55#ifndef QT_NO_SOUND 55#ifndef QT_NO_SOUND
56#include <linux/soundcard.h> 56#include <linux/soundcard.h>
57#endif 57#endif
58 58
59 59
60using namespace Opie::Core; 60using namespace Opie::Core;
61using namespace Opie::Core::Internal; 61using namespace Opie::Core::Internal;
62 62
63#define Model_Keyboardless_2_6 (Model_MyPal_716) 63#define Model_Keyboardless_2_6 (Model_MyPal_716)
64 64
65struct m_button mypal_buttons [] = { 65struct m_button mypal_buttons [] = {
66 // Common button map for all keyboardless devices with 2.6 kernel 66 // Common button map for all keyboardless devices with 2.6 kernel
67 { Model_Keyboardless_2_6, 67 { Model_Keyboardless_2_6,
68 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 68 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
69 "devicebuttons/ipaq_calendar", 69 "devicebuttons/ipaq_calendar",
70 "datebook", "nextView()", 70 "datebook", "nextView()",
71 "today", "raise()" }, 71 "today", "raise()" },
72 { Model_Keyboardless_2_6, 72 { Model_Keyboardless_2_6,
73 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 73 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
74 "devicebuttons/ipaq_contact", 74 "devicebuttons/ipaq_contact",
75 "addressbook", "raise()", 75 "addressbook", "raise()",
76 "addressbook", "beamBusinessCard()" }, 76 "addressbook", "beamBusinessCard()" },
77 { Model_Keyboardless_2_6, 77 { Model_Keyboardless_2_6,
78 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Mail Button"), 78 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Mail Button"),
79 "devicebuttons/ipaq_mail", 79 "devicebuttons/ipaq_mail",
80 "opiemail", "raise()", 80 "opiemail", "raise()",
81 "opiemail", "newMail()" }, 81 "opiemail", "newMail()" },
82 { Model_Keyboardless_2_6, 82 { Model_Keyboardless_2_6,
83 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 83 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
84 "devicebuttons/ipaq_home", 84 "devicebuttons/ipaq_home",
85 "QPE/Launcher", "home()", 85 "QPE/Launcher", "home()",
86 "buttonsettings", "raise()" }, 86 "buttonsettings", "raise()" },
87 { Model_Keyboardless_2_6, 87 { Model_Keyboardless_2_6,
88 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 88 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
89 "devicebuttons/ipaq_record", 89 "devicebuttons/ipaq_record",
90 "QPE/VMemo", "toggleRecord()", 90 "QPE/VMemo", "toggleRecord()",
91 "sound", "raise()" }, 91 "sound", "raise()" },
92}; 92};
93 93
94void MyPal::init(const QString& model) 94void MyPal::init(const QString& model)
95{ 95{
96 d->m_vendorstr = "Asus"; 96 d->m_vendorstr = "Asus";
97 d->m_vendor = Vendor_Asus; 97 d->m_vendor = Vendor_Asus;
98 98
99 d->m_modelstr = model.mid(model.findRev('A')); 99 d->m_modelstr = model.mid(model.findRev('A'));
100 if ( d->m_modelstr == "A716" ) 100 if ( d->m_modelstr == "A716" )
101 d->m_model = Model_MyPal_716; 101 d->m_model = Model_MyPal_716;
102 else 102 else
103 d->m_model = Model_Unknown; 103 d->m_model = Model_Unknown;
104 104
105 d->m_rotation = Rot0; 105 d->m_rotation = Rot0;
106 106
107 m_power_timer = 0; 107 m_power_timer = 0;
108} 108}
109 109
110void MyPal::initButtons() 110void MyPal::initButtons()
111{ 111{
112 if ( d->m_buttons ) 112 if ( d->m_buttons )
113 return; 113 return;
114 114
115 if ( isQWS( ) ) { 115 if ( isQWS( ) ) {
116 addPreHandler(this); 116 addPreHandler(this);
117 } 117 }
118 118
119 d->m_buttons = new QValueList <ODeviceButton>; 119 d->m_buttons = new QValueList <ODeviceButton>;
120 120
121 for ( uint i = 0; i < ( sizeof( mypal_buttons ) / sizeof( m_button )); i++ ) { 121 for ( uint i = 0; i < ( sizeof( mypal_buttons ) / sizeof( m_button )); i++ ) {
122 m_button *mb = mypal_buttons + i; 122 m_button *mb = mypal_buttons + i;
123 ODeviceButton b; 123 ODeviceButton b;
124 124
125 if (( mb->model & d->m_model ) == d->m_model ) { 125 if (( mb->model & d->m_model ) == d->m_model ) {
126 b. setKeycode ( mb->code ); 126 b. setKeycode ( mb->code );
127 b. setUserText ( QObject::tr ( "Button", mb->utext )); 127 b. setUserText ( QObject::tr ( "Button", mb->utext ));
128 b. setPixmap ( OResource::loadPixmap ( mb->pix )); 128 b. setPixmap ( OResource::loadPixmap ( mb->pix ));
129 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( mb->fpressedservice ), mb->fpressedaction )); 129 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( mb->fpressedservice ), mb->fpressedaction ));
130 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( mb->fheldservice ), mb->fheldaction )); 130 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( mb->fheldservice ), mb->fheldaction ));
131 131
132 d->m_buttons->append ( b ); 132 d->m_buttons->append ( b );
133 } 133 }
134 } 134 }
135 reloadButtonMapping(); 135 reloadButtonMapping();
136} 136}
137 137
138bool MyPal::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 138bool MyPal::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
139{ 139{
140 int newkeycode = keycode; 140 int newkeycode = keycode;
141 141
142 switch ( keycode ) { 142 switch ( keycode ) {
143 case Key_Left : 143 case Key_Left :
144 case Key_Right: 144 case Key_Right:
145 case Key_Up : 145 case Key_Up :
146 case Key_Down : { 146 case Key_Down : {
147 // Rotate the cursor keys by 270 147 // Rotate the cursor keys by 270
148 // keycode - Key_Left = position of the button starting from left clockwise 148 // keycode - Key_Left = position of the button starting from left clockwise
149 // add the rotation to it and modolo. No we've the original offset 149 // add the rotation to it and modolo. No we've the original offset
150 // add the offset to the Key_Left key 150 // add the offset to the Key_Left key
151 if ( d->m_model == Model_MyPal_716 ) 151 if ( d->m_model == Model_MyPal_716 )
152 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 152 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
153 break; 153 break;
154 } 154 }
155 155
156 // map Power Button short/long press to F6 156 // map Power Button short/long press
157 case Key_F6: { 157 case HardKey_Suspend: { // Hope we don't have infinite recursion here:
158 if ( isPress ) { 158 if ( isPress ) {
159 if ( m_power_timer ) 159 if ( m_power_timer )
160 killTimer ( m_power_timer ); 160 killTimer ( m_power_timer );
161 m_power_timer = startTimer ( 500 ); 161 m_power_timer = startTimer ( 500 );
162 } 162 }
163 else if ( m_power_timer ) { 163 else if ( m_power_timer ) {
164 killTimer ( m_power_timer ); 164 killTimer ( m_power_timer );
165 m_power_timer = 0; 165 m_power_timer = 0;
166 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 166 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
167 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 167 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
168 } 168 }
169 newkeycode = Key_unknown; 169 newkeycode = Key_unknown;
170 break; 170 break;
171 } 171 }
172 } 172 }
173 173
174 if ( newkeycode != keycode ) { 174 if ( newkeycode != keycode ) {
175 if ( newkeycode != Key_unknown ) 175 if ( newkeycode != Key_unknown )
176 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 176 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
177 return true; 177 return true;
178 } 178 }
179 else 179 else
180 return false; 180 return false;
181} 181}
182 182
183void MyPal::timerEvent ( QTimerEvent * ) 183void MyPal::timerEvent ( QTimerEvent * )
184{ 184{
185 killTimer ( m_power_timer ); 185 killTimer ( m_power_timer );
186 m_power_timer = 0; 186 m_power_timer = 0;
187 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 187 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
188 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 188 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
189} 189}
190 190
191 191
192void MyPal::playAlarmSound() 192void MyPal::playAlarmSound()
193{ 193{
194#ifndef QT_NO_SOUND 194#ifndef QT_NO_SOUND
195 static Sound snd ( "alarm" ); 195 static Sound snd ( "alarm" );
196 if(!snd.isFinished()) 196 if(!snd.isFinished())
197 return; 197 return;
198 198
199 changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); 199 changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
200 snd. play(); 200 snd. play();
201#endif 201#endif
202} 202}
203 203
204bool MyPal::setDisplayBrightness ( int bright ) 204bool MyPal::setDisplayBrightness ( int bright )
205{ 205{
206 bool res = false; 206 bool res = false;
207 207
208 if ( bright > 255 ) 208 if ( bright > 255 )
209 bright = 255; 209 bright = 255;
210 if ( bright < 0 ) 210 if ( bright < 0 )
211 bright = 0; 211 bright = 0;
212 212
213 QDir sysClass( "/sys/class/backlight/pxafb/" ); 213 QDir sysClass( "/sys/class/backlight/pxafb/" );
214 sysClass.setFilter(QDir::Dirs); 214 sysClass.setFilter(QDir::Dirs);
215 int fd; 215 int fd;
216 if ( sysClass.exists() ) { 216 if ( sysClass.exists() ) {
217 QString sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/power" ); 217 QString sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/power" );
218 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK ); 218 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
219 if ( fd ) { 219 if ( fd ) {
220 char buf[10]; 220 char buf[10];
221 buf[0] = bright ? 0 : 4; 221 buf[0] = bright ? 0 : 4;
222 buf[1] = '\0'; 222 buf[1] = '\0';
223 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 223 res = ( ::write( fd, &buf[0], 2 ) == 0 );
224 ::close( fd ); 224 ::close( fd );
225 } 225 }
226 sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/brightness" ); 226 sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/brightness" );
227 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK ); 227 fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
228 if ( fd ) { 228 if ( fd ) {
229 char buf[100]; 229 char buf[100];
230 int len = ::snprintf( &buf[0], sizeof buf, "%d", bright ); 230 int len = ::snprintf( &buf[0], sizeof buf, "%d", bright );
231 res = ( ::write( fd, &buf[0], len ) == 0 ); 231 res = ( ::write( fd, &buf[0], len ) == 0 );
232 ::close( fd ); 232 ::close( fd );
233 } 233 }
234 } 234 }
235 235
236 return res; 236 return res;
237} 237}
238 238
239int MyPal::displayBrightnessResolution() const 239int MyPal::displayBrightnessResolution() const
240{ 240{
241 switch ( model()) { 241 switch ( model()) {
242 case Model_MyPal_716: 242 case Model_MyPal_716:
243 return 7; 243 return 7;
244 default: 244 default:
245 return OAbstractMobileDevice::displayBrightnessResolution(); 245 return OAbstractMobileDevice::displayBrightnessResolution();
246 } 246 }
247} 247}
248 248
249bool MyPal::setDisplayStatus ( bool on ) 249bool MyPal::setDisplayStatus ( bool on )
250{ 250{
251 bool res = false; 251 bool res = false;
252 252
253 QDir sysClass( "/sys/class/lcd/" ); 253 QDir sysClass( "/sys/class/lcd/" );
254 sysClass.setFilter(QDir::Dirs); 254 sysClass.setFilter(QDir::Dirs);
255 if ( sysClass.exists() ) { 255 if ( sysClass.exists() ) {
256 QString sysClassPath = sysClass.absFilePath( "/sys/class/lcd/pxafb/power" ); 256 QString sysClassPath = sysClass.absFilePath( "/sys/class/lcd/pxafb/power" );
257 int fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK ); 257 int fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK );
258 if ( fd ) { 258 if ( fd ) {
259 char buf[10]; 259 char buf[10];
260 buf[0] = on ? 0 : 4; 260 buf[0] = on ? 0 : 4;
261 buf[1] = '\0'; 261 buf[1] = '\0';
262 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 262 res = ( ::write( fd, &buf[0], 2 ) == 0 );
263 ::close( fd ); 263 ::close( fd );
264 } 264 }
265 } 265 }
266 266
267 return res; 267 return res;
268} 268}