Dees Troy | 3be70a8 | 2013-10-22 14:25:12 +0000 | [diff] [blame] | 1 | /* |
| 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_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 18 | |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 19 | #include <linux/input.h> |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 20 | #include <stdlib.h> |
| 21 | #include <string.h> |
Samer Diab (S.a.M.e.R_d) | 71e9b04 | 2014-01-07 20:18:47 +0000 | [diff] [blame] | 22 | #include "../data.hpp" |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 23 | |
| 24 | #include <string> |
| 25 | |
| 26 | extern "C" { |
Dees_Troy | 2673cec | 2013-04-02 20:22:16 +0000 | [diff] [blame] | 27 | #include "../twcommon.h" |
Ethan Yonker | 63e414f | 2015-02-06 15:44:39 -0600 | [diff] [blame] | 28 | #include "gui.h" |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 29 | } |
Ethan Yonker | fbb4353 | 2015-12-28 21:54:50 +0100 | [diff] [blame] | 30 | #include "../minuitwrp/minui.h" |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 31 | |
| 32 | #include "rapidxml.hpp" |
| 33 | #include "objects.hpp" |
| 34 | |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 35 | bool GUIKeyboard::CtrlActive = false; |
| 36 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 37 | GUIKeyboard::GUIKeyboard(xml_node<>* node) |
Vojtech Bocek | ede51c5 | 2014-02-07 23:58:09 +0100 | [diff] [blame] | 38 | : GUIObject(node) |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 39 | { |
| 40 | int layoutindex, rowindex, keyindex, Xindex, Yindex, keyHeight = 0, keyWidth = 0; |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 41 | currentKey = NULL; |
Ethan Yonker | 21ff02a | 2015-02-18 14:35:00 -0600 | [diff] [blame] | 42 | highlightRenderCount = 0; |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 43 | hasHighlight = hasCapsHighlight = hasCtrlHighlight = false; |
Dees_Troy | 3a16cb5 | 2013-01-10 15:16:02 +0000 | [diff] [blame] | 44 | char resource[10], layout[8], row[5], key[6], longpress[7]; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 45 | xml_attribute<>* attr; |
| 46 | xml_node<>* child; |
| 47 | xml_node<>* keylayout; |
| 48 | xml_node<>* keyrow; |
| 49 | |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 50 | for (layoutindex=0; layoutindex<MAX_KEYBOARD_LAYOUTS; layoutindex++) { |
| 51 | layouts[layoutindex].keyboardImg = NULL; |
| 52 | memset(layouts[layoutindex].keys, 0, sizeof(Layout::keys)); |
| 53 | memset(layouts[layoutindex].row_end_y, 0, sizeof(Layout::row_end_y)); |
| 54 | } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 55 | |
| 56 | mRendered = false; |
| 57 | currentLayout = 1; |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 58 | CapsLockOn = false; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 59 | |
| 60 | if (!node) return; |
| 61 | |
Ethan Yonker | 21ff02a | 2015-02-18 14:35:00 -0600 | [diff] [blame] | 62 | mHighlightColor = LoadAttrColor(FindNode(node, "highlight"), "color", &hasHighlight); |
| 63 | mCapsHighlightColor = LoadAttrColor(FindNode(node, "capshighlight"), "color", &hasCapsHighlight); |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 64 | mCtrlHighlightColor = LoadAttrColor(FindNode(node, "ctrlhighlight"), "color", &hasCtrlHighlight); |
Ethan Yonker | c3120d4 | 2014-02-17 07:55:00 -0600 | [diff] [blame] | 65 | |
that | f256b72 | 2015-05-23 20:44:12 +0200 | [diff] [blame] | 66 | child = FindNode(node, "keymargin"); |
| 67 | mKeyMarginX = LoadAttrIntScaleX(child, "x", 0); |
| 68 | mKeyMarginY = LoadAttrIntScaleY(child, "y", 0); |
| 69 | |
| 70 | child = FindNode(node, "background"); |
| 71 | mBackgroundColor = LoadAttrColor(child, "color", COLOR(32,32,32,255)); |
| 72 | |
| 73 | child = FindNode(node, "key-alphanumeric"); |
| 74 | mFont = PageManager::GetResources()->FindFont(LoadAttrString(child, "font", "keylabel")); |
| 75 | mFontColor = LoadAttrColor(child, "textcolor", COLOR(255,255,255,255)); |
| 76 | mKeyColorAlphanumeric = LoadAttrColor(child, "color", COLOR(0,0,0,0)); |
| 77 | |
| 78 | child = FindNode(node, "key-other"); |
| 79 | mSmallFont = PageManager::GetResources()->FindFont(LoadAttrString(child, "font", "keylabel-small")); |
| 80 | mFontColorSmall = LoadAttrColor(child, "textcolor", COLOR(192,192,192,255)); |
| 81 | mKeyColorOther = LoadAttrColor(child, "color", COLOR(0,0,0,0)); |
| 82 | |
| 83 | child = FindNode(node, "longpress"); |
| 84 | mLongpressFont = PageManager::GetResources()->FindFont(LoadAttrString(child, "font", "keylabel-longpress")); |
| 85 | mLongpressFontColor = LoadAttrColor(child, "textcolor", COLOR(128,128,128,255)); |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 86 | LoadPlacement(child, &longpressOffsetX, &longpressOffsetY); |
that | f256b72 | 2015-05-23 20:44:12 +0200 | [diff] [blame] | 87 | |
| 88 | LoadKeyLabels(node, 0); // load global key labels |
| 89 | |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 90 | // compatibility ugliness: resources should be specified in the layouts themselves instead |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 91 | // Load the images for the different layouts |
Ethan Yonker | 21ff02a | 2015-02-18 14:35:00 -0600 | [diff] [blame] | 92 | child = FindNode(node, "layout"); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 93 | if (child) |
| 94 | { |
| 95 | layoutindex = 1; |
| 96 | strcpy(resource, "resource1"); |
| 97 | attr = child->first_attribute(resource); |
| 98 | while (attr && layoutindex < (MAX_KEYBOARD_LAYOUTS + 1)) { |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 99 | layouts[layoutindex - 1].keyboardImg = LoadAttrImage(child, resource); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 100 | |
| 101 | layoutindex++; |
| 102 | resource[8] = (char)(layoutindex + 48); |
| 103 | attr = child->first_attribute(resource); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | // Check the first image to get height and width |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 108 | if (layouts[0].keyboardImg && layouts[0].keyboardImg->GetResource()) |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 109 | { |
that | f256b72 | 2015-05-23 20:44:12 +0200 | [diff] [blame] | 110 | mRenderW = layouts[0].keyboardImg->GetWidth(); |
| 111 | mRenderH = layouts[0].keyboardImg->GetHeight(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | // Load all of the layout maps |
| 115 | layoutindex = 1; |
| 116 | strcpy(layout, "layout1"); |
Ethan Yonker | 21ff02a | 2015-02-18 14:35:00 -0600 | [diff] [blame] | 117 | keylayout = FindNode(node, layout); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 118 | while (keylayout) |
| 119 | { |
| 120 | if (layoutindex > MAX_KEYBOARD_LAYOUTS) { |
Dees_Troy | 2673cec | 2013-04-02 20:22:16 +0000 | [diff] [blame] | 121 | LOGERR("Too many layouts defined in keyboard.\n"); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 122 | return; |
| 123 | } |
| 124 | |
that | f256b72 | 2015-05-23 20:44:12 +0200 | [diff] [blame] | 125 | LoadKeyLabels(keylayout, layoutindex); // load per-layout key labels |
| 126 | |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 127 | Layout& lay = layouts[layoutindex - 1]; |
| 128 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 129 | child = keylayout->first_node("keysize"); |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 130 | keyHeight = LoadAttrIntScaleY(child, "height", 0); |
| 131 | keyWidth = LoadAttrIntScaleX(child, "width", 0); |
| 132 | // compatibility ugliness: capslock="0" means that this is the caps layout. Also it has nothing to do with keysize. |
| 133 | lay.is_caps = (LoadAttrInt(child, "capslock", 1) == 0); |
| 134 | // compatibility ugliness: revert_layout has nothing to do with keysize. |
| 135 | lay.revert_layout = LoadAttrInt(child, "revert_layout", -1); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 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_Troy | 2673cec | 2013-04-02 20:22:16 +0000 | [diff] [blame] | 144 | LOGERR("Too many rows defined in keyboard.\n"); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 145 | return; |
| 146 | } |
| 147 | |
| 148 | Yindex += keyHeight; |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 149 | lay.row_end_y[rowindex - 1] = Yindex; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 150 | |
| 151 | keyindex = 1; |
| 152 | Xindex = 0; |
| 153 | strcpy(key, "key01"); |
| 154 | attr = keyrow->first_attribute(key); |
| 155 | |
| 156 | while (attr) { |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 157 | if (keyindex > MAX_KEYBOARD_KEYS) { |
Dees_Troy | 2673cec | 2013-04-02 20:22:16 +0000 | [diff] [blame] | 158 | LOGERR("Too many keys defined in a keyboard row.\n"); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 159 | return; |
| 160 | } |
| 161 | |
that | 1a7ba97 | 2015-02-01 19:48:19 +0100 | [diff] [blame] | 162 | const char* keyinfo = attr->value(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 163 | |
| 164 | if (strlen(keyinfo) == 0) { |
Dees_Troy | 2673cec | 2013-04-02 20:22:16 +0000 | [diff] [blame] | 165 | LOGERR("No key info on layout%i, row%i, key%dd.\n", layoutindex, rowindex, keyindex); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 166 | return; |
| 167 | } |
| 168 | |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 169 | if (ParseKey(keyinfo, lay.keys[rowindex - 1][keyindex - 1], Xindex, keyWidth, false)) |
that | 1a7ba97 | 2015-02-01 19:48:19 +0100 | [diff] [blame] | 170 | LOGERR("Invalid key info on layout%i, row%i, key%02i.\n", layoutindex, rowindex, keyindex); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 171 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 172 | |
| 173 | // PROCESS LONG PRESS INFO IF EXISTS |
| 174 | sprintf(longpress, "long%02i", keyindex); |
| 175 | attr = keyrow->first_attribute(longpress); |
| 176 | if (attr) { |
that | 1a7ba97 | 2015-02-01 19:48:19 +0100 | [diff] [blame] | 177 | const char* keyinfo = attr->value(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 178 | |
| 179 | if (strlen(keyinfo) == 0) { |
Dees_Troy | 2673cec | 2013-04-02 20:22:16 +0000 | [diff] [blame] | 180 | LOGERR("No long press info on layout%i, row%i, long%dd.\n", layoutindex, rowindex, keyindex); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 181 | return; |
| 182 | } |
| 183 | |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 184 | if (ParseKey(keyinfo, lay.keys[rowindex - 1][keyindex - 1], Xindex, keyWidth, true)) |
that | 1a7ba97 | 2015-02-01 19:48:19 +0100 | [diff] [blame] | 185 | LOGERR("Invalid long press key info on layout%i, row%i, long%02i.\n", layoutindex, rowindex, keyindex); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 186 | } |
| 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 Yonker | 21ff02a | 2015-02-18 14:35:00 -0600 | [diff] [blame] | 197 | keylayout = FindNode(node, layout); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 198 | } |
| 199 | |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 200 | int x, y; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 201 | // Load the placement |
that | f256b72 | 2015-05-23 20:44:12 +0200 | [diff] [blame] | 202 | LoadPlacement(FindNode(node, "placement"), &x, &y, &mRenderW, &mRenderH); |
| 203 | SetRenderPos(x, y, mRenderW, mRenderH); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 204 | return; |
| 205 | } |
| 206 | |
| 207 | GUIKeyboard::~GUIKeyboard() |
| 208 | { |
that | 1a7ba97 | 2015-02-01 19:48:19 +0100 | [diff] [blame] | 209 | } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 210 | |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 211 | int GUIKeyboard::ParseKey(const char* keyinfo, Key& key, int& Xindex, int keyWidth, bool longpress) |
that | 1a7ba97 | 2015-02-01 19:48:19 +0100 | [diff] [blame] | 212 | { |
that | f256b72 | 2015-05-23 20:44:12 +0200 | [diff] [blame] | 213 | key.layout = 0; |
that | 1a7ba97 | 2015-02-01 19:48:19 +0100 | [diff] [blame] | 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 Yonker | 63e414f | 2015-02-06 15:44:39 -0600 | [diff] [blame] | 220 | keyWidth = scale_theme_x(atoi(keyinfo)); |
that | 1a7ba97 | 2015-02-01 19:48:19 +0100 | [diff] [blame] | 221 | |
| 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); |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 235 | } else if (*ptr == 'k') { // This is a Linux keycode from input.h: "k:{number}" |
| 236 | keychar = -atoi(ptr + 2); |
that | 1a7ba97 | 2015-02-01 19:48:19 +0100 | [diff] [blame] | 237 | } else if (*ptr == 'l') { // This is a different layout: "layout{number}" |
that | 1a7ba97 | 2015-02-01 19:48:19 +0100 | [diff] [blame] | 238 | key.layout = atoi(ptr + 6); |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 239 | } else if (*ptr == 'a') { // This is an action: "action" (the Enter key) |
that | 1a7ba97 | 2015-02-01 19:48:19 +0100 | [diff] [blame] | 240 | keychar = KEYBOARD_ACTION; |
| 241 | } else |
| 242 | return -1; |
| 243 | } |
| 244 | |
| 245 | if (longpress) { |
| 246 | key.longpresskey = keychar; |
| 247 | } else { |
| 248 | key.key = keychar; |
| 249 | Xindex += keyWidth; |
| 250 | key.end_x = Xindex - 1; |
| 251 | } |
| 252 | |
| 253 | return 0; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 254 | } |
| 255 | |
that | f256b72 | 2015-05-23 20:44:12 +0200 | [diff] [blame] | 256 | void GUIKeyboard::LoadKeyLabels(xml_node<>* parent, int layout) |
| 257 | { |
| 258 | for (xml_node<>* child = parent->first_node(); child; child = child->next_sibling()) { |
| 259 | std::string name = child->name(); |
| 260 | if (name == "keylabel") { |
| 261 | std::string keydef = LoadAttrString(child, "key", ""); |
| 262 | Key tempkey; |
| 263 | int dummyX; |
| 264 | if (ParseKey(keydef.c_str(), tempkey, dummyX, 0, false) == 0) { |
| 265 | KeyLabel keylabel; |
| 266 | keylabel.key = tempkey.key; |
| 267 | keylabel.layout_from = layout; |
| 268 | keylabel.layout_to = tempkey.layout; |
| 269 | keylabel.text = LoadAttrString(child, "text", ""); |
| 270 | keylabel.image = LoadAttrImage(child, "resource"); |
| 271 | mKeyLabels.push_back(keylabel); |
| 272 | } else { |
| 273 | LOGERR("Ignoring invalid keylabel in layout %d: '%s'.\n", layout, keydef.c_str()); |
| 274 | } |
| 275 | } |
| 276 | } |
| 277 | } |
| 278 | |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 279 | void GUIKeyboard::DrawKey(Key& key, int keyX, int keyY, int keyW, int keyH) |
| 280 | { |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 281 | int keychar = key.key; |
| 282 | if (!keychar && !key.layout) |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 283 | return; |
| 284 | |
| 285 | // key background |
| 286 | COLOR& c = (keychar >= 32 && keychar < 127) ? mKeyColorAlphanumeric : mKeyColorOther; |
| 287 | gr_color(c.red, c.green, c.blue, c.alpha); |
| 288 | keyX += mKeyMarginX; |
| 289 | keyY += mKeyMarginY; |
| 290 | keyW -= mKeyMarginX * 2; |
| 291 | keyH -= mKeyMarginY * 2; |
| 292 | gr_fill(keyX, keyY, keyW, keyH); |
| 293 | |
| 294 | // key label |
| 295 | FontResource* labelFont = mFont; |
| 296 | string labelText; |
| 297 | ImageResource* labelImage = NULL; |
| 298 | if (keychar > 32 && keychar < 127) { |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 299 | // TODO: this will eventually need UTF-8 support |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 300 | labelText = (char) keychar; |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 301 | if (CtrlActive) { |
| 302 | int ctrlchar = KeyCharToCtrlChar(keychar); |
| 303 | if (ctrlchar != keychar) |
| 304 | labelText = std::string("^") + (char)(ctrlchar + 64); |
| 305 | } |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 306 | gr_color(mFontColor.red, mFontColor.green, mFontColor.blue, mFontColor.alpha); |
| 307 | } |
| 308 | else { |
| 309 | // search for a special key label |
| 310 | for (std::vector<KeyLabel>::iterator it = mKeyLabels.begin(); it != mKeyLabels.end(); ++it) { |
| 311 | if (it->layout_from > 0 && it->layout_from != currentLayout) |
| 312 | continue; // this label is for another layout |
| 313 | if (it->key == key.key && it->layout_to == key.layout) |
| 314 | { |
| 315 | // found a label |
| 316 | labelText = it->text; |
| 317 | labelImage = it->image; |
| 318 | break; |
| 319 | } |
| 320 | } |
| 321 | labelFont = mSmallFont; |
| 322 | gr_color(mFontColorSmall.red, mFontColorSmall.green, mFontColorSmall.blue, mFontColorSmall.alpha); |
| 323 | } |
| 324 | |
| 325 | if (labelImage) |
| 326 | { |
| 327 | int w = labelImage->GetWidth(); |
| 328 | int h = labelImage->GetHeight(); |
| 329 | int x = keyX + (keyW - w) / 2; |
| 330 | int y = keyY + (keyH - h) / 2; |
| 331 | gr_blit(labelImage->GetResource(), 0, 0, w, h, x, y); |
| 332 | } |
| 333 | else if (!labelText.empty()) |
| 334 | { |
| 335 | void* fontResource = labelFont->GetResource(); |
Ethan Yonker | fbb4353 | 2015-12-28 21:54:50 +0100 | [diff] [blame] | 336 | int textW = gr_ttf_measureEx(labelText.c_str(), fontResource); |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 337 | int textH = labelFont->GetHeight(); |
| 338 | int textX = keyX + (keyW - textW) / 2; |
| 339 | int textY = keyY + (keyH - textH) / 2; |
Ethan Yonker | b7a54a3 | 2015-10-05 10:16:27 -0500 | [diff] [blame] | 340 | gr_textEx_scaleW(textX, textY, labelText.c_str(), fontResource, keyW, TOP_LEFT, 0); |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | // longpress key label (only if font is defined) |
| 344 | keychar = key.longpresskey; |
| 345 | if (keychar > 32 && keychar < 127 && mLongpressFont->GetResource()) { |
| 346 | void* fontResource = mLongpressFont->GetResource(); |
| 347 | gr_color(mLongpressFontColor.red, mLongpressFontColor.green, mLongpressFontColor.blue, mLongpressFontColor.alpha); |
| 348 | string text(1, keychar); |
| 349 | int textH = mLongpressFont->GetHeight(); |
Ethan Yonker | fbb4353 | 2015-12-28 21:54:50 +0100 | [diff] [blame] | 350 | int textW = gr_ttf_measureEx(text.c_str(), fontResource); |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 351 | int textX = keyX + keyW - longpressOffsetX - textW; |
| 352 | int textY = keyY + longpressOffsetY; |
Ethan Yonker | b7a54a3 | 2015-10-05 10:16:27 -0500 | [diff] [blame] | 353 | gr_textEx_scaleW(textX, textY, text.c_str(), fontResource, keyW, TOP_LEFT, 0); |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 354 | } |
| 355 | } |
| 356 | |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 357 | int GUIKeyboard::KeyCharToCtrlChar(int key) |
| 358 | { |
| 359 | // convert upper and lower case to ctrl chars |
| 360 | // Ctrl+A to Ctrl+_ (we don't support entering null bytes) |
| 361 | if (key >= 65 && key <= 127 && key != 96) |
| 362 | return key & 0x1f; |
| 363 | return key; // pass on others (already ctrl chars, numbers, etc.) unchanged |
| 364 | } |
| 365 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 366 | int GUIKeyboard::Render(void) |
| 367 | { |
| 368 | if (!isConditionTrue()) |
| 369 | { |
| 370 | mRendered = false; |
| 371 | return 0; |
| 372 | } |
| 373 | |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 374 | Layout& lay = layouts[currentLayout - 1]; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 375 | |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 376 | bool drawKeys = false; |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 377 | if (lay.keyboardImg && lay.keyboardImg->GetResource()) |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 378 | // keyboard is image based |
that | f256b72 | 2015-05-23 20:44:12 +0200 | [diff] [blame] | 379 | gr_blit(lay.keyboardImg->GetResource(), 0, 0, mRenderW, mRenderH, mRenderX, mRenderY); |
| 380 | else { |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 381 | // keyboard is software drawn |
| 382 | // fill background |
that | f256b72 | 2015-05-23 20:44:12 +0200 | [diff] [blame] | 383 | gr_color(mBackgroundColor.red, mBackgroundColor.green, mBackgroundColor.blue, mBackgroundColor.alpha); |
| 384 | gr_fill(mRenderX, mRenderY, mRenderW, mRenderH); |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 385 | drawKeys = true; |
| 386 | } |
that | f256b72 | 2015-05-23 20:44:12 +0200 | [diff] [blame] | 387 | |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 388 | // draw keys |
| 389 | int y1 = 0; |
| 390 | for (int row = 0; row < MAX_KEYBOARD_ROWS; ++row) { |
| 391 | int rowY = mRenderY + y1; |
| 392 | int rowH = lay.row_end_y[row] - y1; |
| 393 | y1 = lay.row_end_y[row]; |
| 394 | int x1 = 0; |
| 395 | for (int col = 0; col < MAX_KEYBOARD_KEYS; ++col) { |
| 396 | Key& key = lay.keys[row][col]; |
| 397 | int keyY = rowY; |
| 398 | int keyH = rowH; |
| 399 | int keyX = mRenderX + x1; |
| 400 | int keyW = key.end_x - x1; |
| 401 | x1 = key.end_x; |
that | f256b72 | 2015-05-23 20:44:12 +0200 | [diff] [blame] | 402 | |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 403 | // Draw key for software drawn keyboard |
| 404 | if (drawKeys) |
| 405 | DrawKey(key, keyX, keyY, keyW, keyH); |
| 406 | |
| 407 | // Draw highlight for capslock |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 408 | if (hasCapsHighlight && lay.is_caps && CapsLockOn && key.layout > 0 && key.layout == lay.revert_layout) { |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 409 | gr_color(mCapsHighlightColor.red, mCapsHighlightColor.green, mCapsHighlightColor.blue, mCapsHighlightColor.alpha); |
that | f256b72 | 2015-05-23 20:44:12 +0200 | [diff] [blame] | 410 | gr_fill(keyX, keyY, keyW, keyH); |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 411 | } |
that | f256b72 | 2015-05-23 20:44:12 +0200 | [diff] [blame] | 412 | |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 413 | // Draw highlight for control |
| 414 | if (hasCtrlHighlight && key.key == -KEY_LEFTCTRL && CtrlActive) { |
| 415 | gr_color(mCtrlHighlightColor.red, mCtrlHighlightColor.green, mCtrlHighlightColor.blue, mCtrlHighlightColor.alpha); |
| 416 | gr_fill(keyX, keyY, keyW, keyH); |
| 417 | } |
| 418 | |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 419 | // Highlight current key |
| 420 | if (hasHighlight && &key == currentKey && highlightRenderCount != 0) { |
| 421 | gr_color(mHighlightColor.red, mHighlightColor.green, mHighlightColor.blue, mHighlightColor.alpha); |
| 422 | gr_fill(keyX, keyY, keyW, keyH); |
that | f256b72 | 2015-05-23 20:44:12 +0200 | [diff] [blame] | 423 | } |
| 424 | } |
| 425 | } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 426 | |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 427 | if (!hasHighlight || highlightRenderCount == 0) |
Dees_Troy | 30b962e | 2012-10-19 20:48:59 -0400 | [diff] [blame] | 428 | mRendered = true; |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 429 | else if (highlightRenderCount > 0) |
| 430 | highlightRenderCount--; |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 431 | return 0; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | int GUIKeyboard::Update(void) |
| 435 | { |
| 436 | if (!isConditionTrue()) return (mRendered ? 2 : 0); |
| 437 | if (!mRendered) return 2; |
| 438 | |
| 439 | return 0; |
| 440 | } |
| 441 | |
| 442 | int GUIKeyboard::SetRenderPos(int x, int y, int w, int h) |
| 443 | { |
that | f256b72 | 2015-05-23 20:44:12 +0200 | [diff] [blame] | 444 | RenderObject::SetRenderPos(x, y, w, h); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 445 | SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH); |
| 446 | return 0; |
| 447 | } |
| 448 | |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 449 | GUIKeyboard::Key* GUIKeyboard::HitTestKey(int x, int y) |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 450 | { |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 451 | if (!IsInRegion(x, y)) |
| 452 | return NULL; |
| 453 | |
| 454 | int rely = y - mRenderY; |
| 455 | int relx = x - mRenderX; |
| 456 | |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 457 | Layout& lay = layouts[currentLayout - 1]; |
| 458 | |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 459 | // Find the correct row |
| 460 | int row; |
| 461 | for (row = 0; row < MAX_KEYBOARD_ROWS; ++row) { |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 462 | if (lay.row_end_y[row] > rely) |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 463 | break; |
| 464 | } |
| 465 | if (row == MAX_KEYBOARD_ROWS) |
| 466 | return NULL; |
| 467 | |
| 468 | // Find the correct key (column) |
| 469 | int col; |
| 470 | int x1 = 0; |
| 471 | for (col = 0; col < MAX_KEYBOARD_KEYS; ++col) { |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 472 | Key& key = lay.keys[row][col]; |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 473 | if (x1 <= relx && relx < key.end_x && (key.key != 0 || key.layout != 0)) { |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 474 | // This is the key that was pressed! |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 475 | return &key; |
| 476 | } |
| 477 | x1 = key.end_x; |
| 478 | } |
| 479 | return NULL; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | int GUIKeyboard::NotifyTouch(TOUCH_STATE state, int x, int y) |
| 483 | { |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 484 | static int was_held = 0, startX = 0; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 485 | |
| 486 | if (!isConditionTrue()) return -1; |
| 487 | |
| 488 | switch (state) |
| 489 | { |
| 490 | case TOUCH_START: |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 491 | was_held = 0; |
| 492 | startX = x; |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 493 | currentKey = HitTestKey(x, y); |
| 494 | if (currentKey) |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 495 | highlightRenderCount = -1; |
| 496 | else |
Dees_Troy | 30b962e | 2012-10-19 20:48:59 -0400 | [diff] [blame] | 497 | highlightRenderCount = 0; |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 498 | mRendered = false; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 499 | break; |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 500 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 501 | case TOUCH_DRAG: |
| 502 | break; |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 503 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 504 | case TOUCH_RELEASE: |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 505 | // TODO: we might want to notify of key releases here |
that | f256b72 | 2015-05-23 20:44:12 +0200 | [diff] [blame] | 506 | if (x < startX - (mRenderW * 0.5)) { |
Dees_Troy | 30b962e | 2012-10-19 20:48:59 -0400 | [diff] [blame] | 507 | if (highlightRenderCount != 0) { |
| 508 | highlightRenderCount = 0; |
| 509 | mRendered = false; |
| 510 | } |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 511 | PageManager::NotifyCharInput(KEYBOARD_SWIPE_LEFT); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 512 | return 0; |
that | f256b72 | 2015-05-23 20:44:12 +0200 | [diff] [blame] | 513 | } else if (x > startX + (mRenderW * 0.5)) { |
Dees_Troy | 30b962e | 2012-10-19 20:48:59 -0400 | [diff] [blame] | 514 | if (highlightRenderCount != 0) { |
| 515 | highlightRenderCount = 0; |
| 516 | mRendered = false; |
| 517 | } |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 518 | PageManager::NotifyCharInput(KEYBOARD_SWIPE_RIGHT); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 519 | return 0; |
| 520 | } |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 521 | // fall through |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 522 | case TOUCH_HOLD: |
| 523 | case TOUCH_REPEAT: |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 524 | if (!currentKey) { |
Dees_Troy | 30b962e | 2012-10-19 20:48:59 -0400 | [diff] [blame] | 525 | if (highlightRenderCount != 0) { |
| 526 | highlightRenderCount = 0; |
| 527 | mRendered = false; |
| 528 | } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 529 | return 0; |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | if (highlightRenderCount != 0) { |
Dees_Troy | 30b962e | 2012-10-19 20:48:59 -0400 | [diff] [blame] | 533 | if (state == TOUCH_RELEASE) |
| 534 | highlightRenderCount = 2; |
| 535 | else |
| 536 | highlightRenderCount = -1; |
| 537 | mRendered = false; |
| 538 | } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 539 | |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 540 | if (HitTestKey(x, y) != currentKey) { |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 541 | // We dragged off of the starting key |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 542 | currentKey = NULL; |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 543 | if (highlightRenderCount != 0) { |
| 544 | highlightRenderCount = 0; |
| 545 | mRendered = false; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 546 | } |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 547 | return 0; |
| 548 | } else { |
that | f6b2066 | 2015-06-25 21:51:37 +0200 | [diff] [blame] | 549 | Key& key = *currentKey; |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 550 | bool repeatKey = false; |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 551 | Layout& lay = layouts[currentLayout - 1]; |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 552 | if (state == TOUCH_RELEASE && was_held == 0) { |
| 553 | DataManager::Vibrate("tw_keyboard_vibrate"); |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 554 | if (key.layout > 0) { |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 555 | // Switch layouts |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 556 | if (lay.is_caps && key.layout == lay.revert_layout && !CapsLockOn) { |
| 557 | CapsLockOn = true; // Set the caps lock |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 558 | } else { |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 559 | CapsLockOn = false; // Unset the caps lock and change layouts |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 560 | currentLayout = key.layout; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 561 | } |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 562 | mRendered = false; |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 563 | } else if (key.key == KEYBOARD_ACTION) { |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 564 | // Action |
| 565 | highlightRenderCount = 0; |
| 566 | // Send action notification |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 567 | PageManager::NotifyCharInput(key.key); |
| 568 | } else if (key.key == -KEY_LEFTCTRL) { |
| 569 | CtrlActive = !CtrlActive; // toggle Control key state |
| 570 | mRendered = false; // render Ctrl key highlight |
| 571 | } else if (key.key != 0) { |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 572 | // Regular key |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 573 | if (key.key > 0) { |
| 574 | // ASCII code or character |
| 575 | int keycode = key.key; |
| 576 | if (CtrlActive) { |
| 577 | CtrlActive = false; |
| 578 | mRendered = false; |
| 579 | keycode = KeyCharToCtrlChar(key.key); |
| 580 | } |
| 581 | PageManager::NotifyCharInput(keycode); |
| 582 | } else { |
| 583 | // Linux key code |
| 584 | PageManager::NotifyKey(-key.key, true); |
| 585 | PageManager::NotifyKey(-key.key, false); |
| 586 | } |
that | d86f49d | 2015-03-15 00:56:57 +0100 | [diff] [blame] | 587 | if (!CapsLockOn && lay.is_caps) { |
| 588 | // caps lock was not set, change layouts |
| 589 | currentLayout = lay.revert_layout; |
| 590 | mRendered = false; |
| 591 | } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 592 | } |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 593 | } else if (state == TOUCH_HOLD) { |
| 594 | was_held = 1; |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 595 | if (key.longpresskey > 0) { |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 596 | // Long Press Key |
| 597 | DataManager::Vibrate("tw_keyboard_vibrate"); |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 598 | PageManager::NotifyCharInput(key.longpresskey); |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 599 | } |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 600 | else |
| 601 | repeatKey = true; |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 602 | } else if (state == TOUCH_REPEAT) { |
| 603 | was_held = 1; |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 604 | repeatKey = true; |
| 605 | } |
| 606 | if (repeatKey) { |
| 607 | if (key.key == KEYBOARD_BACKSPACE) { |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 608 | // Repeat backspace |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 609 | PageManager::NotifyCharInput(key.key); |
| 610 | } |
| 611 | switch (key.key) |
| 612 | { |
| 613 | // Repeat arrows |
| 614 | case -KEY_LEFT: |
| 615 | case -KEY_RIGHT: |
| 616 | case -KEY_UP: |
| 617 | case -KEY_DOWN: |
| 618 | PageManager::NotifyKey(-key.key, true); |
| 619 | PageManager::NotifyKey(-key.key, false); |
| 620 | break; |
that | e79878b | 2015-03-14 23:07:23 +0100 | [diff] [blame] | 621 | } |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 622 | } |
| 623 | } |
| 624 | break; |
| 625 | } |
| 626 | |
| 627 | return 0; |
| 628 | } |
that | 8834a0f | 2016-01-05 23:29:30 +0100 | [diff] [blame] | 629 | |
| 630 | void GUIKeyboard::SetPageFocus(int inFocus) |
| 631 | { |
| 632 | if (inFocus) |
| 633 | CtrlActive = false; |
| 634 | } |