summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice_simpad.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/device/odevice_simpad.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp65
1 files changed, 22 insertions, 43 deletions
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index 6630763..6d4624b 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -1,72 +1,72 @@
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_simpad.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
56using namespace Opie::Core; 56using namespace Opie::Core;
57using namespace Opie::Core::Internal; 57using namespace Opie::Core::Internal;
58 58
59struct s_button simpad_buttons [] = { 59struct s_button simpad_buttons [] = {
60 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 60 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
61 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 61 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
62 "devicebuttons/simpad_lower_up", 62 "devicebuttons/simpad_lower_up",
63 "datebook", "nextView()", 63 "datebook", "nextView()",
64 "today", "raise()" }, 64 "today", "raise()" },
65 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 65 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
66 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 66 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
67 "devicebuttons/simpad_lower_down", 67 "devicebuttons/simpad_lower_down",
68 "addressbook", "raise()", 68 "addressbook", "raise()",
69 "addressbook", "beamBusinessCard()" }, 69 "addressbook", "beamBusinessCard()" },
70 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 70 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
71 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 71 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
72 "devicebuttons/simpad_lower_right", 72 "devicebuttons/simpad_lower_right",
@@ -89,118 +89,97 @@ struct s_button simpad_buttons [] = {
89 "addressbook", "raise()", 89 "addressbook", "raise()",
90 "addressbook", "beamBusinessCard()" }, 90 "addressbook", "beamBusinessCard()" },
91 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 91 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
92 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 92 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
93 "devicebuttons/simpad_upper_right", 93 "devicebuttons/simpad_upper_right",
94 "QPE/TaskBar", "toggleMenu()", 94 "QPE/TaskBar", "toggleMenu()",
95 "QPE/TaskBar", "toggleStartMenu()" }, 95 "QPE/TaskBar", "toggleStartMenu()" },
96 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 96 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
97 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 97 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
98 "devicebuttons/simpad_upper_left", 98 "devicebuttons/simpad_upper_left",
99 "QPE/Rotation", "flip()", 99 "QPE/Rotation", "flip()",
100 "QPE/Rotation", "flip()" }, 100 "QPE/Rotation", "flip()" },
101 /* 101 /*
102 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 102 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
103 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 103 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
104 "devicebuttons/simpad_lower_upper", 104 "devicebuttons/simpad_lower_upper",
105 "QPE/Launcher", "home()", 105 "QPE/Launcher", "home()",
106 "buttonsettings", "raise()" }, 106 "buttonsettings", "raise()" },
107 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 107 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
108 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 108 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
109 "devicebuttons/simpad_upper_lower", 109 "devicebuttons/simpad_upper_lower",
110 "QPE/Launcher", "home()", 110 "QPE/Launcher", "home()",
111 "buttonsettings", "raise()" }, 111 "buttonsettings", "raise()" },
112 */ 112 */
113}; 113};
114 114
115void SIMpad::init(const QString&) 115void SIMpad::init(const QString&)
116{ 116{
117 d->m_vendorstr = "SIEMENS"; 117 d->m_vendorstr = "SIEMENS";
118 d->m_vendor = Vendor_SIEMENS; 118 d->m_vendor = Vendor_SIEMENS;
119 119
120 QFile f ( "/proc/hal/model" ); 120 QFile f ( "/proc/hal/model" );
121 121
122 //TODO Implement model checking 122 //TODO Implement model checking
123 //FIXME For now we assume an SL4 123 //FIXME For now we assume an SL4
124 124
125 d->m_modelstr = "SL4"; 125 d->m_modelstr = "SL4";
126 d->m_model = Model_SIMpad_SL4; 126 d->m_model = Model_SIMpad_SL4;
127 127
128 switch ( d->m_model ) { 128 switch ( d->m_model ) {
129 default: 129 default:
130 d->m_rotation = Rot0; 130 d->m_rotation = Rot0;
131 d->m_direction = CCW; 131 d->m_direction = CCW;
132 d->m_holdtime = 1000; // 1000ms 132 d->m_holdtime = 1000; // 1000ms
133 133
134 break; 134 break;
135 } 135 }
136 136
137 f. setName ( "/etc/familiar-version" ); 137 //Distribution detecting code is now in base class
138 if ( f. open ( IO_ReadOnly )) {
139 d->m_systemstr = "Familiar";
140 d->m_system = System_Familiar;
141
142 QTextStream ts ( &f );
143 d->m_sysverstr = ts. readLine(). mid ( 10 );
144
145 f. close();
146 } else {
147 f. setName ( "/etc/oz_version" );
148
149 if ( f. open ( IO_ReadOnly )) {
150 d->m_systemstr = "OpenEmbedded/SIMpad";
151 d->m_system = System_OpenZaurus;
152
153 QTextStream ts ( &f );
154 ts.setDevice ( &f );
155 d->m_sysverstr = ts. readLine();
156 f. close();
157 }
158 }
159 138
160 m_leds [0] = m_leds [1] = Led_Off; 139 m_leds [0] = m_leds [1] = Led_Off;
161 140
162 m_power_timer = 0; 141 m_power_timer = 0;
163 142
164} 143}
165 144
166void SIMpad::initButtons() 145void SIMpad::initButtons()
167{ 146{
168 if ( d->m_buttons ) 147 if ( d->m_buttons )
169 return; 148 return;
170 149
171 if ( isQWS( ) ) 150 if ( isQWS( ) )
172 QWSServer::setKeyboardFilter ( this ); 151 QWSServer::setKeyboardFilter ( this );
173 152
174 d->m_buttons = new QValueList <ODeviceButton>; 153 d->m_buttons = new QValueList <ODeviceButton>;
175 154
176 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 155 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
177 s_button *sb = simpad_buttons + i; 156 s_button *sb = simpad_buttons + i;
178 ODeviceButton b; 157 ODeviceButton b;
179 158
180 if (( sb->model & d->m_model ) == d->m_model ) { 159 if (( sb->model & d->m_model ) == d->m_model ) {
181 b. setKeycode ( sb->code ); 160 b. setKeycode ( sb->code );
182 b. setUserText ( QObject::tr ( "Button", sb->utext )); 161 b. setUserText ( QObject::tr ( "Button", sb->utext ));
183 b. setPixmap ( Resource::loadPixmap ( sb->pix )); 162 b. setPixmap ( Resource::loadPixmap ( sb->pix ));
184 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); 163 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction ));
185 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); 164 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction ));
186 165
187 d->m_buttons->append ( b ); 166 d->m_buttons->append ( b );
188 } 167 }
189 } 168 }
190 reloadButtonMapping(); 169 reloadButtonMapping();
191 170
192 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 171 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
193 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 172 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
194} 173}
195 174
196// SIMpad boardcontrol register CS3 175// SIMpad boardcontrol register CS3
197#define SIMPAD_BOARDCONTROL "/proc/cs3" 176#define SIMPAD_BOARDCONTROL "/proc/cs3"
198#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 177#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
199#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 178#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
200#define SIMPAD_EN1 0x0004 // This is only for EPROM's 179#define SIMPAD_EN1 0x0004 // This is only for EPROM's
201#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 180#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
202#define SIMPAD_DISPLAY_ON 0x0010 181#define SIMPAD_DISPLAY_ON 0x0010
203#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 182#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
204#define SIMPAD_MQ_RESET 0x0040 183#define SIMPAD_MQ_RESET 0x0040
205#define SIMPAD_PCMCIA_RESET 0x0080 184#define SIMPAD_PCMCIA_RESET 0x0080
206#define SIMPAD_DECT_POWER_ON 0x0100 185#define SIMPAD_DECT_POWER_ON 0x0100