author | hash <hash> | 2002-09-24 22:01:40 (UTC) |
---|---|---|
committer | hash <hash> | 2002-09-24 22:01:40 (UTC) |
commit | aa7b6129c81d13492be3f1e50e6c54efe52ceb53 (patch) (side-by-side diff) | |
tree | a39c20cf13ea22a16b156dbd4ad5fb2c29fd49c0 /development/keyview | |
parent | 0792061c7f1758216f9d31314dc2c1bdabda653f (diff) | |
download | opie-aa7b6129c81d13492be3f1e50e6c54efe52ceb53.zip opie-aa7b6129c81d13492be3f1e50e6c54efe52ceb53.tar.gz opie-aa7b6129c81d13492be3f1e50e6c54efe52ceb53.tar.bz2 |
simple keycode viewer for hardware keyboards
-rw-r--r-- | development/keyview/keyboardimpl.cpp | 189 | ||||
-rw-r--r-- | development/keyview/keyboardimpl.h | 51 | ||||
-rw-r--r-- | development/keyview/keyview.cpp | 69 | ||||
-rw-r--r-- | development/keyview/keyview.h | 43 | ||||
-rw-r--r-- | development/keyview/keyview.pro | 26 | ||||
-rw-r--r-- | development/keyview/main.cpp | 12 |
6 files changed, 390 insertions, 0 deletions
diff --git a/development/keyview/keyboardimpl.cpp b/development/keyview/keyboardimpl.cpp new file mode 100644 index 0000000..673eaa5 --- a/dev/null +++ b/development/keyview/keyboardimpl.cpp @@ -0,0 +1,189 @@ +/********************************************************************** +** 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 <qapplication.h> +#include <qpixmap.h> +#include "keyview.h" +#include "keyboardimpl.h" + +/* XPM */ +static const char * kb_xpm[] = { +"28 13 81 1", +" c None", +". c #000000", +"+ c #E5E1D5", +"@ c #FFFFFF", +"# c #DBDBDB", +"$ c #132B07", +"% c #426362", +"& c #558384", +"* c #6E6D67", +"= c #DCD8CD", +"- c #929292", +"; c #446463", +"> c #558585", +", c #466565", +"' c #558685", +") c #B7B7B7", +"! c #A2A2A2", +"~ c #9A9A9A", +"{ c #959595", +"] c #939393", +"^ c #486767", +"/ c #383838", +"( c #303030", +"_ c #2C2C2C", +": c #2A2A2A", +"< c #292929", +"[ c #333333", +"} c #FFFFE9", +"| c #FEFFDD", +"1 c #E4E5AD", +"2 c #202020", +"3 c #466665", +"4 c #2F2F2F", +"5 c #FEFFC1", +"6 c #575742", +"7 c #191919", +"8 c #2D2D2D", +"9 c #29291F", +"0 c #141414", +"a c #122207", +"b c #548584", +"c c #111111", +"d c #131313", +"e c #1B2514", +"f c #112106", +"g c #416160", +"h c #538484", +"i c #2B2B2B", +"j c #0F0F0F", +"k c #14190F", +"l c #192312", +"m c #0F1F06", +"n c #40605F", +"o c #518483", +"p c #9D9D9D", +"q c #747474", +"r c #2B2C2B", +"s c #060704", +"t c #0B0E09", +"u c #12180D", +"v c #17210F", +"w c #0E1E04", +"x c #3D5E5D", +"y c #508382", +"z c #898989", +"A c #9C9C9C", +"B c #050704", +"C c #0A0D08", +"D c #10170B", +"E c #141E0C", +"F c #0C1B04", +"G c #395C5A", +"H c #4F8181", +"I c #242424", +"J c #050604", +"K c #090C06", +"L c #0E1509", +"M c #121C0A", +"N c #0B1A03", +"O c #375A58", +"P c #4D807F", +"...........+..@.@@@@@@@#.$%&", +"..........*=.@.@.@@@@@##.-;>", +"..............@.@.@@@###.-,'", +")!~{{]]]{]]].@.@.@@#.##-.-^'", +"/(_::<<<:<<<..@.@@#..#--.-^'", +"[}|12}|12}|12.#.@#.-.---.-3'", +"4|567|567|567..@@...---.--,'", +"81690169016901.@#.----.--a;b", +"82700ccc0cccd.@@......--efgh", +"i}|1c}|1c}|1j.@#.------klmno", +"i|56c|56c|56.@#.--pqrstuvwxy", +"i169c169c16.@#.--zAqrBCDEFGH", +"82700ccc0cj...--IzAqrJKLMNOP"}; + + + + +KeyboardImpl::KeyboardImpl() + : input(0), icn(0), ref(0) +{ +} + +KeyboardImpl::~KeyboardImpl() +{ + delete input; + delete icn; +} + +QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) +{ + if ( !input ) + input = new Keyview( parent, "Keyview", f ); + return input; +} + +void KeyboardImpl::resetState() +{ + /* + if ( input ) + input->resetState(); + */ +} + +QPixmap *KeyboardImpl::icon() +{ + if ( !icn ) + icn = new QPixmap( (const char **)kb_xpm ); + return icn; +} + +QString KeyboardImpl::name() +{ + // return qApp->translate( "InputMethods", "Keyboard" ); + return "Keyview"; +} + +void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot ) +{ + //if ( input ) + //QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); +} + +#ifndef QT_NO_COMPONENT +QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) +{ + *iface = 0; + if ( uuid == IID_QUnknown ) + *iface = this; + else if ( uuid == IID_InputMethod ) + *iface = this; + + if ( *iface ) + (*iface)->addRef(); + return QS_OK; +} + +Q_EXPORT_INTERFACE() +{ + Q_CREATE_INSTANCE( KeyboardImpl ) +} +#endif diff --git a/development/keyview/keyboardimpl.h b/development/keyview/keyboardimpl.h new file mode 100644 index 0000000..09a1abb --- a/dev/null +++ b/development/keyview/keyboardimpl.h @@ -0,0 +1,51 @@ +/********************************************************************** +** 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. +** +**********************************************************************/ +#ifndef KEYBOARDIMPL_H +#define KEYBOARDIMPL_H + +#include <qpe/inputmethodinterface.h> + +class Keyview; +class QPixmap; + +class KeyboardImpl : public InputMethodInterface +{ +public: + KeyboardImpl(); + virtual ~KeyboardImpl(); + +#ifndef QT_NO_COMPONENT + QRESULT queryInterface( const QUuid&, QUnknownInterface** ); + Q_REFCOUNT +#endif + + virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f ); + virtual void resetState(); + virtual QPixmap *icon(); + virtual QString name(); + virtual void onKeyPress( QObject *receiver, const char *slot ); + +private: + Keyview *input; + QPixmap *icn; + ulong ref; +}; + +#endif diff --git a/development/keyview/keyview.cpp b/development/keyview/keyview.cpp new file mode 100644 index 0000000..15d9f51 --- a/dev/null +++ b/development/keyview/keyview.cpp @@ -0,0 +1,69 @@ +#include "keyview.h" +#include <qgrid.h> +#include <iostream.h> +#include <qlineedit.h> +#include <qlabel.h> + +Keyview::Keyview( QWidget* parent, const char* name, WFlags fl ) + : QGrid ( 2, parent, name, fl ) +{ + setCaption( tr("Keyview") ); + setSpacing(3); + setMargin(4); + + QLabel *l; + + l = new QLabel(QString("unicode:"), this); + unicode = new QLineEdit(this); + unicode->setReadOnly(1); + + l = new QLabel(QString("keycode:"), this); + keycode = new QLineEdit(this); + keycode->setReadOnly(1); + + l = new QLabel(QString("modifiers:"), this); + modifiers = new QLineEdit(this); + modifiers->setReadOnly(1); + + l = new QLabel(QString("isPress:"), this); + isPress = new QLineEdit(this); + isPress->setReadOnly(1); + + l = new QLabel(QString("autoRepeat:"), this); + autoRepeat = new QLineEdit(this); + autoRepeat->setReadOnly(1); + + // spacer + l = new QLabel(QString(""), this); + l->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); + + + KeyFilter *filter = new KeyFilter(this); + QWSServer::setKeyboardFilter(filter); + + connect(filter, SIGNAL(keyPressed(int, int, int, bool, bool)), + this, SLOT(updateItems(int, int, int, bool, bool))); +} + +Keyview::~Keyview() { } + +void Keyview::updateItems(int u, int k, int m, bool p, bool a) { + + unicode->setText("0x" + QString::number(u, 16)); + keycode->setText("0x" + QString::number(k, 16)); + modifiers->setText("0x" + QString::number(m, 16)); + isPress->setText("0x" + QString::number(p, 16)); + autoRepeat->setText("0x" + QString::number(a, 16)); +} + +KeyFilter::KeyFilter(QObject * parent, const char *name) : QObject( parent, name ) { + +} + +bool KeyFilter::filter(int unicode, int keycode, int modifiers, bool isPress, + bool autoRepeat) { + + emit keyPressed(unicode, keycode, modifiers, isPress, autoRepeat); + return 0; // return 1 to stop key emiting + +} diff --git a/development/keyview/keyview.h b/development/keyview/keyview.h new file mode 100644 index 0000000..ab4ae60 --- a/dev/null +++ b/development/keyview/keyview.h @@ -0,0 +1,43 @@ +#ifndef KEYVIEW_H +#define KEYVIEW_H +#include <qgrid.h> +#include <qlineedit.h> +#include <qwindowsystem_qws.h> + + +class Keyview : public QGrid +{ + Q_OBJECT + +public: + Keyview( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~Keyview(); + +private slots: + void updateItems(int, int, int, bool, bool); + +private: + + QLineEdit *unicode; + QLineEdit *keycode; + QLineEdit *modifiers; + QLineEdit *isPress; + QLineEdit *autoRepeat; + +}; + +class KeyFilter : public QObject, public QWSServer::KeyboardFilter +{ + Q_OBJECT + +public: + KeyFilter( QObject* parent, const char* name = 0); + virtual bool filter(int unicode, int keycode, int modifiers, bool isPress, + bool autoRepeat); + +signals: + void keyPressed(int, int, int, bool, bool); + +}; + +#endif diff --git a/development/keyview/keyview.pro b/development/keyview/keyview.pro new file mode 100644 index 0000000..b4694c9 --- a/dev/null +++ b/development/keyview/keyview.pro @@ -0,0 +1,26 @@ +TEMPLATE = lib +#CONFIG = qt warn_on debug +CONFIG = qt warn_on release +HEADERS = keyview.h keyboardimpl.h +SOURCES = keyview.cpp keyboardimpl.cpp +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include ../../launcher +LIBS += -lqpe +INTERFACES = +TARGET = keyview +DESTDIR = $(OPIEDIR)/plugins/inputmethods + +TRANSLATIONS = ../i18n/de/keyview.ts \ + ../i18n/en/keyview.ts \ + ../i18n/es/keyview.ts \ + ../i18n/fr/keyview.ts \ + ../i18n/hu/keyview.ts \ + ../i18n/ja/keyview.ts \ + ../i18n/ko/keyview.ts \ + ../i18n/no/keyview.ts \ + ../i18n/pl/keyview.ts \ + ../i18n/pt/keyview.ts \ + ../i18n/pt_BR/keyview.ts \ + ../i18n/sl/keyview.ts \ + ../i18n/zh_CN/keyview.ts \ + ../i18n/zh_TW/keyview.ts diff --git a/development/keyview/main.cpp b/development/keyview/main.cpp new file mode 100644 index 0000000..811e581 --- a/dev/null +++ b/development/keyview/main.cpp @@ -0,0 +1,12 @@ +#include "keyview.h" +#include <qpe/qpeapplication.h> + +int main( int argc, char ** argv ) +{ + QPEApplication a( argc, argv ); + + Keyview kv; + a.showMainWidget( &kv ); + + return a.exec(); +} |