project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/SDLActivity.java
changeset 7006 6af78154dc62
parent 6839 2dd2c0f2c9d0
parent 6901 c021699c33dc
child 7110 c91d33837b0d
equal deleted inserted replaced
6852:9e724f4863a3 7006:6af78154dc62
    98 	protected void onResume() {
    98 	protected void onResume() {
    99 		Log.v("SDL", "onResume()");
    99 		Log.v("SDL", "onResume()");
   100 		super.onResume();
   100 		super.onResume();
   101 	}
   101 	}
   102 
   102 
   103 	public void onBackPressed(){
       
   104 		super.onBackPressed();
       
   105 		PascalExports.HWterminate(true);
       
   106 	}
       
   107 
       
   108 	protected void onDestroy() {
   103 	protected void onDestroy() {
   109 		super.onDestroy();
   104 		super.onDestroy();
   110 		Log.v("SDL", "onDestroy()");
   105 		Log.v("SDL", "onDestroy()");
   111 		// Send a quit message to the application
   106 		// Send a quit message to the application
   112 		SDLActivity.nativeQuit();
   107 		SDLActivity.nativeQuit();
   439 			ipc.quitIPC();
   434 			ipc.quitIPC();
   440 			ipc.join();
   435 			ipc.join();
   441 		} catch (InterruptedException e) {
   436 		} catch (InterruptedException e) {
   442 			e.printStackTrace();
   437 			e.printStackTrace();
   443 		}
   438 		}
   444 		//Log.v("SDL", "SDL thread terminated");
   439 		Log.v("SDL", "SDL thread terminated");
   445 		//Log.v("SDL", "SDL thread terminated");
   440 		//Log.v("SDL", "SDL thread terminated");
   446 	}
   441 	}
   447 }
   442 }
   448 
   443 
   449 
   444 
   479 	// Called when we have a valid drawing surface
   474 	// Called when we have a valid drawing surface
   480 	public void surfaceCreated(SurfaceHolder holder) {
   475 	public void surfaceCreated(SurfaceHolder holder) {
   481 		Log.v("SDL", "surfaceCreated()");
   476 		Log.v("SDL", "surfaceCreated()");
   482 		holder.setType(SurfaceHolder.SURFACE_TYPE_GPU);
   477 		holder.setType(SurfaceHolder.SURFACE_TYPE_GPU);
   483 		SDLActivity.createEGLSurface();
   478 		SDLActivity.createEGLSurface();
   484 //		enableSensor(Sensor.TYPE_ACCELEROMETER, true);
   479 		//		enableSensor(Sensor.TYPE_ACCELEROMETER, true);
   485 	}
   480 	}
   486 
   481 
   487 	// Called when we lose the surface
   482 	// Called when we lose the surface
   488 	public void surfaceDestroyed(SurfaceHolder holder) {
   483 	public void surfaceDestroyed(SurfaceHolder holder) {
   489 		Log.v("SDL", "surfaceDestroyed()");
   484 		Log.v("SDL", "surfaceDestroyed()");
   490 		SDLActivity.nativePause();
   485 		SDLActivity.nativePause();
   491 //		enableSensor(Sensor.TYPE_ACCELEROMETER, false);
   486 		//		enableSensor(Sensor.TYPE_ACCELEROMETER, false);
   492 	}
   487 	}
   493 
   488 
   494 	// Called when the surface is resized
   489 	// Called when the surface is resized
   495 	public void surfaceChanged(SurfaceHolder holder,
   490 	public void surfaceChanged(SurfaceHolder holder,
   496 			int format, int width, int height) {
   491 			int format, int width, int height) {
   552 
   547 
   553 
   548 
   554 
   549 
   555 	// Key events
   550 	// Key events
   556 	public boolean onKey(View  v, int keyCode, KeyEvent event) {
   551 	public boolean onKey(View  v, int keyCode, KeyEvent event) {
   557 		if(keyCode == KeyEvent.KEYCODE_BACK) return false;
   552 		switch(keyCode){
       
   553 		case KeyEvent.KEYCODE_BACK:
       
   554 		        PascalExports.HWterminate(true);
       
   555                         return true;
       
   556 		case KeyEvent.KEYCODE_VOLUME_DOWN:
       
   557 		case KeyEvent.KEYCODE_VOLUME_UP:
       
   558 		case KeyEvent.KEYCODE_VOLUME_MUTE:
       
   559 			return false;
       
   560 		}
   558 		if (event.getAction() == KeyEvent.ACTION_DOWN) {
   561 		if (event.getAction() == KeyEvent.ACTION_DOWN) {
   559 			//Log.v("SDL", "key down: " + keyCode);
   562 			//Log.v("SDL", "key down: " + keyCode);
   560 			SDLActivity.onNativeKeyDown(keyCode);
   563 			SDLActivity.onNativeKeyDown(keyCode);
   561 			return true;
   564 			return true;
   562 		}
   565 		}