Diffstat (limited to 'libopie2/opiecore/device/odevice_beagle.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice_beagle.cpp | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/libopie2/opiecore/device/odevice_beagle.cpp b/libopie2/opiecore/device/odevice_beagle.cpp index ac12ca6..8735c63 100644 --- a/libopie2/opiecore/device/odevice_beagle.cpp +++ b/libopie2/opiecore/device/odevice_beagle.cpp | |||
@@ -1,81 +1,82 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | Copyright (C) 2004 The Opie Team <opie-devel@handhelds.org> | 3 | |
4 | Copyright (C)2004 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 "odevicebutton.h" | 31 | #include "odevicebutton.h" |
31 | #include "odevice_beagle.h" | 32 | #include "odevice_beagle.h" |
32 | 33 | ||
33 | #include <qpe/resource.h> | 34 | #include <opie2/oresource.h> |
34 | 35 | ||
35 | #include <sys/types.h> | 36 | #include <sys/types.h> |
36 | #include <sys/ioctl.h> | 37 | #include <sys/ioctl.h> |
37 | #include <fcntl.h> | 38 | #include <fcntl.h> |
38 | #include <unistd.h> | 39 | #include <unistd.h> |
39 | 40 | ||
40 | 41 | ||
41 | /* | 42 | /* |
42 | * Intel Assabat FrontLight Control | 43 | * Intel Assabat FrontLight Control |
43 | */ | 44 | */ |
44 | #define _SA1100_FL_IOCTL_ON 1 | 45 | #define _SA1100_FL_IOCTL_ON 1 |
45 | #define _SA1100_FL_IOCTL_OFF 2 | 46 | #define _SA1100_FL_IOCTL_OFF 2 |
46 | #define _SA1100_FL_IOCTL_INTENSITY3 | 47 | #define _SA1100_FL_IOCTL_INTENSITY3 |
47 | #define _SA1100_FL_IOCTL_BACKLIGHT 4 | 48 | #define _SA1100_FL_IOCTL_BACKLIGHT 4 |
48 | #define _SA1100_FL_IOCTL_CONTRAST5 | 49 | #define _SA1100_FL_IOCTL_CONTRAST5 |
49 | #define _SA1100_FL_IOCTL_GET_BACKLIGHT 6 | 50 | #define _SA1100_FL_IOCTL_GET_BACKLIGHT 6 |
50 | #define _SA1100_FL_IOCTL_GET_CONTRAST 7 | 51 | #define _SA1100_FL_IOCTL_GET_CONTRAST 7 |
51 | // added by Sean Hsieh | 52 | // added by Sean Hsieh |
52 | #define _SA1100_FL_IOCTL_PWR_TOGGLE 8 | 53 | #define _SA1100_FL_IOCTL_PWR_TOGGLE 8 |
53 | #define _SA1100_FL_IOCTL_AUTOLIGHT 10 | 54 | #define _SA1100_FL_IOCTL_AUTOLIGHT 10 |
54 | 55 | ||
55 | /* | 56 | /* |
56 | * The device | 57 | * The device |
57 | */ | 58 | */ |
58 | #define FL_MAJOR 60 | 59 | #define FL_MAJOR 60 |
59 | #define FL_NAME "sa1100-fl" | 60 | #define FL_NAME "sa1100-fl" |
60 | #define FL_FILE "/dev/sa1100-fl" | 61 | #define FL_FILE "/dev/sa1100-fl" |
61 | 62 | ||
62 | namespace Opie { | 63 | namespace Opie { |
63 | namespace Core { | 64 | namespace Core { |
64 | namespace Internal { | 65 | namespace Internal { |
65 | 66 | ||
66 | struct b_button { | 67 | struct b_button { |
67 | uint model; | 68 | uint model; |
68 | Qt::Key code; | 69 | Qt::Key code; |
69 | char *utext; | 70 | char *utext; |
70 | char *pix; | 71 | char *pix; |
71 | char *fpressedservice; | 72 | char *fpressedservice; |
72 | char *fpressedaction; | 73 | char *fpressedaction; |
73 | char *fheldservice; | 74 | char *fheldservice; |
74 | char *fheldaction; | 75 | char *fheldaction; |
75 | }; | 76 | }; |
76 | 77 | ||
77 | 78 | ||
78 | /* | 79 | /* |
79 | * The MVista Beagle kernel maps the action | 80 | * The MVista Beagle kernel maps the action |
80 | * buttons to the Qt keymap | 81 | * buttons to the Qt keymap |
81 | */ | 82 | */ |
@@ -101,97 +102,97 @@ struct b_button beagle_buttons [] = { | |||
101 | "todolist", "raise()", | 102 | "todolist", "raise()", |
102 | "QPE/TaskBar", "toggleMenu()" }, | 103 | "QPE/TaskBar", "toggleMenu()" }, |
103 | { Model_Beagle_PA100, | 104 | { Model_Beagle_PA100, |
104 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 105 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
105 | "devicebuttons/beagle_home", | 106 | "devicebuttons/beagle_home", |
106 | "QPE/Launcher", "home()", | 107 | "QPE/Launcher", "home()", |
107 | "buttonsettings", "raise()" }, | 108 | "buttonsettings", "raise()" }, |
108 | }; | 109 | }; |
109 | 110 | ||
110 | 111 | ||
111 | Beagle::Beagle() {} | 112 | Beagle::Beagle() {} |
112 | 113 | ||
113 | Beagle::~Beagle() {} | 114 | Beagle::~Beagle() {} |
114 | 115 | ||
115 | /* | 116 | /* |
116 | * Simply set the Tradesquare.NL data | 117 | * Simply set the Tradesquare.NL data |
117 | */ | 118 | */ |
118 | void Beagle::init( const QString&) { | 119 | void Beagle::init( const QString&) { |
119 | /* | 120 | /* |
120 | * No other assabat model yet | 121 | * No other assabat model yet |
121 | */ | 122 | */ |
122 | d->m_vendorstr = "Tradesquare.NL"; | 123 | d->m_vendorstr = "Tradesquare.NL"; |
123 | d->m_vendor = Vendor_MasterIA; | 124 | d->m_vendor = Vendor_MasterIA; |
124 | d->m_modelstr = "Tuxpda 1"; | 125 | d->m_modelstr = "Tuxpda 1"; |
125 | d->m_rotation = Rot0; | 126 | d->m_rotation = Rot0; |
126 | d->m_model = Model_Beagle_PA100; | 127 | d->m_model = Model_Beagle_PA100; |
127 | } | 128 | } |
128 | 129 | ||
129 | 130 | ||
130 | /* | 131 | /* |
131 | * Initialize the Buttons. We only do it | 132 | * Initialize the Buttons. We only do it |
132 | * if not yet initialized. | 133 | * if not yet initialized. |
133 | * We go through our hardware button array | 134 | * We go through our hardware button array |
134 | * and set the 'Factory' Pressed and Held Action | 135 | * and set the 'Factory' Pressed and Held Action |
135 | * reloadButtonMapping will then apply the user | 136 | * reloadButtonMapping will then apply the user |
136 | * configuration to the buttons | 137 | * configuration to the buttons |
137 | */ | 138 | */ |
138 | void Beagle::initButtons() { | 139 | void Beagle::initButtons() { |
139 | if ( d->m_buttons ) | 140 | if ( d->m_buttons ) |
140 | return; | 141 | return; |
141 | 142 | ||
142 | d->m_buttons = new QValueList<ODeviceButton>; | 143 | d->m_buttons = new QValueList<ODeviceButton>; |
143 | uint length = sizeof( beagle_buttons )/ sizeof( b_button ); | 144 | uint length = sizeof( beagle_buttons )/ sizeof( b_button ); |
144 | for ( uint i = 0; i < length; ++i ) { | 145 | for ( uint i = 0; i < length; ++i ) { |
145 | b_button *bb = &beagle_buttons[i]; | 146 | b_button *bb = &beagle_buttons[i]; |
146 | ODeviceButton b; | 147 | ODeviceButton b; |
147 | b.setKeycode( bb->code ); | 148 | b.setKeycode( bb->code ); |
148 | b.setUserText( QObject::tr( "Button", bb->utext ) ); | 149 | b.setUserText( QObject::tr( "Button", bb->utext ) ); |
149 | b.setPixmap( Resource::loadPixmap( bb->pix ) ); | 150 | b.setPixmap( OResource::loadPixmap( bb->pix ) ); |
150 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel( bb->fpressedservice ), bb->fpressedaction ) ); | 151 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel( bb->fpressedservice ), bb->fpressedaction ) ); |
151 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel( bb->fheldservice ), bb->fheldaction ) ); | 152 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel( bb->fheldservice ), bb->fheldaction ) ); |
152 | d->m_buttons->append( b ); | 153 | d->m_buttons->append( b ); |
153 | } | 154 | } |
154 | 155 | ||
155 | reloadButtonMapping(); | 156 | reloadButtonMapping(); |
156 | } | 157 | } |
157 | 158 | ||
158 | /* | 159 | /* |
159 | * Turn the display on. We do it by ioctl on FL_FILE | 160 | * Turn the display on. We do it by ioctl on FL_FILE |
160 | */ | 161 | */ |
161 | bool Beagle::setDisplayStatus( bool on ) { | 162 | bool Beagle::setDisplayStatus( bool on ) { |
162 | int fd = ::open(FL_FILE, O_WRONLY); | 163 | int fd = ::open(FL_FILE, O_WRONLY); |
163 | 164 | ||
164 | if ( fd < 0 ) | 165 | if ( fd < 0 ) |
165 | return false; | 166 | return false; |
166 | 167 | ||
167 | return ( ::ioctl(fd, on ? _SA1100_FL_IOCTL_ON : _SA1100_FL_IOCTL_OFF, 0 ) == 0 ); | 168 | return ( ::ioctl(fd, on ? _SA1100_FL_IOCTL_ON : _SA1100_FL_IOCTL_OFF, 0 ) == 0 ); |
168 | } | 169 | } |
169 | 170 | ||
170 | /* | 171 | /* |
171 | * 0-100 are legal steps of the frontlight. | 172 | * 0-100 are legal steps of the frontlight. |
172 | */ | 173 | */ |
173 | int Beagle::displayBrightnessResolution()const { | 174 | int Beagle::displayBrightnessResolution()const { |
174 | return 100; | 175 | return 100; |
175 | } | 176 | } |
176 | 177 | ||
177 | /* | 178 | /* |
178 | * Opie uses the values 0-255 for the frontlight | 179 | * Opie uses the values 0-255 for the frontlight |
179 | * intensity and we need to map it to the range | 180 | * intensity and we need to map it to the range |
180 | * of 0-100. | 181 | * of 0-100. |
181 | * But first we do some sanity of the range of brightness | 182 | * But first we do some sanity of the range of brightness |
182 | * | 183 | * |
183 | */ | 184 | */ |
184 | bool Beagle::setDisplayBrightness( int brightness ) { | 185 | bool Beagle::setDisplayBrightness( int brightness ) { |
185 | if ( brightness > 255 ) | 186 | if ( brightness > 255 ) |
186 | brightness = 255; | 187 | brightness = 255; |
187 | else if ( brightness < 0 ) | 188 | else if ( brightness < 0 ) |
188 | brightness = 0; | 189 | brightness = 0; |
189 | brightness = (100*brightness)/255; | 190 | brightness = (100*brightness)/255; |
190 | 191 | ||
191 | int fd = ::open(FL_FILE, O_WRONLY); | 192 | int fd = ::open(FL_FILE, O_WRONLY); |
192 | 193 | ||
193 | if ( fd < 0 ) | 194 | if ( fd < 0 ) |
194 | return false; | 195 | return false; |
195 | 196 | ||
196 | return ( ::ioctl(fd, _SA1100_FL_IOCTL_INTENSITY, brightness ) == 0 ); | 197 | return ( ::ioctl(fd, _SA1100_FL_IOCTL_INTENSITY, brightness ) == 0 ); |
197 | } | 198 | } |