summaryrefslogtreecommitdiff
authorerik <erik>2007-02-08 21:46:07 (UTC)
committer erik <erik>2007-02-08 21:46:07 (UTC)
commit497621fb3ba39ea511842a30cddfcdbda090e7ba (patch) (unidiff)
tree13e70fb1840b7cc1c7b3a16ff9b6e71925b76b57
parent63f64a9733d5504bb04d5f06cdf52b42a4b8006c (diff)
downloadopie-497621fb3ba39ea511842a30cddfcdbda090e7ba.zip
opie-497621fb3ba39ea511842a30cddfcdbda090e7ba.tar.gz
opie-497621fb3ba39ea511842a30cddfcdbda090e7ba.tar.bz2
This commit provides the necessary changes and new files for Opie to
have partial support for the Palm LD, TX and Z72 handheld computers. This commit is based on a patch submitted by Cristiano to the opie-devel list. The patch itself comprises work done by Alex Osborne, Cristiano, Sergey Lapin, Jan Herman and Aaron. Thanks goes to them for sticking with the patch and expanding the number of devices Opie works on.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/device.pro6
-rw-r--r--libopie2/opiecore/device/odevice.cpp2
-rw-r--r--libopie2/opiecore/device/odevice.h7
-rw-r--r--libopie2/opiecore/device/odevice_palm.cpp282
-rw-r--r--libopie2/opiecore/device/odevice_palm.h72
5 files changed, 367 insertions, 2 deletions
diff --git a/libopie2/opiecore/device/device.pro b/libopie2/opiecore/device/device.pro
index b517032..2fd5ded 100644
--- a/libopie2/opiecore/device/device.pro
+++ b/libopie2/opiecore/device/device.pro
@@ -1,30 +1,32 @@
1HEADERS += device/odevice.h \ 1HEADERS += device/odevice.h \
2 device/odevicebutton.h \ 2 device/odevicebutton.h \
3 device/odevice_abstractmobiledevice.h \ 3 device/odevice_abstractmobiledevice.h \
4 device/odevice_beagle.h \ 4 device/odevice_beagle.h \
5 device/odevice_ipaq.h \ 5 device/odevice_ipaq.h \
6 device/odevice_jornada.h \ 6 device/odevice_jornada.h \
7 device/odevice_ramses.h \ 7 device/odevice_ramses.h \
8 device/odevice_simpad.h \ 8 device/odevice_simpad.h \
9 device/odevice_zaurus.h \ 9 device/odevice_zaurus.h \
10 device/odevice_genuineintel.h \ 10 device/odevice_genuineintel.h \
11 device/odevice_yopy.h \ 11 device/odevice_yopy.h \
12 device/odevice_mypal.h \ 12 device/odevice_mypal.h \
13 device/odevice_htc.h \ 13 device/odevice_htc.h \
14 device/odevice_motorola_ezx.h 14 device/odevice_motorola_ezx.h \
15 device/odevice_palm.h
15 16
16SOURCES += device/odevice.cpp \ 17SOURCES += device/odevice.cpp \
17 device/odevicebutton.cpp \ 18 device/odevicebutton.cpp \
18 device/odevice_abstractmobiledevice.cpp \ 19 device/odevice_abstractmobiledevice.cpp \
19 device/odevice_beagle.cpp \ 20 device/odevice_beagle.cpp \
20 device/odevice_ipaq.cpp \ 21 device/odevice_ipaq.cpp \
21 device/odevice_jornada.cpp\ 22 device/odevice_jornada.cpp\
22 device/odevice_ramses.cpp \ 23 device/odevice_ramses.cpp \
23 device/odevice_simpad.cpp \ 24 device/odevice_simpad.cpp \
24 device/odevice_zaurus.cpp \ 25 device/odevice_zaurus.cpp \
25 device/odevice_genuineintel.cpp \ 26 device/odevice_genuineintel.cpp \
26 device/odevice_yopy.cpp \ 27 device/odevice_yopy.cpp \
27 device/odevice_mypal.cpp \ 28 device/odevice_mypal.cpp \
28 device/odevice_htc.cpp \ 29 device/odevice_htc.cpp \
29 device/odevice_motorola_ezx.cpp 30 device/odevice_motorola_ezx.cpp \
31 device/odevice_palm.cpp
30 32
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 8f5be8b..e4233eb 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,89 +1,90 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2002-2006 The Opie Team <opie-devel@handhelds.org> 3 =. (C) 2002-2006 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 30
31#include "odevice_beagle.h" 31#include "odevice_beagle.h"
32#include "odevice_ipaq.h" 32#include "odevice_ipaq.h"
33#include "odevice_mypal.h" 33#include "odevice_mypal.h"
34#include "odevice_jornada.h" 34#include "odevice_jornada.h"
35#include "odevice_ramses.h" 35#include "odevice_ramses.h"
36#include "odevice_simpad.h" 36#include "odevice_simpad.h"
37#include "odevice_yopy.h" 37#include "odevice_yopy.h"
38#include "odevice_zaurus.h" 38#include "odevice_zaurus.h"
39#include "odevice_genuineintel.h" 39#include "odevice_genuineintel.h"
40#include "odevice_htc.h" 40#include "odevice_htc.h"
41#include "odevice_motorola_ezx.h" 41#include "odevice_motorola_ezx.h"
42#include "odevice_palm.h"
42 43
43/* QT */ 44/* QT */
44#include <qapplication.h> 45#include <qapplication.h>
45#include <qfile.h> 46#include <qfile.h>
46#include <qtextstream.h> 47#include <qtextstream.h>
47#include <qwindowsystem_qws.h> 48#include <qwindowsystem_qws.h>
48 49
49/* OPIE */ 50/* OPIE */
50#include <qpe/config.h> 51#include <qpe/config.h>
51#include <qpe/sound.h> 52#include <qpe/sound.h>
52#include <qpe/qcopenvelope_qws.h> 53#include <qpe/qcopenvelope_qws.h>
53#include <qpe/sound.h> 54#include <qpe/sound.h>
54 55
55#include <opie2/okeyfilter.h> 56#include <opie2/okeyfilter.h>
56#include <opie2/oresource.h> 57#include <opie2/oresource.h>
57 58
58/* STD */ 59/* STD */
59#include <fcntl.h> 60#include <fcntl.h>
60#include <math.h> 61#include <math.h>
61#include <stdlib.h> 62#include <stdlib.h>
62#include <signal.h> 63#include <signal.h>
63#include <sys/ioctl.h> 64#include <sys/ioctl.h>
64#include <sys/time.h> 65#include <sys/time.h>
65#include <unistd.h> 66#include <unistd.h>
66#ifndef QT_NO_SOUND 67#ifndef QT_NO_SOUND
67#include <linux/soundcard.h> 68#include <linux/soundcard.h>
68#endif 69#endif
69 70
70namespace Opie { 71namespace Opie {
71namespace Core { 72namespace Core {
72 73
73static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 74static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
74 75
75 76
76/* STATIC and common implementation */ 77/* STATIC and common implementation */
77/* EXPORT */ ODistribution distributions[] = { 78/* EXPORT */ ODistribution distributions[] = {
78 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, 79 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" },
79 { System_OpenZaurus, "OpenZaurus", "/etc/openzaurus-version" }, 80 { System_OpenZaurus, "OpenZaurus", "/etc/openzaurus-version" },
80 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, 81 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" },
81 { System_Unknown, "Linux", "/etc/issue" }, 82 { System_Unknown, "Linux", "/etc/issue" },
82}; 83};
83 84
84 85
85/* EXPORT */ bool isQWS(){ 86/* EXPORT */ bool isQWS(){
86 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; 87 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
87} 88}
88 89
89/* EXPORT */ QCString makeChannel ( const char *str ){ 90/* EXPORT */ QCString makeChannel ( const char *str ){
@@ -103,96 +104,97 @@ struct default_button default_buttons [] = {
103 "datebook", "nextView()", 104 "datebook", "nextView()",
104 "today", "raise()" }, 105 "today", "raise()" },
105 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 106 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
106 "devicebuttons/z_contact", 107 "devicebuttons/z_contact",
107 "addressbook", "raise()", 108 "addressbook", "raise()",
108 "addressbook", "beamBusinessCard()" }, 109 "addressbook", "beamBusinessCard()" },
109 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 110 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
110 "devicebuttons/z_home", 111 "devicebuttons/z_home",
111 "QPE/Launcher", "home()", 112 "QPE/Launcher", "home()",
112 "buttonsettings", "raise()" }, 113 "buttonsettings", "raise()" },
113 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 114 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
114 "devicebuttons/z_menu", 115 "devicebuttons/z_menu",
115 "QPE/TaskBar", "toggleMenu()", 116 "QPE/TaskBar", "toggleMenu()",
116 "QPE/TaskBar", "toggleStartMenu()" }, 117 "QPE/TaskBar", "toggleStartMenu()" },
117 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 118 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
118 "devicebuttons/z_mail", 119 "devicebuttons/z_mail",
119 "opiemail", "raise()", 120 "opiemail", "raise()",
120 "opiemail", "newMail()" }, 121 "opiemail", "newMail()" },
121}; 122};
122 123
123ODevice *ODevice::inst() 124ODevice *ODevice::inst()
124{ 125{
125 static ODevice *dev = 0; 126 static ODevice *dev = 0;
126 QString cpu_info; 127 QString cpu_info;
127 128
128 if ( !dev ) 129 if ( !dev )
129 { 130 {
130 QFile f( PATH_PROC_CPUINFO ); 131 QFile f( PATH_PROC_CPUINFO );
131 if ( f.open( IO_ReadOnly ) ) 132 if ( f.open( IO_ReadOnly ) )
132 { 133 {
133 QTextStream s( &f ); 134 QTextStream s( &f );
134 while ( !s.atEnd() ) 135 while ( !s.atEnd() )
135 { 136 {
136 QString line; 137 QString line;
137 line = s.readLine(); 138 line = s.readLine();
138 if ( line.startsWith( "Hardware" ) ) 139 if ( line.startsWith( "Hardware" ) )
139 { 140 {
140 qDebug( "ODevice() - found '%s'", (const char*) line ); 141 qDebug( "ODevice() - found '%s'", (const char*) line );
141 cpu_info = line; 142 cpu_info = line;
142 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 143 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
143 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 144 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
144 else if ( line.contains( "mypal", false ) ) dev = new Internal::MyPal(); 145 else if ( line.contains( "mypal", false ) ) dev = new Internal::MyPal();
145 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 146 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
146 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 147 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
147 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 148 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
148 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); 149 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle();
149 else if ( line.contains( "HTC", false ) ) dev = new Internal::HTC(); 150 else if ( line.contains( "HTC", false ) ) dev = new Internal::HTC();
150 else if ( line.contains( "Motorola", false ) ) dev = new Internal::Motorola_EZX(); 151 else if ( line.contains( "Motorola", false ) ) dev = new Internal::Motorola_EZX();
152 else if ( line.contains( "Palm", false ) ) dev = new Internal::Palm();
151 153
152 else qWarning( "ODevice() - unknown hardware - using default." ); 154 else qWarning( "ODevice() - unknown hardware - using default." );
153 break; 155 break;
154 } else if ( line.startsWith( "vendor_id" ) ) { 156 } else if ( line.startsWith( "vendor_id" ) ) {
155 qDebug( "ODevice() - found '%s'", (const char*) line ); 157 qDebug( "ODevice() - found '%s'", (const char*) line );
156 cpu_info = line; 158 cpu_info = line;
157 if( line.contains( "genuineintel", false ) ) { 159 if( line.contains( "genuineintel", false ) ) {
158 dev = new Internal::GenuineIntel(); 160 dev = new Internal::GenuineIntel();
159 break; 161 break;
160 } 162 }
161 } 163 }
162 } 164 }
163 } 165 }
164 else 166 else
165 { 167 {
166 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); 168 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
167 } 169 }
168 if ( !dev ) dev = new ODevice(); 170 if ( !dev ) dev = new ODevice();
169 dev->init(cpu_info); 171 dev->init(cpu_info);
170 } 172 }
171 return dev; 173 return dev;
172} 174}
173 175
174ODevice::ODevice() 176ODevice::ODevice()
175{ 177{
176 d = new ODeviceData; 178 d = new ODeviceData;
177 179
178 d->m_modelstr = "Unknown"; 180 d->m_modelstr = "Unknown";
179 d->m_model = Model_Unknown; 181 d->m_model = Model_Unknown;
180 d->m_vendorstr = "Unknown"; 182 d->m_vendorstr = "Unknown";
181 d->m_vendor = Vendor_Unknown; 183 d->m_vendor = Vendor_Unknown;
182 d->m_systemstr = "Unknown"; 184 d->m_systemstr = "Unknown";
183 d->m_system = System_Unknown; 185 d->m_system = System_Unknown;
184 d->m_sysverstr = "0.0"; 186 d->m_sysverstr = "0.0";
185 d->m_rotation = Rot0; 187 d->m_rotation = Rot0;
186 d->m_direction = CW; 188 d->m_direction = CW;
187 d->m_qteDriver = "Transformed"; 189 d->m_qteDriver = "Transformed";
188 190
189 d->m_holdtime = 1000; // 1000ms 191 d->m_holdtime = 1000; // 1000ms
190 d->m_buttons = 0; 192 d->m_buttons = 0;
191 d->m_cpu_frequencies = new QStrList; 193 d->m_cpu_frequencies = new QStrList;
192 194
193 195
194 /* mixer */ 196 /* mixer */
195 d->m_sound = d->m_vol = d->m_mixer = -1; 197 d->m_sound = d->m_vol = d->m_mixer = -1;
196 198
197 /* System QCopChannel created */ 199 /* System QCopChannel created */
198 d->m_initializedButtonQcop = false; 200 d->m_initializedButtonQcop = false;
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index a8362cd..1eb5959 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -93,114 +93,121 @@ enum OModel {
93 93
94 Model_SIMpad_All = ( Model_SIMpad | 0xffff ), 94 Model_SIMpad_All = ( Model_SIMpad | 0xffff ),
95 Model_SIMpad_CL4 = ( Model_SIMpad | 0x0001 ), 95 Model_SIMpad_CL4 = ( Model_SIMpad | 0x0001 ),
96 Model_SIMpad_SL4 = ( Model_SIMpad | 0x0002 ), 96 Model_SIMpad_SL4 = ( Model_SIMpad | 0x0002 ),
97 Model_SIMpad_SLC = ( Model_SIMpad | 0x0003 ), 97 Model_SIMpad_SLC = ( Model_SIMpad | 0x0003 ),
98 Model_SIMpad_TSinus = ( Model_SIMpad | 0x0004 ), 98 Model_SIMpad_TSinus = ( Model_SIMpad | 0x0004 ),
99 99
100 Model_Ramses = ( 4 << 16 ), 100 Model_Ramses = ( 4 << 16 ),
101 101
102 Model_Ramses_All = ( Model_Ramses | 0xffff ), 102 Model_Ramses_All = ( Model_Ramses | 0xffff ),
103 Model_Ramses_MNCI = ( Model_Ramses | 0x0001 ), 103 Model_Ramses_MNCI = ( Model_Ramses | 0x0001 ),
104 Model_Ramses_MNCIRX = ( Model_Ramses | 0x0002 ), 104 Model_Ramses_MNCIRX = ( Model_Ramses | 0x0002 ),
105 105
106 Model_Yopy = ( 5 << 16 ), 106 Model_Yopy = ( 5 << 16 ),
107 107
108 Model_Yopy_All = ( Model_Yopy | 0xffff ), 108 Model_Yopy_All = ( Model_Yopy | 0xffff ),
109 Model_Yopy_3000 = ( Model_Yopy | 0x0001 ), 109 Model_Yopy_3000 = ( Model_Yopy | 0x0001 ),
110 Model_Yopy_3500 = ( Model_Yopy | 0x0002 ), 110 Model_Yopy_3500 = ( Model_Yopy | 0x0002 ),
111 Model_Yopy_3700 = ( Model_Yopy | 0x0003 ), 111 Model_Yopy_3700 = ( Model_Yopy | 0x0003 ),
112 112
113 Model_Beagle = ( 6 << 16 ), 113 Model_Beagle = ( 6 << 16 ),
114 114
115 Model_Beagle_All = ( Model_Beagle | 0xffff ), 115 Model_Beagle_All = ( Model_Beagle | 0xffff ),
116 Model_Beagle_PA100 = ( Model_Beagle | 0x0001 ), 116 Model_Beagle_PA100 = ( Model_Beagle | 0x0001 ),
117 117
118 Model_GenuineIntel = ( 7 << 16 ), 118 Model_GenuineIntel = ( 7 << 16 ),
119 119
120 Model_MyPal = ( 8 << 16 ), 120 Model_MyPal = ( 8 << 16 ),
121 121
122 Model_MyPal_All = ( Model_MyPal | 0xffff ), 122 Model_MyPal_All = ( Model_MyPal | 0xffff ),
123 Model_MyPal_620 = ( Model_MyPal | 0x0001 ), 123 Model_MyPal_620 = ( Model_MyPal | 0x0001 ),
124 Model_MyPal_716 = ( Model_MyPal | 0x0002 ), 124 Model_MyPal_716 = ( Model_MyPal | 0x0002 ),
125 Model_MyPal_730 = ( Model_MyPal | 0x0003 ), 125 Model_MyPal_730 = ( Model_MyPal | 0x0003 ),
126 126
127 Model_HTC = ( 9 << 16 ), 127 Model_HTC = ( 9 << 16 ),
128 Model_HTC_All = ( Model_HTC | 0xffff ), 128 Model_HTC_All = ( Model_HTC | 0xffff ),
129 Model_HTC_Universal = ( Model_HTC | 0x0001 ), 129 Model_HTC_Universal = ( Model_HTC | 0x0001 ),
130 Model_HTC_Alpine = ( Model_HTC | 0x0002 ), 130 Model_HTC_Alpine = ( Model_HTC | 0x0002 ),
131 Model_HTC_Apache = ( Model_HTC | 0x0003 ), 131 Model_HTC_Apache = ( Model_HTC | 0x0003 ),
132 Model_HTC_Beetles = ( Model_HTC | 0x0004 ), 132 Model_HTC_Beetles = ( Model_HTC | 0x0004 ),
133 Model_HTC_Blueangel = ( Model_HTC | 0x0005 ), 133 Model_HTC_Blueangel = ( Model_HTC | 0x0005 ),
134 Model_HTC_Himalaya = ( Model_HTC | 0x0006 ), 134 Model_HTC_Himalaya = ( Model_HTC | 0x0006 ),
135 Model_HTC_Magician = ( Model_HTC | 0x0007 ), 135 Model_HTC_Magician = ( Model_HTC | 0x0007 ),
136 136
137 Model_Motorola = ( 9 << 17 ), 137 Model_Motorola = ( 9 << 17 ),
138 Model_Motorola_All = ( Model_Motorola | 0xffff ), 138 Model_Motorola_All = ( Model_Motorola | 0xffff ),
139 Model_Motorola_EZX = ( Model_Motorola | 0x0001 ), 139 Model_Motorola_EZX = ( Model_Motorola | 0x0001 ),
140 140
141 Model_Palm = ( 10 << 16),
142 Model_Palm_All = ( Model_Palm | 0xffff ),
143 Model_Palm_LD = ( Model_Palm | 0x0001 ),
144 Model_Palm_TX = ( Model_Palm | 0x0002 ),
145 Model_Palm_Z72 = ( Model_Palm | 0x0003 ),
146
141}; 147};
142 148
143/** 149/**
144 * The vendor of the device 150 * The vendor of the device
145 */ 151 */
146enum OVendor { 152enum OVendor {
147 Vendor_Unknown, 153 Vendor_Unknown,
148 154
149 Vendor_HP, 155 Vendor_HP,
150 Vendor_Sharp, 156 Vendor_Sharp,
151 Vendor_SIEMENS, 157 Vendor_SIEMENS,
152 Vendor_MundN, 158 Vendor_MundN,
153 Vendor_GMate, 159 Vendor_GMate,
154 Vendor_MasterIA, 160 Vendor_MasterIA,
155 Vendor_GenuineIntel, 161 Vendor_GenuineIntel,
156 Vendor_Asus, 162 Vendor_Asus,
157 Vendor_HTC, 163 Vendor_HTC,
158 Vendor_Motorola, 164 Vendor_Motorola,
165 Vendor_Palm,
159}; 166};
160 167
161/** 168/**
162 * The System used 169 * The System used
163 */ 170 */
164enum OSystem { 171enum OSystem {
165 System_Unknown, 172 System_Unknown,
166 173
167 System_Familiar, 174 System_Familiar,
168 System_Zaurus, 175 System_Zaurus,
169 System_OpenZaurus, 176 System_OpenZaurus,
170 System_Linupy, 177 System_Linupy,
171 System_OpenEmbedded, 178 System_OpenEmbedded,
172 System_PC, 179 System_PC,
173 System_OpenEZX, 180 System_OpenEZX,
174 System_Angstrom, 181 System_Angstrom,
175}; 182};
176 183
177typedef struct { 184typedef struct {
178 OSystem system; 185 OSystem system;
179 char* sysstr; 186 char* sysstr;
180 char* sysvfile; 187 char* sysvfile;
181} ODistribution; 188} ODistribution;
182 189
183extern ODistribution distributions[]; 190extern ODistribution distributions[];
184 191
185 192
186enum OLedState { 193enum OLedState {
187 Led_Off, 194 Led_Off,
188 Led_On, 195 Led_On,
189 Led_BlinkSlow, 196 Led_BlinkSlow,
190 Led_BlinkFast 197 Led_BlinkFast
191}; 198};
192 199
193enum OLed { 200enum OLed {
194 Led_Mail, 201 Led_Mail,
195 Led_Power, 202 Led_Power,
196 Led_BlueTooth 203 Led_BlueTooth
197}; 204};
198 205
199enum OHardKey { 206enum OHardKey {
200 HardKey_Datebook = Qt::Key_F9, 207 HardKey_Datebook = Qt::Key_F9,
201 HardKey_Contacts = Qt::Key_F10, 208 HardKey_Contacts = Qt::Key_F10,
202 HardKey_Menu = Qt::Key_F11, 209 HardKey_Menu = Qt::Key_F11,
203 HardKey_Home = Qt::Key_F12, 210 HardKey_Home = Qt::Key_F12,
204 HardKey_Mail = Qt::Key_F13, 211 HardKey_Mail = Qt::Key_F13,
205 HardKey_Record = Qt::Key_F24, 212 HardKey_Record = Qt::Key_F24,
206 HardKey_Suspend = Qt::Key_F34, 213 HardKey_Suspend = Qt::Key_F34,
diff --git a/libopie2/opiecore/device/odevice_palm.cpp b/libopie2/opiecore/device/odevice_palm.cpp
new file mode 100644
index 0000000..76399f8
--- a/dev/null
+++ b/libopie2/opiecore/device/odevice_palm.cpp
@@ -0,0 +1,282 @@
1/*
2                 This file is part of the Opie Project
3
4 Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org>
5 =.
6 .=l.
7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17 : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
30
31#include "odevice_palm.h"
32
33/* QT */
34#include <qapplication.h>
35#include <qfile.h>
36#include <qtextstream.h>
37#include <qwindowsystem_qws.h>
38#include <qgfx_qws.h>
39
40/* OPIE */
41#include <qpe/config.h>
42#include <qpe/sound.h>
43#include <qpe/qcopenvelope_qws.h>
44
45#include <opie2/okeyfilter.h>
46#include <opie2/oresource.h>
47
48/* STD */
49#include <fcntl.h>
50#include <math.h>
51#include <stdlib.h>
52#include <signal.h>
53#include <sys/ioctl.h>
54#include <sys/time.h>
55#include <unistd.h>
56#ifndef QT_NO_SOUND
57#include <linux/soundcard.h>
58#endif
59
60using namespace Opie::Core;
61using namespace Opie::Core::Internal;
62
63struct palm_button palm_buttons [] = {
64 { Model_Palm_TX | Model_Palm_LD | Model_Palm_Z72,
65 Qt::Key_F9, QT_TRANSLATE_NOOP( "Button", "Home Button" ),
66 "devicebuttons/palm_home",
67 "QPE/Launcher", "home()",
68 "buttonsettings", "raise()" },
69 { Model_Palm_TX | Model_Palm_LD | Model_Palm_Z72,
70 Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Calendar Button" ),
71 "devicebuttons/palm_calendar",
72 "datebook", "nextView()",
73 "today", "raise()" },
74 { Model_Palm_TX | Model_Palm_LD | Model_Palm_Z72,
75 Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "Todo Button" ),
76 "devicebuttons/palm_todo",
77 "todolist", "raise()",
78 "todolist", "create()" },
79 { Model_Palm_TX | Model_Palm_LD | Model_Palm_Z72,
80 Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "Mail Button" ),
81 "devicebuttons/palm_mail",
82 "opiemail", "raise()",
83 "opiemail", "newmail()" },
84 { Model_Palm_LD,
85 Qt::Key_F7, QT_TRANSLATE_NOOP( "Button", "Voice Memo Button" ),
86 "devicebuttons/palm_voice_memo",
87 "QPE/TaskBar", "toggleMenu()",
88 "QPE/TaskBar", "toggleStartMenu()" },
89 { Model_Palm_LD,
90 Qt::Key_F8, QT_TRANSLATE_NOOP( "Button", "Rotate Button" ),
91 "devicebuttons/palm_rotate",
92 "QPE/Rotation", "flip()",0},
93};
94
95void Palm::init(const QString& cpu_info)
96{
97 d->m_vendorstr = "Palm";
98 d->m_vendor = Vendor_Palm;
99
100 QString model = "unknown";
101
102 int loc = cpu_info.find( ":" );
103 if ( loc != -1 )
104 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
105 else
106 model = cpu_info;
107
108 if ( model == "Palm LifeDrive" ) {
109 d->m_modelstr = "Palm LifeDrive";
110 d->m_model = Model_Palm_LD;
111 }
112 else if ( model == "Palm TX" ) {
113 d->m_modelstr = "Palm TX";
114 d->m_model = Model_Palm_TX;
115 }
116 else if ( model == "Palm Zire 72" ) {
117 d->m_modelstr = "Palm Zire 72";
118 d->m_model = Model_Palm_Z72;
119 }
120 else
121 d->m_model = Model_Unknown;
122
123 switch ( d->m_model )
124 {
125 case Model_Palm_LD:
126 case Model_Palm_TX:
127 case Model_Palm_Z72:
128 m_backlightdev = "/sys/class/backlight/pxapwm-bl/";
129 d->m_rotation = Rot0;
130 d->m_direction = CCW;
131 d->m_qteDriver = "Transformed";
132 break;
133 default:
134 m_backlightdev = "";
135 }
136
137}
138
139
140void Palm::initButtons()
141{
142
143 if ( d->m_buttons )
144 return ;
145
146 if ( isQWS( ) ) {
147 addPreHandler(this);
148 }
149
150 d->m_buttons = new QValueList <ODeviceButton>;
151
152 for ( uint i = 0; i < ( sizeof( palm_buttons ) / sizeof( palm_button ) ); i++ )
153 {
154 palm_button *ib = palm_buttons + i;
155 ODeviceButton b;
156
157 if (( ib->model & d->m_model ) == d->m_model ) {
158 b. setKeycode ( ib->code );
159 b. setUserText ( QObject::tr ( "Button", ib->utext ));
160 b. setPixmap ( OResource::loadPixmap ( ib->pix ));
161 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
162 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
163
164 d->m_buttons->append ( b );
165 }
166 }
167 reloadButtonMapping();
168}
169
170
171bool Palm::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
172{
173 int newkeycode = keycode;
174
175 if (qt_screen->transformOrientation() != Rot0){
176
177 switch ( keycode ) {
178 case Key_Left :
179 case Key_Right:
180 case Key_Up :
181 case Key_Down :
182 newkeycode = Key_Left + ( keycode - Key_Left + (int) qt_screen->transformOrientation() ) % 4;
183 default:
184 break;
185 }
186
187 if (newkeycode!=keycode) {
188 if ( newkeycode != Key_unknown ) {
189 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
190 }
191 return true;
192 }
193
194 }
195
196 return false;
197}
198
199
200bool Palm::suspend()
201{
202 // some Palms do not implement their own power management at the moment.
203
204 bool res = false;
205
206 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
207 return false;
208
209 switch ( d->m_model ) {
210 case Model_Palm_LD:
211 case Model_Palm_Z72:
212 {
213 QCopChannel::send( "QPE/System", "aboutToSuspend()" );
214
215 ::sync(); // flush fs caches
216 res = ( ::system ( "apm --suspend" ) == 0 );
217
218 QCopChannel::send( "QPE/System", "returnFromSuspend()" );
219 }
220 break;
221 }
222
223 return res;
224}
225
226
227int Palm::displayBrightnessResolution() const
228{
229 int res = 1;
230
231 switch ( d->m_model )
232 {
233 case Model_Palm_LD:
234 case Model_Palm_TX:
235 case Model_Palm_Z72:
236 int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK );
237 if ( fd )
238 {
239 char buf[100];
240 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res );
241 ::close( fd );
242 }
243 break;
244
245 default:
246 res = 1;
247 }
248
249 return res;
250}
251
252
253bool Palm::setDisplayBrightness( int bright )
254{
255 bool res = false;
256
257 if ( bright > 255 ) bright = 255;
258 if ( bright < 0 ) bright = 0;
259
260 int numberOfSteps = displayBrightnessResolution();
261 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255;
262
263 switch ( d->m_model )
264 {
265
266 case Model_Palm_LD:
267 case Model_Palm_TX:
268 case Model_Palm_Z72:
269 int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK );
270 if ( fd )
271 {
272 char buf[100];
273 int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
274 res = ( ::write( fd, &buf[0], len ) == 0 );
275 ::close( fd );
276 }
277 break;
278
279 default: res = false;
280 }
281 return res;
282}
diff --git a/libopie2/opiecore/device/odevice_palm.h b/libopie2/opiecore/device/odevice_palm.h
new file mode 100644
index 0000000..3ce786c
--- a/dev/null
+++ b/libopie2/opiecore/device/odevice_palm.h
@@ -0,0 +1,72 @@
1/*
2                This file is part of the Opie Project
3             Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =.
5 .=l.
6          .>+-=
7_;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software
11- .   .-<_>     .<> Foundation; either version 2 of the License,
12    ._= =}       : or (at your option) any later version.
13   .%`+i>       _;_.
14   .i_,=:_.      -<s. This program is distributed in the hope that
15    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16   : ..    .:,     . . . without even the implied warranty of
17   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details.
21:     =  ...= . :.=-
22-.   .:....=;==+<; You should have received a copy of the GNU
23 -_. . .   )=.  = Library General Public License along with
24   --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
29
30#ifndef ODEVICE_PALM
31#define ODEVICE_PALM
32
33#include "odevice_abstractmobiledevice.h"
34
35namespace Opie {
36namespace Core {
37namespace Internal {
38class Palm : public OAbstractMobileDevice, public QWSServer::KeyboardFilter
39{
40 protected:
41
42 virtual void init(const QString&);
43 virtual void initButtons();
44 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
45
46 QString m_backlightdev;
47
48 public:
49 virtual bool suspend();
50
51 virtual bool setDisplayBrightness ( int b );
52 virtual int displayBrightnessResolution() const;
53
54};
55
56struct palm_button
57{
58 uint model;
59 Qt::Key code;
60 char *utext;
61 char *pix;
62 char *fpressedservice;
63 char *fpressedaction;
64 char *fheldservice;
65 char *fheldaction;
66};
67
68}
69}
70}
71
72#endif