summaryrefslogtreecommitdiffstats
path: root/gui/input.cpp
diff options
context:
space:
mode:
authorthat <github@that.at>2016-01-05 23:29:30 +0100
committerthat <github@that.at>2016-01-07 22:30:39 +0100
commit8834a0ffc0be61218ab86bf209cb6cd53a18a565 (patch)
tree1229c2413a373d799831f4e9c6ebe087c4c53fb5 /gui/input.cpp
parentFix translation spellings (diff)
downloadandroid_bootable_recovery-8834a0ffc0be61218ab86bf209cb6cd53a18a565.tar
android_bootable_recovery-8834a0ffc0be61218ab86bf209cb6cd53a18a565.tar.gz
android_bootable_recovery-8834a0ffc0be61218ab86bf209cb6cd53a18a565.tar.bz2
android_bootable_recovery-8834a0ffc0be61218ab86bf209cb6cd53a18a565.tar.lz
android_bootable_recovery-8834a0ffc0be61218ab86bf209cb6cd53a18a565.tar.xz
android_bootable_recovery-8834a0ffc0be61218ab86bf209cb6cd53a18a565.tar.zst
android_bootable_recovery-8834a0ffc0be61218ab86bf209cb6cd53a18a565.zip
Diffstat (limited to 'gui/input.cpp')
-rw-r--r--gui/input.cpp106
1 files changed, 62 insertions, 44 deletions
diff --git a/gui/input.cpp b/gui/input.cpp
index ca27ea812..68bd163b9 100644
--- a/gui/input.cpp
+++ b/gui/input.cpp
@@ -469,7 +469,7 @@ int GUIInput::NotifyTouch(TOUCH_STATE state, int x, int y)
if (GetSelection(x, y) >= 0) {
// When changing focus, we don't scroll or change the cursor location
PageManager::SetKeyBoardFocus(0);
- PageManager::NotifyKeyboard(0);
+ PageManager::NotifyCharInput(0);
SetInputFocus(1);
DrawCursor = true;
mRendered = false;
@@ -561,7 +561,66 @@ int GUIInput::NotifyVarChange(const std::string& varName, const std::string& val
return 0;
}
-int GUIInput::NotifyKeyboard(int key)
+int GUIInput::NotifyKey(int key, bool down)
+{
+ if (!HasInputFocus || !down)
+ return 1;
+
+ string variableValue;
+ switch (key)
+ {
+ case KEY_LEFT:
+ if (mCursorLocation == 0 && skipChars == 0)
+ return 0; // we're already at the beginning
+ if (mCursorLocation == -1) {
+ DataManager::GetValue(mVariable, variableValue);
+ if (variableValue.size() == 0)
+ return 0;
+ mCursorLocation = variableValue.size() - skipChars - 1;
+ } else if (mCursorLocation == 0) {
+ skipChars--;
+ HandleTextLocation(-1002);
+ } else {
+ mCursorLocation--;
+ HandleTextLocation(-1002);
+ }
+ mRendered = false;
+ return 0;
+
+ case KEY_RIGHT:
+ if (mCursorLocation == -1)
+ return 0; // we're already at the end
+ mCursorLocation++;
+ DataManager::GetValue(mVariable, variableValue);
+ if (variableValue.size() <= mCursorLocation + skipChars)
+ mCursorLocation = -1;
+ HandleTextLocation(-1001);
+ mRendered = false;
+ return 0;
+
+ case KEY_HOME:
+ case KEY_UP:
+ DataManager::GetValue(mVariable, variableValue);
+ if (variableValue.size() == 0)
+ return 0;
+ mCursorLocation = 0;
+ skipChars = 0;
+ mRendered = false;
+ HandleTextLocation(-1002);
+ return 0;
+
+ case KEY_END:
+ case KEY_DOWN:
+ mCursorLocation = -1;
+ mRendered = false;
+ HandleTextLocation(-1003);
+ return 0;
+ }
+
+ return 1;
+}
+
+int GUIInput::NotifyCharInput(int key)
{
string variableValue;
@@ -617,48 +676,7 @@ int GUIInput::NotifyKeyboard(int key)
isLocalChange = false;
mRendered = false;
return 0;
- } else if (key == KEYBOARD_ARROW_LEFT) {
- if (mCursorLocation == 0 && skipChars == 0)
- return 0; // we're already at the beginning
- if (mCursorLocation == -1) {
- DataManager::GetValue(mVariable, variableValue);
- if (variableValue.size() == 0)
- return 0;
- mCursorLocation = variableValue.size() - skipChars - 1;
- } else if (mCursorLocation == 0) {
- skipChars--;
- HandleTextLocation(-1002);
- } else {
- mCursorLocation--;
- HandleTextLocation(-1002);
- }
- mRendered = false;
- return 0;
- } else if (key == KEYBOARD_ARROW_RIGHT) {
- if (mCursorLocation == -1)
- return 0; // we're already at the end
- mCursorLocation++;
- DataManager::GetValue(mVariable, variableValue);
- if (variableValue.size() <= mCursorLocation + skipChars)
- mCursorLocation = -1;
- HandleTextLocation(-1001);
- mRendered = false;
- return 0;
- } else if (key == KEYBOARD_HOME || key == KEYBOARD_ARROW_UP) {
- DataManager::GetValue(mVariable, variableValue);
- if (variableValue.size() == 0)
- return 0;
- mCursorLocation = 0;
- skipChars = 0;
- mRendered = false;
- HandleTextLocation(-1002);
- return 0;
- } else if (key == KEYBOARD_END || key == KEYBOARD_ARROW_DOWN) {
- mCursorLocation = -1;
- mRendered = false;
- HandleTextLocation(-1003);
- return 0;
- } else if (key < KEYBOARD_SPECIAL_KEYS && key > 0) {
+ } else if (key >= 32) {
// Regular key
if (HasAllowed && AllowedList.find((char)key) == string::npos) {
return 0;