More stuff starting to work but no video yet. App needs some adaptations I guess

This commit is contained in:
Gerhard Stein
2013-10-15 18:37:46 +02:00
parent 16404b2e2f
commit ca228357aa
7 changed files with 89 additions and 16 deletions

View File

@@ -432,6 +432,8 @@ int SDLCALL SDL_ANDROID_RequestNewAdvertisement(void)
return 1;
}
/*
JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(Settings_nativeSetEnv) ( JNIEnv* env, jobject thiz, jstring j_name, jstring j_value )
{
@@ -460,4 +462,4 @@ JAVA_EXPORT_NAME(Settings_nativeChdir) ( JNIEnv* env, jobject thiz, jstring j_d
const char *dirname = (*env)->GetStringUTFChars(env, j_dir, &iscopy);
chdir(dirname);
(*env)->ReleaseStringUTFChars(env, j_dir, dirname);
}
}*/

View File

@@ -13,7 +13,7 @@ LOCAL_CFLAGS := -DSDL_JAVA_PACKAGE_PATH=$(SDL_JAVA_PACKAGE_PATH) -DSDL_CURDIR_PA
LOCAL_CPP_EXTENSION := .cpp
LOCAL_SRC_FILES := sdl_main.c SDL_android_main.cpp
LOCAL_SRC_FILES := sdl_main.c SDL_android_main.cpp repoNatives.c
LOCAL_SHARED_LIBRARIES := sdl-$(SDL_VERSION) application
LOCAL_LDLIBS := -llog

View File

@@ -0,0 +1,13 @@
/* JNI-C++ wrapper stuff */
#ifndef _JNI_WRAPPER_STUFF_H_
#define _JNI_WRAPPER_STUFF_H_
#ifndef SDL_JAVA_PACKAGE_PATH
#error You have to define SDL_JAVA_PACKAGE_PATH to your package path with dots replaced with underscores, for example "com_example_SanAngeles"
#endif
#define JAVA_EXPORT_NAME2(name,package) Java_##package##_##name
#define JAVA_EXPORT_NAME1(name,package) JAVA_EXPORT_NAME2(name,package)
#define JAVA_EXPORT_NAME(name) JAVA_EXPORT_NAME1(name,SDL_JAVA_PACKAGE_PATH)
#endif

View File

@@ -0,0 +1,56 @@
#include <jni.h>
#include <android/log.h>
//#include <GLES/gl.h>
//#include <GLES/glext.h>
#include <sys/time.h>
#include <time.h>
#include <stdint.h>
#include <math.h>
#include <string.h> // for memset()
/*#include "SDL_config.h"
#include "SDL_version.h"
#include "SDL_video.h"
#include "SDL_mouse.h"
#include "SDL_mutex.h"
#include "SDL_thread.h"
#include "SDL_android.h"
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h"
#include "../SDL_sysvideo.h"
#include "SDL_androidvideo.h"*/
#include "jniwrapperstuff.h"
JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(Settings_nativeSetEnv) ( JNIEnv* env, jobject thiz, jstring j_name, jstring j_value )
{
jboolean iscopy;
const char *name = (*env)->GetStringUTFChars(env, j_name, &iscopy);
const char *value = (*env)->GetStringUTFChars(env, j_value, &iscopy);
setenv(name, value, 1);
(*env)->ReleaseStringUTFChars(env, j_name, name);
(*env)->ReleaseStringUTFChars(env, j_value, value);
}
JNIEXPORT jint JNICALL
JAVA_EXPORT_NAME(Settings_nativeChmod) ( JNIEnv* env, jobject thiz, jstring j_name, jint mode )
{
jboolean iscopy;
const char *name = (*env)->GetStringUTFChars(env, j_name, &iscopy);
int ret = chmod(name, mode);
(*env)->ReleaseStringUTFChars(env, j_name, name);
return (ret == 0);
}
JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(Settings_nativeChdir) ( JNIEnv* env, jobject thiz, jstring j_dir )
{
jboolean iscopy;
const char *dirname = (*env)->GetStringUTFChars(env, j_dir, &iscopy);
chdir(dirname);
(*env)->ReleaseStringUTFChars(env, j_dir, dirname);
}