Commits

rmtew committed ef9d6b2

- Updated release notes.
- Added the move UI layer.
- Added help menu / help window.

  • Participants
  • Parent commits 30a1d48

Comments (0)

Files changed (3)

File res/raw/help.txt

+There are several ways to control the game.
+
+* Touching tiles.
+* Directional movement.
+* Keyboard.
+
+TOUCHING TILES
+
+Simply touch the character or UI element you wish to interact with.  If your device has too small a screen to allow accurate tile touching,
+then you can use the standard pinch and zoom gesture that you might use when viewing maps, pictures or web pages on your mobile device.
+
+DIRECTIONAL MOVEMENT
+
+If you choose to enable the "Move Tapping Layer" menu item, you can tap areas of the screen to move.
+
+* Upper left: up and left.
+* Upper center: up.
+* Upper right: up and right.
+* Middle left: left.
+* Middle: rest.
+* Middle right: right.
+* Lower left: down and left.
+* Lower center: down.
+* Lower right: down and right.
+
+To switch to this touch mode, check the Options / Move tapping layer menu item.  And to switch back, uncheck the menu item.
+
+When your inventory is displayed, you can press the "up" to go up an item, "down" to go down an item and "left" to exit the inventory. If you are asked to press a key to continue, just touch the screen anywhere.
+
+KEYBOARD
+
+If you have an external keyboard for your device, then you may use it to play the game.  Note that there is no escape key, and
+where you would otherwise use escape, you can instead use space.  That is, to dismiss UI items and the like.

File res/raw/releasenotes.txt

 * See the help menu item for information about controls.
 
 RECENT CHANGES
-- Fixed remaining keyboard issues.  '>', '~', '<' and other characters involving pressing SHIFT should now work.
-- Improved pinch to zoom gesture support.  Should zoom nearer center of pinch point, and can be dragged while pinching.
+- Added a directional movement touch mode.  More info within help menu item.
+- Restored support for keys that require shift to be pressed (e.g. >).
+- Improved pinch to zoom gesture support.  Maybe works worse.
 - Added a help menu item to view instructions & controls.
-- Added a directional movement touch mode.  More info within help menu item.
 
 CONTACT INFORMATION
 richard.m.tew@gmail.com

File src/org/disinterest/broguex/SDLActivity.java

 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Hashtable;
 
 import javax.microedition.khronos.egl.EGL10;
 import javax.microedition.khronos.egl.EGLConfig;
 import android.app.*;
 import android.content.*;
 import android.view.*;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup.LayoutParams;
 import android.view.inputmethod.InputMethodManager;
+import android.widget.Button;
 import android.widget.CheckBox;
 import android.widget.CompoundButton;
 import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.LinearLayout;
+import android.widget.PopupWindow;
 import android.widget.TextView;
 import android.os.*;
 import android.util.Log;
     private static String mVersionName;
     private static boolean mDebuggable;
     
-    public static String PREFS_TCOD_FPS_LIMIT = "use-tcod-fps-limit";
-    public static String PREFS_RELEASE_NOTES_SEEN = "release-note-version";
+    public static final String PREFS_TCOD_FPS_LIMIT = "use-tcod-fps-limit";
+    public static final String PREFS_RELEASE_NOTES_SEEN = "release-note-version";
+    public static final String PREFS_JAVA_UI = "java-ui";
+    
+    public static Hashtable<Character, Integer> mCharToKeycode;
     
     // Setup
     protected void onCreate(Bundle savedInstanceState) {
         setContentView(mSurface);
         // SurfaceHolder holder = mSurface.getHolder();        
 
-        mMoveTapping = false;
-
     	SharedPreferences prefs = getPreferences(MODE_PRIVATE);
+    	mMoveTapping = prefs.getBoolean(PREFS_JAVA_UI, false);
     	mTCODFPS = prefs.getInt(PREFS_TCOD_FPS_LIMIT, 30);
     	SDLActivity.nativeTCODSetFPS(mTCODFPS);
 
     		Log.e("BrogueX", "Failed to fetch package info..");
     	}
     	Log.d("BrogueX", String.format("Show release notes: %b", mShowReleaseNotes));
