summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 3e43978..d0cfa51 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -281,682 +281,682 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
281 281
282 } 282 }
283 283
284 keys.setPressed(row, col, usePicks); 284 keys.setPressed(row, col, usePicks);
285 need_repaint = TRUE; 285 need_repaint = TRUE;
286 qkeycode = 0; // don't need to emit Key_F1 286 qkeycode = 0; // don't need to emit Key_F1
287 } else if (qkeycode == Qt::Key_Control) { 287 } else if (qkeycode == Qt::Key_Control) {
288 ctrl = keys.pressedPtr(row, col); 288 ctrl = keys.pressedPtr(row, col);
289 need_repaint = TRUE; 289 need_repaint = TRUE;
290 *ctrl = !keys.pressed(row, col); 290 *ctrl = !keys.pressed(row, col);
291 291
292 } else if (qkeycode == Qt::Key_Alt) { 292 } else if (qkeycode == Qt::Key_Alt) {
293 alt = keys.pressedPtr(row, col); 293 alt = keys.pressedPtr(row, col);
294 need_repaint = TRUE; 294 need_repaint = TRUE;
295 *alt = !keys.pressed(row, col); 295 *alt = !keys.pressed(row, col);
296 296
297 } else if (qkeycode == Qt::Key_Shift) { 297 } else if (qkeycode == Qt::Key_Shift) {
298 need_repaint = TRUE; 298 need_repaint = TRUE;
299 299
300 if (shift) { 300 if (shift) {
301 *shift = 0; 301 *shift = 0;
302 shift = 0; 302 shift = 0;
303 } 303 }
304 else { 304 else {
305 shift = keys.pressedPtr(row, col); 305 shift = keys.pressedPtr(row, col);
306 *shift = 1; 306 *shift = 1;
307 if (lock) { 307 if (lock) {
308 *lock = 0; 308 *lock = 0;
309 lock = 0; 309 lock = 0;
310 } 310 }
311 } 311 }
312 312
313 } else if (qkeycode == Qt::Key_CapsLock) { 313 } else if (qkeycode == Qt::Key_CapsLock) {
314 need_repaint = TRUE; 314 need_repaint = TRUE;
315 315
316 if (lock) { 316 if (lock) {
317 *lock = 0; 317 *lock = 0;
318 lock = 0; 318 lock = 0;
319 } 319 }
320 else { 320 else {
321 lock = keys.pressedPtr(row, col);; 321 lock = keys.pressedPtr(row, col);;
322 *lock = 1; 322 *lock = 1;
323 if (shift) { 323 if (shift) {
324 *shift = 0; 324 *shift = 0;
325 shift = 0; 325 shift = 0;
326 } 326 }
327 } 327 }
328 328
329 } 329 }
330 330
331 } 331 }
332 else { // normal char 332 else { // normal char
333 if ((shift || lock) && keys.shift(unicode)) { 333 if ((shift || lock) && keys.shift(unicode)) {
334 unicode = keys.shift(unicode); 334 unicode = keys.shift(unicode);
335 } 335 }
336 } 336 }
337 337
338 // korean parsing 338 // korean parsing
339 if (LANG == "ko") { 339 if (LANG == "ko") {
340 340
341 unicode = parseKoreanInput(unicode); 341 unicode = parseKoreanInput(unicode);
342 } 342 }
343 343
344 modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); 344 modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0);
345 345
346 emit key(unicode, qkeycode, modifiers, true, false); 346 emit key(unicode, qkeycode, modifiers, true, false);
347 347
348 // pickboard stuff 348 // pickboard stuff
349 if (usePicks) { 349 if (usePicks) {
350 350
351 KeyboardConfig *dc = picks->dc; 351 KeyboardConfig *dc = picks->dc;
352 352
353 if (dc) { 353 if (dc) {
354 if (qkeycode == Qt::Key_Backspace) { 354 if (qkeycode == Qt::Key_Backspace) {
355 dc->input.remove(dc->input.last()); // remove last input 355 dc->input.remove(dc->input.last()); // remove last input
356 dc->decBackspaces(); 356 dc->decBackspaces();
357 } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { 357 } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) {
358 dc->input.clear(); 358 dc->input.clear();
359 dc->resetBackspaces(); 359 dc->resetBackspaces();
360 } else { 360 } else {
361 dc->add(QString(QChar(unicode))); 361 dc->add(QString(QChar(unicode)));
362 dc->incBackspaces(); 362 dc->incBackspaces();
363 } 363 }
364 } 364 }
365 picks->repaint(); 365 picks->repaint();
366 } 366 }
367 367
368 368
369 // painting 369 // painting
370 pressed = TRUE; 370 pressed = TRUE;
371 371
372 pressedKeyRow = row; 372 pressedKeyRow = row;
373 pressedKeyCol = col; 373 pressedKeyCol = col;
374 374
375 if (need_repaint) repaint(FALSE); 375 if (need_repaint) repaint(FALSE);
376 else { // just paint the one key pressed 376 else { // just paint the one key pressed
377 377
378 378
379 379
380 QPainter p(this); 380 QPainter p(this);
381 drawKeyboard(p, row, col); 381 drawKeyboard(p, row, col);
382 382
383 } 383 }
384 384
385 pressTid = startTimer(80); 385 pressTid = startTimer(80);
386 386
387} 387}
388 388
389 389
390/* Keyboard::mouseReleaseEvent {{{1 */ 390/* Keyboard::mouseReleaseEvent {{{1 */
391void Keyboard::mouseReleaseEvent(QMouseEvent*) 391void Keyboard::mouseReleaseEvent(QMouseEvent*)
392{ 392{
393 pressed = FALSE; 393 pressed = FALSE;
394 if ( pressTid == 0 ) 394 if ( pressTid == 0 )
395#if defined(Q_WS_QWS) || defined(_WS_QWS_) 395#if defined(Q_WS_QWS) || defined(_WS_QWS_)
396 if ( unicode != -1 ) { 396 if ( unicode != -1 ) {
397 emit key( unicode, qkeycode, modifiers, false, false ); 397 emit key( unicode, qkeycode, modifiers, false, false );
398 repeatTimer->stop(); 398 repeatTimer->stop();
399 } 399 }
400#endif 400#endif
401 if (shift && unicode != 0) { 401 if (shift && unicode != 0) {
402 402
403 403
404 *shift = 0; // unpress shift key 404 *shift = 0; // unpress shift key
405 shift = 0; // reset the shift pointer 405 shift = 0; // reset the shift pointer
406 repaint(FALSE); 406 repaint(FALSE);
407 407
408 } 408 }
409 else 409 else
410 410
411 clearHighlight(); 411 clearHighlight();
412} 412}
413 413
414/* Keyboard::timerEvent {{{1 */ 414/* Keyboard::timerEvent {{{1 */
415/* 415/*
416void Keyboard::timerEvent(QTimerEvent* e) 416void Keyboard::timerEvent(QTimerEvent* e)
417{ 417{
418 if ( e->timerId() == pressTid ) { 418 if ( e->timerId() == pressTid ) {
419 killTimer(pressTid); 419 killTimer(pressTid);
420 pressTid = 0; 420 pressTid = 0;
421 if ( !pressed ) 421 if ( !pressed )
422 cout << "calling clearHighlight from timerEvent\n"; 422 cout << "calling clearHighlight from timerEvent\n";
423 clearHighlight(); 423 clearHighlight();
424 } 424 }
425} 425}
426*/ 426*/
427 427
428void Keyboard::repeat() 428void Keyboard::repeat()
429{ 429{
430 430
431 repeatTimer->start( 200 ); 431 repeatTimer->start( 200 );
432 emit key( unicode, 0, modifiers, true, true ); 432 emit key( unicode, 0, modifiers, true, true );
433} 433}
434 434
435void Keyboard::clearHighlight() 435void Keyboard::clearHighlight()
436{ 436{
437 if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { 437 if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) {
438 int tmpRow = pressedKeyRow; 438 int tmpRow = pressedKeyRow;
439 int tmpCol = pressedKeyCol; 439 int tmpCol = pressedKeyCol;
440 440
441 pressedKeyRow = -1; 441 pressedKeyRow = -1;
442 pressedKeyCol = -1; 442 pressedKeyCol = -1;
443 443
444 QPainter p(this); 444 QPainter p(this);
445 drawKeyboard(p, tmpRow, tmpCol); 445 drawKeyboard(p, tmpRow, tmpCol);
446 } 446 }
447} 447}
448 448
449 449
450/* Keyboard::sizeHint {{{1 */ 450/* Keyboard::sizeHint {{{1 */
451QSize Keyboard::sizeHint() const 451QSize Keyboard::sizeHint() const
452{ 452{
453 QFontMetrics fm=fontMetrics(); 453 QFontMetrics fm=fontMetrics();
454 int keyHeight = fm.lineSpacing(); 454 int keyHeight = fm.lineSpacing();
455 455
456 return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); 456 return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1);
457} 457}
458 458
459 459
460void Keyboard::resetState() 460void Keyboard::resetState()
461{ 461{
462 schar = mchar = echar = 0; 462 schar = mchar = echar = 0;
463 picks->resetState(); 463 picks->resetState();
464} 464}
465 465
466/* korean input functions {{{1 466/* korean input functions {{{1
467 * 467 *
468 * TODO 468 * TODO
469 * one major problem with this implementation is that you can't move the 469 * one major problem with this implementation is that you can't move the
470 * cursor after inputing korean chars, otherwise it will eat up and replace 470 * cursor after inputing korean chars, otherwise it will eat up and replace
471 * the char before the cursor you move to. fix that 471 * the char before the cursor you move to. fix that
472 * 472 *
473 * make a kor/eng swaping key 473 * make backspace delete one single char, not the whole thing if still
474 * editing.
474 * 475 *
475 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 476 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
476 * 477 *
477 * how korean input works 478 * how korean input works
478 * 479 *
479 * all following chars means unicode char value and are in hex 480 * all following chars means unicode char value and are in hex
480 * 481 *
481 * ÃÊÀ½ = schar (start char) 482 * ÃÊÀ½ = schar (start char)
482 * ÁßÀ½ = mchar (middle char) 483 * ÁßÀ½ = mchar (middle char)
483 * ³¡À½ = echar (end char) 484 * ³¡À½ = echar (end char)
484 * 485 *
485 * there are 19 schars. unicode position is at 1100 - 1112 486 * there are 19 schars. unicode position is at 1100 - 1112
486 * there are 21 mchars. unicode position is at 1161 - 1175 487 * there are 21 mchars. unicode position is at 1161 - 1175
487 * there are 27 echars. unicode position is at 11a8 - 11c2 488 * there are 27 echars. unicode position is at 11a8 - 11c2
488 * 489 *
489 * the map with everything combined is at ac00 - d7a3 490 * the map with everything combined is at ac00 - d7a3
490 * 491 *
491 */ 492 */
492 493
493ushort Keyboard::parseKoreanInput (ushort c) { 494ushort Keyboard::parseKoreanInput (ushort c) {
494 495
495 if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) 496 if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c))
496 || 497 ||
497 (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode 498 (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode
498 && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { 499 && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) {
499 500
500 schar = 0, mchar = 0, echar = 0; 501 schar = 0, mchar = 0, echar = 0;
501 return c; 502 return c;
502 } 503 }
503 504
504 if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input 505 if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input
505 506
506 if (schar == 0 || (schar != 0 && mchar == 0)) { 507 if (schar == 0 || (schar != 0 && mchar == 0)) {
507 schar = c; mchar = 0; echar = 0; 508 schar = c; mchar = 0; echar = 0;
508 return c; 509 return c;
509 } 510 }
510 else if (mchar != 0) { 511 else if (mchar != 0) {
511 512
512 if (echar == 0) { 513 if (echar == 0) {
513 514
514 if (!(echar = constoe(c))) { 515 if (!(echar = constoe(c))) {
515 516
516 schar = c; mchar = 0; echar = 0; 517 schar = c; mchar = 0; echar = 0;
517 return c; 518 return c;
518 } 519 }
519 520
520 } 521 }
521 else { // must figure out what the echar is 522 else { // must figure out what the echar is
522 523
523 if (echar == 0x11a8) { // ¤¡ 524 if (echar == 0x11a8) { // ¤¡
524 525
525 if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡ 526 if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡
526 else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ 527 else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ
527 else { 528 else {
528 schar = c; mchar = 0; echar = 0; 529 schar = c; mchar = 0; echar = 0;
529 return c; 530 return c;
530 } 531 }
531 532
532 } else if (echar == 0x11ab) { // ¤¤ 533 } else if (echar == 0x11ab) { // ¤¤
533 534
534 if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸ 535 if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸
535 else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾ 536 else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾
536 else { 537 else {
537 schar = c; mchar = 0; echar = 0; 538 schar = c; mchar = 0; echar = 0;
538 return c; 539 return c;
539 } 540 }
540 541
541 } else if (echar == 0x11af) { // ¤© 542 } else if (echar == 0x11af) { // ¤©
542 543
543 if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡ 544 if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡
544 else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤± 545 else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤±
545 else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤² 546 else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤²
546 else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ 547 else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ
547 else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼ 548 else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼
548 else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½ 549 else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½
549 else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾ 550 else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾
550 else { 551 else {
551 schar = c; mchar = 0; echar = 0; 552 schar = c; mchar = 0; echar = 0;
552 return c; 553 return c;
553 } 554 }
554 555
555 } else if (echar == 0x11b8) { // ¤² 556 } else if (echar == 0x11b8) { // ¤²
556 557
557 if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ 558 if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ
558 else { 559 else {
559 schar = c; mchar = 0; echar = 0; 560 schar = c; mchar = 0; echar = 0;
560 return c; 561 return c;
561 } 562 }
562 563
563 } else if (echar == 0x11ba) { // ¤µ 564 } else if (echar == 0x11ba) { // ¤µ
564 565
565 if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ 566 if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ
566 else { 567 else {
567 schar = c; mchar = 0; echar = 0; 568 schar = c; mchar = 0; echar = 0;
568 return c; 569 return c;
569 } 570 }
570 571
571 } else { // if any other char, cannot combine chars 572 } else { // if any other char, cannot combine chars
572 573
573 schar = c; mchar = 0; echar = 0; 574 schar = c; mchar = 0; echar = 0;
574 return c; 575 return c;
575 } 576 }
576 577
577 unicode = echar; 578 unicode = echar;
578 } 579 }
579 } 580 }
580 581
581 } 582 }
582 else if (0x1161 <= c && c <= 0x1175) { // mchar was input 583 else if (0x1161 <= c && c <= 0x1175) { // mchar was input
583 584
584 if (schar != 0 && mchar == 0) { mchar = c; } 585 if (schar != 0 && mchar == 0) { mchar = c; }
585 586
586 else if (schar != 0 && mchar != 0 && echar == 0) { 587 else if (schar != 0 && mchar != 0 && echar == 0) {
587 588
588 switch (mchar) { 589 switch (mchar) {
589 case 0x1169: 590 case 0x1169:
590 if (c == 0x1161) mchar = 0x116a; 591 if (c == 0x1161) mchar = 0x116a;
591 else if (c == 0x1162) mchar = 0x116b; 592 else if (c == 0x1162) mchar = 0x116b;
592 else if (c == 0x1175) mchar = 0x116c; 593 else if (c == 0x1175) mchar = 0x116c;
593 else { 594 else {
594 schar = 0; mchar = 0; echar = 0; 595 schar = 0; mchar = 0; echar = 0;
595 return c; 596 return c;
596 } 597 }
597 break; 598 break;
598 case 0x116e: 599 case 0x116e:
599 if (c == 0x1165) mchar = 0x116f; 600 if (c == 0x1165) mchar = 0x116f;
600 else if (c == 0x1166) mchar = 0x1170; 601 else if (c == 0x1166) mchar = 0x1170;
601 else if (c == 0x1175) mchar = 0x1171; 602 else if (c == 0x1175) mchar = 0x1171;
602 else { 603 else {
603 schar = 0; mchar = 0; echar = 0; 604 schar = 0; mchar = 0; echar = 0;
604 return c; 605 return c;
605 } 606 }
606 break; 607 break;
607 case 0x1173: 608 case 0x1173:
608 if (c == 0x1175) mchar = 0x1174; 609 if (c == 0x1175) mchar = 0x1174;
609 else { 610 else {
610 schar = 0; mchar = 0; echar = 0; 611 schar = 0; mchar = 0; echar = 0;
611 return c; 612 return c;
612 } 613 }
613 break; 614 break;
614 default: 615 default:
615 schar = 0; mchar = 0; echar = 0; 616 schar = 0; mchar = 0; echar = 0;
616 return c; 617 return c;
617 } 618 }
618 } 619 }
619 else if (schar != 0 && mchar != 0 && echar != 0) { 620 else if (schar != 0 && mchar != 0 && echar != 0) {
620 621
621 emit key( 8, Qt::Key_Backspace, 0, true, false ); 622 emit key( 8, Qt::Key_Backspace, 0, true, false );
622 623
623 ushort prev = 0; 624 ushort prev = 0;
624 switch (echar) { 625 switch (echar) {
625 /* 626 /*
626 case 0x11a9: 627 case 0x11a9:
627 prev = combineKoreanChars(schar, mchar, 0x11a8); 628 prev = combineKoreanChars(schar, mchar, 0x11a8);
628 schar = 0x1100; 629 schar = 0x1100;
629 break; 630 break;
630 */ 631 */
631 case 0x11aa: 632 case 0x11aa:
632 prev = combineKoreanChars(schar, mchar, 0x11a8); 633 prev = combineKoreanChars(schar, mchar, 0x11a8);
633 schar = 0x1109; 634 schar = 0x1109;
634 break; 635 break;
635 case 0x11ac: 636 case 0x11ac:
636 prev = combineKoreanChars(schar, mchar, 0x11ab); 637 prev = combineKoreanChars(schar, mchar, 0x11ab);
637 schar = 0x110c; 638 schar = 0x110c;
638 break; 639 break;
639 case 0x11ad: 640 case 0x11ad:
640 prev = combineKoreanChars(schar, mchar, 0x11ab); 641 prev = combineKoreanChars(schar, mchar, 0x11ab);
641 schar = 0x1112; 642 schar = 0x1112;
642 break; 643 break;
643 case 0x11b0: 644 case 0x11b0:
644 prev = combineKoreanChars(schar, mchar, 0x11af); 645 prev = combineKoreanChars(schar, mchar, 0x11af);
645 schar = 0x1100; 646 schar = 0x1100;
646 break; 647 break;
647 case 0x11b1: 648 case 0x11b1:
648 prev = combineKoreanChars(schar, mchar, 0x11af); 649 prev = combineKoreanChars(schar, mchar, 0x11af);
649 schar = 0x1106; 650 schar = 0x1106;
650 break; 651 break;
651 case 0x11b2: 652 case 0x11b2:
652 prev = combineKoreanChars(schar, mchar, 0x11af); 653 prev = combineKoreanChars(schar, mchar, 0x11af);
653 schar = 0x1107; 654 schar = 0x1107;
654 break; 655 break;
655 case 0x11b3: 656 case 0x11b3:
656 prev = combineKoreanChars(schar, mchar, 0x11af); 657 prev = combineKoreanChars(schar, mchar, 0x11af);
657 schar = 0x1109; 658 schar = 0x1109;
658 break; 659 break;
659 case 0x11b4: 660 case 0x11b4:
660 prev = combineKoreanChars(schar, mchar, 0x11af); 661 prev = combineKoreanChars(schar, mchar, 0x11af);
661 schar = 0x1110; 662 schar = 0x1110;
662 break; 663 break;
663 case 0x11b9: 664 case 0x11b9:
664 prev = combineKoreanChars(schar, mchar, 0x11b8); 665 prev = combineKoreanChars(schar, mchar, 0x11b8);
665 schar = 0x1109; 666 schar = 0x1109;
666 break; 667 break;
667 /* 668 /*
668 case 0x11bb: 669 case 0x11bb:
669 prev = combineKoreanChars(schar, mchar, 0x11ba); 670 prev = combineKoreanChars(schar, mchar, 0x11ba);
670 schar = 0x1109; 671 schar = 0x1109;
671 break; 672 break;
672 */ 673 */
673 default: 674 default:
674 675
675 if (constoe(echar)) { 676 if (constoe(echar)) {
676 677
677 prev = combineKoreanChars(schar, mchar, 0); 678 prev = combineKoreanChars(schar, mchar, 0);
678 schar = constoe(echar); 679 schar = constoe(echar);
679 } 680 }
680 break; 681 break;
681 } 682 }
682 683
683 emit key( prev, prev, 0, true, false ); 684 emit key( prev, prev, 0, true, false );
684 685
685 mchar = c; echar = 0; 686 mchar = c; echar = 0;
686 687
687 return combineKoreanChars(schar, mchar, 0); 688 return combineKoreanChars(schar, mchar, 0);
688 689
689 } 690 }
690 else { 691 else {
691 schar = 0; mchar = 0; echar = 0; 692 schar = 0; mchar = 0; echar = 0;
692 return c; 693 return c;
693 } 694 }
694 695
695 } 696 }
696 else /*if (c == ' ')*/ return c; 697 else /*if (c == ' ')*/ return c;
697 698
698 699
699 // and now... finally delete previous char, and return new char 700 // and now... finally delete previous char, and return new char
700 emit key( 8, Qt::Key_Backspace, 0, true, false ); 701 emit key( 8, Qt::Key_Backspace, 0, true, false );
701 702
702 703
703 return combineKoreanChars( schar, mchar, echar); 704 return combineKoreanChars( schar, mchar, echar);
704 705
705} 706}
706 707
707ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { 708ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) {
708 709
709 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; 710 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00;
710 711
711} 712}
712 713
713ushort Keyboard::constoe(const ushort c) { 714ushort Keyboard::constoe(const ushort c) {
714 715
715 // converts schars to echars if possible 716 // converts schars to echars if possible
716 717
717 if (0x1100 <= c && c <= 0x1112) { // schar to echar 718 if (0x1100 <= c && c <= 0x1112) { // schar to echar
718 719
719 switch (c) { 720 switch (c) {
720 case 0x1100: return 0x11a8; 721 case 0x1100: return 0x11a8;
721 case 0x1101: return 0x11a9; 722 case 0x1101: return 0x11a9;
722 case 0x1102: return 0x11ab; 723 case 0x1102: return 0x11ab;
723 case 0x1103: return 0x11ae; 724 case 0x1103: return 0x11ae;
724 case 0x1105: return 0x11af; 725 case 0x1105: return 0x11af;
725 case 0x1106: return 0x11b7; 726 case 0x1106: return 0x11b7;
726 case 0x1107: return 0x11b8; 727 case 0x1107: return 0x11b8;
727 case 0x1109: return 0x11ba; 728 case 0x1109: return 0x11ba;
728 case 0x110a: return 0x11bb; 729 case 0x110a: return 0x11bb;
729 case 0x110b: return 0x11bc; 730 case 0x110b: return 0x11bc;
730 case 0x110c: return 0x11bd; 731 case 0x110c: return 0x11bd;
731 case 0x110e: return 0x11be; 732 case 0x110e: return 0x11be;
732 case 0x110f: return 0x11bf; 733 case 0x110f: return 0x11bf;
733 case 0x1110: return 0x11c0; 734 case 0x1110: return 0x11c0;
734 case 0x1111: return 0x11c1; 735 case 0x1111: return 0x11c1;
735 case 0x1112: return 0x11c2; 736 case 0x1112: return 0x11c2;
736 default: return 0; 737 default: return 0;
737 738
738 } 739 }
739 740
740 } else { //echar to schar 741 } else { //echar to schar
741 742
742 switch (c) { 743 switch (c) {
743 case 0x11a8: return 0x1100; 744 case 0x11a8: return 0x1100;
744 case 0x11a9: return 0x1101; 745 case 0x11a9: return 0x1101;
745 case 0x11ab: return 0x1102; 746 case 0x11ab: return 0x1102;
746 case 0x11ae: return 0x1103; 747 case 0x11ae: return 0x1103;
747 case 0x11af: return 0x1105; 748 case 0x11af: return 0x1105;
748 case 0x11b7: return 0x1106; 749 case 0x11b7: return 0x1106;
749 case 0x11b8: return 0x1107; 750 case 0x11b8: return 0x1107;
750 case 0x11ba: return 0x1109; 751 case 0x11ba: return 0x1109;
751 case 0x11bb: return 0x110a; 752 case 0x11bb: return 0x110a;
752 case 0x11bc: return 0x110b; 753 case 0x11bc: return 0x110b;
753 case 0x11bd: return 0x110c; 754 case 0x11bd: return 0x110c;
754 case 0x11be: return 0x110e; 755 case 0x11be: return 0x110e;
755 case 0x11bf: return 0x110f; 756 case 0x11bf: return 0x110f;
756 case 0x11c0: return 0x1110; 757 case 0x11c0: return 0x1110;
757 case 0x11c1: return 0x1111; 758 case 0x11c1: return 0x1111;
758 case 0x11c2: return 0x1112; 759 case 0x11c2: return 0x1112;
759 default: return 0; 760 default: return 0;
760 761
761 } 762 }
762 763
763 } 764 }
764} 765}
765 766
766 767
767// Keys::Keys {{{1 768// Keys::Keys {{{1
768 769
769Keys::Keys() { 770Keys::Keys() {
770 771
771 Config config("locale"); 772 Config config("locale");
772 config.setGroup( "Language" ); 773 config.setGroup( "Language" );
773 QString l = config.readEntry( "Language" ); 774 QString l = config.readEntry( "Language" , "en" );
774 if(l.isEmpty()) l = "en";
775 775
776 QString key_map = QPEApplication::qpeDir() + "/share/multikey/" 776 QString key_map = QPEApplication::qpeDir() + "/share/multikey/"
777 + /* l // testing korean for now */ 777 + /* l // testing korean for now */
778 + "ko.keymap"; 778 + "ko.keymap";
779 779
780 setKeysFromFile(key_map); 780 setKeysFromFile(key_map);
781} 781}
782 782
783Keys::Keys(const char * filename) { 783Keys::Keys(const char * filename) {
784 784
785 setKeysFromFile(filename); 785 setKeysFromFile(filename);
786} 786}
787 787
788// Keys::setKeysFromFile {{{2 788// Keys::setKeysFromFile {{{2
789void Keys::setKeysFromFile(const char * filename) { 789void Keys::setKeysFromFile(const char * filename) {
790 790
791 QFile f(filename); 791 QFile f(filename);
792 792
793 if (f.open(IO_ReadOnly)) { 793 if (f.open(IO_ReadOnly)) {
794 794
795 QTextStream t(&f); 795 QTextStream t(&f);
796 int row; 796 int row;
797 int qcode; 797 int qcode;
798 ushort unicode; 798 ushort unicode;
799 int width; 799 int width;
800 QString buf; 800 QString buf;
801 QString comment; 801 QString comment;
802 char * xpm[256]; //couldnt be larger than that... could it? 802 char * xpm[256]; //couldnt be larger than that... could it?
803 QPixmap *xpm2pix = 0; 803 QPixmap *xpm2pix = 0;
804 804
805 buf = t.readLine(); 805 buf = t.readLine();
806 while (buf) { 806 while (buf) {
807 807
808 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { 808 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) {
809 // no $1 type referencing!!! this implementation of regexp sucks 809 // no $1 type referencing!!! this implementation of regexp sucks
810 810
811 // dont know of any sscanf() type funcs in Qt lib 811 // dont know of any sscanf() type funcs in Qt lib
812 QTextStream tmp (buf, IO_ReadOnly); 812 QTextStream tmp (buf, IO_ReadOnly);
813 tmp >> row >> qcode >> unicode >> width >> comment; 813 tmp >> row >> qcode >> unicode >> width >> comment;
814 814
815 buf = t.readLine(); 815 buf = t.readLine();
816 int xpmLineCount = 0; 816 int xpmLineCount = 0;
817 xpm2pix = 0; 817 xpm2pix = 0;
818 818
819 // erase blank space 819 // erase blank space
820 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); 820 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine();
821 821
822 while (buf.contains(QRegExp("^\\s*\".*\""))) { 822 while (buf.contains(QRegExp("^\\s*\".*\""))) {
823 823
824 QString xpmBuf = buf.stripWhiteSpace(); 824 QString xpmBuf = buf.stripWhiteSpace();
825 825
826 xpm[xpmLineCount] = new char [xpmBuf.length()]; 826 xpm[xpmLineCount] = new char [xpmBuf.length()];
827 827
828 int j = 0; 828 int j = 0;
829 for (ushort i = 0; i < xpmBuf.length(); i++) { 829 for (ushort i = 0; i < xpmBuf.length(); i++) {
830 if (xpmBuf[i].latin1() != '"') { 830 if (xpmBuf[i].latin1() != '"') {
831 831
832 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); 832 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1();
833 j++; 833 j++;
834 } 834 }
835 835
836 } 836 }
837 // have to close that facker up 837 // have to close that facker up
838 ((char *)xpm[xpmLineCount])[j] = '\0'; 838 ((char *)xpm[xpmLineCount])[j] = '\0';
839 839
840 xpmLineCount++; 840 xpmLineCount++;
841 buf = t.readLine(); 841 buf = t.readLine();
842 } 842 }
843 if (xpmLineCount) { 843 if (xpmLineCount) {
844 844
845 xpm2pix = new QPixmap((const char **)xpm); 845 xpm2pix = new QPixmap((const char **)xpm);
846 for (int i = 0; i < xpmLineCount; i++) 846 for (int i = 0; i < xpmLineCount; i++)
847 847
848 delete [] (xpm[i]); 848 delete [] (xpm[i]);
849 849
850 } 850 }
851 setKey(row, qcode, unicode, width, xpm2pix); 851 setKey(row, qcode, unicode, width, xpm2pix);
852 } 852 }
853 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 853 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
854 854
855 QTextStream tmp (buf, IO_ReadOnly); 855 QTextStream tmp (buf, IO_ReadOnly);
856 ushort lower, shift; 856 ushort lower, shift;
857 tmp >> lower >> shift; 857 tmp >> lower >> shift;
858 858
859 shiftMap.insert(lower, shift); 859 shiftMap.insert(lower, shift);
860 860
861 buf = t.readLine(); 861 buf = t.readLine();
862 } 862 }
863 else if (buf.contains(QRegExp("^\\s*#"))) { 863 else if (buf.contains(QRegExp("^\\s*#"))) {
864 864
865 buf = t.readLine(); 865 buf = t.readLine();
866 866
867 } else { // blank line, or garbage 867 } else { // blank line, or garbage
868 868
869 buf = t.readLine(); 869 buf = t.readLine();
870 870
871 } 871 }
872 872
873 } 873 }
874 f.close(); 874 f.close();
875 } 875 }
876 876
877} 877}
878 878
879// Keys::setKey {{{2 879// Keys::setKey {{{2
880void Keys::setKey(const int row, const int qcode, const ushort unicode, 880void Keys::setKey(const int row, const int qcode, const ushort unicode,
881 const int width, QPixmap *pix) { 881 const int width, QPixmap *pix) {
882 882
883 Key * key; 883 Key * key;
884 key = new Key; 884 key = new Key;
885 key->qcode = qcode; 885 key->qcode = qcode;
886 key->unicode = unicode; 886 key->unicode = unicode;
887 key->width = width; 887 key->width = width;
888 888
889 // share key->pressed between same keys 889 // share key->pressed between same keys
890 bool found = 0; 890 bool found = 0;
891 for (int i = 1; i <= 5; i++) { 891 for (int i = 1; i <= 5; i++) {
892 for (unsigned int j = 0; j < keys[i].count(); j++) 892 for (unsigned int j = 0; j < keys[i].count(); j++)
893 if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { 893 if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) {
894 894
895 key->pressed = keys[i].at(j)->pressed; 895 key->pressed = keys[i].at(j)->pressed;
896 found = 1; 896 found = 1;
897 } 897 }
898 898
899 } 899 }
900 if (!found) { 900 if (!found) {
901 901
902 key->pressed = new bool; 902 key->pressed = new bool;
903 *(key->pressed) = 0; 903 *(key->pressed) = 0;
904 } 904 }
905 905
906 key->pix = pix; 906 key->pix = pix;
907 907
908 908
909 keys[row].append(key); 909 keys[row].append(key);
910} 910}
911// Keys:: other functions {{{2 911// Keys:: other functions {{{2
912int Keys::width(const int row, const int col) { 912int Keys::width(const int row, const int col) {
913 913
914 return keys[row].at(col)->width; 914 return keys[row].at(col)->width;
915 915
916} 916}
917ushort Keys::uni(const int row, const int col) { 917ushort Keys::uni(const int row, const int col) {
918 918
919 return keys[row].at(col)->unicode; 919 return keys[row].at(col)->unicode;
920 920
921} 921}
922 922
923int Keys::qcode(const int row, const int col) { 923int Keys::qcode(const int row, const int col) {
924 924
925 return keys[row].at(col)->qcode; 925 return keys[row].at(col)->qcode;
926} 926}
927 927
928QPixmap *Keys::pix(const int row, const int col) { 928QPixmap *Keys::pix(const int row, const int col) {
929 929
930 return keys[row].at(col)->pix; 930 return keys[row].at(col)->pix;
931 931
932} 932}
933bool Keys::pressed(const int row, const int col) { 933bool Keys::pressed(const int row, const int col) {
934 934
935 return *(keys[row].at(col)->pressed); 935 return *(keys[row].at(col)->pressed);
936} 936}
937 937
938int Keys::numKeys(const int row) { 938int Keys::numKeys(const int row) {
939 939
940 return keys[row].count(); 940 return keys[row].count();
941} 941}
942 942
943void Keys::setPressed(const int row, const int col, const bool pressed) { 943void Keys::setPressed(const int row, const int col, const bool pressed) {
944 944
945 *(keys[row].at(col)->pressed) = pressed; 945 *(keys[row].at(col)->pressed) = pressed;
946} 946}
947 947
948ushort Keys::shift(const ushort uni) { 948ushort Keys::shift(const ushort uni) {
949 949
950 if (shiftMap[uni]) { 950 if (shiftMap[uni]) {
951 951
952 return shiftMap[uni]; 952 return shiftMap[uni];
953 } 953 }
954 else 954 else
955 return 0; 955 return 0;
956 956
957} 957}
958 958
959bool *Keys::pressedPtr(const int row, const int col) { 959bool *Keys::pressedPtr(const int row, const int col) {
960 960
961 return keys[row].at(col)->pressed; 961 return keys[row].at(col)->pressed;
962} 962}