blob: 5528be93677ceda9506c40acd0181fb44024e0fe [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
19#include <stdarg.h>
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23#include <fcntl.h>
24#include <sys/reboot.h>
25#include <sys/stat.h>
26#include <sys/time.h>
27#include <sys/mman.h>
28#include <sys/types.h>
29#include <sys/ioctl.h>
30#include <time.h>
31#include <unistd.h>
32#include <stdlib.h>
Samer Diab (S.a.M.e.R_d)71e9b042014-01-07 20:18:47 +000033#include "../data.hpp"
Dees_Troy51a0e822012-09-05 15:24:24 -040034
35#include <string>
36
37extern "C" {
Dees_Troy2673cec2013-04-02 20:22:16 +000038#include "../twcommon.h"
Dees_Troy51a0e822012-09-05 15:24:24 -040039#include "../minuitwrp/minui.h"
Ethan Yonker63e414f2015-02-06 15:44:39 -060040#include "gui.h"
Dees_Troy51a0e822012-09-05 15:24:24 -040041}
42
43#include "rapidxml.hpp"
44#include "objects.hpp"
45
46GUIKeyboard::GUIKeyboard(xml_node<>* node)
Vojtech Bocekede51c52014-02-07 23:58:09 +010047 : GUIObject(node)
Dees_Troy51a0e822012-09-05 15:24:24 -040048{
49 int layoutindex, rowindex, keyindex, Xindex, Yindex, keyHeight = 0, keyWidth = 0;
Dees_Troy30b962e2012-10-19 20:48:59 -040050 rowY = colX = -1;
Ethan Yonkerc3120d42014-02-17 07:55:00 -060051 highlightRenderCount = hasHighlight = hasCapsHighlight = 0;
Dees_Troy3a16cb52013-01-10 15:16:02 +000052 char resource[10], layout[8], row[5], key[6], longpress[7];
Dees_Troy51a0e822012-09-05 15:24:24 -040053 xml_attribute<>* attr;
54 xml_node<>* child;
55 xml_node<>* keylayout;
56 xml_node<>* keyrow;
57
58 for (layoutindex=0; layoutindex<MAX_KEYBOARD_LAYOUTS; layoutindex++)
59 keyboardImg[layoutindex] = NULL;
60
61 mRendered = false;
62 currentLayout = 1;
63 mAction = NULL;
that1a7ba972015-02-01 19:48:19 +010064 KeyboardHeight = KeyboardWidth = 0;
Dees_Troy51a0e822012-09-05 15:24:24 -040065
66 if (!node) return;
67
68 // Load the action
69 child = node->first_node("action");
70 if (child)
71 {
72 mAction = new GUIAction(node);
73 }
74
Dees_Troy30b962e2012-10-19 20:48:59 -040075 memset(&mHighlightColor, 0, sizeof(COLOR));
76 child = node->first_node("highlight");
77 if (child) {
78 attr = child->first_attribute("color");
79 if (attr) {
80 hasHighlight = 1;
81 std::string color = attr->value();
82 ConvertStrToColor(color, &mHighlightColor);
83 }
84 }
85
Ethan Yonkerc3120d42014-02-17 07:55:00 -060086 memset(&mCapsHighlightColor, 0, sizeof(COLOR));
87 child = node->first_node("capshighlight");
88 if (child) {
89 attr = child->first_attribute("color");
90 if (attr) {
91 hasCapsHighlight = 1;
92 std::string color = attr->value();
93 ConvertStrToColor(color, &mCapsHighlightColor);
94 }
95 }
96
Dees_Troy51a0e822012-09-05 15:24:24 -040097 // Load the images for the different layouts
98 child = node->first_node("layout");
99 if (child)
100 {
101 layoutindex = 1;
102 strcpy(resource, "resource1");
103 attr = child->first_attribute(resource);
104 while (attr && layoutindex < (MAX_KEYBOARD_LAYOUTS + 1)) {
thatf6ed8fc2015-02-14 20:23:16 +0100105 keyboardImg[layoutindex - 1] = LoadAttrImage(child, resource);
Dees_Troy51a0e822012-09-05 15:24:24 -0400106
107 layoutindex++;
108 resource[8] = (char)(layoutindex + 48);
109 attr = child->first_attribute(resource);
110 }
111 }
112
113 // Check the first image to get height and width
114 if (keyboardImg[0] && keyboardImg[0]->GetResource())
115 {
thatf6ed8fc2015-02-14 20:23:16 +0100116 KeyboardWidth = keyboardImg[0]->GetWidth();
117 KeyboardHeight = keyboardImg[0]->GetHeight();
Dees_Troy51a0e822012-09-05 15:24:24 -0400118 }
119
120 // Load all of the layout maps
121 layoutindex = 1;
122 strcpy(layout, "layout1");
123 keylayout = node->first_node(layout);
124 while (keylayout)
125 {
126 if (layoutindex > MAX_KEYBOARD_LAYOUTS) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000127 LOGERR("Too many layouts defined in keyboard.\n");
Dees_Troy51a0e822012-09-05 15:24:24 -0400128 return;
129 }
130
131 child = keylayout->first_node("keysize");
132 if (child) {
133 attr = child->first_attribute("height");
134 if (attr)
Ethan Yonker63e414f2015-02-06 15:44:39 -0600135 keyHeight = scale_theme_y(atoi(attr->value()));
Dees_Troy51a0e822012-09-05 15:24:24 -0400136 else
137 keyHeight = 0;
138 attr = child->first_attribute("width");
139 if (attr)
Ethan Yonker63e414f2015-02-06 15:44:39 -0600140 keyWidth = scale_theme_x(atoi(attr->value()));
Dees_Troy51a0e822012-09-05 15:24:24 -0400141 else
142 keyWidth = 0;
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600143 attr = child->first_attribute("capslock");
144 if (attr)
145 caps_tracking[layoutindex - 1].capslock = atoi(attr->value());
146 else
147 caps_tracking[layoutindex - 1].capslock = 1;
148 attr = child->first_attribute("revert_layout");
149 if (attr)
150 caps_tracking[layoutindex - 1].revert_layout = atoi(attr->value());
151 else
152 caps_tracking[layoutindex - 1].revert_layout = -1;
Dees_Troy51a0e822012-09-05 15:24:24 -0400153 }
154
155 rowindex = 1;
156 Yindex = 0;
157 strcpy(row, "row1");
158 keyrow = keylayout->first_node(row);
159 while (keyrow)
160 {
161 if (rowindex > MAX_KEYBOARD_ROWS) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000162 LOGERR("Too many rows defined in keyboard.\n");
Dees_Troy51a0e822012-09-05 15:24:24 -0400163 return;
164 }
165
166 Yindex += keyHeight;
167 row_heights[layoutindex - 1][rowindex - 1] = Yindex;
168
169 keyindex = 1;
170 Xindex = 0;
171 strcpy(key, "key01");
172 attr = keyrow->first_attribute(key);
173
174 while (attr) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400175 if (keyindex > MAX_KEYBOARD_KEYS) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000176 LOGERR("Too many keys defined in a keyboard row.\n");
Dees_Troy51a0e822012-09-05 15:24:24 -0400177 return;
178 }
179
that1a7ba972015-02-01 19:48:19 +0100180 const char* keyinfo = attr->value();
Dees_Troy51a0e822012-09-05 15:24:24 -0400181
182 if (strlen(keyinfo) == 0) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000183 LOGERR("No key info on layout%i, row%i, key%dd.\n", layoutindex, rowindex, keyindex);
Dees_Troy51a0e822012-09-05 15:24:24 -0400184 return;
185 }
186
that1a7ba972015-02-01 19:48:19 +0100187 if (ParseKey(keyinfo, keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1], Xindex, keyWidth, false))
188 LOGERR("Invalid key info on layout%i, row%i, key%02i.\n", layoutindex, rowindex, keyindex);
Dees_Troy51a0e822012-09-05 15:24:24 -0400189
Dees_Troy51a0e822012-09-05 15:24:24 -0400190
191 // PROCESS LONG PRESS INFO IF EXISTS
192 sprintf(longpress, "long%02i", keyindex);
193 attr = keyrow->first_attribute(longpress);
194 if (attr) {
that1a7ba972015-02-01 19:48:19 +0100195 const char* keyinfo = attr->value();
Dees_Troy51a0e822012-09-05 15:24:24 -0400196
197 if (strlen(keyinfo) == 0) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000198 LOGERR("No long press info on layout%i, row%i, long%dd.\n", layoutindex, rowindex, keyindex);
Dees_Troy51a0e822012-09-05 15:24:24 -0400199 return;
200 }
201
that1a7ba972015-02-01 19:48:19 +0100202 if (ParseKey(keyinfo, keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1], Xindex, keyWidth, true))
203 LOGERR("Invalid long press key info on layout%i, row%i, long%02i.\n", layoutindex, rowindex, keyindex);
Dees_Troy51a0e822012-09-05 15:24:24 -0400204 }
205 keyindex++;
206 sprintf(key, "key%02i", keyindex);
207 attr = keyrow->first_attribute(key);
208 }
209 rowindex++;
210 row[3] = (char)(rowindex + 48);
211 keyrow = keylayout->first_node(row);
212 }
213 layoutindex++;
214 layout[6] = (char)(layoutindex + 48);
215 keylayout = node->first_node(layout);
216 }
217
218 int x, y, w, h;
219 // Load the placement
220 LoadPlacement(node->first_node("placement"), &x, &y, &w, &h);
221 SetActionPos(x, y, KeyboardWidth, KeyboardHeight);
222 SetRenderPos(x, y, w, h);
223 return;
224}
225
226GUIKeyboard::~GUIKeyboard()
227{
that1a7ba972015-02-01 19:48:19 +0100228}
Dees_Troy51a0e822012-09-05 15:24:24 -0400229
that1a7ba972015-02-01 19:48:19 +0100230int GUIKeyboard::ParseKey(const char* keyinfo, keyboard_key_class& key, int& Xindex, int keyWidth, bool longpress)
231{
232 int keychar = 0;
233 if (strlen(keyinfo) == 1) {
234 // This is a single key, simple definition
235 keychar = keyinfo[0];
236 } else {
237 // This key has extra data: {keywidth}:{what_the_key_does}
Ethan Yonker63e414f2015-02-06 15:44:39 -0600238 keyWidth = scale_theme_x(atoi(keyinfo));
that1a7ba972015-02-01 19:48:19 +0100239
240 const char* ptr = keyinfo;
241 while (*ptr > 32 && *ptr != ':')
242 ptr++;
243 if (*ptr != ':')
244 return -1; // no colon is an error
245 ptr++;
246
247 if (*ptr == 0) { // This is an empty area
248 keychar = 0;
249 } else if (strlen(ptr) == 1) { // This is the character that this key uses
250 keychar = *ptr;
251 } else if (*ptr == 'c') { // This is an ASCII character code: "c:{number}"
252 keychar = atoi(ptr + 2);
253 } else if (*ptr == 'l') { // This is a different layout: "layout{number}"
254 keychar = KEYBOARD_LAYOUT;
255 key.layout = atoi(ptr + 6);
256 } else if (*ptr == 'a') { // This is an action: "action"
257 keychar = KEYBOARD_ACTION;
258 } else
259 return -1;
260 }
261
262 if (longpress) {
263 key.longpresskey = keychar;
264 } else {
265 key.key = keychar;
266 Xindex += keyWidth;
267 key.end_x = Xindex - 1;
268 }
269
270 return 0;
Dees_Troy51a0e822012-09-05 15:24:24 -0400271}
272
273int GUIKeyboard::Render(void)
274{
275 if (!isConditionTrue())
276 {
277 mRendered = false;
278 return 0;
279 }
280
281 int ret = 0;
282
283 if (keyboardImg[currentLayout - 1] && keyboardImg[currentLayout - 1]->GetResource())
284 gr_blit(keyboardImg[currentLayout - 1]->GetResource(), 0, 0, KeyboardWidth, KeyboardHeight, mRenderX, mRenderY);
285
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600286 // Draw highlight for capslock
287 if (hasCapsHighlight && caps_tracking[currentLayout - 1].capslock == 0 && caps_tracking[currentLayout - 1].set_capslock) {
288 int boxheight, boxwidth, x;
289 gr_color(mCapsHighlightColor.red, mCapsHighlightColor.green, mCapsHighlightColor.blue, mCapsHighlightColor.alpha);
290 for (int indexy=0; indexy<MAX_KEYBOARD_ROWS; indexy++) {
291 for (int indexx=0; indexx<MAX_KEYBOARD_KEYS; indexx++) {
292 if ((int)keyboard_keys[currentLayout - 1][indexy][indexx].key == KEYBOARD_LAYOUT && (int)keyboard_keys[currentLayout - 1][indexy][indexx].layout == caps_tracking[currentLayout - 1].revert_layout) {
293 if (indexy == 0)
294 boxheight = row_heights[currentLayout - 1][indexy];
295 else
296 boxheight = row_heights[currentLayout - 1][indexy] - row_heights[currentLayout - 1][indexy - 1];
297 if (indexx == 0) {
298 x = mRenderX;
299 boxwidth = keyboard_keys[currentLayout - 1][indexy][indexx].end_x;
300 } else {
301 x = mRenderX + keyboard_keys[currentLayout - 1][indexy][indexx - 1].end_x;
302 boxwidth = keyboard_keys[currentLayout - 1][indexy][indexx].end_x - keyboard_keys[currentLayout - 1][indexy][indexx - 1].end_x;
303 }
304 gr_fill(x, mRenderY + row_heights[currentLayout - 1][indexy - 1], boxwidth, boxheight);
305 }
306 }
307 }
308 }
309
Dees_Troy30b962e2012-10-19 20:48:59 -0400310 if (hasHighlight && highlightRenderCount != 0) {
311 int boxheight, boxwidth, x;
312 if (rowY == 0)
313 boxheight = row_heights[currentLayout - 1][rowY];
314 else
315 boxheight = row_heights[currentLayout - 1][rowY] - row_heights[currentLayout - 1][rowY - 1];
316 if (colX == 0) {
317 x = mRenderX;
318 boxwidth = keyboard_keys[currentLayout - 1][rowY][colX].end_x;
319 } else {
320 x = mRenderX + keyboard_keys[currentLayout - 1][rowY][colX - 1].end_x;
321 boxwidth = keyboard_keys[currentLayout - 1][rowY][colX].end_x - keyboard_keys[currentLayout - 1][rowY][colX - 1].end_x;
322 }
323 gr_color(mHighlightColor.red, mHighlightColor.green, mHighlightColor.blue, mHighlightColor.alpha);
324 gr_fill(x, mRenderY + row_heights[currentLayout - 1][rowY - 1], boxwidth, boxheight);
325 if (highlightRenderCount > 0)
326 highlightRenderCount--;
327 } else
328 mRendered = true;
329
Dees_Troy51a0e822012-09-05 15:24:24 -0400330 return ret;
331}
332
333int GUIKeyboard::Update(void)
334{
335 if (!isConditionTrue()) return (mRendered ? 2 : 0);
336 if (!mRendered) return 2;
337
338 return 0;
339}
340
341int GUIKeyboard::SetRenderPos(int x, int y, int w, int h)
342{
343 mRenderX = x;
344 mRenderY = y;
345 if (w || h)
346 {
347 mRenderW = KeyboardWidth;
348 mRenderH = KeyboardHeight;
349 }
350
351 if (mAction) mAction->SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH);
352 SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH);
353 return 0;
354}
355
356int GUIKeyboard::GetSelection(int x, int y)
357{
Dees_Troy30b962e2012-10-19 20:48:59 -0400358 if (x < mRenderX || x - mRenderX > (int)KeyboardWidth || y < mRenderY || y - mRenderY > (int)KeyboardHeight) return -1;
Dees_Troy51a0e822012-09-05 15:24:24 -0400359 return 0;
360}
361
362int GUIKeyboard::NotifyTouch(TOUCH_STATE state, int x, int y)
363{
364 static int startSelection = -1, was_held = 0, startX = 0;
365 static unsigned char initial_key = 0;
that1a7ba972015-02-01 19:48:19 +0100366 int indexy, indexx, rely, relx, rowIndex = 0;
Dees_Troy51a0e822012-09-05 15:24:24 -0400367
368 rely = y - mRenderY;
369 relx = x - mRenderX;
370
371 if (!isConditionTrue()) return -1;
372
373 switch (state)
374 {
375 case TOUCH_START:
376 if (GetSelection(x, y) == 0) {
377 startSelection = -1;
378 was_held = 0;
379 startX = x;
380 // Find the correct row
381 for (indexy=0; indexy<MAX_KEYBOARD_ROWS; indexy++) {
382 if (row_heights[currentLayout - 1][indexy] > rely) {
383 rowIndex = indexy;
Dees_Troy30b962e2012-10-19 20:48:59 -0400384 rowY = indexy;
Dees_Troy51a0e822012-09-05 15:24:24 -0400385 indexy = MAX_KEYBOARD_ROWS;
386 }
387 }
388
389 // Find the correct key (column)
390 for (indexx=0; indexx<MAX_KEYBOARD_KEYS; indexx++) {
391 if (keyboard_keys[currentLayout - 1][rowIndex][indexx].end_x > relx) {
392 // This is the key that was pressed!
393 initial_key = keyboard_keys[currentLayout - 1][rowIndex][indexx].key;
Dees_Troy30b962e2012-10-19 20:48:59 -0400394 colX = indexx;
Dees_Troy51a0e822012-09-05 15:24:24 -0400395 indexx = MAX_KEYBOARD_KEYS;
396 }
397 }
Dees_Troy30b962e2012-10-19 20:48:59 -0400398 if (initial_key != 0)
399 highlightRenderCount = -1;
400 else
401 highlightRenderCount = 0;
402 mRendered = false;
Dees_Troy51a0e822012-09-05 15:24:24 -0400403 } else {
Dees_Troy30b962e2012-10-19 20:48:59 -0400404 if (highlightRenderCount != 0)
405 mRendered = false;
406 highlightRenderCount = 0;
Dees_Troy51a0e822012-09-05 15:24:24 -0400407 startSelection = 0;
408 }
409 break;
410 case TOUCH_DRAG:
411 break;
412 case TOUCH_RELEASE:
Dees_Troy0cb64e52012-10-15 15:56:10 -0400413 if (x < startX - (KeyboardWidth * 0.5)) {
Dees_Troy30b962e2012-10-19 20:48:59 -0400414 if (highlightRenderCount != 0) {
415 highlightRenderCount = 0;
416 mRendered = false;
417 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400418 PageManager::NotifyKeyboard(KEYBOARD_SWIPE_LEFT);
419 return 0;
Dees_Troy0cb64e52012-10-15 15:56:10 -0400420 } else if (x > startX + (KeyboardWidth * 0.5)) {
Dees_Troy30b962e2012-10-19 20:48:59 -0400421 if (highlightRenderCount != 0) {
422 highlightRenderCount = 0;
423 mRendered = false;
424 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400425 PageManager::NotifyKeyboard(KEYBOARD_SWIPE_RIGHT);
426 return 0;
427 }
428
429 case TOUCH_HOLD:
430 case TOUCH_REPEAT:
431
Dees_Troy30b962e2012-10-19 20:48:59 -0400432 if (startSelection == 0 || GetSelection(x, y) == -1) {
433 if (highlightRenderCount != 0) {
434 highlightRenderCount = 0;
435 mRendered = false;
436 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400437 return 0;
Dees_Troy30b962e2012-10-19 20:48:59 -0400438 } else if (highlightRenderCount != 0) {
439 if (state == TOUCH_RELEASE)
440 highlightRenderCount = 2;
441 else
442 highlightRenderCount = -1;
443 mRendered = false;
444 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400445
446 // Find the correct row
447 for (indexy=0; indexy<MAX_KEYBOARD_ROWS; indexy++) {
448 if (row_heights[currentLayout - 1][indexy] > rely) {
449 rowIndex = indexy;
450 indexy = MAX_KEYBOARD_ROWS;
451 }
452 }
453
454 // Find the correct key (column)
455 for (indexx=0; indexx<MAX_KEYBOARD_KEYS; indexx++) {
that1a7ba972015-02-01 19:48:19 +0100456 keyboard_key_class& key = keyboard_keys[currentLayout - 1][rowIndex][indexx];
457 if (key.end_x > relx) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400458 // This is the key that was pressed!
that1a7ba972015-02-01 19:48:19 +0100459 if (key.key != initial_key) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400460 // We dragged off of the starting key
461 startSelection = 0;
462 break;
463 } else if (state == TOUCH_RELEASE && was_held == 0) {
Ethan Yonker03db3262014-02-05 08:02:06 -0600464 DataManager::Vibrate("tw_keyboard_vibrate");
that1a7ba972015-02-01 19:48:19 +0100465 if ((int)key.key < KEYBOARD_SPECIAL_KEYS && (int)key.key > 0) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400466 // Regular key
that1a7ba972015-02-01 19:48:19 +0100467 PageManager::NotifyKeyboard(key.key);
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600468 if (caps_tracking[currentLayout - 1].capslock == 0 && !caps_tracking[currentLayout - 1].set_capslock) {
469 // caps lock was not set, change layouts
470 currentLayout = caps_tracking[currentLayout - 1].revert_layout;
471 mRendered = false;
472 }
that1a7ba972015-02-01 19:48:19 +0100473 } else if ((int)key.key == KEYBOARD_LAYOUT) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400474 // Switch layouts
that1a7ba972015-02-01 19:48:19 +0100475 if (caps_tracking[currentLayout - 1].capslock == 0 && key.layout == caps_tracking[currentLayout - 1].revert_layout) {
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600476 if (!caps_tracking[currentLayout - 1].set_capslock) {
477 caps_tracking[currentLayout - 1].set_capslock = 1; // Set the caps lock
478 } else {
479 caps_tracking[currentLayout - 1].set_capslock = 0; // Unset the caps lock and change layouts
that1a7ba972015-02-01 19:48:19 +0100480 currentLayout = key.layout;
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600481 }
482 } else {
that1a7ba972015-02-01 19:48:19 +0100483 currentLayout = key.layout;
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600484 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400485 mRendered = false;
that1a7ba972015-02-01 19:48:19 +0100486 } else if ((int)key.key == KEYBOARD_ACTION) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400487 // Action
Dees_Troy30b962e2012-10-19 20:48:59 -0400488 highlightRenderCount = 0;
Dees_Troy51a0e822012-09-05 15:24:24 -0400489 if (mAction) {
490 // Keyboard has its own action defined
491 return (mAction ? mAction->NotifyTouch(state, x, y) : 1);
492 } else {
493 // Send action notification
that1a7ba972015-02-01 19:48:19 +0100494 PageManager::NotifyKeyboard(key.key);
Dees_Troy51a0e822012-09-05 15:24:24 -0400495 }
496 }
497 } else if (state == TOUCH_HOLD) {
498 was_held = 1;
that1a7ba972015-02-01 19:48:19 +0100499 if ((int)key.key == KEYBOARD_BACKSPACE) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400500 // Repeat backspace
that1a7ba972015-02-01 19:48:19 +0100501 PageManager::NotifyKeyboard(key.key);
502 } else if ((int)key.longpresskey < KEYBOARD_SPECIAL_KEYS && (int)key.longpresskey > 0) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400503 // Long Press Key
Ethan Yonker03db3262014-02-05 08:02:06 -0600504 DataManager::Vibrate("tw_keyboard_vibrate");
that1a7ba972015-02-01 19:48:19 +0100505 PageManager::NotifyKeyboard(key.longpresskey);
Dees_Troy51a0e822012-09-05 15:24:24 -0400506 }
507 } else if (state == TOUCH_REPEAT) {
508 was_held = 1;
that1a7ba972015-02-01 19:48:19 +0100509 if ((int)key.key == KEYBOARD_BACKSPACE) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400510 // Repeat backspace
that1a7ba972015-02-01 19:48:19 +0100511 PageManager::NotifyKeyboard(key.key);
Dees_Troy51a0e822012-09-05 15:24:24 -0400512 }
513 }
514 indexx = MAX_KEYBOARD_KEYS;
515 }
516 }
517 break;
518 }
519
520 return 0;
521}