blob: bbc6ed2d821ab04ec5569e0d6efc8d1b75d410e8 [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"
Dees_Troy51a0e822012-09-05 15:24:24 -040040}
41
42#include "rapidxml.hpp"
43#include "objects.hpp"
44
45GUIKeyboard::GUIKeyboard(xml_node<>* node)
Vojtech Bocekede51c52014-02-07 23:58:09 +010046 : GUIObject(node)
Dees_Troy51a0e822012-09-05 15:24:24 -040047{
48 int layoutindex, rowindex, keyindex, Xindex, Yindex, keyHeight = 0, keyWidth = 0;
Dees_Troy30b962e2012-10-19 20:48:59 -040049 rowY = colX = -1;
Ethan Yonkerc3120d42014-02-17 07:55:00 -060050 highlightRenderCount = hasHighlight = hasCapsHighlight = 0;
Dees_Troy3a16cb52013-01-10 15:16:02 +000051 char resource[10], layout[8], row[5], key[6], longpress[7];
Dees_Troy51a0e822012-09-05 15:24:24 -040052 xml_attribute<>* attr;
53 xml_node<>* child;
54 xml_node<>* keylayout;
55 xml_node<>* keyrow;
56
57 for (layoutindex=0; layoutindex<MAX_KEYBOARD_LAYOUTS; layoutindex++)
58 keyboardImg[layoutindex] = NULL;
59
60 mRendered = false;
61 currentLayout = 1;
62 mAction = NULL;
that1a7ba972015-02-01 19:48:19 +010063 KeyboardHeight = KeyboardWidth = 0;
Dees_Troy51a0e822012-09-05 15:24:24 -040064
65 if (!node) return;
66
67 // Load the action
68 child = node->first_node("action");
69 if (child)
70 {
71 mAction = new GUIAction(node);
72 }
73
Dees_Troy30b962e2012-10-19 20:48:59 -040074 memset(&mHighlightColor, 0, sizeof(COLOR));
75 child = node->first_node("highlight");
76 if (child) {
77 attr = child->first_attribute("color");
78 if (attr) {
79 hasHighlight = 1;
80 std::string color = attr->value();
81 ConvertStrToColor(color, &mHighlightColor);
82 }
83 }
84
Ethan Yonkerc3120d42014-02-17 07:55:00 -060085 memset(&mCapsHighlightColor, 0, sizeof(COLOR));
86 child = node->first_node("capshighlight");
87 if (child) {
88 attr = child->first_attribute("color");
89 if (attr) {
90 hasCapsHighlight = 1;
91 std::string color = attr->value();
92 ConvertStrToColor(color, &mCapsHighlightColor);
93 }
94 }
95
Dees_Troy51a0e822012-09-05 15:24:24 -040096 // Load the images for the different layouts
97 child = node->first_node("layout");
98 if (child)
99 {
100 layoutindex = 1;
101 strcpy(resource, "resource1");
102 attr = child->first_attribute(resource);
103 while (attr && layoutindex < (MAX_KEYBOARD_LAYOUTS + 1)) {
104 keyboardImg[layoutindex - 1] = PageManager::FindResource(attr->value());
105
106 layoutindex++;
107 resource[8] = (char)(layoutindex + 48);
108 attr = child->first_attribute(resource);
109 }
110 }
111
112 // Check the first image to get height and width
113 if (keyboardImg[0] && keyboardImg[0]->GetResource())
114 {
115 KeyboardWidth = gr_get_width(keyboardImg[0]->GetResource());
116 KeyboardHeight = gr_get_height(keyboardImg[0]->GetResource());
117 }
118
119 // Load all of the layout maps
120 layoutindex = 1;
121 strcpy(layout, "layout1");
122 keylayout = node->first_node(layout);
123 while (keylayout)
124 {
125 if (layoutindex > MAX_KEYBOARD_LAYOUTS) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000126 LOGERR("Too many layouts defined in keyboard.\n");
Dees_Troy51a0e822012-09-05 15:24:24 -0400127 return;
128 }
129
130 child = keylayout->first_node("keysize");
131 if (child) {
132 attr = child->first_attribute("height");
133 if (attr)
134 keyHeight = atoi(attr->value());
135 else
136 keyHeight = 0;
137 attr = child->first_attribute("width");
138 if (attr)
139 keyWidth = atoi(attr->value());
140 else
141 keyWidth = 0;
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600142 attr = child->first_attribute("capslock");
143 if (attr)
144 caps_tracking[layoutindex - 1].capslock = atoi(attr->value());
145 else
146 caps_tracking[layoutindex - 1].capslock = 1;
147 attr = child->first_attribute("revert_layout");
148 if (attr)
149 caps_tracking[layoutindex - 1].revert_layout = atoi(attr->value());
150 else
151 caps_tracking[layoutindex - 1].revert_layout = -1;
Dees_Troy51a0e822012-09-05 15:24:24 -0400152 }
153
154 rowindex = 1;
155 Yindex = 0;
156 strcpy(row, "row1");
157 keyrow = keylayout->first_node(row);
158 while (keyrow)
159 {
160 if (rowindex > MAX_KEYBOARD_ROWS) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000161 LOGERR("Too many rows defined in keyboard.\n");
Dees_Troy51a0e822012-09-05 15:24:24 -0400162 return;
163 }
164
165 Yindex += keyHeight;
166 row_heights[layoutindex - 1][rowindex - 1] = Yindex;
167
168 keyindex = 1;
169 Xindex = 0;
170 strcpy(key, "key01");
171 attr = keyrow->first_attribute(key);
172
173 while (attr) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400174 if (keyindex > MAX_KEYBOARD_KEYS) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000175 LOGERR("Too many keys defined in a keyboard row.\n");
Dees_Troy51a0e822012-09-05 15:24:24 -0400176 return;
177 }
178
that1a7ba972015-02-01 19:48:19 +0100179 const char* keyinfo = attr->value();
Dees_Troy51a0e822012-09-05 15:24:24 -0400180
181 if (strlen(keyinfo) == 0) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000182 LOGERR("No key info on layout%i, row%i, key%dd.\n", layoutindex, rowindex, keyindex);
Dees_Troy51a0e822012-09-05 15:24:24 -0400183 return;
184 }
185
that1a7ba972015-02-01 19:48:19 +0100186 if (ParseKey(keyinfo, keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1], Xindex, keyWidth, false))
187 LOGERR("Invalid key info on layout%i, row%i, key%02i.\n", layoutindex, rowindex, keyindex);
Dees_Troy51a0e822012-09-05 15:24:24 -0400188
Dees_Troy51a0e822012-09-05 15:24:24 -0400189
190 // PROCESS LONG PRESS INFO IF EXISTS
191 sprintf(longpress, "long%02i", keyindex);
192 attr = keyrow->first_attribute(longpress);
193 if (attr) {
that1a7ba972015-02-01 19:48:19 +0100194 const char* keyinfo = attr->value();
Dees_Troy51a0e822012-09-05 15:24:24 -0400195
196 if (strlen(keyinfo) == 0) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000197 LOGERR("No long press info on layout%i, row%i, long%dd.\n", layoutindex, rowindex, keyindex);
Dees_Troy51a0e822012-09-05 15:24:24 -0400198 return;
199 }
200
that1a7ba972015-02-01 19:48:19 +0100201 if (ParseKey(keyinfo, keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1], Xindex, keyWidth, true))
202 LOGERR("Invalid long press key info on layout%i, row%i, long%02i.\n", layoutindex, rowindex, keyindex);
Dees_Troy51a0e822012-09-05 15:24:24 -0400203 }
204 keyindex++;
205 sprintf(key, "key%02i", keyindex);
206 attr = keyrow->first_attribute(key);
207 }
208 rowindex++;
209 row[3] = (char)(rowindex + 48);
210 keyrow = keylayout->first_node(row);
211 }
212 layoutindex++;
213 layout[6] = (char)(layoutindex + 48);
214 keylayout = node->first_node(layout);
215 }
216
217 int x, y, w, h;
218 // Load the placement
219 LoadPlacement(node->first_node("placement"), &x, &y, &w, &h);
220 SetActionPos(x, y, KeyboardWidth, KeyboardHeight);
221 SetRenderPos(x, y, w, h);
222 return;
223}
224
225GUIKeyboard::~GUIKeyboard()
226{
that1a7ba972015-02-01 19:48:19 +0100227}
Dees_Troy51a0e822012-09-05 15:24:24 -0400228
that1a7ba972015-02-01 19:48:19 +0100229int GUIKeyboard::ParseKey(const char* keyinfo, keyboard_key_class& key, int& Xindex, int keyWidth, bool longpress)
230{
231 int keychar = 0;
232 if (strlen(keyinfo) == 1) {
233 // This is a single key, simple definition
234 keychar = keyinfo[0];
235 } else {
236 // This key has extra data: {keywidth}:{what_the_key_does}
237 keyWidth = atoi(keyinfo);
238
239 const char* ptr = keyinfo;
240 while (*ptr > 32 && *ptr != ':')
241 ptr++;
242 if (*ptr != ':')
243 return -1; // no colon is an error
244 ptr++;
245
246 if (*ptr == 0) { // This is an empty area
247 keychar = 0;
248 } else if (strlen(ptr) == 1) { // This is the character that this key uses
249 keychar = *ptr;
250 } else if (*ptr == 'c') { // This is an ASCII character code: "c:{number}"
251 keychar = atoi(ptr + 2);
252 } else if (*ptr == 'l') { // This is a different layout: "layout{number}"
253 keychar = KEYBOARD_LAYOUT;
254 key.layout = atoi(ptr + 6);
255 } else if (*ptr == 'a') { // This is an action: "action"
256 keychar = KEYBOARD_ACTION;
257 } else
258 return -1;
259 }
260
261 if (longpress) {
262 key.longpresskey = keychar;
263 } else {
264 key.key = keychar;
265 Xindex += keyWidth;
266 key.end_x = Xindex - 1;
267 }
268
269 return 0;
Dees_Troy51a0e822012-09-05 15:24:24 -0400270}
271
272int GUIKeyboard::Render(void)
273{
274 if (!isConditionTrue())
275 {
276 mRendered = false;
277 return 0;
278 }
279
280 int ret = 0;
281
282 if (keyboardImg[currentLayout - 1] && keyboardImg[currentLayout - 1]->GetResource())
283 gr_blit(keyboardImg[currentLayout - 1]->GetResource(), 0, 0, KeyboardWidth, KeyboardHeight, mRenderX, mRenderY);
284
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600285 // Draw highlight for capslock
286 if (hasCapsHighlight && caps_tracking[currentLayout - 1].capslock == 0 && caps_tracking[currentLayout - 1].set_capslock) {
287 int boxheight, boxwidth, x;
288 gr_color(mCapsHighlightColor.red, mCapsHighlightColor.green, mCapsHighlightColor.blue, mCapsHighlightColor.alpha);
289 for (int indexy=0; indexy<MAX_KEYBOARD_ROWS; indexy++) {
290 for (int indexx=0; indexx<MAX_KEYBOARD_KEYS; indexx++) {
291 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) {
292 if (indexy == 0)
293 boxheight = row_heights[currentLayout - 1][indexy];
294 else
295 boxheight = row_heights[currentLayout - 1][indexy] - row_heights[currentLayout - 1][indexy - 1];
296 if (indexx == 0) {
297 x = mRenderX;
298 boxwidth = keyboard_keys[currentLayout - 1][indexy][indexx].end_x;
299 } else {
300 x = mRenderX + keyboard_keys[currentLayout - 1][indexy][indexx - 1].end_x;
301 boxwidth = keyboard_keys[currentLayout - 1][indexy][indexx].end_x - keyboard_keys[currentLayout - 1][indexy][indexx - 1].end_x;
302 }
303 gr_fill(x, mRenderY + row_heights[currentLayout - 1][indexy - 1], boxwidth, boxheight);
304 }
305 }
306 }
307 }
308
Dees_Troy30b962e2012-10-19 20:48:59 -0400309 if (hasHighlight && highlightRenderCount != 0) {
310 int boxheight, boxwidth, x;
311 if (rowY == 0)
312 boxheight = row_heights[currentLayout - 1][rowY];
313 else
314 boxheight = row_heights[currentLayout - 1][rowY] - row_heights[currentLayout - 1][rowY - 1];
315 if (colX == 0) {
316 x = mRenderX;
317 boxwidth = keyboard_keys[currentLayout - 1][rowY][colX].end_x;
318 } else {
319 x = mRenderX + keyboard_keys[currentLayout - 1][rowY][colX - 1].end_x;
320 boxwidth = keyboard_keys[currentLayout - 1][rowY][colX].end_x - keyboard_keys[currentLayout - 1][rowY][colX - 1].end_x;
321 }
322 gr_color(mHighlightColor.red, mHighlightColor.green, mHighlightColor.blue, mHighlightColor.alpha);
323 gr_fill(x, mRenderY + row_heights[currentLayout - 1][rowY - 1], boxwidth, boxheight);
324 if (highlightRenderCount > 0)
325 highlightRenderCount--;
326 } else
327 mRendered = true;
328
Dees_Troy51a0e822012-09-05 15:24:24 -0400329 return ret;
330}
331
332int GUIKeyboard::Update(void)
333{
334 if (!isConditionTrue()) return (mRendered ? 2 : 0);
335 if (!mRendered) return 2;
336
337 return 0;
338}
339
340int GUIKeyboard::SetRenderPos(int x, int y, int w, int h)
341{
342 mRenderX = x;
343 mRenderY = y;
344 if (w || h)
345 {
346 mRenderW = KeyboardWidth;
347 mRenderH = KeyboardHeight;
348 }
349
350 if (mAction) mAction->SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH);
351 SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH);
352 return 0;
353}
354
355int GUIKeyboard::GetSelection(int x, int y)
356{
Dees_Troy30b962e2012-10-19 20:48:59 -0400357 if (x < mRenderX || x - mRenderX > (int)KeyboardWidth || y < mRenderY || y - mRenderY > (int)KeyboardHeight) return -1;
Dees_Troy51a0e822012-09-05 15:24:24 -0400358 return 0;
359}
360
361int GUIKeyboard::NotifyTouch(TOUCH_STATE state, int x, int y)
362{
363 static int startSelection = -1, was_held = 0, startX = 0;
364 static unsigned char initial_key = 0;
that1a7ba972015-02-01 19:48:19 +0100365 int indexy, indexx, rely, relx, rowIndex = 0;
Dees_Troy51a0e822012-09-05 15:24:24 -0400366
367 rely = y - mRenderY;
368 relx = x - mRenderX;
369
370 if (!isConditionTrue()) return -1;
371
372 switch (state)
373 {
374 case TOUCH_START:
375 if (GetSelection(x, y) == 0) {
376 startSelection = -1;
377 was_held = 0;
378 startX = x;
379 // Find the correct row
380 for (indexy=0; indexy<MAX_KEYBOARD_ROWS; indexy++) {
381 if (row_heights[currentLayout - 1][indexy] > rely) {
382 rowIndex = indexy;
Dees_Troy30b962e2012-10-19 20:48:59 -0400383 rowY = indexy;
Dees_Troy51a0e822012-09-05 15:24:24 -0400384 indexy = MAX_KEYBOARD_ROWS;
385 }
386 }
387
388 // Find the correct key (column)
389 for (indexx=0; indexx<MAX_KEYBOARD_KEYS; indexx++) {
390 if (keyboard_keys[currentLayout - 1][rowIndex][indexx].end_x > relx) {
391 // This is the key that was pressed!
392 initial_key = keyboard_keys[currentLayout - 1][rowIndex][indexx].key;
Dees_Troy30b962e2012-10-19 20:48:59 -0400393 colX = indexx;
Dees_Troy51a0e822012-09-05 15:24:24 -0400394 indexx = MAX_KEYBOARD_KEYS;
395 }
396 }
Dees_Troy30b962e2012-10-19 20:48:59 -0400397 if (initial_key != 0)
398 highlightRenderCount = -1;
399 else
400 highlightRenderCount = 0;
401 mRendered = false;
Dees_Troy51a0e822012-09-05 15:24:24 -0400402 } else {
Dees_Troy30b962e2012-10-19 20:48:59 -0400403 if (highlightRenderCount != 0)
404 mRendered = false;
405 highlightRenderCount = 0;
Dees_Troy51a0e822012-09-05 15:24:24 -0400406 startSelection = 0;
407 }
408 break;
409 case TOUCH_DRAG:
410 break;
411 case TOUCH_RELEASE:
Dees_Troy0cb64e52012-10-15 15:56:10 -0400412 if (x < startX - (KeyboardWidth * 0.5)) {
Dees_Troy30b962e2012-10-19 20:48:59 -0400413 if (highlightRenderCount != 0) {
414 highlightRenderCount = 0;
415 mRendered = false;
416 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400417 PageManager::NotifyKeyboard(KEYBOARD_SWIPE_LEFT);
418 return 0;
Dees_Troy0cb64e52012-10-15 15:56:10 -0400419 } else if (x > startX + (KeyboardWidth * 0.5)) {
Dees_Troy30b962e2012-10-19 20:48:59 -0400420 if (highlightRenderCount != 0) {
421 highlightRenderCount = 0;
422 mRendered = false;
423 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400424 PageManager::NotifyKeyboard(KEYBOARD_SWIPE_RIGHT);
425 return 0;
426 }
427
428 case TOUCH_HOLD:
429 case TOUCH_REPEAT:
430
Dees_Troy30b962e2012-10-19 20:48:59 -0400431 if (startSelection == 0 || GetSelection(x, y) == -1) {
432 if (highlightRenderCount != 0) {
433 highlightRenderCount = 0;
434 mRendered = false;
435 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400436 return 0;
Dees_Troy30b962e2012-10-19 20:48:59 -0400437 } else if (highlightRenderCount != 0) {
438 if (state == TOUCH_RELEASE)
439 highlightRenderCount = 2;
440 else
441 highlightRenderCount = -1;
442 mRendered = false;
443 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400444
445 // Find the correct row
446 for (indexy=0; indexy<MAX_KEYBOARD_ROWS; indexy++) {
447 if (row_heights[currentLayout - 1][indexy] > rely) {
448 rowIndex = indexy;
449 indexy = MAX_KEYBOARD_ROWS;
450 }
451 }
452
453 // Find the correct key (column)
454 for (indexx=0; indexx<MAX_KEYBOARD_KEYS; indexx++) {
that1a7ba972015-02-01 19:48:19 +0100455 keyboard_key_class& key = keyboard_keys[currentLayout - 1][rowIndex][indexx];
456 if (key.end_x > relx) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400457 // This is the key that was pressed!
that1a7ba972015-02-01 19:48:19 +0100458 if (key.key != initial_key) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400459 // We dragged off of the starting key
460 startSelection = 0;
461 break;
462 } else if (state == TOUCH_RELEASE && was_held == 0) {
Ethan Yonker03db3262014-02-05 08:02:06 -0600463 DataManager::Vibrate("tw_keyboard_vibrate");
that1a7ba972015-02-01 19:48:19 +0100464 if ((int)key.key < KEYBOARD_SPECIAL_KEYS && (int)key.key > 0) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400465 // Regular key
that1a7ba972015-02-01 19:48:19 +0100466 PageManager::NotifyKeyboard(key.key);
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600467 if (caps_tracking[currentLayout - 1].capslock == 0 && !caps_tracking[currentLayout - 1].set_capslock) {
468 // caps lock was not set, change layouts
469 currentLayout = caps_tracking[currentLayout - 1].revert_layout;
470 mRendered = false;
471 }
that1a7ba972015-02-01 19:48:19 +0100472 } else if ((int)key.key == KEYBOARD_LAYOUT) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400473 // Switch layouts
that1a7ba972015-02-01 19:48:19 +0100474 if (caps_tracking[currentLayout - 1].capslock == 0 && key.layout == caps_tracking[currentLayout - 1].revert_layout) {
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600475 if (!caps_tracking[currentLayout - 1].set_capslock) {
476 caps_tracking[currentLayout - 1].set_capslock = 1; // Set the caps lock
477 } else {
478 caps_tracking[currentLayout - 1].set_capslock = 0; // Unset the caps lock and change layouts
that1a7ba972015-02-01 19:48:19 +0100479 currentLayout = key.layout;
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600480 }
481 } else {
that1a7ba972015-02-01 19:48:19 +0100482 currentLayout = key.layout;
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600483 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400484 mRendered = false;
that1a7ba972015-02-01 19:48:19 +0100485 } else if ((int)key.key == KEYBOARD_ACTION) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400486 // Action
Dees_Troy30b962e2012-10-19 20:48:59 -0400487 highlightRenderCount = 0;
Dees_Troy51a0e822012-09-05 15:24:24 -0400488 if (mAction) {
489 // Keyboard has its own action defined
490 return (mAction ? mAction->NotifyTouch(state, x, y) : 1);
491 } else {
492 // Send action notification
that1a7ba972015-02-01 19:48:19 +0100493 PageManager::NotifyKeyboard(key.key);
Dees_Troy51a0e822012-09-05 15:24:24 -0400494 }
495 }
496 } else if (state == TOUCH_HOLD) {
497 was_held = 1;
that1a7ba972015-02-01 19:48:19 +0100498 if ((int)key.key == KEYBOARD_BACKSPACE) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400499 // Repeat backspace
that1a7ba972015-02-01 19:48:19 +0100500 PageManager::NotifyKeyboard(key.key);
501 } else if ((int)key.longpresskey < KEYBOARD_SPECIAL_KEYS && (int)key.longpresskey > 0) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400502 // Long Press Key
Ethan Yonker03db3262014-02-05 08:02:06 -0600503 DataManager::Vibrate("tw_keyboard_vibrate");
that1a7ba972015-02-01 19:48:19 +0100504 PageManager::NotifyKeyboard(key.longpresskey);
Dees_Troy51a0e822012-09-05 15:24:24 -0400505 }
506 } else if (state == TOUCH_REPEAT) {
507 was_held = 1;
that1a7ba972015-02-01 19:48:19 +0100508 if ((int)key.key == KEYBOARD_BACKSPACE) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400509 // Repeat backspace
that1a7ba972015-02-01 19:48:19 +0100510 PageManager::NotifyKeyboard(key.key);
Dees_Troy51a0e822012-09-05 15:24:24 -0400511 }
512 }
513 indexx = MAX_KEYBOARD_KEYS;
514 }
515 }
516 break;
517 }
518
519 return 0;
520}