+    	
+    	mCharToKeycode = new Hashtable<Character, Integer>();
+    	mCharToKeycode.put((char)8, KeyEvent.KEYCODE_DEL);
+    	mCharToKeycode.put((char)13, KeyEvent.KEYCODE_ENTER);
+    	
+    	mCharToKeycode.put('n', KeyEvent.KEYCODE_N);
+    	mCharToKeycode.put('o', KeyEvent.KEYCODE_O);
+    	mCharToKeycode.put('v', KeyEvent.KEYCODE_V);
+    	mCharToKeycode.put('h', KeyEvent.KEYCODE_H);
+    	mCharToKeycode.put('q', KeyEvent.KEYCODE_Q);
+
+    	mCharToKeycode.put('x', KeyEvent.KEYCODE_X);
+    	mCharToKeycode.put('z', KeyEvent.KEYCODE_Z);
+    	mCharToKeycode.put('s', KeyEvent.KEYCODE_S);
+    	mCharToKeycode.put('i', KeyEvent.KEYCODE_I);
+
+    	mCharToKeycode.put('0', KeyEvent.KEYCODE_0);
+    	mCharToKeycode.put('1', KeyEvent.KEYCODE_1);
+    	mCharToKeycode.put('2', KeyEvent.KEYCODE_2);
+    	mCharToKeycode.put('3', KeyEvent.KEYCODE_3);
+    	mCharToKeycode.put('4', KeyEvent.KEYCODE_4);
+    	mCharToKeycode.put('5', KeyEvent.KEYCODE_5);
+    	mCharToKeycode.put('6', KeyEvent.KEYCODE_6);
+    	mCharToKeycode.put('7', KeyEvent.KEYCODE_7);
+    	mCharToKeycode.put('8', KeyEvent.KEYCODE_8);
+    	mCharToKeycode.put('9', KeyEvent.KEYCODE_9);
     }
 
     // Events
 			break;
 		case R.id.toggle_move_tapping_menu_item:
 			mMoveTapping = !mMoveTapping;
-			break;
+			/* This should also take care of hiding or showing the button menus. */
+			if (mMoveTapping)
+				brogueMenuState.display();
+			else
+				brogueMenuState.dismiss();
+
+			/* Persist new setting. */
+	    	prefs = getPreferences(MODE_PRIVATE);
+	    	prefsEd = prefs.edit();
+	    	prefsEd.putBoolean(PREFS_JAVA_UI, mMoveTapping);
+	    	prefsEd.commit();
+
+	    	break;
 		case R.id.toggle_keyboard_menu_item:
 			/* This comes back to Java in a roundabout way, but should make SDL's API more reliable. */
 			nativeSDLToggleScreenKeyboard();
     public static native void nativeTCODSetScaleFactor(float scale_factor);
     public static native void nativeTCODSetFPS(int value);
     public static native void nativeSDLToggleScreenKeyboard();
+    public static native void nativeFakeMouseClick(int cx, int cy);
 
     // Java functions called from C
 
     public static void openMenu() {
     	mSingleton.openOptionsMenu();
     }
