-rw-r--r-- | inputmethods/keyboard/keyboard.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/inputmethods/keyboard/keyboard.cpp b/inputmethods/keyboard/keyboard.cpp index 233f08e..a04c45a 100644 --- a/inputmethods/keyboard/keyboard.cpp +++ b/inputmethods/keyboard/keyboard.cpp | |||
@@ -1,229 +1,229 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "keyboard.h" | 21 | #include "keyboard.h" |
22 | 22 | ||
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | 24 | ||
25 | #include <qwindowsystem_qws.h> | 25 | #include <qwindowsystem_qws.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qfontmetrics.h> | 27 | #include <qfontmetrics.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <ctype.h> | 29 | #include <ctype.h> |
30 | 30 | ||
31 | #include <sys/utsname.h> | 31 | #include <sys/utsname.h> |
32 | 32 | ||
33 | 33 | ||
34 | #define USE_SMALL_BACKSPACE | 34 | #define USE_SMALL_BACKSPACE |
35 | 35 | ||
36 | Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : | 36 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : |
37 | QFrame(parent, name, f), shift(FALSE), lock(FALSE), ctrl(FALSE), | 37 | QFrame(parent, _name, f), shift(FALSE), lock(FALSE), ctrl(FALSE), |
38 | alt(FALSE), useLargeKeys(TRUE), useOptiKeys(0), pressedKey(-1), | 38 | alt(FALSE), useLargeKeys(TRUE), useOptiKeys(0), pressedKey(-1), |
39 | unicode(-1), qkeycode(0), modifiers(0) | 39 | unicode(-1), qkeycode(0), modifiers(0) |
40 | { | 40 | { |
41 | // setPalette(QPalette(QColor(240,240,230))); // Beige! | 41 | // setPalette(QPalette(QColor(240,240,230))); // Beige! |
42 | // setFont( QFont( "Helvetica", 8 ) ); | 42 | // setFont( QFont( "Helvetica", 8 ) ); |
43 | // setPalette(QPalette(QColor(200,200,200))); // Gray | 43 | // setPalette(QPalette(QColor(200,200,200))); // Gray |
44 | setPalette(QPalette(QColor(220,220,220))); // Gray | 44 | setPalette(QPalette(QColor(220,220,220))); // Gray |
45 | 45 | ||
46 | picks = new KeyboardPicks( this ); | 46 | picks = new KeyboardPicks( this ); |
47 | picks->setFont( QFont( "smallsmooth", 9 ) ); | 47 | picks->setFont( QFont( "smallsmooth", 9 ) ); |
48 | setFont( QFont( "smallsmooth", 9 ) ); | 48 | setFont( QFont( "smallsmooth", 9 ) ); |
49 | picks->initialise(); | 49 | picks->initialise(); |
50 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 50 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
51 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 51 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
52 | 52 | ||
53 | repeatTimer = new QTimer( this ); | 53 | repeatTimer = new QTimer( this ); |
54 | 54 | ||
55 | // temporary quick and dirty fix for the "sticky keyboard bug" | 55 | // temporary quick and dirty fix for the "sticky keyboard bug" |
56 | // on ipaq. | 56 | // on ipaq. |
57 | struct utsname name; | 57 | struct utsname name; |
58 | if (uname(&name) != -1) | 58 | if (uname(&name) != -1) |
59 | { | 59 | { |
60 | QString release=name.release; | 60 | QString release=name.release; |
61 | qWarning("System release: %s\n", name.release); | 61 | qWarning("System release: %s\n", name.release); |
62 | if(release.find("embedix",0,TRUE) !=-1) | 62 | if(release.find("embedix",0,TRUE) !=-1) |
63 | { | 63 | { |
64 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | 64 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); |
65 | } | 65 | } |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | void Keyboard::resizeEvent(QResizeEvent*) | 69 | void Keyboard::resizeEvent(QResizeEvent*) |
70 | { | 70 | { |
71 | int ph = picks->sizeHint().height(); | 71 | int ph = picks->sizeHint().height(); |
72 | picks->setGeometry( 0, 0, width(), ph ); | 72 | picks->setGeometry( 0, 0, width(), ph ); |
73 | keyHeight = (height()-ph)/5; | 73 | keyHeight = (height()-ph)/5; |
74 | int nk; | 74 | int nk; |
75 | if ( useOptiKeys ) { | 75 | if ( useOptiKeys ) { |
76 | nk = 15; | 76 | nk = 15; |
77 | } else if ( useLargeKeys ) { | 77 | } else if ( useLargeKeys ) { |
78 | nk = 15; | 78 | nk = 15; |
79 | } else { | 79 | } else { |
80 | nk = 19; | 80 | nk = 19; |
81 | } | 81 | } |
82 | defaultKeyWidth = width()/nk; | 82 | defaultKeyWidth = width()/nk; |
83 | xoffs = (width()-defaultKeyWidth*nk)/2; | 83 | xoffs = (width()-defaultKeyWidth*nk)/2; |
84 | } | 84 | } |
85 | 85 | ||
86 | void KeyboardPicks::initialise() | 86 | void KeyboardPicks::initialise() |
87 | { | 87 | { |
88 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 88 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
89 | mode = 0; | 89 | mode = 0; |
90 | dc = new KeyboardConfig(this); | 90 | dc = new KeyboardConfig(this); |
91 | configs.append(dc); | 91 | configs.append(dc); |
92 | } | 92 | } |
93 | 93 | ||
94 | QSize KeyboardPicks::sizeHint() const | 94 | QSize KeyboardPicks::sizeHint() const |
95 | { | 95 | { |
96 | return QSize(240,fontMetrics().lineSpacing()); | 96 | return QSize(240,fontMetrics().lineSpacing()); |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | void KeyboardConfig::generateText(const QString &s) | 100 | void KeyboardConfig::generateText(const QString &s) |
101 | { | 101 | { |
102 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 102 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
103 | for (int i=0; i<(int)backspaces; i++) { | 103 | for (int i=0; i<(int)backspaces; i++) { |
104 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); | 104 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); |
105 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); | 105 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); |
106 | } | 106 | } |
107 | for (int i=0; i<(int)s.length(); i++) { | 107 | for (int i=0; i<(int)s.length(); i++) { |
108 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); | 108 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); |
109 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); | 109 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); |
110 | } | 110 | } |
111 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); | 111 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); |
112 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); | 112 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); |
113 | backspaces = 0; | 113 | backspaces = 0; |
114 | #endif | 114 | #endif |
115 | } | 115 | } |
116 | 116 | ||
117 | 117 | ||
118 | //PC keyboard layout and scancodes | 118 | //PC keyboard layout and scancodes |
119 | 119 | ||
120 | /* | 120 | /* |
121 | Format: length, code, length, code, ..., 0 | 121 | Format: length, code, length, code, ..., 0 |
122 | 122 | ||
123 | length is measured in half the width of a standard key. | 123 | length is measured in half the width of a standard key. |
124 | If code < 0x80 we have length/2 consecutive standard keys, | 124 | If code < 0x80 we have length/2 consecutive standard keys, |
125 | starting with scancode code. | 125 | starting with scancode code. |
126 | 126 | ||
127 | Special keys are hardcoded, one at a time, with length of key | 127 | Special keys are hardcoded, one at a time, with length of key |
128 | and code >= 0x80, these are NOT standard PC scancodes, but are looked | 128 | and code >= 0x80, these are NOT standard PC scancodes, but are looked |
129 | up in specialM[]. (The special keys are not keymappable.) | 129 | up in specialM[]. (The special keys are not keymappable.) |
130 | 130 | ||
131 | */ | 131 | */ |
132 | 132 | ||
133 | static const uchar * const keyboard_opti[5] = { | 133 | static const uchar * const keyboard_opti[5] = { |
134 | (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", | 134 | (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", |
135 | (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", | 135 | (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", |
136 | (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", | 136 | (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", |
137 | (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", | 137 | (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", |
138 | (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" | 138 | (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" |
139 | }; | 139 | }; |
140 | 140 | ||
141 | 141 | ||
142 | static const uchar * const keyboard_standard[5] = { | 142 | static const uchar * const keyboard_standard[5] = { |
143 | 143 | ||
144 | #ifdef USE_SMALL_BACKSPACE | 144 | #ifdef USE_SMALL_BACKSPACE |
145 | (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", | 145 | (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", |
146 | #else | 146 | #else |
147 | (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", | 147 | (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", |
148 | #endif | 148 | #endif |
149 | //~ + 123...+ BACKSPACE //+ INSERT + HOME + PGUP | 149 | //~ + 123...+ BACKSPACE //+ INSERT + HOME + PGUP |
150 | 150 | ||
151 | (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", | 151 | (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", |
152 | //TAB + qwerty.. + backslash //+ DEL + END + PGDN | 152 | //TAB + qwerty.. + backslash //+ DEL + END + PGDN |
153 | 153 | ||
154 | (const uchar *const)"\004\202\002a\002s\002d\002f\002g\002h\002j\002k\002l\002;\002'\004\203", | 154 | (const uchar *const)"\004\202\002a\002s\002d\002f\002g\002h\002j\002k\002l\002;\002'\004\203", |
155 | //CAPS + asdf.. + RETURN | 155 | //CAPS + asdf.. + RETURN |
156 | 156 | ||
157 | (const uchar *const)"\005\204\002z\002x\002c\002v\002b\002n\002m\002,\002.\002/\005\204\002\223\002\223\002\211", | 157 | (const uchar *const)"\005\204\002z\002x\002c\002v\002b\002n\002m\002,\002.\002/\005\204\002\223\002\223\002\211", |
158 | //SHIFT + zxcv... //+ UP | 158 | //SHIFT + zxcv... //+ UP |
159 | 159 | ||
160 | (const uchar *const)"\003\205\003\206\022\207\003\206\003\205\002\223\002\212\002\213\002\214" | 160 | (const uchar *const)"\003\205\003\206\022\207\003\206\003\205\002\223\002\212\002\213\002\214" |
161 | //CTRL + ALT + SPACE //+ LEFT + DOWN + RIGHT | 161 | //CTRL + ALT + SPACE //+ LEFT + DOWN + RIGHT |
162 | 162 | ||
163 | }; | 163 | }; |
164 | 164 | ||
165 | 165 | ||
166 | struct ShiftMap { | 166 | struct ShiftMap { |
167 | char normal; | 167 | char normal; |
168 | char shifted; | 168 | char shifted; |
169 | }; | 169 | }; |
170 | 170 | ||
171 | 171 | ||
172 | static const ShiftMap shiftMap[] = { | 172 | static const ShiftMap shiftMap[] = { |
173 | { '`', '~' }, | 173 | { '`', '~' }, |
174 | { '1', '!' }, | 174 | { '1', '!' }, |
175 | { '2', '@' }, | 175 | { '2', '@' }, |
176 | { '3', '#' }, | 176 | { '3', '#' }, |
177 | { '4', '$' }, | 177 | { '4', '$' }, |
178 | { '5', '%' }, | 178 | { '5', '%' }, |
179 | { '6', '^' }, | 179 | { '6', '^' }, |
180 | { '7', '&' }, | 180 | { '7', '&' }, |
181 | { '8', '*' }, | 181 | { '8', '*' }, |
182 | { '9', '(' }, | 182 | { '9', '(' }, |
183 | { '0', ')' }, | 183 | { '0', ')' }, |
184 | { '-', '_' }, | 184 | { '-', '_' }, |
185 | { '=', '+' }, | 185 | { '=', '+' }, |
186 | { '\\', '|' }, | 186 | { '\\', '|' }, |
187 | { '[', '{' }, | 187 | { '[', '{' }, |
188 | { ']', '}' }, | 188 | { ']', '}' }, |
189 | { ';', ':' }, | 189 | { ';', ':' }, |
190 | { '\'', '"' }, | 190 | { '\'', '"' }, |
191 | { ',', '<' }, | 191 | { ',', '<' }, |
192 | { '.', '>' }, | 192 | { '.', '>' }, |
193 | { '/', '?' } | 193 | { '/', '?' } |
194 | }; | 194 | }; |
195 | 195 | ||
196 | 196 | ||
197 | /* XPM */ | 197 | /* XPM */ |
198 | static const char * const uparrow_xpm[]={ | 198 | static const char * const uparrow_xpm[]={ |
199 | "9 9 2 1", | 199 | "9 9 2 1", |
200 | "a c #000000", | 200 | "a c #000000", |
201 | ". c None", | 201 | ". c None", |
202 | ".........", | 202 | ".........", |
203 | "....a....", | 203 | "....a....", |
204 | "...aaa...", | 204 | "...aaa...", |
205 | "..aaaaa..", | 205 | "..aaaaa..", |
206 | "....a....", | 206 | "....a....", |
207 | "....a....", | 207 | "....a....", |
208 | "....a....", | 208 | "....a....", |
209 | "....a....", | 209 | "....a....", |
210 | "........."}; | 210 | "........."}; |
211 | /* XPM */ | 211 | /* XPM */ |
212 | static const char * const leftarrow_xpm[]={ | 212 | static const char * const leftarrow_xpm[]={ |
213 | "9 9 2 1", | 213 | "9 9 2 1", |
214 | "a c #000000", | 214 | "a c #000000", |
215 | ". c None", | 215 | ". c None", |
216 | ".........", | 216 | ".........", |
217 | ".........", | 217 | ".........", |
218 | "...a.....", | 218 | "...a.....", |
219 | "..aa.....", | 219 | "..aa.....", |
220 | ".aaaaaaa.", | 220 | ".aaaaaaa.", |
221 | "..aa.....", | 221 | "..aa.....", |
222 | "...a.....", | 222 | "...a.....", |
223 | ".........", | 223 | ".........", |
224 | "........."}; | 224 | "........."}; |
225 | /* XPM */ | 225 | /* XPM */ |
226 | static const char * const downarrow_xpm[]={ | 226 | static const char * const downarrow_xpm[]={ |
227 | "9 9 2 1", | 227 | "9 9 2 1", |
228 | "a c #000000", | 228 | "a c #000000", |
229 | ". c None", | 229 | ". c None", |