Add support for actions triggered by key combination

Change-Id: I9dfa7de40229f00412d63fc9c1eb3a809a6eb2e6
Signed-off-by: Vojtech Bocek <vbocek@gmail.com>
diff --git a/gui/gui.cpp b/gui/gui.cpp
index 0164ec3..c0bd008 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -187,8 +187,8 @@
 	static int x = 0, y = 0;
 	static int lshift = 0, rshift = 0;
 	static struct timeval touchStart;
-	HardwareKeyboard kb;
 	string seconds;
+	HardwareKeyboard *kb = PageManager::GetHardwareKeyboard();
 	MouseCursor *cursor = PageManager::GetMouseCursor();
 
 #ifndef TW_NO_SCREEN_TIMEOUT
@@ -249,7 +249,7 @@
 #endif
 				gettimeofday(&touchStart, NULL);
 				key_repeat = 2;
-				kb.KeyRepeat();
+				kb->KeyRepeat();
 #ifndef TW_NO_SCREEN_TIMEOUT
 				blankTimer.resetTimerAndUnblank();
 #endif
@@ -261,7 +261,7 @@
 				LOGERR("KEY_REPEAT: %d,%d\n", x, y);
 #endif
 				gettimeofday(&touchStart, NULL);
-				kb.KeyRepeat();
+				kb->KeyRepeat();
 #ifndef TW_NO_SCREEN_TIMEOUT
 				blankTimer.resetTimerAndUnblank();
 #endif
@@ -356,6 +356,9 @@
 					{
 						cursor->GetPos(x, y);
 
+#ifdef _EVENT_LOGGING
+						LOGERR("TOUCH_RELEASE: %d,%d\n", x, y);
+#endif
 						PageManager::NotifyTouch(TOUCH_RELEASE, x, y);
 
 						touch_and_hold = 0;
@@ -371,15 +374,13 @@
 			else if(ev.code == BTN_SIDE)
 			{
 				if(ev.value == 1)
-					kb.KeyDown(KEY_BACK);
+					kb->KeyDown(KEY_BACK);
 				else
-					kb.KeyUp(KEY_BACK);
-			}
-			else if (ev.value != 0)
-			{
+					kb->KeyUp(KEY_BACK);
+			} else if (ev.value != 0) {
 				// This is a key press
-				if (kb.KeyDown(ev.code))
-				{
+				if (kb->KeyDown(ev.code)) {
+					// Key repeat is enabled for this key
 					key_repeat = 1;
 					touch_and_hold = 0;
 					touch_repeat = 0;
@@ -388,9 +389,7 @@
 #ifndef TW_NO_SCREEN_TIMEOUT
 					blankTimer.resetTimerAndUnblank();
 #endif
-				}
-				else
-				{
+				} else {
 					key_repeat = 0;
 					touch_and_hold = 0;
 					touch_repeat = 0;
@@ -399,11 +398,9 @@
 					blankTimer.resetTimerAndUnblank();
 #endif
 				}
-			}
-			else
-			{
+			} else {
 				// This is a key release
-				kb.KeyUp(ev.code);
+				kb->KeyUp(ev.code);
 				key_repeat = 0;
 				touch_and_hold = 0;
 				touch_repeat = 0;