# HG changeset patch # User Xeli # Date 1312980900 -7200 # Node ID dcfa3bf24a2a271e24457988b77e213d979e26e7 # Parent 61431600b1334afcd38ccae74c9bdf5c40405633 back key now quits the game diff -r 61431600b133 -r dcfa3bf24a2a project_files/Android-build/SDL-android-project/src/org/hedgewars/mobile/SDLActivity.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/mobile/SDLActivity.java Wed Aug 10 14:52:51 2011 +0200 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/mobile/SDLActivity.java Wed Aug 10 14:55:00 2011 +0200 @@ -83,6 +83,11 @@ // Log.v("SDL", "onResume()"); super.onResume(); } + + public void onBackPressed(){ + nativeQuit(); + super.onBackPressed(); + } // Messages from the SDLMain thread static int COMMAND_CHANGE_TITLE = 1; @@ -497,6 +502,7 @@ for (StackTraceElement s : e.getStackTrace()) { Log.v("SDL", s.toString()); } + } } @@ -504,11 +510,17 @@ public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { - // Log.v("SDL", "key down: " + keyCode); - SDLActivity.onNativeKeyDown(keyCode); + Log.v("SDL", "key down: " + keyCode); + if(keyCode == KeyEvent.KEYCODE_BACK){//TODO ask user to quit or not + SDLActivity.nativeQuit(); + SDLActivity.mSingleton.finish(); + }else{ + SDLActivity.onNativeKeyDown(keyCode); + } + return true; } else if (event.getAction() == KeyEvent.ACTION_UP) { - // Log.v("SDL", "key up: " + keyCode); + Log.v("SDL", "key up: " + keyCode); SDLActivity.onNativeKeyUp(keyCode); return true; }