blob: 914c944f1fd0308ef81efcf039384d44b74c2585 [file] [log] [blame]
Dees Troy3be70a82013-10-22 14:25:12 +00001/*
2 Copyright 2012 bigbiff/Dees_Troy TeamWin
3 This file is part of TWRP/TeamWin Recovery Project.
4
5 TWRP is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 TWRP is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with TWRP. If not, see <http://www.gnu.org/licenses/>.
17*/
Dees_Troy51a0e822012-09-05 15:24:24 -040018
Dees_Troy51a0e822012-09-05 15:24:24 -040019#include <stdlib.h>
20#include <string.h>
Samer Diab (S.a.M.e.R_d)71e9b042014-01-07 20:18:47 +000021#include "../data.hpp"
Dees_Troy51a0e822012-09-05 15:24:24 -040022
23#include <string>
24
25extern "C" {
Dees_Troy2673cec2013-04-02 20:22:16 +000026#include "../twcommon.h"
Dees_Troy51a0e822012-09-05 15:24:24 -040027#include "../minuitwrp/minui.h"
Ethan Yonker63e414f2015-02-06 15:44:39 -060028#include "gui.h"
Dees_Troy51a0e822012-09-05 15:24:24 -040029}
30
31#include "rapidxml.hpp"
32#include "objects.hpp"
33
34GUIKeyboard::GUIKeyboard(xml_node<>* node)
Vojtech Bocekede51c52014-02-07 23:58:09 +010035 : GUIObject(node)
Dees_Troy51a0e822012-09-05 15:24:24 -040036{
37 int layoutindex, rowindex, keyindex, Xindex, Yindex, keyHeight = 0, keyWidth = 0;
Dees_Troy30b962e2012-10-19 20:48:59 -040038 rowY = colX = -1;
Ethan Yonker21ff02a2015-02-18 14:35:00 -060039 highlightRenderCount = 0;
40 hasHighlight = hasCapsHighlight = false;
Dees_Troy3a16cb52013-01-10 15:16:02 +000041 char resource[10], layout[8], row[5], key[6], longpress[7];
Dees_Troy51a0e822012-09-05 15:24:24 -040042 xml_attribute<>* attr;
43 xml_node<>* child;
44 xml_node<>* keylayout;
45 xml_node<>* keyrow;
46
thatd86f49d2015-03-15 00:56:57 +010047 for (layoutindex=0; layoutindex<MAX_KEYBOARD_LAYOUTS; layoutindex++) {
48 layouts[layoutindex].keyboardImg = NULL;
49 memset(layouts[layoutindex].keys, 0, sizeof(Layout::keys));
50 memset(layouts[layoutindex].row_end_y, 0, sizeof(Layout::row_end_y));
51 }
Dees_Troy51a0e822012-09-05 15:24:24 -040052
53 mRendered = false;
54 currentLayout = 1;
thatd86f49d2015-03-15 00:56:57 +010055 CapsLockOn = false;
that1a7ba972015-02-01 19:48:19 +010056 KeyboardHeight = KeyboardWidth = 0;
Dees_Troy51a0e822012-09-05 15:24:24 -040057
58 if (!node) return;
59
Ethan Yonker21ff02a2015-02-18 14:35:00 -060060 mHighlightColor = LoadAttrColor(FindNode(node, "highlight"), "color", &hasHighlight);
61 mCapsHighlightColor = LoadAttrColor(FindNode(node, "capshighlight"), "color", &hasCapsHighlight);
Ethan Yonkerc3120d42014-02-17 07:55:00 -060062
thatd86f49d2015-03-15 00:56:57 +010063 // compatibility ugliness: resources should be specified in the layouts themselves instead
Dees_Troy51a0e822012-09-05 15:24:24 -040064 // Load the images for the different layouts
Ethan Yonker21ff02a2015-02-18 14:35:00 -060065 child = FindNode(node, "layout");
Dees_Troy51a0e822012-09-05 15:24:24 -040066 if (child)
67 {
68 layoutindex = 1;
69 strcpy(resource, "resource1");
70 attr = child->first_attribute(resource);
71 while (attr && layoutindex < (MAX_KEYBOARD_LAYOUTS + 1)) {
thatd86f49d2015-03-15 00:56:57 +010072 layouts[layoutindex - 1].keyboardImg = LoadAttrImage(child, resource);
Dees_Troy51a0e822012-09-05 15:24:24 -040073
74 layoutindex++;
75 resource[8] = (char)(layoutindex + 48);
76 attr = child->first_attribute(resource);
77 }
78 }
79
80 // Check the first image to get height and width
thatd86f49d2015-03-15 00:56:57 +010081 if (layouts[0].keyboardImg && layouts[0].keyboardImg->GetResource())
Dees_Troy51a0e822012-09-05 15:24:24 -040082 {
thatd86f49d2015-03-15 00:56:57 +010083 KeyboardWidth = layouts[0].keyboardImg->GetWidth();
84 KeyboardHeight = layouts[0].keyboardImg->GetHeight();
Dees_Troy51a0e822012-09-05 15:24:24 -040085 }
86
87 // Load all of the layout maps
88 layoutindex = 1;
89 strcpy(layout, "layout1");
Ethan Yonker21ff02a2015-02-18 14:35:00 -060090 keylayout = FindNode(node, layout);
Dees_Troy51a0e822012-09-05 15:24:24 -040091 while (keylayout)
92 {
93 if (layoutindex > MAX_KEYBOARD_LAYOUTS) {
Dees_Troy2673cec2013-04-02 20:22:16 +000094 LOGERR("Too many layouts defined in keyboard.\n");
Dees_Troy51a0e822012-09-05 15:24:24 -040095 return;
96 }
97
thatd86f49d2015-03-15 00:56:57 +010098 Layout& lay = layouts[layoutindex - 1];
99
Dees_Troy51a0e822012-09-05 15:24:24 -0400100 child = keylayout->first_node("keysize");
thatd86f49d2015-03-15 00:56:57 +0100101 keyHeight = LoadAttrIntScaleY(child, "height", 0);
102 keyWidth = LoadAttrIntScaleX(child, "width", 0);
103 // compatibility ugliness: capslock="0" means that this is the caps layout. Also it has nothing to do with keysize.
104 lay.is_caps = (LoadAttrInt(child, "capslock", 1) == 0);
105 // compatibility ugliness: revert_layout has nothing to do with keysize.
106 lay.revert_layout = LoadAttrInt(child, "revert_layout", -1);
Dees_Troy51a0e822012-09-05 15:24:24 -0400107
108 rowindex = 1;
109 Yindex = 0;
110 strcpy(row, "row1");
111 keyrow = keylayout->first_node(row);
112 while (keyrow)
113 {
114 if (rowindex > MAX_KEYBOARD_ROWS) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000115 LOGERR("Too many rows defined in keyboard.\n");
Dees_Troy51a0e822012-09-05 15:24:24 -0400116 return;
117 }
118
119 Yindex += keyHeight;
thatd86f49d2015-03-15 00:56:57 +0100120 lay.row_end_y[rowindex - 1] = Yindex;
Dees_Troy51a0e822012-09-05 15:24:24 -0400121
122 keyindex = 1;
123 Xindex = 0;
124 strcpy(key, "key01");
125 attr = keyrow->first_attribute(key);
126
127 while (attr) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400128 if (keyindex > MAX_KEYBOARD_KEYS) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000129 LOGERR("Too many keys defined in a keyboard row.\n");
Dees_Troy51a0e822012-09-05 15:24:24 -0400130 return;
131 }
132
that1a7ba972015-02-01 19:48:19 +0100133 const char* keyinfo = attr->value();
Dees_Troy51a0e822012-09-05 15:24:24 -0400134
135 if (strlen(keyinfo) == 0) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000136 LOGERR("No key info on layout%i, row%i, key%dd.\n", layoutindex, rowindex, keyindex);
Dees_Troy51a0e822012-09-05 15:24:24 -0400137 return;
138 }
139
thatd86f49d2015-03-15 00:56:57 +0100140 if (ParseKey(keyinfo, lay.keys[rowindex - 1][keyindex - 1], Xindex, keyWidth, false))
that1a7ba972015-02-01 19:48:19 +0100141 LOGERR("Invalid key info on layout%i, row%i, key%02i.\n", layoutindex, rowindex, keyindex);
Dees_Troy51a0e822012-09-05 15:24:24 -0400142
Dees_Troy51a0e822012-09-05 15:24:24 -0400143
144 // PROCESS LONG PRESS INFO IF EXISTS
145 sprintf(longpress, "long%02i", keyindex);
146 attr = keyrow->first_attribute(longpress);
147 if (attr) {
that1a7ba972015-02-01 19:48:19 +0100148 const char* keyinfo = attr->value();
Dees_Troy51a0e822012-09-05 15:24:24 -0400149
150 if (strlen(keyinfo) == 0) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000151 LOGERR("No long press info on layout%i, row%i, long%dd.\n", layoutindex, rowindex, keyindex);
Dees_Troy51a0e822012-09-05 15:24:24 -0400152 return;
153 }
154
thatd86f49d2015-03-15 00:56:57 +0100155 if (ParseKey(keyinfo, lay.keys[rowindex - 1][keyindex - 1], Xindex, keyWidth, true))
that1a7ba972015-02-01 19:48:19 +0100156 LOGERR("Invalid long press key info on layout%i, row%i, long%02i.\n", layoutindex, rowindex, keyindex);
Dees_Troy51a0e822012-09-05 15:24:24 -0400157 }
158 keyindex++;
159 sprintf(key, "key%02i", keyindex);
160 attr = keyrow->first_attribute(key);
161 }
162 rowindex++;
163 row[3] = (char)(rowindex + 48);
164 keyrow = keylayout->first_node(row);
165 }
166 layoutindex++;
167 layout[6] = (char)(layoutindex + 48);
Ethan Yonker21ff02a2015-02-18 14:35:00 -0600168 keylayout = FindNode(node, layout);
Dees_Troy51a0e822012-09-05 15:24:24 -0400169 }
170
thate79878b2015-03-14 23:07:23 +0100171 int x, y;
Dees_Troy51a0e822012-09-05 15:24:24 -0400172 // Load the placement
thate79878b2015-03-14 23:07:23 +0100173 LoadPlacement(FindNode(node, "placement"), &x, &y);
174 SetRenderPos(x, y, KeyboardWidth, KeyboardHeight);
Dees_Troy51a0e822012-09-05 15:24:24 -0400175 return;
176}
177
178GUIKeyboard::~GUIKeyboard()
179{
that1a7ba972015-02-01 19:48:19 +0100180}
Dees_Troy51a0e822012-09-05 15:24:24 -0400181
thate79878b2015-03-14 23:07:23 +0100182int GUIKeyboard::ParseKey(const char* keyinfo, Key& key, int& Xindex, int keyWidth, bool longpress)
that1a7ba972015-02-01 19:48:19 +0100183{
184 int keychar = 0;
185 if (strlen(keyinfo) == 1) {
186 // This is a single key, simple definition
187 keychar = keyinfo[0];
188 } else {
189 // This key has extra data: {keywidth}:{what_the_key_does}
Ethan Yonker63e414f2015-02-06 15:44:39 -0600190 keyWidth = scale_theme_x(atoi(keyinfo));
that1a7ba972015-02-01 19:48:19 +0100191
192 const char* ptr = keyinfo;
193 while (*ptr > 32 && *ptr != ':')
194 ptr++;
195 if (*ptr != ':')
196 return -1; // no colon is an error
197 ptr++;
198
199 if (*ptr == 0) { // This is an empty area
200 keychar = 0;
201 } else if (strlen(ptr) == 1) { // This is the character that this key uses
202 keychar = *ptr;
203 } else if (*ptr == 'c') { // This is an ASCII character code: "c:{number}"
204 keychar = atoi(ptr + 2);
205 } else if (*ptr == 'l') { // This is a different layout: "layout{number}"
206 keychar = KEYBOARD_LAYOUT;
207 key.layout = atoi(ptr + 6);
208 } else if (*ptr == 'a') { // This is an action: "action"
209 keychar = KEYBOARD_ACTION;
210 } else
211 return -1;
212 }
213
214 if (longpress) {
215 key.longpresskey = keychar;
216 } else {
217 key.key = keychar;
218 Xindex += keyWidth;
219 key.end_x = Xindex - 1;
220 }
221
222 return 0;
Dees_Troy51a0e822012-09-05 15:24:24 -0400223}
224
225int GUIKeyboard::Render(void)
226{
227 if (!isConditionTrue())
228 {
229 mRendered = false;
230 return 0;
231 }
232
thatd86f49d2015-03-15 00:56:57 +0100233 Layout& lay = layouts[currentLayout - 1];
Dees_Troy51a0e822012-09-05 15:24:24 -0400234
thatd86f49d2015-03-15 00:56:57 +0100235 if (lay.keyboardImg && lay.keyboardImg->GetResource())
236 gr_blit(lay.keyboardImg->GetResource(), 0, 0, KeyboardWidth, KeyboardHeight, mRenderX, mRenderY);
Dees_Troy51a0e822012-09-05 15:24:24 -0400237
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600238 // Draw highlight for capslock
thatd86f49d2015-03-15 00:56:57 +0100239 if (hasCapsHighlight && lay.is_caps && CapsLockOn) {
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600240 gr_color(mCapsHighlightColor.red, mCapsHighlightColor.green, mCapsHighlightColor.blue, mCapsHighlightColor.alpha);
241 for (int indexy=0; indexy<MAX_KEYBOARD_ROWS; indexy++) {
242 for (int indexx=0; indexx<MAX_KEYBOARD_KEYS; indexx++) {
thatd86f49d2015-03-15 00:56:57 +0100243 if ((int)lay.keys[indexy][indexx].key == KEYBOARD_LAYOUT && (int)lay.keys[indexy][indexx].layout == lay.revert_layout) {
244 int boxheight, boxwidth, x;
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600245 if (indexy == 0)
thatd86f49d2015-03-15 00:56:57 +0100246 boxheight = lay.row_end_y[indexy];
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600247 else
thatd86f49d2015-03-15 00:56:57 +0100248 boxheight = lay.row_end_y[indexy] - lay.row_end_y[indexy - 1];
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600249 if (indexx == 0) {
250 x = mRenderX;
thatd86f49d2015-03-15 00:56:57 +0100251 boxwidth = lay.keys[indexy][indexx].end_x;
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600252 } else {
thatd86f49d2015-03-15 00:56:57 +0100253 x = mRenderX + lay.keys[indexy][indexx - 1].end_x;
254 boxwidth = lay.keys[indexy][indexx].end_x - lay.keys[indexy][indexx - 1].end_x;
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600255 }
thatd86f49d2015-03-15 00:56:57 +0100256 gr_fill(x, mRenderY + lay.row_end_y[indexy - 1], boxwidth, boxheight);
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600257 }
258 }
259 }
260 }
261
Dees_Troy30b962e2012-10-19 20:48:59 -0400262 if (hasHighlight && highlightRenderCount != 0) {
263 int boxheight, boxwidth, x;
264 if (rowY == 0)
thatd86f49d2015-03-15 00:56:57 +0100265 boxheight = lay.row_end_y[rowY];
Dees_Troy30b962e2012-10-19 20:48:59 -0400266 else
thatd86f49d2015-03-15 00:56:57 +0100267 boxheight = lay.row_end_y[rowY] - lay.row_end_y[rowY - 1];
Dees_Troy30b962e2012-10-19 20:48:59 -0400268 if (colX == 0) {
269 x = mRenderX;
thatd86f49d2015-03-15 00:56:57 +0100270 boxwidth = lay.keys[rowY][colX].end_x;
Dees_Troy30b962e2012-10-19 20:48:59 -0400271 } else {
thatd86f49d2015-03-15 00:56:57 +0100272 x = mRenderX + lay.keys[rowY][colX - 1].end_x;
273 boxwidth = lay.keys[rowY][colX].end_x - lay.keys[rowY][colX - 1].end_x;
Dees_Troy30b962e2012-10-19 20:48:59 -0400274 }
275 gr_color(mHighlightColor.red, mHighlightColor.green, mHighlightColor.blue, mHighlightColor.alpha);
thatd86f49d2015-03-15 00:56:57 +0100276 gr_fill(x, mRenderY + lay.row_end_y[rowY - 1], boxwidth, boxheight);
Dees_Troy30b962e2012-10-19 20:48:59 -0400277 if (highlightRenderCount > 0)
278 highlightRenderCount--;
279 } else
280 mRendered = true;
281
thatd86f49d2015-03-15 00:56:57 +0100282 return 0;
Dees_Troy51a0e822012-09-05 15:24:24 -0400283}
284
285int GUIKeyboard::Update(void)
286{
287 if (!isConditionTrue()) return (mRendered ? 2 : 0);
288 if (!mRendered) return 2;
289
290 return 0;
291}
292
293int GUIKeyboard::SetRenderPos(int x, int y, int w, int h)
294{
295 mRenderX = x;
296 mRenderY = y;
thate79878b2015-03-14 23:07:23 +0100297 mRenderW = KeyboardWidth;
298 mRenderH = KeyboardHeight;
Dees_Troy51a0e822012-09-05 15:24:24 -0400299 SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH);
300 return 0;
301}
302
thate79878b2015-03-14 23:07:23 +0100303GUIKeyboard::Key* GUIKeyboard::HitTestKey(int x, int y)
Dees_Troy51a0e822012-09-05 15:24:24 -0400304{
thate79878b2015-03-14 23:07:23 +0100305 if (!IsInRegion(x, y))
306 return NULL;
307
308 int rely = y - mRenderY;
309 int relx = x - mRenderX;
310
thatd86f49d2015-03-15 00:56:57 +0100311 Layout& lay = layouts[currentLayout - 1];
312
thate79878b2015-03-14 23:07:23 +0100313 // Find the correct row
314 int row;
315 for (row = 0; row < MAX_KEYBOARD_ROWS; ++row) {
thatd86f49d2015-03-15 00:56:57 +0100316 if (lay.row_end_y[row] > rely)
thate79878b2015-03-14 23:07:23 +0100317 break;
318 }
319 if (row == MAX_KEYBOARD_ROWS)
320 return NULL;
321
322 // Find the correct key (column)
323 int col;
324 int x1 = 0;
325 for (col = 0; col < MAX_KEYBOARD_KEYS; ++col) {
thatd86f49d2015-03-15 00:56:57 +0100326 Key& key = lay.keys[row][col];
thate79878b2015-03-14 23:07:23 +0100327 if (x1 <= relx && relx < key.end_x && key.key != 0) {
328 // This is the key that was pressed!
329 rowY = row;
330 colX = col;
331 return &key;
332 }
333 x1 = key.end_x;
334 }
335 return NULL;
Dees_Troy51a0e822012-09-05 15:24:24 -0400336}
337
338int GUIKeyboard::NotifyTouch(TOUCH_STATE state, int x, int y)
339{
thate79878b2015-03-14 23:07:23 +0100340 static int was_held = 0, startX = 0;
341 static Key* initial_key = 0;
Dees_Troy51a0e822012-09-05 15:24:24 -0400342
343 if (!isConditionTrue()) return -1;
344
345 switch (state)
346 {
347 case TOUCH_START:
thate79878b2015-03-14 23:07:23 +0100348 was_held = 0;
349 startX = x;
350 initial_key = HitTestKey(x, y);
351 if (initial_key)
352 highlightRenderCount = -1;
353 else
Dees_Troy30b962e2012-10-19 20:48:59 -0400354 highlightRenderCount = 0;
thate79878b2015-03-14 23:07:23 +0100355 mRendered = false;
Dees_Troy51a0e822012-09-05 15:24:24 -0400356 break;
thate79878b2015-03-14 23:07:23 +0100357
Dees_Troy51a0e822012-09-05 15:24:24 -0400358 case TOUCH_DRAG:
359 break;
thate79878b2015-03-14 23:07:23 +0100360
Dees_Troy51a0e822012-09-05 15:24:24 -0400361 case TOUCH_RELEASE:
Dees_Troy0cb64e52012-10-15 15:56:10 -0400362 if (x < startX - (KeyboardWidth * 0.5)) {
Dees_Troy30b962e2012-10-19 20:48:59 -0400363 if (highlightRenderCount != 0) {
364 highlightRenderCount = 0;
365 mRendered = false;
366 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400367 PageManager::NotifyKeyboard(KEYBOARD_SWIPE_LEFT);
368 return 0;
Dees_Troy0cb64e52012-10-15 15:56:10 -0400369 } else if (x > startX + (KeyboardWidth * 0.5)) {
Dees_Troy30b962e2012-10-19 20:48:59 -0400370 if (highlightRenderCount != 0) {
371 highlightRenderCount = 0;
372 mRendered = false;
373 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400374 PageManager::NotifyKeyboard(KEYBOARD_SWIPE_RIGHT);
375 return 0;
376 }
thate79878b2015-03-14 23:07:23 +0100377 // fall through
Dees_Troy51a0e822012-09-05 15:24:24 -0400378 case TOUCH_HOLD:
379 case TOUCH_REPEAT:
thate79878b2015-03-14 23:07:23 +0100380 if (!initial_key) {
Dees_Troy30b962e2012-10-19 20:48:59 -0400381 if (highlightRenderCount != 0) {
382 highlightRenderCount = 0;
383 mRendered = false;
384 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400385 return 0;
thate79878b2015-03-14 23:07:23 +0100386 }
387
388 if (highlightRenderCount != 0) {
Dees_Troy30b962e2012-10-19 20:48:59 -0400389 if (state == TOUCH_RELEASE)
390 highlightRenderCount = 2;
391 else
392 highlightRenderCount = -1;
393 mRendered = false;
394 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400395
thate79878b2015-03-14 23:07:23 +0100396 if (HitTestKey(x, y) != initial_key) {
397 // We dragged off of the starting key
398 if (highlightRenderCount != 0) {
399 highlightRenderCount = 0;
400 mRendered = false;
Dees_Troy51a0e822012-09-05 15:24:24 -0400401 }
thate79878b2015-03-14 23:07:23 +0100402 return 0;
403 } else {
404 Key& key = *initial_key;
thatd86f49d2015-03-15 00:56:57 +0100405 Layout& lay = layouts[currentLayout - 1];
thate79878b2015-03-14 23:07:23 +0100406 if (state == TOUCH_RELEASE && was_held == 0) {
407 DataManager::Vibrate("tw_keyboard_vibrate");
thatd86f49d2015-03-15 00:56:57 +0100408 if ((int)key.key == KEYBOARD_LAYOUT) {
thate79878b2015-03-14 23:07:23 +0100409 // Switch layouts
thatd86f49d2015-03-15 00:56:57 +0100410 if (lay.is_caps && key.layout == lay.revert_layout && !CapsLockOn) {
411 CapsLockOn = true; // Set the caps lock
thate79878b2015-03-14 23:07:23 +0100412 } else {
thatd86f49d2015-03-15 00:56:57 +0100413 CapsLockOn = false; // Unset the caps lock and change layouts
thate79878b2015-03-14 23:07:23 +0100414 currentLayout = key.layout;
Dees_Troy51a0e822012-09-05 15:24:24 -0400415 }
thate79878b2015-03-14 23:07:23 +0100416 mRendered = false;
417 } else if ((int)key.key == KEYBOARD_ACTION) {
418 // Action
419 highlightRenderCount = 0;
420 // Send action notification
421 PageManager::NotifyKeyboard(key.key);
thatd86f49d2015-03-15 00:56:57 +0100422 } else if ((int)key.key < KEYBOARD_SPECIAL_KEYS && (int)key.key > 0) {
423 // Regular key
424 PageManager::NotifyKeyboard(key.key);
425 if (!CapsLockOn && lay.is_caps) {
426 // caps lock was not set, change layouts
427 currentLayout = lay.revert_layout;
428 mRendered = false;
429 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400430 }
thate79878b2015-03-14 23:07:23 +0100431 } else if (state == TOUCH_HOLD) {
432 was_held = 1;
433 if ((int)key.key == KEYBOARD_BACKSPACE) {
434 // Repeat backspace
435 PageManager::NotifyKeyboard(key.key);
436 } else if ((int)key.longpresskey < KEYBOARD_SPECIAL_KEYS && (int)key.longpresskey > 0) {
437 // Long Press Key
438 DataManager::Vibrate("tw_keyboard_vibrate");
439 PageManager::NotifyKeyboard(key.longpresskey);
440 }
441 } else if (state == TOUCH_REPEAT) {
442 was_held = 1;
443 if ((int)key.key == KEYBOARD_BACKSPACE) {
444 // Repeat backspace
445 PageManager::NotifyKeyboard(key.key);
446 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400447 }
448 }
449 break;
450 }
451
452 return 0;
453}