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 PascalExports.HWterminate(true); |
|
105 } |
|
106 |
|
107 protected void onDestroy() { |
103 protected void onDestroy() { |
108 super.onDestroy(); |
104 super.onDestroy(); |
109 Log.v("SDL", "onDestroy()"); |
105 Log.v("SDL", "onDestroy()"); |
110 // Send a quit message to the application |
106 // Send a quit message to the application |
111 SDLActivity.nativeQuit(); |
107 SDLActivity.nativeQuit(); |
478 // Called when we have a valid drawing surface |
474 // Called when we have a valid drawing surface |
479 public void surfaceCreated(SurfaceHolder holder) { |
475 public void surfaceCreated(SurfaceHolder holder) { |
480 Log.v("SDL", "surfaceCreated()"); |
476 Log.v("SDL", "surfaceCreated()"); |
481 holder.setType(SurfaceHolder.SURFACE_TYPE_GPU); |
477 holder.setType(SurfaceHolder.SURFACE_TYPE_GPU); |
482 SDLActivity.createEGLSurface(); |
478 SDLActivity.createEGLSurface(); |
483 // enableSensor(Sensor.TYPE_ACCELEROMETER, true); |
479 // enableSensor(Sensor.TYPE_ACCELEROMETER, true); |
484 } |
480 } |
485 |
481 |
486 // Called when we lose the surface |
482 // Called when we lose the surface |
487 public void surfaceDestroyed(SurfaceHolder holder) { |
483 public void surfaceDestroyed(SurfaceHolder holder) { |
488 Log.v("SDL", "surfaceDestroyed()"); |
484 Log.v("SDL", "surfaceDestroyed()"); |
489 SDLActivity.nativePause(); |
485 SDLActivity.nativePause(); |
490 // enableSensor(Sensor.TYPE_ACCELEROMETER, false); |
486 // enableSensor(Sensor.TYPE_ACCELEROMETER, false); |
491 } |
487 } |
492 |
488 |
493 // Called when the surface is resized |
489 // Called when the surface is resized |
494 public void surfaceChanged(SurfaceHolder holder, |
490 public void surfaceChanged(SurfaceHolder holder, |
495 int format, int width, int height) { |
491 int format, int width, int height) { |
551 |
547 |
552 |
548 |
553 |
549 |
554 // Key events |
550 // Key events |
555 public boolean onKey(View v, int keyCode, KeyEvent event) { |
551 public boolean onKey(View v, int keyCode, KeyEvent event) { |
556 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 } |
557 if (event.getAction() == KeyEvent.ACTION_DOWN) { |
561 if (event.getAction() == KeyEvent.ACTION_DOWN) { |
558 //Log.v("SDL", "key down: " + keyCode); |
562 //Log.v("SDL", "key down: " + keyCode); |
559 SDLActivity.onNativeKeyDown(keyCode); |
563 SDLActivity.onNativeKeyDown(keyCode); |
560 return true; |
564 return true; |
561 } |
565 } |