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