- Don't crash on back press, but shutdown hedgewars
- enable volume up/down/mute buttons
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/SDLActivity.java Sat Apr 21 17:59:14 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/SDLActivity.java Sat Apr 21 18:02:44 2012 +0200
@@ -100,10 +100,6 @@
super.onResume();
}
- public void onBackPressed(){
- PascalExports.HWterminate(true);
- }
-
protected void onDestroy() {
super.onDestroy();
Log.v("SDL", "onDestroy()");
@@ -480,14 +476,14 @@
Log.v("SDL", "surfaceCreated()");
holder.setType(SurfaceHolder.SURFACE_TYPE_GPU);
SDLActivity.createEGLSurface();
-// enableSensor(Sensor.TYPE_ACCELEROMETER, true);
+ // enableSensor(Sensor.TYPE_ACCELEROMETER, true);
}
// Called when we lose the surface
public void surfaceDestroyed(SurfaceHolder holder) {
Log.v("SDL", "surfaceDestroyed()");
SDLActivity.nativePause();
-// enableSensor(Sensor.TYPE_ACCELEROMETER, false);
+ // enableSensor(Sensor.TYPE_ACCELEROMETER, false);
}
// Called when the surface is resized
@@ -553,7 +549,15 @@
// Key events
public boolean onKey(View v, int keyCode, KeyEvent event) {
- if(keyCode == KeyEvent.KEYCODE_BACK) return false;
+ switch(keyCode){
+ case KeyEvent.KEYCODE_BACK:
+ PascalExports.HWterminate(true);
+ return true;
+ case KeyEvent.KEYCODE_VOLUME_DOWN:
+ case KeyEvent.KEYCODE_VOLUME_UP:
+ case KeyEvent.KEYCODE_VOLUME_MUTE:
+ return false;
+ }
if (event.getAction() == KeyEvent.ACTION_DOWN) {
//Log.v("SDL", "key down: " + keyCode);
SDLActivity.onNativeKeyDown(keyCode);