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.cpp48
1 files changed, 25 insertions, 23 deletions
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index 550da5e..f2805de 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -1,92 +1,94 @@
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
4 Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org>
4 =. 5 =.
5 .=l. 6 .=l.
6           .>+-= 7           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 14    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 17 : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 21++=   -.     .`     .: details.
21 :     =  ...= . :.=- 22:     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
28*/ 29*/
29 30
30#include "odevice_simpad.h" 31#include "odevice_simpad.h"
31 32
32/* QT */ 33/* QT */
33#include <qapplication.h> 34#include <qapplication.h>
34#include <qfile.h> 35#include <qfile.h>
35#include <qtextstream.h> 36#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 37#include <qwindowsystem_qws.h>
37#include <qwidgetlist.h> 38#include <qwidgetlist.h>
38 39
39/* OPIE */ 40/* OPIE */
40#include <qpe/config.h> 41#include <qpe/config.h>
41#include <qpe/resource.h>
42#include <qpe/sound.h> 42#include <qpe/sound.h>
43#include <qpe/qcopenvelope_qws.h> 43#include <qpe/qcopenvelope_qws.h>
44
44#include <opie2/okeyfilter.h> 45#include <opie2/okeyfilter.h>
46#include <opie2/oresource.h>
45 47
46/* STD */ 48/* STD */
47#include <fcntl.h> 49#include <fcntl.h>
48#include <math.h> 50#include <math.h>
49#include <stdlib.h> 51#include <stdlib.h>
50#include <signal.h> 52#include <signal.h>
51#include <sys/ioctl.h> 53#include <sys/ioctl.h>
52#include <sys/time.h> 54#include <sys/time.h>
53#include <unistd.h> 55#include <unistd.h>
54#ifndef QT_NO_SOUND 56#ifndef QT_NO_SOUND
55#include <linux/soundcard.h> 57#include <linux/soundcard.h>
56#endif 58#endif
57 59
58namespace Opie { 60namespace Opie {
59namespace Core { 61namespace Core {
60namespace Internal { 62namespace Internal {
61namespace { 63namespace {
62struct s_button { 64struct s_button {
63 uint model; 65 uint model;
64 Qt::Key code; 66 Qt::Key code;
65 char *utext; 67 char *utext;
66 char *pix; 68 char *pix;
67 char *fpressedservice; 69 char *fpressedservice;
68 char *fpressedaction; 70 char *fpressedaction;
69 char *fheldservice; 71 char *fheldservice;
70 char *fheldaction; 72 char *fheldaction;
71}; 73};
72 74
73static struct s_button simpad_buttons [] = { 75static struct s_button simpad_buttons [] = {
74 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 76 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
75 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 77 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
76 "devicebuttons/simpad_lower_up", 78 "devicebuttons/simpad_lower_up",
77 "datebook", "nextView()", 79 "datebook", "nextView()",
78 "today", "raise()" }, 80 "today", "raise()" },
79 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 81 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
80 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 82 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
81 "devicebuttons/simpad_lower_down", 83 "devicebuttons/simpad_lower_down",
82 "addressbook", "raise()", 84 "addressbook", "raise()",
83 "addressbook", "beamBusinessCard()" }, 85 "addressbook", "beamBusinessCard()" },
84 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 86 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
85 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 87 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
86 "devicebuttons/simpad_lower_right", 88 "devicebuttons/simpad_lower_right",
87 "QPE/TaskBar", "toggleMenu()", 89 "QPE/TaskBar", "toggleMenu()",
88 "QPE/TaskBar", "toggleStartMenu()" }, 90 "QPE/TaskBar", "toggleStartMenu()" },
89 { 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,
90 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 92 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
91 "devicebuttons/simpad_lower_left", 93 "devicebuttons/simpad_lower_left",
92 "opiemail", "raise()", 94 "opiemail", "raise()",
@@ -126,97 +128,97 @@ static struct s_button simpad_buttons [] = {
126 */ 128 */
127}; 129};
128} 130}
129 131
130 132
131void SIMpad::init(const QString&) 133void SIMpad::init(const QString&)
132{ 134{
133 d->m_vendorstr = "SIEMENS"; 135 d->m_vendorstr = "SIEMENS";
134 d->m_vendor = Vendor_SIEMENS; 136 d->m_vendor = Vendor_SIEMENS;
135 137
136 138
137 //TODO Implement model checking 139 //TODO Implement model checking
138 //FIXME For now we assume an SL4 140 //FIXME For now we assume an SL4
139 141
140 d->m_modelstr = "SL4"; 142 d->m_modelstr = "SL4";
141 d->m_model = Model_SIMpad_SL4; 143 d->m_model = Model_SIMpad_SL4;
142 144
143 switch ( d->m_model ) { 145 switch ( d->m_model ) {
144 default: 146 default:
145 d->m_rotation = Rot0; 147 d->m_rotation = Rot0;
146 d->m_direction = CCW; 148 d->m_direction = CCW;
147 d->m_holdtime = 1000; // 1000ms 149 d->m_holdtime = 1000; // 1000ms
148 150
149 break; 151 break;
150 } 152 }
151 153
152 //Distribution detecting code is now in base class 154 //Distribution detecting code is now in base class
153 m_leds [0] = m_leds [1] = Led_Off; 155 m_leds [0] = m_leds [1] = Led_Off;
154 156
155 m_power_timer = 0; 157 m_power_timer = 0;
156 158
157} 159}
158 160
159void SIMpad::initButtons() 161void SIMpad::initButtons()
160{ 162{
161 if ( d->m_buttons ) 163 if ( d->m_buttons )
162 return; 164 return;
163 165
164 d->m_buttons = new QValueList <ODeviceButton>; 166 d->m_buttons = new QValueList <ODeviceButton>;
165 167
166 uint size = sizeof(simpad_buttons)/sizeof(s_button); 168 uint size = sizeof(simpad_buttons)/sizeof(s_button);
167 for ( uint i = 0; i < size; i++ ) { 169 for ( uint i = 0; i < size; i++ ) {
168 s_button *sb = simpad_buttons + i; 170 s_button *sb = simpad_buttons + i;
169 ODeviceButton b; 171 ODeviceButton b;
170 172
171 if (( sb->model & d->m_model ) == d->m_model ) { 173 if (( sb->model & d->m_model ) == d->m_model ) {
172 b. setKeycode ( sb->code ); 174 b. setKeycode ( sb->code );
173 b. setUserText ( QObject::tr ( "Button", sb->utext )); 175 b. setUserText ( QObject::tr ( "Button", sb->utext ));
174 b. setPixmap ( Resource::loadPixmap ( sb->pix )); 176 b. setPixmap ( OResource::loadPixmap ( sb->pix ));
175 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); 177 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction ));
176 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); 178 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction ));
177 179
178 d->m_buttons->append ( b ); 180 d->m_buttons->append ( b );
179 } 181 }
180 } 182 }
181 reloadButtonMapping(); 183 reloadButtonMapping();
182} 184}
183 185
184// SIMpad boardcontrol register CS3 186// SIMpad boardcontrol register CS3
185#define SIMPAD_BOARDCONTROL "/proc/cs3" 187#define SIMPAD_BOARDCONTROL "/proc/cs3"
186#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 188#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
187#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 189#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
188#define SIMPAD_EN1 0x0004 // This is only for EPROM's 190#define SIMPAD_EN1 0x0004 // This is only for EPROM's
189#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 191#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
190#define SIMPAD_DISPLAY_ON 0x0010 192#define SIMPAD_DISPLAY_ON 0x0010
191#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 193#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
192#define SIMPAD_MQ_RESET 0x0040 194#define SIMPAD_MQ_RESET 0x0040
193#define SIMPAD_PCMCIA_RESET 0x0080 195#define SIMPAD_PCMCIA_RESET 0x0080
194#define SIMPAD_DECT_POWER_ON 0x0100 196#define SIMPAD_DECT_POWER_ON 0x0100
195#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 197#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
196#define SIMPAD_RS232_ON 0x0400 198#define SIMPAD_RS232_ON 0x0400
197#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 199#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
198#define SIMPAD_LED2_ON 0x1000 200#define SIMPAD_LED2_ON 0x1000
199#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 201#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
200#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 202#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
201#define SIMPAD_RESET_SIMCARD 0x8000 203#define SIMPAD_RESET_SIMCARD 0x8000
202 204
203//SIMpad touchscreen backlight strength control 205//SIMpad touchscreen backlight strength control
204#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/backlight" 206#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/backlight"
205 207
206 208
207/* 209/*
208 * The SIMpad exposes ChipSelect3 to userspace 210 * The SIMpad exposes ChipSelect3 to userspace
209 * via a proc filesystem file. Using this register 211 * via a proc filesystem file. Using this register
210 * one can toggle power of serial, irda, dect circuits 212 * one can toggle power of serial, irda, dect circuits
211 * change the video driver and display status and 213 * change the video driver and display status and
212 * many more things. 214 * many more things.
213 * To not lose the current setting we read the current 215 * To not lose the current setting we read the current
214 * cs3 setting and toggle the necessary bits and then 216 * cs3 setting and toggle the necessary bits and then
215 * write it. 217 * write it.
216 */ 218 */
217static bool setCS3Bit( bool bitset, int bit ) { 219static bool setCS3Bit( bool bitset, int bit ) {
218 QFile file( SIMPAD_BOARDCONTROL ); 220 QFile file( SIMPAD_BOARDCONTROL );
219 if ( !file.open( IO_ReadOnly ) ) 221 if ( !file.open( IO_ReadOnly ) )
220 return false; 222 return false;
221 223
222 unsigned int val = 0; 224 unsigned int val = 0;