author | harlekin <harlekin> | 2002-02-16 02:00:41 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-02-16 02:00:41 (UTC) |
commit | f8744f9a9a59f7968ddbac66c927ba8da358f223 (patch) (side-by-side diff) | |
tree | 8a9670929d1025bd1c610cd3350a6e2cb35ef6b8 | |
parent | c91dc39fb820f6f6b9805b96aea282f1deb4d576 (diff) | |
download | opie-f8744f9a9a59f7968ddbac66c927ba8da358f223.zip opie-f8744f9a9a59f7968ddbac66c927ba8da358f223.tar.gz opie-f8744f9a9a59f7968ddbac66c927ba8da358f223.tar.bz2 |
Quick and dirty fix for the sticky keyboard problem on ipaq - just turn it off. Turned on on zaurus
-rw-r--r-- | inputmethods/keyboard/keyboard.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/inputmethods/keyboard/keyboard.cpp b/inputmethods/keyboard/keyboard.cpp index 9dd24e4..233f08e 100644 --- a/inputmethods/keyboard/keyboard.cpp +++ b/inputmethods/keyboard/keyboard.cpp @@ -1,148 +1,162 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "keyboard.h" #include <qpe/global.h> #include <qwindowsystem_qws.h> #include <qpainter.h> #include <qfontmetrics.h> #include <qtimer.h> #include <ctype.h> +#include <sys/utsname.h> + #define USE_SMALL_BACKSPACE Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : QFrame(parent, name, f), shift(FALSE), lock(FALSE), ctrl(FALSE), alt(FALSE), useLargeKeys(TRUE), useOptiKeys(0), pressedKey(-1), unicode(-1), qkeycode(0), modifiers(0) { // setPalette(QPalette(QColor(240,240,230))); // Beige! // setFont( QFont( "Helvetica", 8 ) ); // setPalette(QPalette(QColor(200,200,200))); // Gray setPalette(QPalette(QColor(220,220,220))); // Gray picks = new KeyboardPicks( this ); picks->setFont( QFont( "smallsmooth", 9 ) ); setFont( QFont( "smallsmooth", 9 ) ); picks->initialise(); QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); repeatTimer = new QTimer( this ); - connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); + + // temporary quick and dirty fix for the "sticky keyboard bug" + // on ipaq. + struct utsname name; + if (uname(&name) != -1) + { + QString release=name.release; + qWarning("System release: %s\n", name.release); + if(release.find("embedix",0,TRUE) !=-1) + { + connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); + } + } } void Keyboard::resizeEvent(QResizeEvent*) { int ph = picks->sizeHint().height(); picks->setGeometry( 0, 0, width(), ph ); keyHeight = (height()-ph)/5; int nk; if ( useOptiKeys ) { nk = 15; } else if ( useLargeKeys ) { nk = 15; } else { nk = 19; } defaultKeyWidth = width()/nk; xoffs = (width()-defaultKeyWidth*nk)/2; } void KeyboardPicks::initialise() { setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); mode = 0; dc = new KeyboardConfig(this); configs.append(dc); } QSize KeyboardPicks::sizeHint() const { return QSize(240,fontMetrics().lineSpacing()); } void KeyboardConfig::generateText(const QString &s) { #if defined(Q_WS_QWS) || defined(_WS_QWS_) for (int i=0; i<(int)backspaces; i++) { parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); 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 ); } parent->emitKey( 0, Qt::Key_Space, 0, true, false ); parent->emitKey( 0, Qt::Key_Space, 0, false, false ); backspaces = 0; #endif } //PC keyboard layout and scancodes /* 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. 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.) */ static const uchar * const keyboard_opti[5] = { (const uchar *const) "\001\223\003\240\002\20\002\41\002\26\002\62\002\56\002\45\002\54\003\200\001\223\002\226\002\235\002\234\002\236", (const uchar *const) "\001\223\003\201\004\207\002\30\002\24\002\43\004\207\003\203\001\223\006\002\002\065", (const uchar *const) "\001\223\003\202\002\60\002\37\002\23\002\22\002\36\002\21\002\55\003\203\001\223\006\005\002\055", (const uchar *const) "\001\223\003\205\004\207\002\27\002\61\002\40\004\207\003\204\001\223\006\010\002\014", (const uchar *const) "\001\223\003\206\002\44\002\31\002\57\002\42\002\46\002\25\002\207\003\204\001\223\002\013\002\064\002\015\002\230" }; static const uchar * const keyboard_standard[5] = { #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", #endif //~ + 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 (const uchar *const)"\004\202\002a\002s\002d\002f\002g\002h\002j\002k\002l\002;\002'\004\203", //CAPS + asdf.. + RETURN (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 (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 @@ -668,127 +682,128 @@ void Keyboard::mousePressEvent(QMouseEvent *e) } } 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 for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) if ( shiftMap[i].normal == k ) shifted = shiftMap[i].shifted; } else { shifted = toupper( k ); } QChar tempChar( shift^lock ? shifted : k ); unicode = tempChar.unicode(); #endif } if ( unicode != -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 ); #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; if (dc) { if (qkeycode == Qt::Key_Backspace) { dc->input.remove(dc->input.last()); // remove last input dc->decBackspaces(); } else if ( k == 0226 || qkeycode == Qt::Key_Return || qkeycode == Qt::Key_Space || QChar(unicode).isPunct() ) { dc->input.clear(); dc->resetBackspaces(); } else { dc->add(QString(QChar(unicode))); dc->incBackspaces(); } } picks->repaint(); } pressedKey = k; if ( need_repaint ) { repaint( FALSE ); } else { QPainter p(this); drawKeyboard( p, pressedKey ); } pressTid = startTimer(80); pressed = TRUE; } void Keyboard::mouseReleaseEvent(QMouseEvent*) { if ( pressTid == 0 ) clearHighlight(); #if defined(Q_WS_QWS) || defined(_WS_QWS_) if ( unicode != -1 ) { emit key( unicode, qkeycode, modifiers, false, false ); repeatTimer->stop(); } #endif pressed = FALSE; } void Keyboard::timerEvent(QTimerEvent* e) { if ( e->timerId() == pressTid ) { killTimer(pressTid); pressTid = 0; if ( !pressed ) clearHighlight(); } } void Keyboard::repeat() { - repeatTimer->start( 150 ); - emit key( unicode, qkeycode, modifiers, true, true ); + + repeatTimer->start( 200 ); + emit key( unicode, qkeycode, modifiers, true, true ); } void Keyboard::clearHighlight() { if ( pressedKey >= 0 ) { int tmp = pressedKey; pressedKey = -1; QPainter p(this); drawKeyboard( p, tmp ); } } QSize Keyboard::sizeHint() const { QFontMetrics fm=fontMetrics(); int keyHeight = fm.lineSpacing()+2; if (useOptiKeys) keyHeight += 1; return QSize( 320, keyHeight * 5 + picks->sizeHint().height() + 1 ); } void Keyboard::resetState() { picks->resetState(); } |