-rw-r--r-- | libopie2/opiecore/device/odevice_jornada.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/libopie2/opiecore/device/odevice_jornada.cpp b/libopie2/opiecore/device/odevice_jornada.cpp index c7ed4bc..272109b 100644 --- a/libopie2/opiecore/device/odevice_jornada.cpp +++ b/libopie2/opiecore/device/odevice_jornada.cpp | |||
@@ -1,198 +1,208 @@ | |||
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_jornada.h" | 30 | #include "odevice_jornada.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 | ||
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 | ||
64 | typedef struct { | 64 | typedef 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 | ||
71 | typedef struct { | 71 | typedef 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 | ||
80 | using namespace Opie::Core; | 80 | using namespace Opie::Core; |
81 | using namespace Opie::Core::Internal; | 81 | using namespace Opie::Core::Internal; |
82 | 82 | ||
83 | struct j_button jornada56x_buttons [] = { | 83 | struct j_button jornada56x_buttons [] = { |
84 | { Model_Jornada_56x, | 84 | { Model_Jornada_56x, |
85 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 85 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
86 | "devicebuttons/jornada56x_calendar", | 86 | "devicebuttons/jornada56x_calendar", |
87 | "datebook", "nextView()", | 87 | "datebook", "nextView()", |
88 | "today", "raise()" }, | 88 | "today", "raise()" }, |
89 | { Model_Jornada_56x, | 89 | { Model_Jornada_56x, |
90 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 90 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
91 | "devicebuttons/jornada56x_contact", | 91 | "devicebuttons/jornada56x_contact", |
92 | "addressbook", "raise()", | 92 | "addressbook", "raise()", |
93 | "addressbook", "beamBusinessCard()" }, | 93 | "addressbook", "beamBusinessCard()" }, |
94 | { Model_Jornada_56x, | 94 | { Model_Jornada_56x, |
95 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"), | 95 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"), |
96 | "devicebuttons/jornada56x_todo", | 96 | "devicebuttons/jornada56x_todo", |
97 | "todolist", "raise()", | 97 | "todolist", "raise()", |
98 | "todolist", "create()" }, | 98 | "todolist", "create()" }, |
99 | { Model_Jornada_56x, | 99 | { Model_Jornada_56x, |
100 | Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Home Button"), | 100 | Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Home Button"), |
101 | "devicebuttons/jornada56x_home", | 101 | "devicebuttons/jornada56x_home", |
102 | "QPE/Launcher", "home()", | 102 | "QPE/Launcher", "home()", |
103 | "buttonsettings", "raise()" }, | 103 | "buttonsettings", "raise()" }, |
104 | { Model_Jornada_56x, | 104 | { Model_Jornada_56x, |
105 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Record Button"), | 105 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Record Button"), |
106 | "devicebuttons/jornada56x_record", | 106 | "devicebuttons/jornada56x_record", |
107 | "QPE/VMemo", "toggleRecord()", | 107 | "QPE/VMemo", "toggleRecord()", |
108 | "sound", "raise()" }, | 108 | "sound", "raise()" }, |
109 | }; | 109 | }; |
110 | 110 | ||
111 | void Jornada::init(const QString& cpu_info) | 111 | void Jornada::init(const QString& cpu_info) |
112 | { | 112 | { |
113 | d->m_vendorstr = "HP"; | 113 | d->m_vendorstr = "HP"; |
114 | d->m_vendor = Vendor_HP; | 114 | d->m_vendor = Vendor_HP; |
115 | 115 | ||
116 | QString model; | 116 | QString model; |
117 | int loc = cpu_info.find( ":" ); | 117 | int loc = cpu_info.find( ":" ); |
118 | if ( loc != -1 ) | 118 | if ( loc != -1 ) |
119 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 119 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
120 | else | 120 | else |
121 | model = cpu_info; | 121 | model = cpu_info; |
122 | 122 | ||
123 | if ( model == "HP Jornada 56x" ) { | 123 | if ( model == "HP Jornada 56x" ) { |
124 | d->m_modelstr = "Jornada 56x"; | 124 | d->m_modelstr = "Jornada 56x"; |
125 | d->m_model = Model_Jornada_56x; | 125 | d->m_model = Model_Jornada_56x; |
126 | } else if ( model == "HP Jornada 720" ) { | 126 | } else if ( model == "HP Jornada 720" ) { |
127 | d->m_modelstr = "Jornada 720"; | 127 | d->m_modelstr = "Jornada 720"; |
128 | d->m_model = Model_Jornada_720; | 128 | d->m_model = Model_Jornada_720; |
129 | } | 129 | } |
130 | 130 | ||
131 | d->m_rotation = Rot0; //all Jornadas need this rotation | 131 | d->m_rotation = Rot0; //all Jornadas need this rotation |
132 | //Distribution detecting code is now in base class | 132 | //Distribution detecting code is now in base class |
133 | } | 133 | } |
134 | 134 | ||
135 | void Jornada::initButtons() | 135 | void Jornada::initButtons() |
136 | { | 136 | { |
137 | if ( d->m_buttons ) | 137 | if ( d->m_buttons ) |
138 | return; | 138 | return; |
139 | 139 | ||
140 | d->m_buttons = new QValueList <ODeviceButton>; | 140 | d->m_buttons = new QValueList <ODeviceButton>; |
141 | 141 | ||
142 | for ( uint i = 0; i < ( sizeof( jornada56x_buttons ) / sizeof( j_button )); i++ ) { | 142 | for ( uint i = 0; i < ( sizeof( jornada56x_buttons ) / sizeof( j_button )); i++ ) { |
143 | j_button *ib = jornada56x_buttons + i; | 143 | j_button *ib = jornada56x_buttons + i; |
144 | ODeviceButton b; | 144 | ODeviceButton b; |
145 | 145 | ||
146 | if (( ib->model & d->m_model ) == d->m_model ) { | 146 | if (( ib->model & d->m_model ) == d->m_model ) { |
147 | b. setKeycode ( ib->code ); | 147 | b. setKeycode ( ib->code ); |
148 | b. setUserText ( QObject::tr ( "Button", ib->utext )); | 148 | b. setUserText ( QObject::tr ( "Button", ib->utext )); |
149 | b. setPixmap ( Resource::loadPixmap ( ib->pix )); | 149 | b. setPixmap ( Resource::loadPixmap ( ib->pix )); |
150 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); | 150 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); |
151 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); | 151 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); |
152 | 152 | ||
153 | d->m_buttons->append ( b ); | 153 | d->m_buttons->append ( b ); |
154 | } | 154 | } |
155 | } | 155 | } |
156 | reloadButtonMapping(); | 156 | reloadButtonMapping(); |
157 | } | 157 | } |
158 | 158 | ||
159 | int Jornada::displayBrightnessResolution() const | 159 | int Jornada::displayBrightnessResolution() const |
160 | { | 160 | { |
161 | return 255; | 161 | return 255; |
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | bool Jornada::setDisplayBrightness( int bright ) | 165 | bool Jornada::setDisplayBrightness( int bright ) |
166 | { | 166 | { |
167 | bool res = false; | 167 | bool res = false; |
168 | 168 | ||
169 | if ( bright > 255 ) | 169 | if ( bright > 255 ) |
170 | bright = 255; | 170 | bright = 255; |
171 | if ( bright < 0 ) | 171 | if ( bright < 0 ) |
172 | bright = 0; | 172 | bright = 0; |
173 | 173 | ||
174 | QString cmdline; | 174 | QString cmdline; |
175 | 175 | ||
176 | if ( !bright ) | 176 | if ( d->m_model == Model_Jornada_56x ) { |
177 | cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/*/power"); | 177 | if ( !bright ) |
178 | else | 178 | cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/sa1100fb/power"); |
179 | cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/*/power; echo %1 > /sys/class/backlight/*/brightness" ).arg( bright ); | 179 | else |
180 | cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/sa1100/power; echo %1 > /sys/class/backlight/sa1100/brightness" ).arg( bright ); | ||
181 | } else if ( d->m_model == Model_Jornada_720 ) { | ||
182 | cmdline = QString::fromLatin1( "echo %1 > /sys/class/backlight/e1356fb/brightness" ).arg( bright ); | ||
183 | } | ||
180 | 184 | ||
181 | // No Global::shellQuote as we gurantee it to be sane | 185 | // No Global::shellQuote as we gurantee it to be sane |
182 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); | 186 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); |
183 | 187 | ||
184 | return res; | 188 | return res; |
185 | } | 189 | } |
186 | 190 | ||
187 | 191 | ||
188 | bool Jornada::setDisplayStatus ( bool on ) | 192 | bool Jornada::setDisplayStatus ( bool on ) |
189 | { | 193 | { |
190 | bool res = false; | 194 | bool res = false; |
191 | 195 | ||
192 | QString cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/*/power; echo %2 > /sys/class/backlight/*/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); | 196 | QString cmdline; |
197 | |||
198 | if ( d->m_model == Model_Jornada_56x ) { | ||
199 | QString cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/*/power; echo %2 > /sys/class/backlight/*/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); | ||
200 | } else if ( d->m_model == Model_Jornada_720 ) { | ||
201 | QString cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/e1356fb/power").arg( on ? "0" : "4" ); | ||
202 | } | ||
193 | 203 | ||
194 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); | 204 | res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); |
195 | 205 | ||
196 | return res; | 206 | return res; |
197 | } | 207 | } |
198 | 208 | ||