summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/zkbapplet/keyzcfg/zkb.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/noncore/applets/zkbapplet/keyzcfg/zkb.cpp b/noncore/applets/zkbapplet/keyzcfg/zkb.cpp
index a357b88..3cc3669 100644
--- a/noncore/applets/zkbapplet/keyzcfg/zkb.cpp
+++ b/noncore/applets/zkbapplet/keyzcfg/zkb.cpp
@@ -214,116 +214,117 @@ bool State::set(int keycode, bool pressed, Action& action) {
214State* State::getParent() const { 214State* State::getParent() const {
215 return parent; 215 return parent;
216} 216}
217 217
218void State::setParent(State* s) { 218void State::setParent(State* s) {
219 parent = s; 219 parent = s;
220} 220}
221 221
222int State::translateKeycode(int keycode) const { 222int State::translateKeycode(int keycode) const {
223 if (keycode < 0x20) { 223 if (keycode < 0x20) {
224 return -1; 224 return -1;
225 } 225 }
226 226
227 if (keycode < 0x80) { 227 if (keycode < 0x80) {
228 return x1[keycode - 0x20]; 228 return x1[keycode - 0x20];
229 } 229 }
230 230
231 if (keycode < 0x1000) { 231 if (keycode < 0x1000) {
232 return -1; 232 return -1;
233 } 233 }
234 234
235 if (keycode < 0x1057) { 235 if (keycode < 0x1057) {
236 return x2[keycode - 0x1000]; 236 return x2[keycode - 0x1000];
237 } 237 }
238 238
239 return -1; 239 return -1;
240} 240}
241 241
242// Implementation of Keymap class 242// Implementation of Keymap class
243Keymap::Keymap():enabled(true), currentState(0), autoRepeatAction(0), repeater(this) { 243Keymap::Keymap():enabled(true), currentState(0), autoRepeatAction(0), repeater(this) {
244 repeatDelay=400; 244 repeatDelay=400;
245 repeatPeriod=80; 245 repeatPeriod=80;
246 connect(&repeater, SIGNAL(timeout()), this, SLOT(autoRepeat())); 246 connect(&repeater, SIGNAL(timeout()), this, SLOT(autoRepeat()));
247} 247}
248 248
249Keymap::~Keymap() { 249Keymap::~Keymap() {
250 odebug << "removing keyboard filter for zkb"<<oendl; 250 odebug << "removing keyboard filter for zkb"<<oendl;
251 Opie::Core::OKeyFilter::inst()->remHandler(this); 251 Opie::Core::OKeyFilter::inst()->remHandler(this);
252 QMap<QString, State*>::Iterator it; 252 QMap<QString, State*>::Iterator it;
253 for(it = states.begin(); it != states.end(); ++it) { 253 for(it = states.begin(); it != states.end(); ++it) {
254 delete it.data(); 254 delete it.data();
255 } 255 }
256 states.clear(); 256 states.clear();
257} 257}
258 258
259bool Keymap::filter(int unicode, int keycode, int modifiers, 259bool Keymap::filter(int unicode, int keycode, int modifiers,
260 bool isPress, bool autoRepeat) { 260 bool isPress, bool autoRepeat) {
261 261
262 odebug << "filter: >>> unicode=" << unicode << ", keycode=" << keycode
263 << ", modifiers=" << modifiers << ", ispressed=" << isPress << oendl;
264
265 if (!enabled) { 262 if (!enabled) {
266 return false; 263 return false;
267 } 264 }
268 265
266 odebug << "filter: >>> unicode=" << unicode << ", keycode=" << keycode
267 << ", modifiers=" << modifiers << ", ispressed=" << isPress << oendl;
268
269 // the second check is workaround to make suspend work if 269 // the second check is workaround to make suspend work if
270 // the user pressed it right after he did resume. for some 270 // the user pressed it right after he did resume. for some
271 // reason the event sent by qt has autoRepeat true in this 271 // reason the event sent by qt has autoRepeat true in this
272 // case 272 // case
273 if (autoRepeat && keycode != 4177) { 273 if (autoRepeat && keycode != 4177) {
274 return true; 274 return true;
275 } 275 }
276 276
277 (void) unicode; (void) modifiers; 277 (void) unicode; (void) modifiers;
278 278
279 Action* action = currentState->get(keycode, isPress, true); 279 Action* action = currentState->get(keycode, isPress, true);
280 if (action==0 || !action->isDefined()) { 280 if (action==0 || !action->isDefined()) {
281 return true; 281 odebug << "no action defined for that"<<oendl;
282 return false;
282 } 283 }
283 284
284 if (action->hasEvent()) { 285 if (action->hasEvent()) {
285 odebug << "filter:<<< unicode=" << action->getUnicode() << ", keycode=" << action->getKeycode() 286 odebug << "filter:<<< unicode=" << action->getUnicode() << ", keycode=" << action->getKeycode()
286 << ", modifiers=" << action->getModifiers() << ", ispressed=" << action->isPressed() << oendl; 287 << ", modifiers=" << action->getModifiers() << ", ispressed=" << action->isPressed() << oendl;
287 288
288 QWSServer::sendKeyEvent(action->getUnicode(), 289 QWSServer::sendKeyEvent(action->getUnicode(),
289 action->getKeycode(), action->getModifiers(), 290 action->getKeycode(), action->getModifiers(),
290 action->isPressed(), false); 291 action->isPressed(), false);
291 } 292 }
292 293
293 if (action->isAutorepeat()) { 294 if (action->isAutorepeat()) {
294 autoRepeatAction = action; 295 autoRepeatAction = action;
295 repeater.start(repeatDelay, TRUE); 296 repeater.start(repeatDelay, TRUE);
296 } else { 297 } else {
297 autoRepeatAction = 0; 298 autoRepeatAction = 0;
298 } 299 }
299 300
300 State* nstate = action->getState(); 301 State* nstate = action->getState();
301 if (nstate != 0) { 302 if (nstate != 0) {
302 setCurrentState(nstate); 303 setCurrentState(nstate);
303 QString lbl = getCurrentLabel(); 304 QString lbl = getCurrentLabel();
304 if (!lbl.isEmpty()) { 305 if (!lbl.isEmpty()) {
305 emit stateChanged(lbl); 306 emit stateChanged(lbl);
306 } 307 }
307 } 308 }
308 309
309 310
310 return true; 311 return true;
311} 312}
312 313
313void Keymap::enable() { 314void Keymap::enable() {
314 enabled = true; 315 enabled = true;
315} 316}
316 317
317void Keymap::disable() { 318void Keymap::disable() {
318 enabled = false; 319 enabled = false;
319} 320}
320 321
321QStringList Keymap::listStates() { 322QStringList Keymap::listStates() {
322 QStringList ret; 323 QStringList ret;
323 324
324 QMap<QString, State*>::Iterator it; 325 QMap<QString, State*>::Iterator it;
325 for(it = states.begin(); it != states.end(); ++it) { 326 for(it = states.begin(); it != states.end(); ++it) {
326 ret.append(it.key()); 327 ret.append(it.key());
327 } 328 }
328 329
329 return ret; 330 return ret;