summaryrefslogtreecommitdiff
authorchicken <chicken>2004-05-21 19:16:16 (UTC)
committer chicken <chicken>2004-05-21 19:16:16 (UTC)
commit91fcb5849e61a39336ae1ae06a41b4eac501fbf5 (patch) (unidiff)
treeeeb63644fe18c091d1a0507017d9a8ef74bd9621
parent265c43b58186a7527144038f113501a8329ff8e7 (diff)
downloadopie-91fcb5849e61a39336ae1ae06a41b4eac501fbf5.zip
opie-91fcb5849e61a39336ae1ae06a41b4eac501fbf5.tar.gz
opie-91fcb5849e61a39336ae1ae06a41b4eac501fbf5.tar.bz2
correct jornada 56x button handling for opie
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_jornada.cpp63
-rw-r--r--libopie2/opiecore/device/odevice_jornada.h13
2 files changed, 71 insertions, 5 deletions
diff --git a/libopie2/opiecore/device/odevice_jornada.cpp b/libopie2/opiecore/device/odevice_jornada.cpp
index 75c9fc5..526f9cb 100644
--- a/libopie2/opiecore/device/odevice_jornada.cpp
+++ b/libopie2/opiecore/device/odevice_jornada.cpp
@@ -48,119 +48,172 @@
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/* KERNEL */ 56/* KERNEL */
57#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 ))
58 58
59#define OD_IO(type,number) OD_IOC(0,type,number,0) 59#define OD_IO(type,number) OD_IOC(0,type,number,0)
60#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))
61#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))
62#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))
63 63
64typedef struct { 64typedef struct {
65 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 65 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
66 unsigned char TotalTime; /* Units of 5 seconds */ 66 unsigned char TotalTime; /* Units of 5 seconds */
67 unsigned char OnTime; /* units of 100m/s */ 67 unsigned char OnTime; /* units of 100m/s */
68 unsigned char OffTime; /* units of 100m/s */ 68 unsigned char OffTime; /* units of 100m/s */
69} LED_IN; 69} LED_IN;
70 70
71typedef struct { 71typedef struct {
72 unsigned char mode; 72 unsigned char mode;
73 unsigned char pwr; 73 unsigned char pwr;
74 unsigned char brightness; 74 unsigned char brightness;
75} FLITE_IN; 75} FLITE_IN;
76 76
77#define LED_ON OD_IOW( 'f', 5, LED_IN ) 77#define LED_ON OD_IOW( 'f', 5, LED_IN )
78#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 78#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
79 79
80using namespace Opie::Core;
80using namespace Opie::Core::Internal; 81using namespace Opie::Core::Internal;
81 82
83struct j_button jornada56x_buttons [] = {
84 { Model_Jornada_56x,
85 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
86 "devicebuttons/jornada56x_calendar",
87 "datebook", "nextView()",
88 "today", "raise()" },
89 { Model_Jornada_56x,
90 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
91 "devicebuttons/jornada56x_contact",
92 "addressbook", "raise()",
93 "addressbook", "beamBusinessCard()" },
94 { Model_Jornada_56x,
95 Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Todo Button"),
96 "devicebuttons/jornada56x_todo",
97 "todolist", "raise()",
98 "todolist", "create()" },
99 { Model_Jornada_56x,
100 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Home Button"),
101 "devicebuttons/jornada56x_home",
102 "QPE/Launcher", "home()",
103 "buttonsettings", "raise()" },
104 { Model_Jornada_56x,
105 Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Record Button"),
106 "devicebuttons/jornada56x_record",
107 "QPE/VMemo", "toggleRecord()",
108 "sound", "raise()" },
109};
110
82void Jornada::init(const QString&) 111void Jornada::init(const QString&)
83{ 112{
84 d->m_vendorstr = "HP"; 113 d->m_vendorstr = "HP";
85 d->m_vendor = Vendor_HP; 114 d->m_vendor = Vendor_HP;
86 d->m_modelstr = "Jornada 56x"; 115 d->m_modelstr = "Jornada 56x";
87 d->m_model = Model_Jornada_56x; 116 d->m_model = Model_Jornada_56x;
88 d->m_systemstr = "Familiar"; 117 d->m_systemstr = "Familiar";
89 d->m_system = System_Familiar; 118 d->m_system = System_Familiar;
90 d->m_rotation = Rot0; 119 d->m_rotation = Rot0;
91 120
92 QFile f ( "/etc/familiar-version" ); 121 QFile f ( "/etc/familiar-version" );
93 f.setName ( "/etc/familiar-version" ); 122 f.setName ( "/etc/familiar-version" );
94 if ( f.open ( IO_ReadOnly )) { 123 if ( f.open ( IO_ReadOnly )) {
95 124
96 QTextStream ts ( &f ); 125 QTextStream ts ( &f );
97 d->m_sysverstr = ts.readLine().mid( 10 ); 126 d->m_sysverstr = ts.readLine().mid( 10 );
98 127
99 f. close(); 128 f. close();
100 } 129 }
101} 130}
102 131
132void Jornada::initButtons()
133{
134 if ( d->m_buttons )
135 return;
136
137 d->m_buttons = new QValueList <ODeviceButton>;
138
139 for ( uint i = 0; i < ( sizeof( jornada56x_buttons ) / sizeof( j_button )); i++ ) {
140 j_button *ib = jornada56x_buttons + i;
141 ODeviceButton b;
142
143 if (( ib->model & d->m_model ) == d->m_model ) {
144 b. setKeycode ( ib->code );
145 b. setUserText ( QObject::tr ( "Button", ib->utext ));
146 b. setPixmap ( Resource::loadPixmap ( ib->pix ));
147 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
148 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
149
150 d->m_buttons->append ( b );
151 }
152 }
153 reloadButtonMapping();
154
155 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
156 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
157}
103 158
104int Jornada::displayBrightnessResolution() const 159int Jornada::displayBrightnessResolution() const
105{ 160{
106 return 255; 161 return 255;
107} 162}
108 163
109 164
110bool Jornada::setDisplayBrightness( int bright ) 165bool Jornada::setDisplayBrightness( int bright )
111{ 166{
112 bool res = false; 167 bool res = false;
113 int fd;
114 168
115 if ( bright > 255 ) 169 if ( bright > 255 )
116 bright = 255; 170 bright = 255;
117 if ( bright < 0 ) 171 if ( bright < 0 )
118 bright = 0; 172 bright = 0;
119 173
120 QString cmdline; 174 QString cmdline;
121 175
122 int value = 255 - bright; 176 int value = 255 - bright;
123 if ( !bright ) 177 if ( !bright )
124 cmdline = QString().sprintf( "echo 0 > /sys/class/backlight/sa1100fb/power"); 178 cmdline = QString().sprintf( "echo 0 > /sys/class/backlight/sa1100fb/power");
125 else 179 else
126 cmdline = QString().sprintf( "echo 1 > /sys/class/backlight/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/brightness", value ); 180 cmdline = QString().sprintf( "echo 1 > /sys/class/backlight/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/brightness", value );
127 181
128 res = ( ::system( (const char*) cmdline ) == 0 ); 182 res = ( ::system( (const char*) cmdline ) == 0 );
129 183
130 return res; 184 return res;
131} 185}
132 186
133 187
134bool Jornada::suspend( ) 188bool Jornada::suspend( )
135{ 189{
136 qDebug("ODevice::suspend"); 190 qDebug("ODevice::suspend");
137 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 191 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
138 return false; 192 return false;
139 193
140 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 194 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
141 return false; 195 return false;
142 196
143 bool res = false; 197 bool res = false;
144 ODevice::sendSuspendmsg(); 198 ODevice::sendSuspendmsg();
145 199
146 struct timeval tvs, tvn; 200 struct timeval tvs;
147 ::gettimeofday ( &tvs, 0 ); 201 ::gettimeofday ( &tvs, 0 );
148 202
149 ::sync(); // flush fs caches 203 ::sync(); // flush fs caches
150 res = ( ::system ( "apm --suspend" ) == 0 ); 204 res = ( ::system ( "apm --suspend" ) == 0 );
151 205
152 return res; 206 return res;
153} 207}
154 208
155bool Jornada::setDisplayStatus ( bool on ) 209bool Jornada::setDisplayStatus ( bool on )
156{ 210{
157 bool res = false; 211 bool res = false;
158 int fd; 212
159 213 QString cmdline = QString().sprintf( "echo %d > /sys/class/lcd/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/power", on ? "1" : "0", on ? "1" : "0" );
160 QString cmdline = QString().sprintf( "echo %d > /sys/class/lcd/sa1100fb/power; echo %d > /sys/class/backlight/sa1100fb/power", on ? "1" : "0",on ? "1" : "0" );
161 214
162 res = ( ::system( (const char*) cmdline ) == 0 ); 215 res = ( ::system( (const char*) cmdline ) == 0 );
163 216
164 return res; 217 return res;
165} 218}
166 219
diff --git a/libopie2/opiecore/device/odevice_jornada.h b/libopie2/opiecore/device/odevice_jornada.h
index 2a9e821..b17fa8b 100644
--- a/libopie2/opiecore/device/odevice_jornada.h
+++ b/libopie2/opiecore/device/odevice_jornada.h
@@ -11,44 +11,57 @@
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_JORNADA 30#ifndef ODEVICE_JORNADA
31#define ODEVICE_JORNADA 31#define ODEVICE_JORNADA
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34 34
35namespace Opie { 35namespace Opie {
36namespace Core { 36namespace Core {
37namespace Internal { 37namespace Internal {
38class Jornada : public ODevice 38class Jornada : public ODevice
39{ 39{
40 40
41 protected: 41 protected:
42 virtual void init(const QString&); 42 virtual void init(const QString&);
43 virtual void initButtons();
43 44
44 public: 45 public:
45 virtual bool suspend ( ); 46 virtual bool suspend ( );
46 virtual bool setDisplayBrightness ( int b ); 47 virtual bool setDisplayBrightness ( int b );
47 virtual bool setDisplayStatus ( bool on); 48 virtual bool setDisplayStatus ( bool on);
48 virtual int displayBrightnessResolution() const; 49 virtual int displayBrightnessResolution() const;
49}; 50};
51
52struct j_button {
53 uint model;
54 Qt::Key code;
55 char *utext;
56 char *pix;
57 char *fpressedservice;
58 char *fpressedaction;
59 char *fheldservice;
60 char *fheldaction;
61};
62
50} 63}
51} 64}
52} 65}
53#endif 66#endif
54 67