コード例 #1
0
ファイル: SDLActivity.java プロジェクト: kobr4/Lincity4droid
  // Key events
  public boolean onKey(View v, int keyCode, KeyEvent event) {

    if (event.getAction() == KeyEvent.ACTION_DOWN) {
      // Log.v("SDL", "key down: " + keyCode);
      SDLActivity.onNativeKeyDown(keyCode);
      return true;
    } else if (event.getAction() == KeyEvent.ACTION_UP) {
      // Log.v("SDL", "key up: " + keyCode);
      SDLActivity.onNativeKeyUp(keyCode);
      return true;
    }

    return false;
  }
コード例 #2
0
ファイル: SDLActivity.java プロジェクト: kobr4/Lincity4droid
  // Called when the surface is resized
  public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
    // Log.v("SDL", "surfaceChanged()");

    int sdlFormat = 0x85151002; // SDL_PIXELFORMAT_RGB565 by default
    switch (format) {
      case PixelFormat.A_8:
        Log.v("SDL", "pixel format A_8");
        break;
      case PixelFormat.LA_88:
        Log.v("SDL", "pixel format LA_88");
        break;
      case PixelFormat.L_8:
        Log.v("SDL", "pixel format L_8");
        break;
      case PixelFormat.RGBA_4444:
        Log.v("SDL", "pixel format RGBA_4444");
        sdlFormat = 0x85421002; // SDL_PIXELFORMAT_RGBA4444
        break;
      case PixelFormat.RGBA_5551:
        Log.v("SDL", "pixel format RGBA_5551");
        sdlFormat = 0x85441002; // SDL_PIXELFORMAT_RGBA5551
        break;
      case PixelFormat.RGBA_8888:
        Log.v("SDL", "pixel format RGBA_8888");
        sdlFormat = 0x86462004; // SDL_PIXELFORMAT_RGBA8888
        break;
      case PixelFormat.RGBX_8888:
        Log.v("SDL", "pixel format RGBX_8888");
        sdlFormat = 0x86262004; // SDL_PIXELFORMAT_RGBX8888
        break;
      case PixelFormat.RGB_332:
        Log.v("SDL", "pixel format RGB_332");
        sdlFormat = 0x84110801; // SDL_PIXELFORMAT_RGB332
        break;
      case PixelFormat.RGB_565:
        Log.v("SDL", "pixel format RGB_565");
        sdlFormat = 0x85151002; // SDL_PIXELFORMAT_RGB565
        break;
      case PixelFormat.RGB_888:
        Log.v("SDL", "pixel format RGB_888");
        // Not sure this is right, maybe SDL_PIXELFORMAT_RGB24 instead?
        sdlFormat = 0x86161804; // SDL_PIXELFORMAT_RGB888
        break;
      default:
        Log.v("SDL", "pixel format unknown " + format);
        break;
    }
    SDLActivity.onNativeResize(width, height, sdlFormat);

    // Now start up the C app thread
    if (mSDLThread == null) {
      mSDLThread = new Thread(new SDLMain(), "SDLThread");
      mSDLThread.start();
    }
  }
コード例 #3
0
ファイル: SDLActivity.java プロジェクト: kobr4/Lincity4droid
  // Touch events
  public boolean onTouch(View v, MotionEvent event) {

    int action = event.getAction();
    float x = event.getX();
    float y = event.getY();
    float p = event.getPressure();

    // TODO: Anything else we need to pass?
    SDLActivity.onNativeTouch(action, x, y, p);
    return true;
  }
コード例 #4
0
ファイル: SDLActivity.java プロジェクト: kobr4/Lincity4droid
  // Called when we lose the surface
  public void surfaceDestroyed(SurfaceHolder holder) {
    // Log.v("SDL", "surfaceDestroyed()");

    // Send a quit message to the application
    SDLActivity.nativeQuit();

    // Now wait for the SDL thread to quit
    if (mSDLThread != null) {
      try {
        mSDLThread.join();
      } catch (Exception e) {
        Log.v("SDL", "Problem stopping thread: " + e);
      }
      mSDLThread = null;

      // Log.v("SDL", "Finished waiting for SDL thread");
    }

    enableSensor(Sensor.TYPE_ACCELEROMETER, false);
  }
コード例 #5
0
ファイル: SDLActivity.java プロジェクト: kobr4/Lincity4droid
 public void onSensorChanged(SensorEvent event) {
   if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
     SDLActivity.onNativeAccel(event.values[0], event.values[1], event.values[2]);
   }
 }
コード例 #6
0
ファイル: SDLActivity.java プロジェクト: kobr4/Lincity4droid
  public void run() {
    // Runs SDL_main()
    SDLActivity.nativeInit();

    // Log.v("SDL", "SDL thread terminated");
  }
コード例 #7
0
ファイル: SDLActivity.java プロジェクト: kobr4/Lincity4droid
 public static void setActivityTitle(String title) {
   // Called from SDLMain() thread and can't directly affect the view
   mSingleton.sendCommand(COMMAND_CHANGE_TITLE, title);
 }