summaryrefslogtreecommitdiff
path: root/inputmethods/kjumpx/keyboard.cpp
Unidiff
Diffstat (limited to 'inputmethods/kjumpx/keyboard.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/kjumpx/keyboard.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/inputmethods/kjumpx/keyboard.cpp b/inputmethods/kjumpx/keyboard.cpp
index 3af6a78..dc44805 100644
--- a/inputmethods/kjumpx/keyboard.cpp
+++ b/inputmethods/kjumpx/keyboard.cpp
@@ -47,192 +47,193 @@ static const int mod2w = mod2x2 - mod2x1;
47static const int cursorx1 = 207; 47static const int cursorx1 = 207;
48static const int cursorw = 16; 48static const int cursorw = 16;
49 49
50static const int myParenID = -10; 50static const int myParenID = -10;
51 51
52 52
53typedef struct mapElement 53typedef struct mapElement
54{ 54{
55 int qcode; 55 int qcode;
56 ushort unicode; 56 ushort unicode;
57}; 57};
58 58
59static const mapElement mod1Map[] = { 59static const mapElement mod1Map[] = {
60 { Qt::Key_Escape, 27 }, 60 { Qt::Key_Escape, 27 },
61 { Qt::Key_Tab, 9 }, 61 { Qt::Key_Tab, 9 },
62 { Qt::Key_Return, 13 }, 62 { Qt::Key_Return, 13 },
63 { Qt::Key_Alt, 0 }, 63 { Qt::Key_Alt, 0 },
64 { Qt::Key_Control, 0 }, 64 { Qt::Key_Control, 0 },
65}; 65};
66 66
67static const uchar *const letterMap[] = { 67static const uchar *const letterMap[] = {
68 (const uchar *const)"zvchwk", 68 (const uchar *const)"zvchwk",
69 (const uchar *const)"fitaly", 69 (const uchar *const)"fitaly",
70 (const uchar *const)" ne ", 70 (const uchar *const)" ne ",
71 (const uchar *const)"gdorsb", 71 (const uchar *const)"gdorsb",
72 (const uchar *const)"qjumpx", 72 (const uchar *const)"qjumpx",
73}; 73};
74 74
75static const ushort kletterMap[][6] = { 75static const ushort kletterMap[][6] = {
76 { 0x110c, 0x1112, 0x1109, 0x116d, 0x1167, 0x1163 }, 76 { 0x110c, 0x1112, 0x1109, 0x116d, 0x1167, 0x1163 },
77 { 0x110f, 0x1105, 0x1100, 0x1161, 0x1175, 0x1162 }, 77 { 0x110f, 0x1105, 0x1100, 0x1161, 0x1175, 0x1162 },
78 { ' ', ' ', 0x110b, 0x1165, ' ', ' ' }, 78 { ' ', ' ', 0x110b, 0x1165, ' ', ' ' },
79 { 0x1110, 0x1103, 0x1102, 0x1169, 0x1173, 0x1166 }, 79 { 0x1110, 0x1103, 0x1102, 0x1169, 0x1173, 0x1166 },
80 { 0x110e, 0x1107, 0x1106, 0x1111, 0x116e, 0x1172 }, 80 { 0x110e, 0x1107, 0x1106, 0x1111, 0x116e, 0x1172 },
81}; 81};
82 82
83static const uchar *const letterMapShift[] = { 83static const uchar *const letterMapShift[] = {
84 (const uchar *const)"ZVCHWK", 84 (const uchar *const)"ZVCHWK",
85 (const uchar *const)"FITALY", 85 (const uchar *const)"FITALY",
86 (const uchar *const)" NE ", 86 (const uchar *const)" NE ",
87 (const uchar *const)"GDORSB", 87 (const uchar *const)"GDORSB",
88 (const uchar *const)"QJUMPX", 88 (const uchar *const)"QJUMPX",
89}; 89};
90 90
91static const ushort kletterMapShift[][6] = { 91static const ushort kletterMapShift[][6] = {
92 { 0x110d, 0x1112, 0x110a, 0x116d, 0x1167, 0x1163 }, 92 { 0x110d, 0x1112, 0x110a, 0x116d, 0x1167, 0x1163 },
93 { 0x110f, 0x1105, 0x1101, 0x1161, 0x1175, 0x1164 }, 93 { 0x110f, 0x1105, 0x1101, 0x1161, 0x1175, 0x1164 },
94 { ' ', ' ', 0x110b, 0x1165, ' ', ' ' }, 94 { ' ', ' ', 0x110b, 0x1165, ' ', ' ' },
95 { 0x1110, 0x1104, 0x1102, 0x1169, 0x1173, 0x1168 }, 95 { 0x1110, 0x1104, 0x1102, 0x1169, 0x1173, 0x1168 },
96 { 0x110e, 0x1108, 0x1106, 0x1111, 0x116e, 0x1172 }, 96 { 0x110e, 0x1108, 0x1106, 0x1111, 0x116e, 0x1172 },
97}; 97};
98 98
99static const uchar *const num1Map = (const uchar *const)"12345"; 99static const uchar *const num1Map = (const uchar *const)"12345";
100 100
101static const uchar *const specialMap[] = { 101static const uchar *const specialMap[] = {
102 (const uchar *const)"-+", 102 (const uchar *const)"-+",
103 (const uchar *const)"*!", 103 (const uchar *const)"*!",
104 (const uchar *const)",'", 104 (const uchar *const)",'",
105 (const uchar *const)".%", 105 (const uchar *const)".%",
106 (const uchar *const)"/$", 106 (const uchar *const)"/$",
107}; 107};
108 108
109static const uchar *const specialMapShift[] = { 109static const uchar *const specialMapShift[] = {
110 (const uchar *const)"_=", 110 (const uchar *const)"_=",
111 (const uchar *const)"#?", 111 (const uchar *const)"#?",
112 (const uchar *const)";\"", 112 (const uchar *const)";\"",
113 (const uchar *const)":|", 113 (const uchar *const)":|",
114 (const uchar *const)"\\&", 114 (const uchar *const)"\\&",
115}; 115};
116 116
117static const uchar *const specialMapParen[] = { 117static const uchar *const specialMapParen[] = {
118 (const uchar *const)"()", 118 (const uchar *const)"()",
119 (const uchar *const)"[]", 119 (const uchar *const)"[]",
120 (const uchar *const)"{}", 120 (const uchar *const)"{}",
121 (const uchar *const)"<>", 121 (const uchar *const)"<>",
122 (const uchar *const)"@~", 122 (const uchar *const)"@~",
123}; 123};
124 124
125static const uchar *const num2Map = (const uchar *const)"67890"; 125static const uchar *const num2Map = (const uchar *const)"67890";
126 126
127static const mapElement mod2Map[] = { 127static const mapElement mod2Map[] = {
128 { Qt::Key_Backspace, 8 }, 128 { Qt::Key_Backspace, 8 },
129 { Qt::Key_Delete, 0 }, 129 { Qt::Key_Delete, 0 },
130 { Qt::Key_Return, 13 }, 130 { Qt::Key_Return, 13 },
131 { Qt::Key_Shift, 0 }, 131 { Qt::Key_Shift, 0 },
132 { myParenID, 0 }, 132 { myParenID, 0 },
133}; 133};
134 134
135static const int cursorMap[][2] = { 135static const int cursorMap[][2] = {
136 { Qt::Key_Home, Qt::Key_PageUp }, 136 { Qt::Key_Home, Qt::Key_PageUp },
137 { Qt::Key_End, Qt::Key_PageDown }, 137 { Qt::Key_End, Qt::Key_PageDown },
138 { Qt::Key_Up, Qt::Key_Up }, 138 { Qt::Key_Up, Qt::Key_Up },
139 { Qt::Key_Left, Qt::Key_Right }, 139 { Qt::Key_Left, Qt::Key_Right },
140 { Qt::Key_Down, Qt::Key_Down }, 140 { Qt::Key_Down, Qt::Key_Down },
141}; 141};
142 142
143using namespace KJumpX;
143 144
144Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : 145Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) :
145 QFrame(parent, name, f), 146 QFrame(parent, name, f),
146 shift(0), paren(0), ctrl(0), alt(0), lang(1), lastKey(0), 147 shift(0), paren(0), ctrl(0), alt(0), lang(1), lastKey(0),
147 pressedKeyUnicode(0), pressedKeyQcode(0), pressedMod(0), 148 pressedKeyUnicode(0), pressedKeyQcode(0), pressedMod(0),
148 isnoncont(false), 149 isnoncont(false),
149 slideKeyUnicodeH(0), slideKeyQcodeH(0), slideKeyUnicodeV(0), slideKeyQcodeV(0), 150 slideKeyUnicodeH(0), slideKeyQcodeH(0), slideKeyUnicodeV(0), slideKeyQcodeV(0),
150 enableMouseTracking(false), slidePix(NULL), slidePixH(NULL), slidePixV(NULL), 151 enableMouseTracking(false), slidePix(NULL), slidePixH(NULL), slidePixV(NULL),
151 releasedPix(NULL), pressedPix(NULL) 152 releasedPix(NULL), pressedPix(NULL)
152{ 153{
153 //setPalette(QPalette(QColor(240,240,230))); // Beige! 154 //setPalette(QPalette(QColor(240,240,230))); // Beige!
154 155
155 releasedPlain = releasedShift = releasedParen = Resource::loadPixmap("kjumpx/released"); 156 releasedPlain = releasedShift = releasedParen = Resource::loadPixmap("kjumpx/released");
156 pressedPlain = pressedShift = pressedParen = Resource::loadPixmap("kjumpx/pressed"); 157 pressedPlain = pressedShift = pressedParen = Resource::loadPixmap("kjumpx/pressed");
157 pressedDigit = Resource::loadPixmap("kjumpx/pressed"); 158 pressedDigit = Resource::loadPixmap("kjumpx/pressed");
158 159
159 QPixmap tmp; 160 QPixmap tmp;
160 161
161 tmp = Resource::loadPixmap("kjumpx/releasedShift"); 162 tmp = Resource::loadPixmap("kjumpx/releasedShift");
162 bitBlt(&releasedShift, letterx1, 0, &tmp); 163 bitBlt(&releasedShift, letterx1, 0, &tmp);
163 164
164 tmp = Resource::loadPixmap("kjumpx/releasedParen"); 165 tmp = Resource::loadPixmap("kjumpx/releasedParen");
165 bitBlt(&releasedParen, specialx1, 0, &tmp); 166 bitBlt(&releasedParen, specialx1, 0, &tmp);
166 167
167 tmp = Resource::loadPixmap("kjumpx/pressedShift"); 168 tmp = Resource::loadPixmap("kjumpx/pressedShift");
168 bitBlt(&pressedShift, letterx1, 0, &tmp); 169 bitBlt(&pressedShift, letterx1, 0, &tmp);
169 170
170 tmp = Resource::loadPixmap("kjumpx/pressedParen"); 171 tmp = Resource::loadPixmap("kjumpx/pressedParen");
171 bitBlt(&pressedParen, specialx1, 0, &tmp); 172 bitBlt(&pressedParen, specialx1, 0, &tmp);
172 173
173 tmp = Resource::loadPixmap("kjumpx/pressedDigit"); 174 tmp = Resource::loadPixmap("kjumpx/pressedDigit");
174 bitBlt(&pressedDigit, specialx1, 0, &tmp); 175 bitBlt(&pressedDigit, specialx1, 0, &tmp);
175 176
176 offscreen = QPixmap( releasedPlain ); 177 offscreen = QPixmap( releasedPlain );
177 178
178 releasedPix = &releasedPlain; 179 releasedPix = &releasedPlain;
179 pressedPix = &pressedPlain; 180 pressedPix = &pressedPlain;
180 slidePix = &pressedPlain; 181 slidePix = &pressedPlain;
181 182
182 delayTimer = new QTimer(this); 183 delayTimer = new QTimer(this);
183 rateTimer = new QTimer(this); 184 rateTimer = new QTimer(this);
184 connect( delayTimer, SIGNAL( timeout() ), this, SLOT( delayTimerDone() ) ); 185 connect( delayTimer, SIGNAL( timeout() ), this, SLOT( delayTimerDone() ) );
185 connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) ); 186 connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) );
186} 187}
187 188
188void Keyboard::resizeEvent(QResizeEvent*) 189void Keyboard::resizeEvent(QResizeEvent*)
189{ 190{
190 //cout << "resizeEvent()" << endl; 191 //cout << "resizeEvent()" << endl;
191} 192}
192 193
193void Keyboard::paintEvent(QPaintEvent*) 194void Keyboard::paintEvent(QPaintEvent*)
194{ 195{
195 bitBlt(this, 0, 0, &offscreen); 196 bitBlt(this, 0, 0, &offscreen);
196} 197}
197 198
198void Keyboard::mousePressEvent(QMouseEvent *e) 199void Keyboard::mousePressEvent(QMouseEvent *e)
199{ 200{
200 pressedx = -1; 201 pressedx = -1;
201 pressedKeyUnicode = pressedKeyQcode = pressedMod = 0; 202 pressedKeyUnicode = pressedKeyQcode = pressedMod = 0;
202 203
203 int x = e->x(); 204 int x = e->x();
204 int y = e->y(); 205 int y = e->y();
205 206
206 int row = (y - 1) / letterh; 207 int row = (y - 1) / letterh;
207 208
208 if ( x <= mod1x2 ) // mod1 209 if ( x <= mod1x2 ) // mod1
209 { 210 {
210 pressedx = mod1x1; 211 pressedx = mod1x1;
211 pressedy = row * letterh; 212 pressedy = row * letterh;
212 pressedw = mod1w + 1; 213 pressedw = mod1w + 1;
213 pressedh = letterh + 1; 214 pressedh = letterh + 1;
214 if ( row == 2 ) // return 215 if ( row == 2 ) // return
215 { 216 {
216 pressed2x = mod2x1; 217 pressed2x = mod2x1;
217 pressed2y = 2 * letterh; 218 pressed2y = 2 * letterh;
218 pressed2w = mod2w + 1; 219 pressed2w = mod2w + 1;
219 pressed2h = letterh + 1; 220 pressed2h = letterh + 1;
220 isnoncont = true; 221 isnoncont = true;
221 } 222 }
222 else if ( row == 3 ) // alt 223 else if ( row == 3 ) // alt
223 alt = 1; 224 alt = 1;
224 else if ( row == 4 ) // ctrl 225 else if ( row == 4 ) // ctrl
225 ctrl = 1; 226 ctrl = 1;
226 pressedKeyUnicode = mod1Map[row].unicode; 227 pressedKeyUnicode = mod1Map[row].unicode;
227 pressedKeyQcode = mod1Map[row].qcode; 228 pressedKeyQcode = mod1Map[row].qcode;
228 } 229 }
229 else if ( x >= letterx1 && x <= letterx2 ) // letter 230 else if ( x >= letterx1 && x <= letterx2 ) // letter
230 { 231 {
231 int column = (x - letterx1 - 1) / letterw; 232 int column = (x - letterx1 - 1) / letterw;
232 QChar temp; 233 QChar temp;
233 if (lang == 0) // english 234 if (lang == 0) // english
234 if ( shift ) 235 if ( shift )
235 temp = QChar( letterMapShift[row][column] ); 236 temp = QChar( letterMapShift[row][column] );
236 else 237 else
237 temp = QChar( letterMap[row][column] ); 238 temp = QChar( letterMap[row][column] );
238 else if (lang == 1) // korean 239 else if (lang == 1) // korean