blob: f193a1245de0a47a8697c76d72d9acaa9218dfbc [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
47 for (layoutindex=0; layoutindex<MAX_KEYBOARD_LAYOUTS; layoutindex++)
48 keyboardImg[layoutindex] = NULL;
49
50 mRendered = false;
51 currentLayout = 1;
that1a7ba972015-02-01 19:48:19 +010052 KeyboardHeight = KeyboardWidth = 0;
Dees_Troy51a0e822012-09-05 15:24:24 -040053
54 if (!node) return;
55
Ethan Yonker21ff02a2015-02-18 14:35:00 -060056 mHighlightColor = LoadAttrColor(FindNode(node, "highlight"), "color", &hasHighlight);
57 mCapsHighlightColor = LoadAttrColor(FindNode(node, "capshighlight"), "color", &hasCapsHighlight);
Ethan Yonkerc3120d42014-02-17 07:55:00 -060058
Dees_Troy51a0e822012-09-05 15:24:24 -040059 // Load the images for the different layouts
Ethan Yonker21ff02a2015-02-18 14:35:00 -060060 child = FindNode(node, "layout");
Dees_Troy51a0e822012-09-05 15:24:24 -040061 if (child)
62 {
63 layoutindex = 1;
64 strcpy(resource, "resource1");
65 attr = child->first_attribute(resource);
66 while (attr && layoutindex < (MAX_KEYBOARD_LAYOUTS + 1)) {
thatf6ed8fc2015-02-14 20:23:16 +010067 keyboardImg[layoutindex - 1] = LoadAttrImage(child, resource);
Dees_Troy51a0e822012-09-05 15:24:24 -040068
69 layoutindex++;
70 resource[8] = (char)(layoutindex + 48);
71 attr = child->first_attribute(resource);
72 }
73 }
74
75 // Check the first image to get height and width
76 if (keyboardImg[0] && keyboardImg[0]->GetResource())
77 {
thatf6ed8fc2015-02-14 20:23:16 +010078 KeyboardWidth = keyboardImg[0]->GetWidth();
79 KeyboardHeight = keyboardImg[0]->GetHeight();
Dees_Troy51a0e822012-09-05 15:24:24 -040080 }
81
82 // Load all of the layout maps
83 layoutindex = 1;
84 strcpy(layout, "layout1");
Ethan Yonker21ff02a2015-02-18 14:35:00 -060085 keylayout = FindNode(node, layout);
Dees_Troy51a0e822012-09-05 15:24:24 -040086 while (keylayout)
87 {
88 if (layoutindex > MAX_KEYBOARD_LAYOUTS) {
Dees_Troy2673cec2013-04-02 20:22:16 +000089 LOGERR("Too many layouts defined in keyboard.\n");
Dees_Troy51a0e822012-09-05 15:24:24 -040090 return;
91 }
92
93 child = keylayout->first_node("keysize");
94 if (child) {
95 attr = child->first_attribute("height");
96 if (attr)
Ethan Yonker63e414f2015-02-06 15:44:39 -060097 keyHeight = scale_theme_y(atoi(attr->value()));
Dees_Troy51a0e822012-09-05 15:24:24 -040098 else
99 keyHeight = 0;
100 attr = child->first_attribute("width");
101 if (attr)
Ethan Yonker63e414f2015-02-06 15:44:39 -0600102 keyWidth = scale_theme_x(atoi(attr->value()));
Dees_Troy51a0e822012-09-05 15:24:24 -0400103 else
104 keyWidth = 0;
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600105 attr = child->first_attribute("capslock");
106 if (attr)
107 caps_tracking[layoutindex - 1].capslock = atoi(attr->value());
108 else
109 caps_tracking[layoutindex - 1].capslock = 1;
110 attr = child->first_attribute("revert_layout");
111 if (attr)
112 caps_tracking[layoutindex - 1].revert_layout = atoi(attr->value());
113 else
114 caps_tracking[layoutindex - 1].revert_layout = -1;
Dees_Troy51a0e822012-09-05 15:24:24 -0400115 }
116
117 rowindex = 1;
118 Yindex = 0;
119 strcpy(row, "row1");
120 keyrow = keylayout->first_node(row);
121 while (keyrow)
122 {
123 if (rowindex > MAX_KEYBOARD_ROWS) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000124 LOGERR("Too many rows defined in keyboard.\n");
Dees_Troy51a0e822012-09-05 15:24:24 -0400125 return;
126 }
127
128 Yindex += keyHeight;
129 row_heights[layoutindex - 1][rowindex - 1] = Yindex;
130
131 keyindex = 1;
132 Xindex = 0;
133 strcpy(key, "key01");
134 attr = keyrow->first_attribute(key);
135
136 while (attr) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400137 if (keyindex > MAX_KEYBOARD_KEYS) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000138 LOGERR("Too many keys defined in a keyboard row.\n");
Dees_Troy51a0e822012-09-05 15:24:24 -0400139 return;
140 }
141
that1a7ba972015-02-01 19:48:19 +0100142 const char* keyinfo = attr->value();
Dees_Troy51a0e822012-09-05 15:24:24 -0400143
144 if (strlen(keyinfo) == 0) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000145 LOGERR("No key info on layout%i, row%i, key%dd.\n", layoutindex, rowindex, keyindex);
Dees_Troy51a0e822012-09-05 15:24:24 -0400146 return;
147 }
148
that1a7ba972015-02-01 19:48:19 +0100149 if (ParseKey(keyinfo, keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1], Xindex, keyWidth, false))
150 LOGERR("Invalid key info on layout%i, row%i, key%02i.\n", layoutindex, rowindex, keyindex);
Dees_Troy51a0e822012-09-05 15:24:24 -0400151
Dees_Troy51a0e822012-09-05 15:24:24 -0400152
153 // PROCESS LONG PRESS INFO IF EXISTS
154 sprintf(longpress, "long%02i", keyindex);
155 attr = keyrow->first_attribute(longpress);
156 if (attr) {
that1a7ba972015-02-01 19:48:19 +0100157 const char* keyinfo = attr->value();
Dees_Troy51a0e822012-09-05 15:24:24 -0400158
159 if (strlen(keyinfo) == 0) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000160 LOGERR("No long press info on layout%i, row%i, long%dd.\n", layoutindex, rowindex, keyindex);
Dees_Troy51a0e822012-09-05 15:24:24 -0400161 return;
162 }
163
that1a7ba972015-02-01 19:48:19 +0100164 if (ParseKey(keyinfo, keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1], Xindex, keyWidth, true))
165 LOGERR("Invalid long press key info on layout%i, row%i, long%02i.\n", layoutindex, rowindex, keyindex);
Dees_Troy51a0e822012-09-05 15:24:24 -0400166 }
167 keyindex++;
168 sprintf(key, "key%02i", keyindex);
169 attr = keyrow->first_attribute(key);
170 }
171 rowindex++;
172 row[3] = (char)(rowindex + 48);
173 keyrow = keylayout->first_node(row);
174 }
175 layoutindex++;
176 layout[6] = (char)(layoutindex + 48);
Ethan Yonker21ff02a2015-02-18 14:35:00 -0600177 keylayout = FindNode(node, layout);
Dees_Troy51a0e822012-09-05 15:24:24 -0400178 }
179
180 int x, y, w, h;
181 // Load the placement
Ethan Yonker21ff02a2015-02-18 14:35:00 -0600182 LoadPlacement(FindNode(node, "placement"), &x, &y, &w, &h);
Dees_Troy51a0e822012-09-05 15:24:24 -0400183 SetActionPos(x, y, KeyboardWidth, KeyboardHeight);
184 SetRenderPos(x, y, w, h);
185 return;
186}
187
188GUIKeyboard::~GUIKeyboard()
189{
that1a7ba972015-02-01 19:48:19 +0100190}
Dees_Troy51a0e822012-09-05 15:24:24 -0400191
that1a7ba972015-02-01 19:48:19 +0100192int GUIKeyboard::ParseKey(const char* keyinfo, keyboard_key_class& key, int& Xindex, int keyWidth, bool longpress)
193{
194 int keychar = 0;
195 if (strlen(keyinfo) == 1) {
196 // This is a single key, simple definition
197 keychar = keyinfo[0];
198 } else {
199 // This key has extra data: {keywidth}:{what_the_key_does}
Ethan Yonker63e414f2015-02-06 15:44:39 -0600200 keyWidth = scale_theme_x(atoi(keyinfo));
that1a7ba972015-02-01 19:48:19 +0100201
202 const char* ptr = keyinfo;
203 while (*ptr > 32 && *ptr != ':')
204 ptr++;
205 if (*ptr != ':')
206 return -1; // no colon is an error
207 ptr++;
208
209 if (*ptr == 0) { // This is an empty area
210 keychar = 0;
211 } else if (strlen(ptr) == 1) { // This is the character that this key uses
212 keychar = *ptr;
213 } else if (*ptr == 'c') { // This is an ASCII character code: "c:{number}"
214 keychar = atoi(ptr + 2);
215 } else if (*ptr == 'l') { // This is a different layout: "layout{number}"
216 keychar = KEYBOARD_LAYOUT;
217 key.layout = atoi(ptr + 6);
218 } else if (*ptr == 'a') { // This is an action: "action"
219 keychar = KEYBOARD_ACTION;
220 } else
221 return -1;
222 }
223
224 if (longpress) {
225 key.longpresskey = keychar;
226 } else {
227 key.key = keychar;
228 Xindex += keyWidth;
229 key.end_x = Xindex - 1;
230 }
231
232 return 0;
Dees_Troy51a0e822012-09-05 15:24:24 -0400233}
234
235int GUIKeyboard::Render(void)
236{
237 if (!isConditionTrue())
238 {
239 mRendered = false;
240 return 0;
241 }
242
243 int ret = 0;
244
245 if (keyboardImg[currentLayout - 1] && keyboardImg[currentLayout - 1]->GetResource())
246 gr_blit(keyboardImg[currentLayout - 1]->GetResource(), 0, 0, KeyboardWidth, KeyboardHeight, mRenderX, mRenderY);
247
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600248 // Draw highlight for capslock
249 if (hasCapsHighlight && caps_tracking[currentLayout - 1].capslock == 0 && caps_tracking[currentLayout - 1].set_capslock) {
250 int boxheight, boxwidth, x;
251 gr_color(mCapsHighlightColor.red, mCapsHighlightColor.green, mCapsHighlightColor.blue, mCapsHighlightColor.alpha);
252 for (int indexy=0; indexy<MAX_KEYBOARD_ROWS; indexy++) {
253 for (int indexx=0; indexx<MAX_KEYBOARD_KEYS; indexx++) {
254 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) {
255 if (indexy == 0)
256 boxheight = row_heights[currentLayout - 1][indexy];
257 else
258 boxheight = row_heights[currentLayout - 1][indexy] - row_heights[currentLayout - 1][indexy - 1];
259 if (indexx == 0) {
260 x = mRenderX;
261 boxwidth = keyboard_keys[currentLayout - 1][indexy][indexx].end_x;
262 } else {
263 x = mRenderX + keyboard_keys[currentLayout - 1][indexy][indexx - 1].end_x;
264 boxwidth = keyboard_keys[currentLayout - 1][indexy][indexx].end_x - keyboard_keys[currentLayout - 1][indexy][indexx - 1].end_x;
265 }
266 gr_fill(x, mRenderY + row_heights[currentLayout - 1][indexy - 1], boxwidth, boxheight);
267 }
268 }
269 }
270 }
271
Dees_Troy30b962e2012-10-19 20:48:59 -0400272 if (hasHighlight && highlightRenderCount != 0) {
273 int boxheight, boxwidth, x;
274 if (rowY == 0)
275 boxheight = row_heights[currentLayout - 1][rowY];
276 else
277 boxheight = row_heights[currentLayout - 1][rowY] - row_heights[currentLayout - 1][rowY - 1];
278 if (colX == 0) {
279 x = mRenderX;
280 boxwidth = keyboard_keys[currentLayout - 1][rowY][colX].end_x;
281 } else {
282 x = mRenderX + keyboard_keys[currentLayout - 1][rowY][colX - 1].end_x;
283 boxwidth = keyboard_keys[currentLayout - 1][rowY][colX].end_x - keyboard_keys[currentLayout - 1][rowY][colX - 1].end_x;
284 }
285 gr_color(mHighlightColor.red, mHighlightColor.green, mHighlightColor.blue, mHighlightColor.alpha);
286 gr_fill(x, mRenderY + row_heights[currentLayout - 1][rowY - 1], boxwidth, boxheight);
287 if (highlightRenderCount > 0)
288 highlightRenderCount--;
289 } else
290 mRendered = true;
291
Dees_Troy51a0e822012-09-05 15:24:24 -0400292 return ret;
293}
294
295int GUIKeyboard::Update(void)
296{
297 if (!isConditionTrue()) return (mRendered ? 2 : 0);
298 if (!mRendered) return 2;
299
300 return 0;
301}
302
303int GUIKeyboard::SetRenderPos(int x, int y, int w, int h)
304{
305 mRenderX = x;
306 mRenderY = y;
307 if (w || h)
308 {
309 mRenderW = KeyboardWidth;
310 mRenderH = KeyboardHeight;
311 }
312
Dees_Troy51a0e822012-09-05 15:24:24 -0400313 SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH);
314 return 0;
315}
316
317int GUIKeyboard::GetSelection(int x, int y)
318{
Dees_Troy30b962e2012-10-19 20:48:59 -0400319 if (x < mRenderX || x - mRenderX > (int)KeyboardWidth || y < mRenderY || y - mRenderY > (int)KeyboardHeight) return -1;
Dees_Troy51a0e822012-09-05 15:24:24 -0400320 return 0;
321}
322
323int GUIKeyboard::NotifyTouch(TOUCH_STATE state, int x, int y)
324{
325 static int startSelection = -1, was_held = 0, startX = 0;
326 static unsigned char initial_key = 0;
that1a7ba972015-02-01 19:48:19 +0100327 int indexy, indexx, rely, relx, rowIndex = 0;
Dees_Troy51a0e822012-09-05 15:24:24 -0400328
329 rely = y - mRenderY;
330 relx = x - mRenderX;
331
332 if (!isConditionTrue()) return -1;
333
334 switch (state)
335 {
336 case TOUCH_START:
337 if (GetSelection(x, y) == 0) {
338 startSelection = -1;
339 was_held = 0;
340 startX = x;
341 // Find the correct row
342 for (indexy=0; indexy<MAX_KEYBOARD_ROWS; indexy++) {
343 if (row_heights[currentLayout - 1][indexy] > rely) {
344 rowIndex = indexy;
Dees_Troy30b962e2012-10-19 20:48:59 -0400345 rowY = indexy;
Dees_Troy51a0e822012-09-05 15:24:24 -0400346 indexy = MAX_KEYBOARD_ROWS;
347 }
348 }
349
350 // Find the correct key (column)
351 for (indexx=0; indexx<MAX_KEYBOARD_KEYS; indexx++) {
352 if (keyboard_keys[currentLayout - 1][rowIndex][indexx].end_x > relx) {
353 // This is the key that was pressed!
354 initial_key = keyboard_keys[currentLayout - 1][rowIndex][indexx].key;
Dees_Troy30b962e2012-10-19 20:48:59 -0400355 colX = indexx;
Dees_Troy51a0e822012-09-05 15:24:24 -0400356 indexx = MAX_KEYBOARD_KEYS;
357 }
358 }
Dees_Troy30b962e2012-10-19 20:48:59 -0400359 if (initial_key != 0)
360 highlightRenderCount = -1;
361 else
362 highlightRenderCount = 0;
363 mRendered = false;
Dees_Troy51a0e822012-09-05 15:24:24 -0400364 } else {
Dees_Troy30b962e2012-10-19 20:48:59 -0400365 if (highlightRenderCount != 0)
366 mRendered = false;
367 highlightRenderCount = 0;
Dees_Troy51a0e822012-09-05 15:24:24 -0400368 startSelection = 0;
369 }
370 break;
371 case TOUCH_DRAG:
372 break;
373 case TOUCH_RELEASE:
Dees_Troy0cb64e52012-10-15 15:56:10 -0400374 if (x < startX - (KeyboardWidth * 0.5)) {
Dees_Troy30b962e2012-10-19 20:48:59 -0400375 if (highlightRenderCount != 0) {
376 highlightRenderCount = 0;
377 mRendered = false;
378 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400379 PageManager::NotifyKeyboard(KEYBOARD_SWIPE_LEFT);
380 return 0;
Dees_Troy0cb64e52012-10-15 15:56:10 -0400381 } else if (x > startX + (KeyboardWidth * 0.5)) {
Dees_Troy30b962e2012-10-19 20:48:59 -0400382 if (highlightRenderCount != 0) {
383 highlightRenderCount = 0;
384 mRendered = false;
385 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400386 PageManager::NotifyKeyboard(KEYBOARD_SWIPE_RIGHT);
387 return 0;
388 }
389
390 case TOUCH_HOLD:
391 case TOUCH_REPEAT:
392
Dees_Troy30b962e2012-10-19 20:48:59 -0400393 if (startSelection == 0 || GetSelection(x, y) == -1) {
394 if (highlightRenderCount != 0) {
395 highlightRenderCount = 0;
396 mRendered = false;
397 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400398 return 0;
Dees_Troy30b962e2012-10-19 20:48:59 -0400399 } else if (highlightRenderCount != 0) {
400 if (state == TOUCH_RELEASE)
401 highlightRenderCount = 2;
402 else
403 highlightRenderCount = -1;
404 mRendered = false;
405 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400406
407 // Find the correct row
408 for (indexy=0; indexy<MAX_KEYBOARD_ROWS; indexy++) {
409 if (row_heights[currentLayout - 1][indexy] > rely) {
410 rowIndex = indexy;
411 indexy = MAX_KEYBOARD_ROWS;
412 }
413 }
414
415 // Find the correct key (column)
416 for (indexx=0; indexx<MAX_KEYBOARD_KEYS; indexx++) {
that1a7ba972015-02-01 19:48:19 +0100417 keyboard_key_class& key = keyboard_keys[currentLayout - 1][rowIndex][indexx];
418 if (key.end_x > relx) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400419 // This is the key that was pressed!
that1a7ba972015-02-01 19:48:19 +0100420 if (key.key != initial_key) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400421 // We dragged off of the starting key
422 startSelection = 0;
423 break;
424 } else if (state == TOUCH_RELEASE && was_held == 0) {
Ethan Yonker03db3262014-02-05 08:02:06 -0600425 DataManager::Vibrate("tw_keyboard_vibrate");
that1a7ba972015-02-01 19:48:19 +0100426 if ((int)key.key < KEYBOARD_SPECIAL_KEYS && (int)key.key > 0) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400427 // Regular key
that1a7ba972015-02-01 19:48:19 +0100428 PageManager::NotifyKeyboard(key.key);
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600429 if (caps_tracking[currentLayout - 1].capslock == 0 && !caps_tracking[currentLayout - 1].set_capslock) {
430 // caps lock was not set, change layouts
431 currentLayout = caps_tracking[currentLayout - 1].revert_layout;
432 mRendered = false;
433 }
that1a7ba972015-02-01 19:48:19 +0100434 } else if ((int)key.key == KEYBOARD_LAYOUT) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400435 // Switch layouts
that1a7ba972015-02-01 19:48:19 +0100436 if (caps_tracking[currentLayout - 1].capslock == 0 && key.layout == caps_tracking[currentLayout - 1].revert_layout) {
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600437 if (!caps_tracking[currentLayout - 1].set_capslock) {
438 caps_tracking[currentLayout - 1].set_capslock = 1; // Set the caps lock
439 } else {
440 caps_tracking[currentLayout - 1].set_capslock = 0; // Unset the caps lock and change layouts
that1a7ba972015-02-01 19:48:19 +0100441 currentLayout = key.layout;
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600442 }
443 } else {
that1a7ba972015-02-01 19:48:19 +0100444 currentLayout = key.layout;
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600445 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400446 mRendered = false;
that1a7ba972015-02-01 19:48:19 +0100447 } else if ((int)key.key == KEYBOARD_ACTION) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400448 // Action
Dees_Troy30b962e2012-10-19 20:48:59 -0400449 highlightRenderCount = 0;
that6db855e2015-03-14 21:31:43 +0100450 // Send action notification
451 PageManager::NotifyKeyboard(key.key);
Dees_Troy51a0e822012-09-05 15:24:24 -0400452 }
453 } else if (state == TOUCH_HOLD) {
454 was_held = 1;
that1a7ba972015-02-01 19:48:19 +0100455 if ((int)key.key == KEYBOARD_BACKSPACE) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400456 // Repeat backspace
that1a7ba972015-02-01 19:48:19 +0100457 PageManager::NotifyKeyboard(key.key);
458 } else if ((int)key.longpresskey < KEYBOARD_SPECIAL_KEYS && (int)key.longpresskey > 0) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400459 // Long Press Key
Ethan Yonker03db3262014-02-05 08:02:06 -0600460 DataManager::Vibrate("tw_keyboard_vibrate");
that1a7ba972015-02-01 19:48:19 +0100461 PageManager::NotifyKeyboard(key.longpresskey);
Dees_Troy51a0e822012-09-05 15:24:24 -0400462 }
463 } else if (state == TOUCH_REPEAT) {
464 was_held = 1;
that1a7ba972015-02-01 19:48:19 +0100465 if ((int)key.key == KEYBOARD_BACKSPACE) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400466 // Repeat backspace
that1a7ba972015-02-01 19:48:19 +0100467 PageManager::NotifyKeyboard(key.key);
Dees_Troy51a0e822012-09-05 15:24:24 -0400468 }
469 }
470 indexx = MAX_KEYBOARD_KEYS;
471 }
472 }
473 break;
474 }
475
476 return 0;
477}