--- qtopia-free-1.5.0-k1/inputmethods/keyboard/keyboard.cpp.org Tue Oct 8 22:01:12 2002 +++ qtopia-free-1.5.0-k1/inputmethods/keyboard/keyboard.cpp Fri Oct 11 21:55:41 2002 @@ -22,14 +22,16 @@ #include +#ifdef QWS #include +#endif #include #include #include #include -#define USE_SMALL_BACKSPACE +// #define USE_SMALL_BACKSPACE Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : QFrame(parent, name, f), shift(FALSE), lock(FALSE), ctrl(FALSE), @@ -91,8 +93,12 @@ parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); } for (int i=0; i<(int)s.length(); i++) { - parent->emitKey( s[i].unicode(), 0, 0, true, false ); - parent->emitKey( s[i].unicode(), 0, 0, false, false ); + uint code = 0; + if ( s[i].unicode() >= 'a' && s[i].unicode() <= 'z' ) { + code = s[i].unicode() - 'a' + Key_A; + } + parent->emitKey( s[i].unicode(), code, 0, true, false ); + parent->emitKey( s[i].unicode(), code, 0, false, false ); } parent->emitKey( 0, Qt::Key_Space, 0, true, false ); parent->emitKey( 0, Qt::Key_Space, 0, false, false ); @@ -107,12 +113,9 @@ Format: length, code, length, code, ..., 0 length is measured in half the width of a standard key. - If code < 0x80 we have length/2 consecutive standard keys, - starting with scancode code. + If code < 0x80, code gives the ASCII value of the key - Special keys are hardcoded, one at a time, with length of key - and code >= 0x80, these are NOT standard PC scancodes, but are looked - up in specialM[]. (The special keys are not keymappable.) + If code >= 0x80, the key is looked up in specialM[]. */ @@ -130,21 +133,30 @@ #ifdef USE_SMALL_BACKSPACE (const uchar *const)"\002\240\002`\0021\0022\0023\0024\0025\0026\0027\0028\0029\0020\002-\002=\002\200\002\223\002\215\002\216\002\217", #else - (const uchar *const)"\002\051\0021\0022\0023\0024\0025\0026\0027\0028\0029\0020\002-\002=\004\200\002\223\002\215\002\216\002\217", ++ (const uchar *const)"\002\240\0021\0022\0023\0024\0025\0026\0027\0028\0029\0020\002-\002=\004\200\002\223\002\215\002\216\002\217", #endif - //~ + 123...+ BACKSPACE //+ INSERT + HOME + PGUP + //ESC + 123...+ BACKSPACE //+ INSERT + HOME + PGUP (const uchar *const)"\003\201\002q\002w\002e\002r\002t\002y\002u\002i\002o\002p\002[\002]\002\\\001\224\002\223\002\221\002\220\002\222", //TAB + qwerty.. + backslash //+ DEL + END + PGDN +#ifdef USE_SMALL_BACKSPACE (const uchar *const)"\004\202\002a\002s\002d\002f\002g\002h\002j\002k\002l\002;\002'\004\203", //CAPS + asdf.. + RETURN - +#else + (const uchar *const)"\004\205\002a\002s\002d\002f\002g\002h\002j\002k\002l\002;\002'\004\203", + //CTRL + asdf.. + RETURN +#endif (const uchar *const)"\005\204\002z\002x\002c\002v\002b\002n\002m\002,\002.\002/\005\204\002\223\002\223\002\211", //SHIFT + zxcv... //+ UP +#ifdef USE_SMALL_BACKSPACE (const uchar *const)"\003\205\003\206\022\207\003\206\003\205\002\223\002\212\002\213\002\214" //CTRL + ALT + SPACE //+ LEFT + DOWN + RIGHT +#else + (const uchar *const)"\003\202\003\206\002`\015\207\003\243\003\206\003\205\002\223\002\212\002\213\002\214" + //CAPS + ALT + SPACE //+ LEFT + DOWN + RIGHT +#endif }; @@ -356,13 +368,13 @@ ". c None", ".....................", ".....................", -".....aaa..a..........", -".a...a..a.a.a.aaa.aaa", -"aaaa.aaa..aa..aa..a.a", -".a...a..a.aaa..aa.a.a", -".....aaaa.a.a.aaa.aa.", -"..................a..", -"....................."}; +"..........a..........", +"........aa...........", +"......aaa............", +"....aaaaaaaaaaaaaaaaa", +"......aaa............", +"........aa...........", +"..........a.........."}; #endif /* XPM */ static const char * const escape_xpm[]={ @@ -433,7 +445,15 @@ { Sqrt, 0, "^1/2", NULL }, { Inverse, 0, "1/x", NULL }, - { Escape, 27, "ESC", escape_xpm } + { Escape, 27, "ESC", escape_xpm }, + { Qt::Key_F21, 0, "ZEN", NULL }, + { Qt::Key_F26, 0, "KNA", NULL }, + { Qt::Key_F25, 0, "KNJ", NULL }, + { Qt::Key_F27, 0, "HKNA", NULL }, + { Qt::Key_F28, 0, "HHAN", NULL }, + { Qt::Key_F29, 0, "HEI", NULL }, + { Qt::Key_F23, 0, "ONK", NULL }, + { Qt::Key_F24, 0, "HEN", NULL } }; @@ -667,42 +687,36 @@ unicode = specialM[ k - 0x80 ].unicode; } } else { -#if defined(Q_WS_QWS) || defined(_WS_QWS_) -/* - qk = QWSServer::keyMap()[k].key_code; - if ( qk != Key_unknown ) { - if ( ctrl ) - u = QWSServer::keyMap()[k].ctrl_unicode; - else if ( shift^lock ) - u = QWSServer::keyMap()[k].shift_unicode; - else - u = QWSServer::keyMap()[k].unicode; - } -*/ - char shifted = k; - if ( !isalpha( k ) ) { - // ### Fixme, bad code, needs improving, whole thing needs to - // be re-coded to get rid of the way it did things with scancodes etc + //due to the way the keyboard is defined, we know that + //k is within the ASCII range, and can be directly mapped to + //a qkeycode + qkeycode = k; + if ( shift^lock ) { + if ( !isalpha( k ) ) { for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) - if ( shiftMap[i].normal == k ) - shifted = shiftMap[i].shifted; + if ( shiftMap[i].normal == k ) { + unicode = shiftMap[i].shifted; + qkeycode = unicode; + break; + } + } else { + unicode = toupper( k ); + } } else { - shifted = toupper( k ); + unicode = k; } - QChar tempChar( shift^lock ? shifted : k ); - unicode = tempChar.unicode(); -#endif } if ( unicode != -1 ) { + if ( ctrl && unicode >= 'a' && unicode <= 'z' ) + unicode = unicode - 'a'+1; modifiers = (shift ? Qt::ShiftButton : 0) | (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); #if defined(Q_WS_QWS) || defined(_WS_QWS_) emit key( unicode, qkeycode, modifiers, true, false ); - repeatTimer->start( 500 ); + repeatTimer->start( 300 ); #endif need_repaint = shift || alt || ctrl; shift = alt = ctrl = FALSE; - //qDebug( "pressed %d -> %04x ('%c')", k, u, u&0xffff < 256 ? u&0xff : 0 ); KeyboardConfig *dc = picks->dc; @@ -761,7 +775,7 @@ void Keyboard::repeat() { - repeatTimer->start( 150 ); + repeatTimer->start( 60 ); emit key( unicode, qkeycode, modifiers, true, true ); } --- qtopia-free-1.5.0-k1/inputmethods/keyboard/keyboardimpl.cpp.org Tue Oct 8 22:01:12 2002 +++ qtopia-free-1.5.0-k1/inputmethods/keyboard/keyboardimpl.cpp Fri Oct 11 21:55:41 2002 @@ -100,8 +100,9 @@ QString KeyboardImpl::name() { - return qApp->translate( "InputMethods", "Keyboard" ); +// return qApp->translate( "InputMethods", "Keyboard" ); // return qApp->translate( "InputMethods", "Opti" ); + return qApp->translate( "InputMethods", "USKeyboard" ); } void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot ) @@ -118,6 +119,8 @@ *iface = this; else if ( uuid == IID_InputMethod ) *iface = this; + else + return QS_FALSE; if ( *iface ) (*iface)->addRef();