+    
+    /* BrogueX hack layer begins. */
+    
+    private static String stripBrogueString(String text) {
+    	int outIdx = 0, inIdx = 0, outIdxStart = -1, outIdxEnd = 0;
+    	char[] in = text.toCharArray();
+    	char[] out = new char[in.length];
+    	while (inIdx < in.length) {
+    		if (in[inIdx] == 25) { /* Remove colour sequences. */
+    			inIdx += 3;
+    		} else if (outIdxStart == -1 && in[inIdx] == ' ') {
+    			;
+    		} else {
+    			if (outIdxStart == -1) /* Note start of useful text. */
+    				outIdxStart = outIdxEnd = outIdx;
+    			if (in[inIdx] != ' ') /* Note end of useful text. */
+    				outIdxEnd = outIdx;
+    			out[outIdx++] = in[inIdx];
+    		}
+    		inIdx += 1;
+    	}
+    	if (outIdxStart == -1 && outIdxEnd == 0)
+    		return "";
+    	return String.valueOf(out, outIdxStart, outIdxEnd-outIdxStart+1);
+    }
+
+    /* Constants from Brogue C source code. */
+    public static final int BROGUE_NG_NOTHING = 0;
+    public static final int BROGUE_NG_NEW_GAME = 1;
+    public static final int BROGUE_NG_NEW_GAME_WITH_SEED = 2;
+    public static final int BROGUE_NG_OPEN_GAME = 3;
+    public static final int BROGUE_NG_VIEW_RECORDING = 4;
+    public static final int BROGUE_NG_HIGH_SCORES = 5;
+    public static final int BROGUE_NG_QUIT = 6;
+    
+    public static final String newGameLabel = "New Game";
+    public static final String customGameLabel = "(custom)";
+   
+    public static final int mainMenuAlpha = 127;
+    public static final int gameMenuAlpha = 85;
+    public static final int numericKeyboardAlpha = 255;
+    
+    /*
+     * Rules given move tapping is enabled:
+     * - BROGUE_NG_NOTHING:
+     *   - Show adjusted menu.
+     * - BROGUE_NG_NEW_GAME / BROGUE_NG_NEW_GAME_WITH_SEED:
+     *   - Allow menus to be browsed.
+     */
+    private static class BrogueMenuState {
+        public int buttonCount, buttonIndex, buttonMode;
+        public String[] labels;
+        public char[] hotkeys;
+        public int[] cxs;
+        public int[] cys;
+        PopupWindow window;
+        public int displayY, displayGravity;
+        
+        public BrogueMenuState(int count, int mode) {
+			super();
+
+			buttonCount = count;
+			buttonMode = mode;
+
+	    	labels = new String[15];
+	    	hotkeys = new char[15];
+	    	cxs = new int[15];
+	    	cys = new int[15];
+	    	buttonIndex = 0;
+	    	window = null;
+		}
+        
+        public void addButton(String text, char hotkey, int cx, int cy) {
+			if (buttonMode == BROGUE_NG_NEW_GAME || buttonMode == BROGUE_NG_NEW_GAME_WITH_SEED) {
+				String arr[] = text.split(" ", 2);
+				text = arr[0];
+			}
+
+        	labels[buttonIndex] = text;
+        	hotkeys[buttonIndex] = hotkey;
+        	cxs[buttonIndex] = cx;
+        	cys[buttonIndex] = cy;
+        	buttonIndex += 1;
+        	
+        	if (buttonMode == BROGUE_NG_NOTHING && text.equals(newGameLabel))
+        		addButton(text +" "+ customGameLabel, hotkey, cx, cy);
+        }
+        
+        public boolean haveAllButtons() {
+        	return buttonIndex == buttonCount;
+        }
+
+		public void display() {
+			if (window != null)
+				return;
+
+			Button button;
+    		LinearLayout layout = new LinearLayout(mSingleton);
+    		int alpha = 0;
+			
+			switch (buttonMode) {
+			case BROGUE_NG_NEW_GAME:
+			case BROGUE_NG_NEW_GAME_WITH_SEED:
+				if (SDLActivity.brogueInInventoryFlag) {
+					if (!SDLActivity.brogueInInventoryItemFlag)
+						return;
+				}
+				
+				displayY = 1;
+				displayGravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
+				layout.setGravity(displayGravity);
+	    		layout.setOrientation(LinearLayout.HORIZONTAL);
+	    		alpha = gameMenuAlpha;
+				break;
+			case BROGUE_NG_NOTHING:
+				displayY = 0;
+				displayGravity = Gravity.CENTER;
+				layout.setGravity(Gravity.TOP);
+	    		layout.setOrientation(LinearLayout.VERTICAL);
+	    		alpha = mainMenuAlpha;
+				break;
+			}
+    		
+    		layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
+    			    		
+    		for (int i = 0; i < buttonCount; i++) {
+    			if (labels[i].length() == 0)
+    				continue;
+    			
+    			button = new Button(mSingleton);
+    			button.setId(i);
+    			button.setText(labels[i]);
+	    		button.getBackground().setAlpha(alpha);
+
+    			button.setOnClickListener(new OnClickListener() {
+					public void onClick(View arg0) {
+						int idx = arg0.getId();
+						boolean controlPress = buttonMode == BROGUE_NG_NOTHING && labels[idx].endsWith(customGameLabel);
+						if (controlPress)
+							brogueEvents.add(new BrogueEvent(true, CustomKeys.CTRL_LEFT));
+						brogueEvents.add(new BrogueEvent(cxs[idx], cys[idx]));
+						if (controlPress)
+							brogueEvents.add(new BrogueEvent(false, CustomKeys.CTRL_LEFT));
+						/* We need to send one event to trigger the fallout. */
+				    	dispatchNextBrogueEvent();
+					}
+    			});
+    			
+    			layout.addView(button);
+    		}
+
+    		layout.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
+    		window = new PopupWindow(layout, layout.getMeasuredWidth(), layout.getMeasuredHeight());
+    	    mSingleton.runOnUiThread(new java.lang.Runnable() {
+				public void run() {
+		    		window.showAtLocation(SDLActivity.mSurface, displayGravity, 0, displayY);
+				}        		
+        	});
+        }
+		
+		public void dismiss() {
+			if (window != null) {
+	    	    mSingleton.runOnUiThread(new java.lang.Runnable() {
+					public void run() {
+						window.dismiss();
+						window = null;
+					}        		
+	        	});
+			}
+		}
+    }
+
+    private static class BrogueEvent {
+    	public static final int  MOUSE = 0;
+    	public static final int KEYUP = 1;
+    	public static final int KEYDOWN = 2;
+    	
+    	private int mouse_x, mouse_y;
+    	private int keycode;
+    	private int type;
+    	
+        public BrogueEvent(int x, int y) {
+			super();
+        	type = MOUSE;
+        	mouse_x = x;
+        	mouse_y = y;
+        }
+        
+        public BrogueEvent(boolean pressed, int kc) {
+        	super();
+        	if (pressed)
+        		type = KEYDOWN;
+        	else
+        		type = KEYUP;
+        	keycode = kc;
+        }
+        
+        public void dispatch() {
+    	    mSingleton.runOnUiThread(new java.lang.Runnable() {
+				public void run() {
+					switch (type) {
+					case MOUSE:
+						SDLActivity.nativeFakeMouseClick(mouse_x, mouse_y);
+						break;
+					case KEYUP:
+						SDLActivity.onNativeKeyUp(keycode);
+						break;
+					case KEYDOWN:
+						SDLActivity.onNativeKeyDown(keycode);
+						break;
+					}
+				}        		
+        	});
+        }
+    }
+    
+    private static boolean dispatchNextBrogueEvent() {
+    	if (!brogueEvents.isEmpty()) {
+    		BrogueEvent event = brogueEvents.remove(0);
+    		event.dispatch();
+    		return true;
+    	}    	
+    	return false;
+    }
+
+    public static boolean brogueInGameMenu = false;
+    private static BrogueMenuState brogueMenuState;
+    private static BrogueMenuState brogueMenuStateCopy;
+    public static int brogueMode = BROGUE_NG_QUIT;
+    public static PopupWindow brogueNumericKeyboard = null;
+    public static ArrayList<BrogueEvent> brogueEvents = null;
+    public static boolean brogueInInventoryFlag = false;
+    public static boolean brogueInInventoryItemFlag = false;
+    public static boolean brogueInAcknowledgeState = false;
+
+    /*
+     * Notification of when a new main menu switch happens.
+     */
+    public static void brogueApplicationMode(int mode) {
+    	//Log.v("SDL", String.format("brogueApplicationMode %d", mode));
+    	if (brogueEvents == null)
+    		brogueEvents = new ArrayList<BrogueEvent>();
+    	/* Flush the event queue. */
+    	while (dispatchNextBrogueEvent())
+    		;
+    	/* If we are switching modes, we definitely want to remove the popup window. */
+    	if (mode != brogueMode) {
+    		if (brogueMenuState != null) {
+	    		brogueMenuState.dismiss();
+	    		brogueMenuState = null;
+    		}
+        	brogueMode = mode;
+    		brogueMenuStateCopy = null;
+    	}
+    }
+    
+    /*
+     * Nofication when entering and exiting the inventory window.
+     */
+    public static void brogueInInventory(int flag) {
+    	//Log.v("SDL", String.format("brogueInInventory %d", flag));
+        brogueInInventoryFlag = flag == 1;
+        if (!brogueInInventoryFlag) {
+	    	//Log.v("SDL", String.format("brogueInInventory - ! check"));
+        	/* Exiting the inventory does not recreate the bottom of screen game buttons. */
+        	brogueMenuState = brogueMenuStateCopy;
+        	brogueInGameMenu = true;
+			if (mMoveTapping) {
+		    	//Log.v("SDL", String.format("brogueInInventory - display"));
+				brogueMenuState.display();
+			}
+        }
+    }
+    
+    public static void brogueInInventoryItem(int flag) {
+    	//Log.v("SDL", String.format("brogueInInventoryItem %d", flag));
+        brogueInInventoryItemFlag = flag == 1;
+    	if (!brogueInInventoryItemFlag && brogueMenuState != null) {
+    		brogueMenuState.dismiss();
+    		brogueMenuState = null;
+    	}
+    }
+
+    /*
+     * Identify the creation of a new set of buttons.
+     */
+    public static void brogueInitButtons(int buttonCount) {
+    	//Log.v("SDL", String.format("brogueInitButtons %d", buttonCount));
+    	if (brogueMenuState != null)
+    		brogueMenuState.dismiss();
+    	brogueMenuState = new BrogueMenuState(buttonCount, brogueMode);
+    	dispatchNextBrogueEvent();
+    }
+
+    /*
+     * Identify the display of one of the button set.
+     */
+    public static void brogueInitButton(String text, char hotkey, int cx, int cy) {
+    	//Log.v("SDL", String.format("brogueInitButton %s %c", stripBrogueString(text), hotkey));
+    	text = stripBrogueString(text);
+    	brogueMenuState.addButton(text, hotkey, cx, cy);
+    	/* When all the buttons have been initialised, show the menu (if global option is enabled). */
+    	if (brogueMenuState.haveAllButtons()) {
+			if (mMoveTapping && brogueEvents.isEmpty()) {
+				/* The game menu is constant, we need to manually redisplay it, so keep a copy for that. */
+				if (brogueMenuStateCopy == null) {
+					brogueMenuStateCopy = brogueMenuState;
+		        	brogueInGameMenu = true;
+				}
+				brogueMenuState.display();
+			}
+    	}
+    }
+    
+    public static void brogueButtonPress(int flag) {
+    }
+    
+    public static void brogueShowGameMenu() {
+		brogueMenuState = brogueMenuStateCopy;
+    	brogueInGameMenu = true;
+		brogueMenuState.display();    	
+    }
+
+    public static void brogueExitButtonLoop(int flag) {
+    	/* The general assumption is that a button press dismisses the current menu. */
+    	//Log.v("SDL", "brogueExitButtonLoop");
+    	if (brogueMenuState != null) {
+        	//Log.v("SDL", "brogueExitButtonLoop 1");
+    		brogueMenuState.dismiss();
+    		brogueMenuState = null;
+    	}
+    	if (!brogueInInventoryFlag)
+    		brogueShowGameMenu();
+    }
+
+    public static Button brogueCreateButton(int buttonId, String buttonLabel) {
+		Button button = new Button(mSingleton);
+		button.setId(buttonId);
+		button.setText(buttonLabel);
+		button.getBackground().setAlpha(numericKeyboardAlpha);
+		
+		button.setOnClickListener(new OnClickListener() {
+			public void onClick(View arg0) {
+				int buttonId = arg0.getId();
+				int kc = SDLActivity.mCharToKeycode.get((char)buttonId);
+				if (kc > 0) {
+		            SDLActivity.onNativeKeyDown(kc);
+		            SDLActivity.onNativeKeyUp(kc);
+				}
+			}
+		});
+		return button;
+    }
+    
+    public static void brogueTextDismissed(int flag) {
+    	brogueInAcknowledgeState = flag == 0;
+    	//Log.v("SDL", String.format("brogueTextDismissed - enter - %d", flag));
+    	if (brogueMode == BROGUE_NG_NEW_GAME || brogueMode == BROGUE_NG_NEW_GAME_WITH_SEED) {
+			if (mMoveTapping) {
+				if (flag == 1) {
+			    	//Log.v("SDL", String.format("brogueTextDismissed - restore menu"));
+		    		brogueShowGameMenu();
+				} else {
+			    	//Log.v("SDL", String.format("brogueTextDismissed - hide current menu"));
+			    	if (brogueMenuState != null) {
+			    		brogueMenuState.dismiss();
+			    		brogueMenuState = null;
+			    	}					
+				}
+			}    		
+    	}
+    }
+    
+    public static void broguePromptDismissed(int flag) {
+    	if (brogueMode == BROGUE_NG_NEW_GAME || brogueMode == BROGUE_NG_NEW_GAME_WITH_SEED) {
+			if (mMoveTapping) {
+			    	//Log.v("SDL", String.format("brogueTextDismissed - restore menu"));
+			    	if (brogueMenuState != null) {
+			    		brogueMenuState.dismiss();
+			    		brogueMenuState = null;
+			    	}					
+		    		brogueShowGameMenu();
+			}    		
+    	}
+    }
+
+    public static void brogueDisplayNumericKeyboard(int flag) {
+    	//Log.v("SDL", String.format("brogueDisplayNumericKeyboard(%d)", flag));
+    	if (flag == 1) {
+    		LinearLayout layout = new LinearLayout(mSingleton);
+    		
+			layout.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
+    		layout.setOrientation(LinearLayout.HORIZONTAL);
+    		layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
+    		
+    		for (int i = 1; i < 11; i++) {
+    			int buttonValue = i % 10;
+    			int buttonId = (int)String.valueOf(buttonValue).charAt(0);
+    			layout.addView(brogueCreateButton(buttonId, String.valueOf(buttonValue)));
+    		}
+			layout.addView(brogueCreateButton(8, "\u2190")); /* Backspace = left arrow */
+			layout.addView(brogueCreateButton(13, "\u2713")); /* Carriage return = check mark */
+    		
+    		layout.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
+    		brogueNumericKeyboard = new PopupWindow(layout, layout.getMeasuredWidth(), layout.getMeasuredHeight());
+    	    mSingleton.runOnUiThread(new java.lang.Runnable() {
+				public void run() {
+					brogueNumericKeyboard.showAtLocation(SDLActivity.mSurface, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 30);
+				}        		
+        	});
+    	} else {
+    		if (brogueNumericKeyboard != null) {
+	    	    mSingleton.runOnUiThread(new java.lang.Runnable() {
+					public void run() {
+			    		brogueNumericKeyboard.dismiss();
+			    		brogueNumericKeyboard = null;
+					}        		
+	        	});
+			}
+    	}
+    }
+    
+    
+    /* BrogueX hack layer ends. */
 
     public static Context getContext() {
         return mSingleton;
 	public static int NUMPAD_7 = 151;
 	public static int NUMPAD_8 = 152;
 	public static int NUMPAD_9 = 153;
+	
+	public static int CTRL_LEFT = 113;
 }
 
 /**
     public void onMoveTapJiggeryPokery(float x, float y) {
         int keyCode = 0;
 
-	   	if (x < 0.333f) {
-	   		if (y < 0.333f)			keyCode = CustomKeys.NUMPAD_7;
-	   		else if (y < 0.666f)	keyCode = CustomKeys.NUMPAD_4;
-	   		else					keyCode = CustomKeys.NUMPAD_1;
+		if (SDLActivity.brogueInAcknowledgeState) {
+   			keyCode = KeyEvent.KEYCODE_SPACE;
+		} else if (x < 0.333f) {
+	   		if (SDLActivity.brogueInInventoryFlag) {
+	   			keyCode = KeyEvent.KEYCODE_SPACE;
+	   		} else {
+		   		if (y < 0.333f)			keyCode = CustomKeys.NUMPAD_7;
+		   		else if (y < 0.666f)	keyCode = CustomKeys.NUMPAD_4;
+		   		else					keyCode = CustomKeys.NUMPAD_1;
+	   		}
 	   	} else if (x < 0.666f) {
 	   		if (y < 0.333f)			keyCode = CustomKeys.NUMPAD_8;
 	   		else if (y < 0.666f)	keyCode = CustomKeys.NUMPAD_5;