Permalink
Browse files

enable touch, thanks to napstar

  • Loading branch information...
1 parent b4c438a commit 3e243feb7d46cf320838b9adb5f6a2f00efaa7c5 @Squadzone Squadzone committed Feb 12, 2012
Showing with 98 additions and 4 deletions.
  1. +98 −4 recovery/recovery_ui.c
View
@@ -20,6 +20,33 @@
#include "common.h"
#include "extendedcommands.h"
+/*
+ to enable on-screen debug code printing set this to 1
+ to disable on-screen debug code printing set this to 0
+*/
+int TOUCH_CONTROL_DEBUG = 0;
+
+//In this case MENU_SELECT icon has maximum possible height.
+#define MENU_MAX_HEIGHT 80 //gr_get_height(gMenuIcon[MENU_SELECT]) //Maximum allowed height for navigation icons
+
+//Device specific boundaries for touch recognition
+/*
+ WARNING
+ these might not be the same as resX, resY (from below)
+ these have to be found by setting them to zero and then in debug mode
+ check the values returned by on screen touch output by click on the
+ touch panel extremeties
+*/
+int maxX=240; //Set to 0 for debugging
+int maxY=320; //Set to 0 for debugging
+
+/*
+ the values of following two variables are dependent on specifc device resolution
+ and can be obtained using the outputs of the gr_fb functions
+*/
+int resX=240; //Value obtained from function 'gr_fb_width()'
+int resY=320; //Value obtained from function 'gr_fb_height()'
+
char* MENU_HEADERS[] = { NULL };
char* MENU_ITEMS[] = { "reboot system now",
@@ -30,7 +57,6 @@ char* MENU_ITEMS[] = { "reboot system now",
"backup and restore",
"mounts and storage",
"advanced",
- "power off",
NULL };
int device_recovery_start() {
@@ -44,7 +70,6 @@ int device_toggle_display(volatile char* key_pressed, int key_code) {
// allow toggling of the display if the correct key is pressed, and the display toggle is allowed or the display is currently off
if (ui_get_showing_back_button()) {
return 0;
- //return get_allow_toggle_display() && (key_code == KEY_HOME || key_code == KEY_MENU || key_code == KEY_END);
}
return get_allow_toggle_display() && (key_code == KEY_HOME || key_code == KEY_MENU || key_code == KEY_POWER || key_code == KEY_END);
}
@@ -59,13 +84,11 @@ int device_handle_key(int key_code, int visible) {
case KEY_CAPSLOCK:
case KEY_DOWN:
case KEY_VOLUMEDOWN:
- case KEY_MENU:
return HIGHLIGHT_DOWN;
case KEY_LEFTSHIFT:
case KEY_UP:
case KEY_VOLUMEUP:
- case KEY_HOME:
return HIGHLIGHT_UP;
case KEY_POWER:
@@ -82,6 +105,7 @@ int device_handle_key(int key_code, int visible) {
case KEY_CAMERA:
case KEY_F21:
case KEY_SEND:
+ case KEY_HOME:
return SELECT_ITEM;
case KEY_END:
@@ -93,6 +117,7 @@ int device_handle_key(int key_code, int visible) {
if (!get_allow_toggle_display())
return GO_BACK;
case KEY_BACK:
+ case KEY_MENU:
return GO_BACK;
}
}
@@ -107,3 +132,72 @@ int device_perform_action(int which) {
int device_wipe_data() {
return 0;
}
+
+int get_menu_icon_info(int indx1, int indx2) {
+
+//ToDo: Following switch case should be replaced by array or structure
+int caseN = indx1*4 + indx2;
+/*
+int MENU_ICON1[] = {
+ { 1*resX/8, (resY - MENU_MAX_HEIGHT/2), 0*resX/4, 1*resX/4 },
+ { 3*resX/8, (resY - MENU_MAX_HEIGHT/2), 1*resX/4, 2*resX/4 },
+ { 5*resX/8, (resY - MENU_MAX_HEIGHT/2), 2*resX/4, 3*resX/4 },
+ { 7*resX/8, (resY - MENU_MAX_HEIGHT/2), 3*resX/4, 4*resX/4 },
+ };
+
+*/
+
+switch (caseN) {
+ case 0:
+ return 1*resX/8;
+ case 1:
+ return (resY - MENU_MAX_HEIGHT/2);
+ case 2:
+ return 0*resX/4;
+ case 3:
+ return 1*resX/4;
+ case 4:
+ return 3*resX/8;
+ case 5:
+ return (resY - MENU_MAX_HEIGHT/2);
+ case 6:
+ return 1*resX/4;
+ case 7:
+ return 2*resX/4;
+ case 8:
+ return 5*resX/8;
+ case 9:
+ return (resY - MENU_MAX_HEIGHT/2);
+ case 10:
+ return 2*resX/4;
+ case 11:
+ return 3*resX/4;
+ case 12:
+ return 7*resX/8;
+ case 13:
+ return (resY - MENU_MAX_HEIGHT/2);
+ case 14:
+ return 3*resX/4;
+ case 15:
+ return 4*resX/4;
+
+}
+return 0;
+}
+
+//For those devices which has skewed X axis and Y axis detection limit (Not similar to XY resolution of device), So need normalization
+int MT_X(int x)
+{
+ int out;
+ out = maxX ? (x*gr_fb_width()/maxX) : x;
+
+ return out;
+}
+
+int MT_Y(int y)
+{
+ int out;
+ out = maxY ? (y*gr_fb_height()/maxY) : y;
+
+ return out;
+}

0 comments on commit 3e243fe

Please sign in to comment.