blob: d0262aac281b58933741dda4a77ec47f6dfa49b1 [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 Yonker21ff02a2015-02-18 14:35:00 -060051 highlightRenderCount = 0;
52 hasHighlight = hasCapsHighlight = false;
Dees_Troy3a16cb52013-01-10 15:16:02 +000053 char resource[10], layout[8], row[5], key[6], longpress[7];
Dees_Troy51a0e822012-09-05 15:24:24 -040054 xml_attribute<>* attr;
55 xml_node<>* child;
56 xml_node<>* keylayout;
57 xml_node<>* keyrow;
58
59 for (layoutindex=0; layoutindex<MAX_KEYBOARD_LAYOUTS; layoutindex++)
60 keyboardImg[layoutindex] = NULL;
61
62 mRendered = false;
63 currentLayout = 1;
64 mAction = NULL;
that1a7ba972015-02-01 19:48:19 +010065 KeyboardHeight = KeyboardWidth = 0;
Dees_Troy51a0e822012-09-05 15:24:24 -040066
67 if (!node) return;
68
69 // Load the action
Ethan Yonker21ff02a2015-02-18 14:35:00 -060070 child = FindNode(node, "action");
Dees_Troy51a0e822012-09-05 15:24:24 -040071 if (child)
72 {
73 mAction = new GUIAction(node);
74 }
75
Ethan Yonker21ff02a2015-02-18 14:35:00 -060076 mHighlightColor = LoadAttrColor(FindNode(node, "highlight"), "color", &hasHighlight);
77 mCapsHighlightColor = LoadAttrColor(FindNode(node, "capshighlight"), "color", &hasCapsHighlight);
Ethan Yonkerc3120d42014-02-17 07:55:00 -060078
Dees_Troy51a0e822012-09-05 15:24:24 -040079 // Load the images for the different layouts
Ethan Yonker21ff02a2015-02-18 14:35:00 -060080 child = FindNode(node, "layout");
Dees_Troy51a0e822012-09-05 15:24:24 -040081 if (child)
82 {
83 layoutindex = 1;
84 strcpy(resource, "resource1");
85 attr = child->first_attribute(resource);
86 while (attr && layoutindex < (MAX_KEYBOARD_LAYOUTS + 1)) {
thatf6ed8fc2015-02-14 20:23:16 +010087 keyboardImg[layoutindex - 1] = LoadAttrImage(child, resource);
Dees_Troy51a0e822012-09-05 15:24:24 -040088
89 layoutindex++;
90 resource[8] = (char)(layoutindex + 48);
91 attr = child->first_attribute(resource);
92 }
93 }
94
95 // Check the first image to get height and width
96 if (keyboardImg[0] && keyboardImg[0]->GetResource())
97 {
thatf6ed8fc2015-02-14 20:23:16 +010098 KeyboardWidth = keyboardImg[0]->GetWidth();
99 KeyboardHeight = keyboardImg[0]->GetHeight();
Dees_Troy51a0e822012-09-05 15:24:24 -0400100 }
101
102 // Load all of the layout maps
103 layoutindex = 1;
104 strcpy(layout, "layout1");
Ethan Yonker21ff02a2015-02-18 14:35:00 -0600105 keylayout = FindNode(node, layout);
Dees_Troy51a0e822012-09-05 15:24:24 -0400106 while (keylayout)
107 {
108 if (layoutindex > MAX_KEYBOARD_LAYOUTS) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000109 LOGERR("Too many layouts defined in keyboard.\n");
Dees_Troy51a0e822012-09-05 15:24:24 -0400110 return;
111 }
112
113 child = keylayout->first_node("keysize");
114 if (child) {
115 attr = child->first_attribute("height");
116 if (attr)
Ethan Yonker63e414f2015-02-06 15:44:39 -0600117 keyHeight = scale_theme_y(atoi(attr->value()));
Dees_Troy51a0e822012-09-05 15:24:24 -0400118 else
119 keyHeight = 0;
120 attr = child->first_attribute("width");
121 if (attr)
Ethan Yonker63e414f2015-02-06 15:44:39 -0600122 keyWidth = scale_theme_x(atoi(attr->value()));
Dees_Troy51a0e822012-09-05 15:24:24 -0400123 else
124 keyWidth = 0;
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600125 attr = child->first_attribute("capslock");
126 if (attr)
127 caps_tracking[layoutindex - 1].capslock = atoi(attr->value());
128 else
129 caps_tracking[layoutindex - 1].capslock = 1;
130 attr = child->first_attribute("revert_layout");
131 if (attr)
132 caps_tracking[layoutindex - 1].revert_layout = atoi(attr->value());
133 else
134 caps_tracking[layoutindex - 1].revert_layout = -1;
Dees_Troy51a0e822012-09-05 15:24:24 -0400135 }
136
137 rowindex = 1;
138 Yindex = 0;
139 strcpy(row, "row1");
140 keyrow = keylayout->first_node(row);
141 while (keyrow)
142 {
143 if (rowindex > MAX_KEYBOARD_ROWS) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000144 LOGERR("Too many rows defined in keyboard.\n");
Dees_Troy51a0e822012-09-05 15:24:24 -0400145 return;
146 }
147
148 Yindex += keyHeight;
149 row_heights[layoutindex - 1][rowindex - 1] = Yindex;
150
151 keyindex = 1;
152 Xindex = 0;
153 strcpy(key, "key01");
154 attr = keyrow->first_attribute(key);
155
156 while (attr) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400157 if (keyindex > MAX_KEYBOARD_KEYS) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000158 LOGERR("Too many keys defined in a keyboard row.\n");
Dees_Troy51a0e822012-09-05 15:24:24 -0400159 return;
160 }
161
that1a7ba972015-02-01 19:48:19 +0100162 const char* keyinfo = attr->value();
Dees_Troy51a0e822012-09-05 15:24:24 -0400163
164 if (strlen(keyinfo) == 0) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000165 LOGERR("No key info on layout%i, row%i, key%dd.\n", layoutindex, rowindex, keyindex);
Dees_Troy51a0e822012-09-05 15:24:24 -0400166 return;
167 }
168
that1a7ba972015-02-01 19:48:19 +0100169 if (ParseKey(keyinfo, keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1], Xindex, keyWidth, false))
170 LOGERR("Invalid key info on layout%i, row%i, key%02i.\n", layoutindex, rowindex, keyindex);
Dees_Troy51a0e822012-09-05 15:24:24 -0400171
Dees_Troy51a0e822012-09-05 15:24:24 -0400172
173 // PROCESS LONG PRESS INFO IF EXISTS
174 sprintf(longpress, "long%02i", keyindex);
175 attr = keyrow->first_attribute(longpress);
176 if (attr) {
that1a7ba972015-02-01 19:48:19 +0100177 const char* keyinfo = attr->value();
Dees_Troy51a0e822012-09-05 15:24:24 -0400178
179 if (strlen(keyinfo) == 0) {
Dees_Troy2673cec2013-04-02 20:22:16 +0000180 LOGERR("No long press info on layout%i, row%i, long%dd.\n", layoutindex, rowindex, keyindex);
Dees_Troy51a0e822012-09-05 15:24:24 -0400181 return;
182 }
183
that1a7ba972015-02-01 19:48:19 +0100184 if (ParseKey(keyinfo, keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1], Xindex, keyWidth, true))
185 LOGERR("Invalid long press key info on layout%i, row%i, long%02i.\n", layoutindex, rowindex, keyindex);
Dees_Troy51a0e822012-09-05 15:24:24 -0400186 }
187 keyindex++;
188 sprintf(key, "key%02i", keyindex);
189 attr = keyrow->first_attribute(key);
190 }
191 rowindex++;
192 row[3] = (char)(rowindex + 48);
193 keyrow = keylayout->first_node(row);
194 }
195 layoutindex++;
196 layout[6] = (char)(layoutindex + 48);
Ethan Yonker21ff02a2015-02-18 14:35:00 -0600197 keylayout = FindNode(node, layout);
Dees_Troy51a0e822012-09-05 15:24:24 -0400198 }
199
200 int x, y, w, h;
201 // Load the placement
Ethan Yonker21ff02a2015-02-18 14:35:00 -0600202 LoadPlacement(FindNode(node, "placement"), &x, &y, &w, &h);
Dees_Troy51a0e822012-09-05 15:24:24 -0400203 SetActionPos(x, y, KeyboardWidth, KeyboardHeight);
204 SetRenderPos(x, y, w, h);
205 return;
206}
207
208GUIKeyboard::~GUIKeyboard()
209{
that1a7ba972015-02-01 19:48:19 +0100210}
Dees_Troy51a0e822012-09-05 15:24:24 -0400211
that1a7ba972015-02-01 19:48:19 +0100212int GUIKeyboard::ParseKey(const char* keyinfo, keyboard_key_class& key, int& Xindex, int keyWidth, bool longpress)
213{
214 int keychar = 0;
215 if (strlen(keyinfo) == 1) {
216 // This is a single key, simple definition
217 keychar = keyinfo[0];
218 } else {
219 // This key has extra data: {keywidth}:{what_the_key_does}
Ethan Yonker63e414f2015-02-06 15:44:39 -0600220 keyWidth = scale_theme_x(atoi(keyinfo));
that1a7ba972015-02-01 19:48:19 +0100221
222 const char* ptr = keyinfo;
223 while (*ptr > 32 && *ptr != ':')
224 ptr++;
225 if (*ptr != ':')
226 return -1; // no colon is an error
227 ptr++;
228
229 if (*ptr == 0) { // This is an empty area
230 keychar = 0;
231 } else if (strlen(ptr) == 1) { // This is the character that this key uses
232 keychar = *ptr;
233 } else if (*ptr == 'c') { // This is an ASCII character code: "c:{number}"
234 keychar = atoi(ptr + 2);
235 } else if (*ptr == 'l') { // This is a different layout: "layout{number}"
236 keychar = KEYBOARD_LAYOUT;
237 key.layout = atoi(ptr + 6);
238 } else if (*ptr == 'a') { // This is an action: "action"
239 keychar = KEYBOARD_ACTION;
240 } else
241 return -1;
242 }
243
244 if (longpress) {
245 key.longpresskey = keychar;
246 } else {
247 key.key = keychar;
248 Xindex += keyWidth;
249 key.end_x = Xindex - 1;
250 }
251
252 return 0;
Dees_Troy51a0e822012-09-05 15:24:24 -0400253}
254
255int GUIKeyboard::Render(void)
256{
257 if (!isConditionTrue())
258 {
259 mRendered = false;
260 return 0;
261 }
262
263 int ret = 0;
264
265 if (keyboardImg[currentLayout - 1] && keyboardImg[currentLayout - 1]->GetResource())
266 gr_blit(keyboardImg[currentLayout - 1]->GetResource(), 0, 0, KeyboardWidth, KeyboardHeight, mRenderX, mRenderY);
267
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600268 // Draw highlight for capslock
269 if (hasCapsHighlight && caps_tracking[currentLayout - 1].capslock == 0 && caps_tracking[currentLayout - 1].set_capslock) {
270 int boxheight, boxwidth, x;
271 gr_color(mCapsHighlightColor.red, mCapsHighlightColor.green, mCapsHighlightColor.blue, mCapsHighlightColor.alpha);
272 for (int indexy=0; indexy<MAX_KEYBOARD_ROWS; indexy++) {
273 for (int indexx=0; indexx<MAX_KEYBOARD_KEYS; indexx++) {
274 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) {
275 if (indexy == 0)
276 boxheight = row_heights[currentLayout - 1][indexy];
277 else
278 boxheight = row_heights[currentLayout - 1][indexy] - row_heights[currentLayout - 1][indexy - 1];
279 if (indexx == 0) {
280 x = mRenderX;
281 boxwidth = keyboard_keys[currentLayout - 1][indexy][indexx].end_x;
282 } else {
283 x = mRenderX + keyboard_keys[currentLayout - 1][indexy][indexx - 1].end_x;
284 boxwidth = keyboard_keys[currentLayout - 1][indexy][indexx].end_x - keyboard_keys[currentLayout - 1][indexy][indexx - 1].end_x;
285 }
286 gr_fill(x, mRenderY + row_heights[currentLayout - 1][indexy - 1], boxwidth, boxheight);
287 }
288 }
289 }
290 }
291
Dees_Troy30b962e2012-10-19 20:48:59 -0400292 if (hasHighlight && highlightRenderCount != 0) {
293 int boxheight, boxwidth, x;
294 if (rowY == 0)
295 boxheight = row_heights[currentLayout - 1][rowY];
296 else
297 boxheight = row_heights[currentLayout - 1][rowY] - row_heights[currentLayout - 1][rowY - 1];
298 if (colX == 0) {
299 x = mRenderX;
300 boxwidth = keyboard_keys[currentLayout - 1][rowY][colX].end_x;
301 } else {
302 x = mRenderX + keyboard_keys[currentLayout - 1][rowY][colX - 1].end_x;
303 boxwidth = keyboard_keys[currentLayout - 1][rowY][colX].end_x - keyboard_keys[currentLayout - 1][rowY][colX - 1].end_x;
304 }
305 gr_color(mHighlightColor.red, mHighlightColor.green, mHighlightColor.blue, mHighlightColor.alpha);
306 gr_fill(x, mRenderY + row_heights[currentLayout - 1][rowY - 1], boxwidth, boxheight);
307 if (highlightRenderCount > 0)
308 highlightRenderCount--;
309 } else
310 mRendered = true;
311
Dees_Troy51a0e822012-09-05 15:24:24 -0400312 return ret;
313}
314
315int GUIKeyboard::Update(void)
316{
317 if (!isConditionTrue()) return (mRendered ? 2 : 0);
318 if (!mRendered) return 2;
319
320 return 0;
321}
322
323int GUIKeyboard::SetRenderPos(int x, int y, int w, int h)
324{
325 mRenderX = x;
326 mRenderY = y;
327 if (w || h)
328 {
329 mRenderW = KeyboardWidth;
330 mRenderH = KeyboardHeight;
331 }
332
333 if (mAction) mAction->SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH);
334 SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH);
335 return 0;
336}
337
338int GUIKeyboard::GetSelection(int x, int y)
339{
Dees_Troy30b962e2012-10-19 20:48:59 -0400340 if (x < mRenderX || x - mRenderX > (int)KeyboardWidth || y < mRenderY || y - mRenderY > (int)KeyboardHeight) return -1;
Dees_Troy51a0e822012-09-05 15:24:24 -0400341 return 0;
342}
343
344int GUIKeyboard::NotifyTouch(TOUCH_STATE state, int x, int y)
345{
346 static int startSelection = -1, was_held = 0, startX = 0;
347 static unsigned char initial_key = 0;
that1a7ba972015-02-01 19:48:19 +0100348 int indexy, indexx, rely, relx, rowIndex = 0;
Dees_Troy51a0e822012-09-05 15:24:24 -0400349
350 rely = y - mRenderY;
351 relx = x - mRenderX;
352
353 if (!isConditionTrue()) return -1;
354
355 switch (state)
356 {
357 case TOUCH_START:
358 if (GetSelection(x, y) == 0) {
359 startSelection = -1;
360 was_held = 0;
361 startX = x;
362 // Find the correct row
363 for (indexy=0; indexy<MAX_KEYBOARD_ROWS; indexy++) {
364 if (row_heights[currentLayout - 1][indexy] > rely) {
365 rowIndex = indexy;
Dees_Troy30b962e2012-10-19 20:48:59 -0400366 rowY = indexy;
Dees_Troy51a0e822012-09-05 15:24:24 -0400367 indexy = MAX_KEYBOARD_ROWS;
368 }
369 }
370
371 // Find the correct key (column)
372 for (indexx=0; indexx<MAX_KEYBOARD_KEYS; indexx++) {
373 if (keyboard_keys[currentLayout - 1][rowIndex][indexx].end_x > relx) {
374 // This is the key that was pressed!
375 initial_key = keyboard_keys[currentLayout - 1][rowIndex][indexx].key;
Dees_Troy30b962e2012-10-19 20:48:59 -0400376 colX = indexx;
Dees_Troy51a0e822012-09-05 15:24:24 -0400377 indexx = MAX_KEYBOARD_KEYS;
378 }
379 }
Dees_Troy30b962e2012-10-19 20:48:59 -0400380 if (initial_key != 0)
381 highlightRenderCount = -1;
382 else
383 highlightRenderCount = 0;
384 mRendered = false;
Dees_Troy51a0e822012-09-05 15:24:24 -0400385 } else {
Dees_Troy30b962e2012-10-19 20:48:59 -0400386 if (highlightRenderCount != 0)
387 mRendered = false;
388 highlightRenderCount = 0;
Dees_Troy51a0e822012-09-05 15:24:24 -0400389 startSelection = 0;
390 }
391 break;
392 case TOUCH_DRAG:
393 break;
394 case TOUCH_RELEASE:
Dees_Troy0cb64e52012-10-15 15:56:10 -0400395 if (x < startX - (KeyboardWidth * 0.5)) {
Dees_Troy30b962e2012-10-19 20:48:59 -0400396 if (highlightRenderCount != 0) {
397 highlightRenderCount = 0;
398 mRendered = false;
399 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400400 PageManager::NotifyKeyboard(KEYBOARD_SWIPE_LEFT);
401 return 0;
Dees_Troy0cb64e52012-10-15 15:56:10 -0400402 } else if (x > startX + (KeyboardWidth * 0.5)) {
Dees_Troy30b962e2012-10-19 20:48:59 -0400403 if (highlightRenderCount != 0) {
404 highlightRenderCount = 0;
405 mRendered = false;
406 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400407 PageManager::NotifyKeyboard(KEYBOARD_SWIPE_RIGHT);
408 return 0;
409 }
410
411 case TOUCH_HOLD:
412 case TOUCH_REPEAT:
413
Dees_Troy30b962e2012-10-19 20:48:59 -0400414 if (startSelection == 0 || GetSelection(x, y) == -1) {
415 if (highlightRenderCount != 0) {
416 highlightRenderCount = 0;
417 mRendered = false;
418 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400419 return 0;
Dees_Troy30b962e2012-10-19 20:48:59 -0400420 } else if (highlightRenderCount != 0) {
421 if (state == TOUCH_RELEASE)
422 highlightRenderCount = 2;
423 else
424 highlightRenderCount = -1;
425 mRendered = false;
426 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400427
428 // Find the correct row
429 for (indexy=0; indexy<MAX_KEYBOARD_ROWS; indexy++) {
430 if (row_heights[currentLayout - 1][indexy] > rely) {
431 rowIndex = indexy;
432 indexy = MAX_KEYBOARD_ROWS;
433 }
434 }
435
436 // Find the correct key (column)
437 for (indexx=0; indexx<MAX_KEYBOARD_KEYS; indexx++) {
that1a7ba972015-02-01 19:48:19 +0100438 keyboard_key_class& key = keyboard_keys[currentLayout - 1][rowIndex][indexx];
439 if (key.end_x > relx) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400440 // This is the key that was pressed!
that1a7ba972015-02-01 19:48:19 +0100441 if (key.key != initial_key) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400442 // We dragged off of the starting key
443 startSelection = 0;
444 break;
445 } else if (state == TOUCH_RELEASE && was_held == 0) {
Ethan Yonker03db3262014-02-05 08:02:06 -0600446 DataManager::Vibrate("tw_keyboard_vibrate");
that1a7ba972015-02-01 19:48:19 +0100447 if ((int)key.key < KEYBOARD_SPECIAL_KEYS && (int)key.key > 0) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400448 // Regular key
that1a7ba972015-02-01 19:48:19 +0100449 PageManager::NotifyKeyboard(key.key);
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600450 if (caps_tracking[currentLayout - 1].capslock == 0 && !caps_tracking[currentLayout - 1].set_capslock) {
451 // caps lock was not set, change layouts
452 currentLayout = caps_tracking[currentLayout - 1].revert_layout;
453 mRendered = false;
454 }
that1a7ba972015-02-01 19:48:19 +0100455 } else if ((int)key.key == KEYBOARD_LAYOUT) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400456 // Switch layouts
that1a7ba972015-02-01 19:48:19 +0100457 if (caps_tracking[currentLayout - 1].capslock == 0 && key.layout == caps_tracking[currentLayout - 1].revert_layout) {
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600458 if (!caps_tracking[currentLayout - 1].set_capslock) {
459 caps_tracking[currentLayout - 1].set_capslock = 1; // Set the caps lock
460 } else {
461 caps_tracking[currentLayout - 1].set_capslock = 0; // Unset the caps lock and change layouts
that1a7ba972015-02-01 19:48:19 +0100462 currentLayout = key.layout;
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600463 }
464 } else {
that1a7ba972015-02-01 19:48:19 +0100465 currentLayout = key.layout;
Ethan Yonkerc3120d42014-02-17 07:55:00 -0600466 }
Dees_Troy51a0e822012-09-05 15:24:24 -0400467 mRendered = false;
that1a7ba972015-02-01 19:48:19 +0100468 } else if ((int)key.key == KEYBOARD_ACTION) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400469 // Action
Dees_Troy30b962e2012-10-19 20:48:59 -0400470 highlightRenderCount = 0;
Dees_Troy51a0e822012-09-05 15:24:24 -0400471 if (mAction) {
472 // Keyboard has its own action defined
473 return (mAction ? mAction->NotifyTouch(state, x, y) : 1);
474 } else {
475 // Send action notification
that1a7ba972015-02-01 19:48:19 +0100476 PageManager::NotifyKeyboard(key.key);
Dees_Troy51a0e822012-09-05 15:24:24 -0400477 }
478 }
479 } else if (state == TOUCH_HOLD) {
480 was_held = 1;
that1a7ba972015-02-01 19:48:19 +0100481 if ((int)key.key == KEYBOARD_BACKSPACE) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400482 // Repeat backspace
that1a7ba972015-02-01 19:48:19 +0100483 PageManager::NotifyKeyboard(key.key);
484 } else if ((int)key.longpresskey < KEYBOARD_SPECIAL_KEYS && (int)key.longpresskey > 0) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400485 // Long Press Key
Ethan Yonker03db3262014-02-05 08:02:06 -0600486 DataManager::Vibrate("tw_keyboard_vibrate");
that1a7ba972015-02-01 19:48:19 +0100487 PageManager::NotifyKeyboard(key.longpresskey);
Dees_Troy51a0e822012-09-05 15:24:24 -0400488 }
489 } else if (state == TOUCH_REPEAT) {
490 was_held = 1;
that1a7ba972015-02-01 19:48:19 +0100491 if ((int)key.key == KEYBOARD_BACKSPACE) {
Dees_Troy51a0e822012-09-05 15:24:24 -0400492 // Repeat backspace
that1a7ba972015-02-01 19:48:19 +0100493 PageManager::NotifyKeyboard(key.key);
Dees_Troy51a0e822012-09-05 15:24:24 -0400494 }
495 }
496 indexx = MAX_KEYBOARD_KEYS;
497 }
498 }
499 break;
500 }
501
502 return 0;
503}