author | aquadran <aquadran> | 2006-12-13 20:36:14 (UTC) |
---|---|---|
committer | aquadran <aquadran> | 2006-12-13 20:36:14 (UTC) |
commit | bb6f32ae999168fc44d50d3523c3ef232824185a (patch) (unidiff) | |
tree | 1d89bf239f98c4e3ce6fc83131b6b2c4ec5aac2c | |
parent | 5a0012fb3b75ff41437b0685386731d1367e4e7b (diff) | |
download | opie-bb6f32ae999168fc44d50d3523c3ef232824185a.zip opie-bb6f32ae999168fc44d50d3523c3ef232824185a.tar.gz opie-bb6f32ae999168fc44d50d3523c3ef232824185a.tar.bz2 |
changed suspend button mapping for mypal too same as for ipaqs
-rw-r--r-- | libopie2/opiecore/device/odevice_mypal.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libopie2/opiecore/device/odevice_mypal.cpp b/libopie2/opiecore/device/odevice_mypal.cpp index 208be46..73b31cb 100644 --- a/libopie2/opiecore/device/odevice_mypal.cpp +++ b/libopie2/opiecore/device/odevice_mypal.cpp | |||
@@ -92,131 +92,131 @@ struct m_button mypal_buttons [] = { | |||
92 | }; | 92 | }; |
93 | 93 | ||
94 | void MyPal::init(const QString& model) | 94 | void MyPal::init(const QString& model) |
95 | { | 95 | { |
96 | d->m_vendorstr = "Asus"; | 96 | d->m_vendorstr = "Asus"; |
97 | d->m_vendor = Vendor_Asus; | 97 | d->m_vendor = Vendor_Asus; |
98 | 98 | ||
99 | d->m_modelstr = model.mid(model.findRev('A')); | 99 | d->m_modelstr = model.mid(model.findRev('A')); |
100 | if ( d->m_modelstr == "A716" ) | 100 | if ( d->m_modelstr == "A716" ) |
101 | d->m_model = Model_MyPal_716; | 101 | d->m_model = Model_MyPal_716; |
102 | else | 102 | else |
103 | d->m_model = Model_Unknown; | 103 | d->m_model = Model_Unknown; |
104 | 104 | ||
105 | d->m_rotation = Rot0; | 105 | d->m_rotation = Rot0; |
106 | 106 | ||
107 | m_power_timer = 0; | 107 | m_power_timer = 0; |
108 | } | 108 | } |
109 | 109 | ||
110 | void MyPal::initButtons() | 110 | void MyPal::initButtons() |
111 | { | 111 | { |
112 | if ( d->m_buttons ) | 112 | if ( d->m_buttons ) |
113 | return; | 113 | return; |
114 | 114 | ||
115 | if ( isQWS( ) ) { | 115 | if ( isQWS( ) ) { |
116 | addPreHandler(this); | 116 | addPreHandler(this); |
117 | } | 117 | } |
118 | 118 | ||
119 | d->m_buttons = new QValueList <ODeviceButton>; | 119 | d->m_buttons = new QValueList <ODeviceButton>; |
120 | 120 | ||
121 | for ( uint i = 0; i < ( sizeof( mypal_buttons ) / sizeof( m_button )); i++ ) { | 121 | for ( uint i = 0; i < ( sizeof( mypal_buttons ) / sizeof( m_button )); i++ ) { |
122 | m_button *mb = mypal_buttons + i; | 122 | m_button *mb = mypal_buttons + i; |
123 | ODeviceButton b; | 123 | ODeviceButton b; |
124 | 124 | ||
125 | if (( mb->model & d->m_model ) == d->m_model ) { | 125 | if (( mb->model & d->m_model ) == d->m_model ) { |
126 | b. setKeycode ( mb->code ); | 126 | b. setKeycode ( mb->code ); |
127 | b. setUserText ( QObject::tr ( "Button", mb->utext )); | 127 | b. setUserText ( QObject::tr ( "Button", mb->utext )); |
128 | b. setPixmap ( OResource::loadPixmap ( mb->pix )); | 128 | b. setPixmap ( OResource::loadPixmap ( mb->pix )); |
129 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( mb->fpressedservice ), mb->fpressedaction )); | 129 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( mb->fpressedservice ), mb->fpressedaction )); |
130 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( mb->fheldservice ), mb->fheldaction )); | 130 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( mb->fheldservice ), mb->fheldaction )); |
131 | 131 | ||
132 | d->m_buttons->append ( b ); | 132 | d->m_buttons->append ( b ); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | reloadButtonMapping(); | 135 | reloadButtonMapping(); |
136 | } | 136 | } |
137 | 137 | ||
138 | bool MyPal::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 138 | bool MyPal::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
139 | { | 139 | { |
140 | int newkeycode = keycode; | 140 | int newkeycode = keycode; |
141 | 141 | ||
142 | switch ( keycode ) { | 142 | switch ( keycode ) { |
143 | case Key_Left : | 143 | case Key_Left : |
144 | case Key_Right: | 144 | case Key_Right: |
145 | case Key_Up : | 145 | case Key_Up : |
146 | case Key_Down : { | 146 | case Key_Down : { |
147 | // Rotate the cursor keys by 270 | 147 | // Rotate the cursor keys by 270 |
148 | // keycode - Key_Left = position of the button starting from left clockwise | 148 | // keycode - Key_Left = position of the button starting from left clockwise |
149 | // add the rotation to it and modolo. No we've the original offset | 149 | // add the rotation to it and modolo. No we've the original offset |
150 | // add the offset to the Key_Left key | 150 | // add the offset to the Key_Left key |
151 | if ( d->m_model == Model_MyPal_716 ) | 151 | if ( d->m_model == Model_MyPal_716 ) |
152 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; | 152 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; |
153 | break; | 153 | break; |
154 | } | 154 | } |
155 | 155 | ||
156 | // map Power Button short/long press to F6 | 156 | // map Power Button short/long press |
157 | case Key_F6: { | 157 | case HardKey_Suspend: { // Hope we don't have infinite recursion here: |
158 | if ( isPress ) { | 158 | if ( isPress ) { |
159 | if ( m_power_timer ) | 159 | if ( m_power_timer ) |
160 | killTimer ( m_power_timer ); | 160 | killTimer ( m_power_timer ); |
161 | m_power_timer = startTimer ( 500 ); | 161 | m_power_timer = startTimer ( 500 ); |
162 | } | 162 | } |
163 | else if ( m_power_timer ) { | 163 | else if ( m_power_timer ) { |
164 | killTimer ( m_power_timer ); | 164 | killTimer ( m_power_timer ); |
165 | m_power_timer = 0; | 165 | m_power_timer = 0; |
166 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 166 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
167 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 167 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
168 | } | 168 | } |
169 | newkeycode = Key_unknown; | 169 | newkeycode = Key_unknown; |
170 | break; | 170 | break; |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | if ( newkeycode != keycode ) { | 174 | if ( newkeycode != keycode ) { |
175 | if ( newkeycode != Key_unknown ) | 175 | if ( newkeycode != Key_unknown ) |
176 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 176 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
177 | return true; | 177 | return true; |
178 | } | 178 | } |
179 | else | 179 | else |
180 | return false; | 180 | return false; |
181 | } | 181 | } |
182 | 182 | ||
183 | void MyPal::timerEvent ( QTimerEvent * ) | 183 | void MyPal::timerEvent ( QTimerEvent * ) |
184 | { | 184 | { |
185 | killTimer ( m_power_timer ); | 185 | killTimer ( m_power_timer ); |
186 | m_power_timer = 0; | 186 | m_power_timer = 0; |
187 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 187 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
188 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 188 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
189 | } | 189 | } |
190 | 190 | ||
191 | 191 | ||
192 | void MyPal::playAlarmSound() | 192 | void MyPal::playAlarmSound() |
193 | { | 193 | { |
194 | #ifndef QT_NO_SOUND | 194 | #ifndef QT_NO_SOUND |
195 | static Sound snd ( "alarm" ); | 195 | static Sound snd ( "alarm" ); |
196 | if(!snd.isFinished()) | 196 | if(!snd.isFinished()) |
197 | return; | 197 | return; |
198 | 198 | ||
199 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); | 199 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); |
200 | snd. play(); | 200 | snd. play(); |
201 | #endif | 201 | #endif |
202 | } | 202 | } |
203 | 203 | ||
204 | bool MyPal::setDisplayBrightness ( int bright ) | 204 | bool MyPal::setDisplayBrightness ( int bright ) |
205 | { | 205 | { |
206 | bool res = false; | 206 | bool res = false; |
207 | 207 | ||
208 | if ( bright > 255 ) | 208 | if ( bright > 255 ) |
209 | bright = 255; | 209 | bright = 255; |
210 | if ( bright < 0 ) | 210 | if ( bright < 0 ) |
211 | bright = 0; | 211 | bright = 0; |
212 | 212 | ||
213 | QDir sysClass( "/sys/class/backlight/pxafb/" ); | 213 | QDir sysClass( "/sys/class/backlight/pxafb/" ); |
214 | sysClass.setFilter(QDir::Dirs); | 214 | sysClass.setFilter(QDir::Dirs); |
215 | int fd; | 215 | int fd; |
216 | if ( sysClass.exists() ) { | 216 | if ( sysClass.exists() ) { |
217 | QString sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/power" ); | 217 | QString sysClassPath = sysClass.absFilePath( "/sys/class/backlight/pxafb/power" ); |
218 | fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK ); | 218 | fd = ::open( sysClassPath, O_WRONLY | O_NONBLOCK ); |
219 | if ( fd ) { | 219 | if ( fd ) { |
220 | char buf[10]; | 220 | char buf[10]; |
221 | buf[0] = bright ? 0 : 4; | 221 | buf[0] = bright ? 0 : 4; |
222 | buf[1] = '\0'; | 222 | buf[1] = '\0'; |