170 lines
3.1 KiB
C++
170 lines
3.1 KiB
C++
#include "android_api.h"
|
|
|
|
#include "main_code.h"
|
|
#include "boost\thread.hpp"
|
|
|
|
boost::shared_ptr<TMyApplication> App(new TMyApplication);
|
|
|
|
boost::mutex m;
|
|
|
|
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height)
|
|
{
|
|
|
|
m.lock();
|
|
try
|
|
{
|
|
if (App->IsInited())
|
|
{
|
|
App->OuterDeinit(); //Clean up what is left at previous launch (if applicable)
|
|
}
|
|
|
|
App->OuterInit(width, height, 480.f, 320.f);
|
|
|
|
App->Inited = true;
|
|
}
|
|
catch (...)
|
|
{
|
|
throw;
|
|
}
|
|
m.unlock();
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_StopSounds(JNIEnv * env, jobject obj)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Update(JNIEnv * env, jobject obj, long dt)
|
|
{
|
|
m.lock();
|
|
try
|
|
{
|
|
if (App->IsInited())
|
|
{
|
|
App->OuterDraw();
|
|
App->OuterUpdate(dt);
|
|
}
|
|
|
|
}
|
|
catch (...)
|
|
{
|
|
throw;
|
|
}
|
|
m.unlock();
|
|
|
|
}
|
|
|
|
JNIEXPORT int JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_IsInited(JNIEnv * env, jobject obj)
|
|
{
|
|
|
|
if (App->IsInited())
|
|
{
|
|
return 1;
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Destroy(JNIEnv * env, jobject obj)
|
|
{
|
|
m.lock();
|
|
try
|
|
{
|
|
if (App->IsInited())
|
|
{
|
|
App->OuterDeinit();
|
|
App->Inited = false;
|
|
}
|
|
|
|
}
|
|
catch (...)
|
|
{
|
|
throw;
|
|
}
|
|
m.unlock();
|
|
}
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapDown(JNIEnv * env, jobject obj, float x, float y, long time)
|
|
{
|
|
*Console<<"OuterOnTapDown";
|
|
m.lock();
|
|
try
|
|
{
|
|
*Console<<"OuterOnTapDown2";
|
|
App->OuterOnTapDown(vec2(x,y));
|
|
}
|
|
catch (...)
|
|
{
|
|
throw;
|
|
}
|
|
m.unlock();
|
|
}
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapUp(JNIEnv * env, jobject obj, float x, float y, long time)
|
|
{
|
|
*Console<<"OuterOnTapUp";
|
|
m.lock();
|
|
try
|
|
{
|
|
*Console<<"OuterOnTapUp2";
|
|
App->OuterOnTapUp(vec2(x,y));
|
|
}
|
|
catch (...)
|
|
{
|
|
throw;
|
|
}
|
|
m.unlock();
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapUpAfterShift(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time)
|
|
{
|
|
m.lock();
|
|
try
|
|
{
|
|
*Console<<"OuterOnTapUp2";
|
|
App->OuterOnTapUpAfterShift(vec2(x,y));
|
|
}
|
|
catch (...)
|
|
{
|
|
throw;
|
|
}
|
|
m.unlock();
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapMove(JNIEnv * env, jobject obj, float x, float y, long time)
|
|
{
|
|
//NIU???
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnFling(JNIEnv * env, jobject obj, jfloat velocityX, jfloat velocityY, long time)
|
|
{
|
|
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnScroll(JNIEnv * env, jobject obj, jfloat distanceX, jfloat distanceY, long time)
|
|
{
|
|
*Console<<"OuterOnMove";
|
|
m.lock();
|
|
try
|
|
{
|
|
*Console<<"OuterOnMove2";
|
|
App->OuterOnMove(vec2(distanceX,distanceY));
|
|
}
|
|
catch (...)
|
|
{
|
|
throw;
|
|
}
|
|
m.unlock();
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnKeyPress(JNIEnv * env, jobject obj, jint keyCode)
|
|
{
|
|
//App->OnKeyPress(keyCode);
|
|
}
|