From 8fd060fd039f5804aa1f99b1ea48490dbc6d440a Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 3 Sep 2013 21:46:15 +0200 Subject: [PATCH] [DEV] rework android Context --- build | 2 +- sources/ewol/renderer/Android/Context.cpp | 1348 ++++++++++++--------- sources/ewol/renderer/Windows/Context.cpp | 2 +- sources/ewol/renderer/eContext.h | 30 +- 4 files changed, 787 insertions(+), 595 deletions(-) diff --git a/build b/build index 8fd16ebb..4d31bbfa 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 8fd16ebb053e581abae3d839b06bce63ffa69ab3 +Subproject commit 4d31bbfa3d7918ff38cc721da3267519e3b21c91 diff --git a/sources/ewol/renderer/Android/Context.cpp b/sources/ewol/renderer/Android/Context.cpp index 334cbdfc..faa93f8b 100644 --- a/sources/ewol/renderer/Android/Context.cpp +++ b/sources/ewol/renderer/Android/Context.cpp @@ -12,488 +12,15 @@ #include #include #include -#include +#include #include #include /* include auto generated file */ #include -typedef enum { - appl_unknow, - appl_application, - appl_wallpaper -} application_te; -static application_te javaApplicationType = appl_unknow; - -// get a resources from the java environement : -static JNIEnv* JavaVirtualMachinePointer = NULL; // the JVM -static jclass javaClassEwol = 0; // main activity class (android ...) -static jclass javaClassEwolCallbackAndActivity = 0; -static jobject javaObjectEwolCallbackAndActivity = 0; - -static jmethodID javaMethodEwolCallbackEventNotifier = 0; // basic methode to call ... -static jmethodID javaMethodEwolCallbackKeyboardUpdate = 0; // basic methode to call ... -static jmethodID javaMethodEwolCallbackOrientationUpdate = 0; -static jmethodID javaMethodEwolActivitySetTitle = 0; -// generic classes -static jclass javaDefaultClassString = 0; // default string class - -static int32_t m_currentHeight = 0; - -static JavaVM* g_JavaVM = NULL; - -// special key of the android system : -static ewol::SpecialKey guiKeyBoardSpecialKeyMode; -// jni doc : /usr/lib/jvm/java-1.6.0-openjdk/include - - -#define __jni_safe_init_method_id(mid, cls, name, sign) ({ \ - mid = JavaVirtualMachinePointer->GetMethodID(cls, name, sign); \ - if(mid == NULL) { \ - EWOL_ERROR("C->java : Can't find the method " << name); \ - /* remove access on the virtual machine : */ \ - JavaVirtualMachinePointer = NULL; \ - return; \ - } \ - }) - -static void java_check_exception(JNIEnv* env) { - if (env->ExceptionOccurred()) { - EWOL_ERROR("C->java : EXEPTION ..."); - env->ExceptionDescribe(); - env->ExceptionClear(); - } -} - -static bool java_attach_current_thread(int *rstatus) { - EWOL_DEBUG("C->java : call java"); - if (NULL == g_JavaVM) { - EWOL_ERROR("C->java : JVM not initialised"); - return false; - } - JNIEnv *JavaVirtualMachinePointer_tmp; - *rstatus = g_JavaVM->GetEnv((void **) &JavaVirtualMachinePointer_tmp, JNI_VERSION_1_6); - if (*rstatus == JNI_EDETACHED) { - JavaVMAttachArgs lJavaVMAttachArgs; - lJavaVMAttachArgs.version = JNI_VERSION_1_6; - lJavaVMAttachArgs.name = "EwolNativeThread"; - lJavaVMAttachArgs.group = NULL; - int status = g_JavaVM->AttachCurrentThread(&JavaVirtualMachinePointer_tmp, &lJavaVMAttachArgs); - java_check_exception(JavaVirtualMachinePointer); - if (status != JNI_OK) { - EWOL_ERROR("C->java : AttachCurrentThread failed : " << status); - return false; - } - } - return true; -} - -static void java_detach_current_thread(int status) { - if(status == JNI_EDETACHED) g_JavaVM->DetachCurrentThread(); -} - - -void SendJavaKeyboardUpdate(bool showIt) -{ - int status; - if(!java_attach_current_thread(&status)) return; - - //Call java ... - JavaVirtualMachinePointer->CallVoidMethod(javaObjectEwolCallbackAndActivity, javaMethodEwolCallbackKeyboardUpdate, showIt ? JNI_TRUE : JNI_FALSE); - // manage execption : - java_check_exception(JavaVirtualMachinePointer); - java_detach_current_thread(status); -} - -// mode 0 : auto; 1 landscape, 2 portrait -void SendJavaOrientationUpdate(int32_t mode) -{ -#ifndef __ANDROID_PERMISSION__SET_ORIENTATION__ - EWOL_ERROR("C->java : call set orientation without Allow application to do it ... Break..."); - return; -#else - int status; - if(!java_attach_current_thread(&status)) { - return; - } - jint param = mode; - - //Call java ... - JavaVirtualMachinePointer->CallVoidMethod(javaObjectEwolCallbackAndActivity, javaMethodEwolCallbackOrientationUpdate, param); - - // manage execption : - java_check_exception(JavaVirtualMachinePointer); - java_detach_current_thread(status); -#endif -} - - -void SendJavaSetTitle(const char * dataString) -{ - EWOL_DEBUG("C->java : send message to the java : \"" << dataString << "\""); - if (javaApplicationType == appl_application) { - int status; - if(!java_attach_current_thread(&status)) { - return; - } - EWOL_DEBUG("C->java : 222"); - if (NULL == dataString) { - EWOL_ERROR("C->java : No data to send ..."); - return; - } - - //Call java ... - jstring title = JavaVirtualMachinePointer->NewStringUTF(dataString); - JavaVirtualMachinePointer->CallVoidMethod(javaObjectEwolCallbackAndActivity, javaMethodEwolActivitySetTitle, title); - JavaVirtualMachinePointer->DeleteLocalRef(title); - // manage execption : - java_check_exception(JavaVirtualMachinePointer); - java_detach_current_thread(status); - } else { - EWOL_ERROR("C->java : can not set title on appliation that is not real application"); - } -} - - - -void SendSystemMessage(const char * dataString) -{ - EWOL_DEBUG("C->java : send message to the java : \"" << dataString << "\""); - int status; - if(!java_attach_current_thread(&status)) { - return; - } - EWOL_DEBUG("C->java : 222"); - if (NULL == dataString) { - EWOL_ERROR("C->java : No data to send ..."); - return; - } - EWOL_DEBUG("C->java : 333"); - // create the string to the java - jstring jstr = JavaVirtualMachinePointer->NewStringUTF(dataString); - if (jstr == 0) { - EWOL_ERROR("C->java : Out of memory" ); - return; - } - EWOL_DEBUG("C->java : 444"); - // create argument list - jobjectArray args = JavaVirtualMachinePointer->NewObjectArray(1, javaDefaultClassString, jstr); - if (args == 0) { - EWOL_ERROR("C->java : Out of memory" ); - return; - } - EWOL_DEBUG("C->java : 555"); - //Call java ... - JavaVirtualMachinePointer->CallVoidMethod(javaObjectEwolCallbackAndActivity, javaMethodEwolCallbackEventNotifier, args); - - EWOL_DEBUG("C->java : 666"); - java_check_exception(JavaVirtualMachinePointer); - java_detach_current_thread(status); -} - - - -namespace guiAbstraction { - void SendKeyboardEvent(bool isDown, uniChar_t keyInput); -}; - -extern "C" -{ - // JNI OnLoad - JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* jvm, void* reserved) - { - // get the java virtual machine handle ... - g_JavaVM = jvm; - EWOL_DEBUG("JNI-> load the jvm ..." ); - return JNI_VERSION_1_6; - } - // JNI OnUnLoad - JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) - { - g_JavaVM = NULL; - EWOL_DEBUG("JNI-> Un-load the jvm ..." ); - } - - /* Call to initialize the graphics state */ - void Java_org_ewol_Ewol_paramSetArchiveDir(JNIEnv* env, jclass cls, jint mode, jstring myString) - { - // direct setting of the date in the string system ... - jboolean isCopy; - const char* str = env->GetStringUTFChars(myString, &isCopy); - eSystem::SetArchiveDir(mode, str); - if (isCopy == JNI_TRUE) { - // from here str is reset ... - env->ReleaseStringUTFChars(myString, str); - str = NULL; - } - } - - static void setJavaVirtualMachineStart(JNIEnv* env, jclass classBase, jobject objCallback) - { - EWOL_DEBUG("*******************************************"); - if (javaApplicationType == appl_application) { - EWOL_DEBUG("** Set JVM Pointer (application) **"); - } else { - EWOL_DEBUG("** Set JVM Pointer (LiveWallpaper) **"); - } - EWOL_DEBUG("*******************************************"); - JavaVirtualMachinePointer = env; - // get default needed all time elements : - if (NULL != JavaVirtualMachinePointer) { - EWOL_DEBUG("C->java : try load org/ewol/Ewol class"); - javaClassEwol = JavaVirtualMachinePointer->FindClass("org/ewol/Ewol" ); - if (javaClassEwol == 0) { - EWOL_ERROR("C->java : Can't find org/ewol/Ewol class"); - // remove access on the virtual machine : - JavaVirtualMachinePointer = NULL; - return; - } - /* The object field extends Activity and implement EwolCallback */ - javaClassEwolCallbackAndActivity = JavaVirtualMachinePointer->GetObjectClass(objCallback); - if(javaClassEwolCallbackAndActivity == NULL) { - EWOL_ERROR("C->java : Can't find org/ewol/EwolCallback class"); - // remove access on the virtual machine : - JavaVirtualMachinePointer = NULL; - return; - } - - if (javaApplicationType == appl_application) { - __jni_safe_init_method_id(javaMethodEwolActivitySetTitle, - javaClassEwolCallbackAndActivity, - "setTitle", - "(Ljava/lang/CharSequence;)V"); - } - - __jni_safe_init_method_id(javaMethodEwolCallbackEventNotifier, - javaClassEwolCallbackAndActivity, - "eventNotifier", - "([Ljava/lang/String;)V"); - - __jni_safe_init_method_id(javaMethodEwolCallbackKeyboardUpdate, - javaClassEwolCallbackAndActivity, - "keyboardUpdate", - "(Z)V"); - - __jni_safe_init_method_id(javaMethodEwolCallbackOrientationUpdate, - javaClassEwolCallbackAndActivity, - "orientationUpdate", - "(I)V"); - - javaObjectEwolCallbackAndActivity = env->NewGlobalRef(objCallback); - //javaObjectEwolCallbackAndActivity = objCallback; - - javaDefaultClassString = JavaVirtualMachinePointer->FindClass("java/lang/String" ); - if (javaDefaultClassString == 0) { - EWOL_ERROR("C->java : Can't find java/lang/String" ); - // remove access on the virtual machine : - JavaVirtualMachinePointer = NULL; - return; - } - } - } - - void Java_org_ewol_Ewol_setJavaVirtualMachineStart(JNIEnv* _env, jclass _classBase, jobject _objCallback) - { - javaApplicationType = appl_application; - setJavaVirtualMachineStart(_env, _classBase, _objCallback); - } - - void Java_org_ewol_Ewol_setJavaVirtualMachineStartWallpaperEngine(JNIEnv* _env, jclass _classBase, jobject _objCallback) - { - javaApplicationType = appl_wallpaper; - setJavaVirtualMachineStart(_env, _classBase, _objCallback); - } - - - void Java_org_ewol_Ewol_setJavaVirtualMachineStop(JNIEnv* env, jclass cls) { - EWOL_DEBUG("*******************************************"); - EWOL_DEBUG("** Remove JVM Pointer **"); - EWOL_DEBUG("*******************************************"); - env->DeleteGlobalRef(javaObjectEwolCallbackAndActivity); - JavaVirtualMachinePointer = NULL; - } - void Java_org_ewol_Ewol_touchEvent( JNIEnv* env, jobject thiz ) - { - EWOL_DEBUG(" ==> Touch Event"); - java_check_exception(env); - } - - void Java_org_ewol_Ewol_onCreate( JNIEnv* env, jobject thiz ) - { - EWOL_DEBUG("*******************************************"); - EWOL_DEBUG("** Activity On Create **"); - EWOL_DEBUG("*******************************************"); - eSystem::Init(); - } - - void Java_org_ewol_Ewol_onStart(JNIEnv* env, jobject thiz) - { - EWOL_DEBUG("*******************************************"); - EWOL_DEBUG("** Activity On Start **"); - EWOL_DEBUG("*******************************************"); - //SendSystemMessage(" testmessages ... "); - } - void Java_org_ewol_Ewol_onReStart(JNIEnv* env, jobject thiz) - { - EWOL_DEBUG("*******************************************"); - EWOL_DEBUG("** Activity On Re-Start **"); - EWOL_DEBUG("*******************************************"); - } - void Java_org_ewol_Ewol_onResume(JNIEnv* env, jobject thiz) - { - EWOL_DEBUG("*******************************************"); - EWOL_DEBUG("** Activity On Resume **"); - EWOL_DEBUG("*******************************************"); - } - void Java_org_ewol_Ewol_onPause(JNIEnv* env, jobject thiz) - { - EWOL_DEBUG("*******************************************"); - EWOL_DEBUG("** Activity On Pause **"); - EWOL_DEBUG("*******************************************"); - // All the openGl has been destroyed ... - eSystem::OpenGlContextDestroy(); - } - void Java_org_ewol_Ewol_onStop(JNIEnv* env, jobject thiz) - { - EWOL_DEBUG("*******************************************"); - EWOL_DEBUG("** Activity On Stop **"); - EWOL_DEBUG("*******************************************"); - } - void Java_org_ewol_Ewol_onDestroy(JNIEnv* env, jobject thiz) - { - EWOL_DEBUG("*******************************************"); - EWOL_DEBUG("** Activity On Destroy **"); - EWOL_DEBUG("*******************************************"); - eSystem::UnInit(); - } - - - - /* ********************************************************************************************** - * ** IO section : - * ********************************************************************************************** */ - void Java_org_ewol_Ewol_inputEventMotion( JNIEnv* env, jobject thiz, jint pointerID, jfloat x, jfloat y ) - { - eSystem::SetInputMotion(pointerID+1, x, m_currentHeight-y); - } - - void Java_org_ewol_Ewol_inputEventState( JNIEnv* env, jobject thiz, jint pointerID, jboolean isUp, jfloat x, jfloat y ) - { - eSystem::SetInputState(pointerID+1, isUp, x, m_currentHeight-y); - } - - void Java_org_ewol_Ewol_mouseEventMotion( JNIEnv* env, jobject thiz, jint pointerID, jfloat x, jfloat y ) - { - eSystem::SetMouseMotion(pointerID+1, x, m_currentHeight-y); - } - - void Java_org_ewol_Ewol_mouseEventState( JNIEnv* env, jobject thiz, jint pointerID, jboolean isUp, jfloat x, jfloat y ) - { - eSystem::SetMouseState(pointerID+1, isUp, x, m_currentHeight-y); - } - - void Java_org_ewol_Ewol_unknowEvent( JNIEnv* env, jobject thiz, jint pointerID) - { - EWOL_DEBUG("Unknown IO event : " << pointerID << " ???"); - } - - void Java_org_ewol_Ewol_keyboardEventMove( JNIEnv* env, jobject thiz, jint type, jboolean isdown) - { - EWOL_DEBUG("IO keyboard Move event : \"" << type << "\" is down=" << isdown); - } - - void Java_org_ewol_Ewol_keyboardEventKey( JNIEnv* env, jobject thiz, jint uniChar, jboolean isdown) - { - EWOL_DEBUG("IO keyboard Key event : \"" << uniChar << "\" is down=" << isdown); - eSystem::SetKeyboard(guiKeyBoardSpecialKeyMode, uniChar, isdown); - } - - void Java_org_ewol_Ewol_displayPropertyMetrics( JNIEnv* env, jobject thiz, jfloat ratioX, jfloat ratioY) - { - // set the internal system ratio properties ... - ewol::dimension::SetPixelRatio(vec2(ratioX,ratioY), ewol::Dimension::Inch); - } - - // TODO : Set a return true or false if we want to grep this event ... - void Java_org_ewol_Ewol_keyboardEventKeySystem( JNIEnv* env, jobject thiz, jint keyVal, jboolean isdown) - { - switch (keyVal) { - case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_VOLUME_UP: - EWOL_DEBUG("IO keyboard Key System \"VOLUME_UP\" is down=" << isdown); - break; - case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_VOLUME_DOWN: - EWOL_DEBUG("IO keyboard Key System \"VOLUME_DOWN\" is down=" << isdown); - break; - case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_MENU: - EWOL_DEBUG("IO keyboard Key System \"MENU\" is down=" << isdown); - break; - case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_CAMERA: - EWOL_DEBUG("IO keyboard Key System \"CAMERA\" is down=" << isdown); - break; - case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_HOME: - EWOL_DEBUG("IO keyboard Key System \"HOME\" is down=" << isdown); - break; - case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_POWER: - EWOL_DEBUG("IO keyboard Key System \"POWER\" is down=" << isdown); - break; - default: - EWOL_DEBUG("IO keyboard Key System event : \"" << keyVal << "\" is down=" << isdown); - break; - } - } - - - /* ********************************************************************************************** - * ** Renderer section : - * ********************************************************************************************** */ - void Java_org_ewol_Ewol_renderInit(JNIEnv* env, jobject thiz) - { - - } - - void Java_org_ewol_Ewol_renderResize( JNIEnv* env, jobject thiz, jint w, jint h ) - { - m_currentHeight = h; - eSystem::Resize(w, h); - } - - void Java_org_ewol_Ewol_renderDraw(JNIEnv* env, jobject thiz) - { - eSystem::Draw(true); - } - - void Java_org_ewol_Ewol_audioPlayback(JNIEnv* env, void* reserved, jshortArray location, jint frameRate, jint nbChannels) - { - // Get the short* pointer from the Java array - jboolean isCopy; - jshort* dst = env->GetShortArrayElements(location, &isCopy); - if (NULL != dst) { - ewol::audio::GetData(dst, frameRate, nbChannels); - } - //APPL_DEBUG("IO Audio event request: Frames=" << frameRate << " channels=" << nbChannels); - // TODO : Understand why it did not work corectly ... - //if (isCopy == JNI_TRUE) { - // Release the short* pointer - env->ReleaseShortArrayElements(location, dst, 0); - //} - } - -}; - - -#undef __class__ -#define __class__ "guiInterface" - - -int guiInterface::main(int argc, const char *argv[]) -{ - // unneeded fuction, all is controlled by android java ... - return 0; -} - -int64_t guiInterface::GetTime(void) +int64_t ewol::GetTime(void) { struct timeval now; gettimeofday(&now, NULL); @@ -502,119 +29,784 @@ int64_t guiInterface::GetTime(void) } -void guiInterface::SetTitle(etk::UString& title) -{ - SendJavaSetTitle(title.c_str()); +// jni doc : /usr/lib/jvm/java-1.6.0-openjdk/include + +static JavaVM* g_JavaVM=NULL; // global acces on the unique JVM !!! + +void java_check_exception(JNIEnv* _env) { + if (_env->ExceptionOccurred()) { + EWOL_ERROR("C->java : EXEPTION ..."); + _env->ExceptionDescribe(); + _env->ExceptionClear(); + } } - -// ------------------------------------------------------------------------- -// ClipBoard AREA : -// ------------------------------------------------------------------------- - -bool l_clipBoardOwnerStd = false; -void guiInterface::ClipBoardGet(ewol::clipBoard::clipboardListe_te clipboardID) +class AndroidContext : public ewol::eContext { - // this is to force the local system to think we have the buffer - // TODO : Remove this 2 Line when code will be writen - l_clipBoardOwnerStd = true; - switch (clipboardID) - { - case ewol::clipBoard::clipboardSelection: - // NOTE : Windows does not support the middle button the we do it internaly - // just transmit an event , we have the data in the system - eSystem::ClipBoardArrive(clipboardID); - break; - case ewol::clipBoard::clipboardStd: - if (false == l_clipBoardOwnerStd) { - // Generate a request TO the OS - // TODO : Send the message to the OS "We disire to receive the copy buffer ... + public: + typedef enum { + appl_unknow, + appl_application, + appl_wallpaper + } application_te; + private: + application_te m_javaApplicationType; + // get a resources from the java environement : + JNIEnv* m_JavaVirtualMachinePointer; //!< the JVM + jclass m_javaClassEwol; //!< main activity class (android ...) + jclass m_javaClassEwolCallbackAndActivity; + jobject m_javaObjectEwolCallbackAndActivity; + jmethodID m_javaMethodEwolCallbackEventNotifier; //!< basic methode to call ... + jmethodID m_javaMethodEwolCallbackKeyboardUpdate; //!< basic methode to call ... + jmethodID m_javaMethodEwolCallbackOrientationUpdate; + jmethodID m_javaMethodEwolActivitySetTitle; + jclass m_javaDefaultClassString; //!< default string class + int32_t m_currentHeight; + ewol::SpecialKey m_guiKeyBoardSpecialKeyMode;//!< special key of the android system : + bool m_clipBoardOwnerStd; + private: + bool SafeInitMethodID(jmethodID& _mid, jclass& _cls, char* _name, char* _sign) + { + _mid = m_JavaVirtualMachinePointer->GetMethodID(_cls, _name, _sign); + if(_mid == NULL) { + EWOL_ERROR("C->java : Can't find the method " << _name); + /* remove access on the virtual machine : */ + m_JavaVirtualMachinePointer = NULL; + return false; + } + return true; + } + public: + AndroidContext(JNIEnv* _env, jclass _classBase, jobject _objCallback, application_te _typeAPPL) : + m_javaApplicationType(_typeAPPL), + m_JavaVirtualMachinePointer(NULL), + m_javaClassEwol(0), + m_javaClassEwolCallbackAndActivity(0), + m_javaObjectEwolCallbackAndActivity(0), + m_javaMethodEwolCallbackEventNotifier(0), + m_javaMethodEwolCallbackKeyboardUpdate(0), + m_javaMethodEwolCallbackOrientationUpdate(0), + m_javaMethodEwolActivitySetTitle(0), + m_javaDefaultClassString(0), + m_currentHeight(0), + m_clipBoardOwnerStd(false) + { + EWOL_DEBUG("*******************************************"); + if (m_javaApplicationType == appl_application) { + EWOL_DEBUG("** Set JVM Pointer (application) **"); } else { - // just transmit an event , we have the data in the system - eSystem::ClipBoardArrive(clipboardID); + EWOL_DEBUG("** Set JVM Pointer (LiveWallpaper) **"); } - break; - default: - EWOL_ERROR("Request an unknow ClipBoard ..."); - break; - } -} + EWOL_DEBUG("*******************************************"); + m_JavaVirtualMachinePointer = _env; + // get default needed all time elements : + if (NULL != m_JavaVirtualMachinePointer) { + EWOL_DEBUG("C->java : try load org/ewol/Ewol class"); + m_javaClassEwol = m_JavaVirtualMachinePointer->FindClass("org/ewol/Ewol" ); + if (m_javaClassEwol == 0) { + EWOL_ERROR("C->java : Can't find org/ewol/Ewol class"); + // remove access on the virtual machine : + m_JavaVirtualMachinePointer = NULL; + return; + } + /* The object field extends Activity and implement EwolCallback */ + m_javaClassEwolCallbackAndActivity = m_JavaVirtualMachinePointer->GetObjectClass(_objCallback); + if(m_javaClassEwolCallbackAndActivity == NULL) { + EWOL_ERROR("C->java : Can't find org/ewol/EwolCallback class"); + // remove access on the virtual machine : + m_JavaVirtualMachinePointer = NULL; + return; + } + bool ret= false; + if (m_javaApplicationType == appl_application) { + ret=SafeInitMethodID(m_javaMethodEwolActivitySetTitle, + m_javaClassEwolCallbackAndActivity, + "setTitle", + "(Ljava/lang/CharSequence;)V"); + if (ret==false) { + return; + } + } + + ret=SafeInitMethodID(m_javaMethodEwolCallbackEventNotifier, + m_javaClassEwolCallbackAndActivity, + "eventNotifier", + "([Ljava/lang/String;)V"); + if (ret==false) { + return; + } + + ret=SafeInitMethodID(m_javaMethodEwolCallbackKeyboardUpdate, + m_javaClassEwolCallbackAndActivity, + "keyboardUpdate", + "(Z)V"); + if (ret==false) { + return; + } + + ret=SafeInitMethodID(m_javaMethodEwolCallbackOrientationUpdate, + m_javaClassEwolCallbackAndActivity, + "orientationUpdate", + "(I)V"); + if (ret==false) { + return; + } + + m_javaObjectEwolCallbackAndActivity = _env->NewGlobalRef(_objCallback); + //javaObjectEwolCallbackAndActivity = objCallback; + + m_javaDefaultClassString = m_JavaVirtualMachinePointer->FindClass("java/lang/String" ); + if (m_javaDefaultClassString == 0) { + EWOL_ERROR("C->java : Can't find java/lang/String" ); + // remove access on the virtual machine : + m_JavaVirtualMachinePointer = NULL; + return; + } + } + } + + ~AndroidContext(void) + { + + } + + void UnInit(JNIEnv* _env) + { + _env->DeleteGlobalRef(m_javaObjectEwolCallbackAndActivity); + m_javaObjectEwolCallbackAndActivity = NULL; + } + + + int32_t Run(void) + { + // might never be called !!! + return -1; + } + + void Stop(void) + { + // TODO : send a message to the android system to stop ... + } + + void ClipBoardGet(ewol::clipBoard::clipboardListe_te _clipboardID) + { + // this is to force the local system to think we have the buffer + // TODO : Remove this 2 Line when code will be writen + m_clipBoardOwnerStd = true; + switch (_clipboardID) + { + case ewol::clipBoard::clipboardSelection: + // NOTE : Windows does not support the middle button the we do it internaly + // just transmit an event , we have the data in the system + OS_ClipBoardArrive(_clipboardID); + break; + case ewol::clipBoard::clipboardStd: + if (false == m_clipBoardOwnerStd) { + // Generate a request TO the OS + // TODO : Send the message to the OS "We disire to receive the copy buffer ... + } else { + // just transmit an event , we have the data in the system + OS_ClipBoardArrive(_clipboardID); + } + break; + default: + EWOL_ERROR("Request an unknow ClipBoard ..."); + break; + } + } + + void ClipBoardSet(ewol::clipBoard::clipboardListe_te _clipboardID) + { + switch (_clipboardID) + { + case ewol::clipBoard::clipboardSelection: + // NOTE : nothing to do : Windows deas ot supported Middle button + break; + case ewol::clipBoard::clipboardStd: + // Request the clipBoard : + if (false == m_clipBoardOwnerStd) { + // TODO : Inform the OS that we have the current buffer of copy ... + m_clipBoardOwnerStd = true; + } + break; + default: + EWOL_ERROR("Request an unknow ClipBoard ..."); + break; + } + } -void guiInterface::ClipBoardSet(ewol::clipBoard::clipboardListe_te clipboardID) + private: + + + bool java_attach_current_thread(int *_rstatus) { + EWOL_DEBUG("C->java : call java"); + if (NULL == g_JavaVM) { + EWOL_ERROR("C->java : JVM not initialised"); + return false; + } + JNIEnv *JavaVirtualMachinePointer_tmp; + *_rstatus = g_JavaVM->GetEnv((void **) &JavaVirtualMachinePointer_tmp, JNI_VERSION_1_6); + if (*_rstatus == JNI_EDETACHED) { + JavaVMAttachArgs lJavaVMAttachArgs; + lJavaVMAttachArgs.version = JNI_VERSION_1_6; + lJavaVMAttachArgs.name = "EwolNativeThread"; + lJavaVMAttachArgs.group = NULL; + int status = g_JavaVM->AttachCurrentThread(&JavaVirtualMachinePointer_tmp, &lJavaVMAttachArgs); + java_check_exception(m_JavaVirtualMachinePointer); + if (status != JNI_OK) { + EWOL_ERROR("C->java : AttachCurrentThread failed : " << status); + return false; + } + } + return true; + } + + void java_detach_current_thread(int _status) { + if(_status == JNI_EDETACHED) { + g_JavaVM->DetachCurrentThread(); + } + } + + + void SendJavaKeyboardUpdate(jboolean _showIt) + { + int status; + if(!java_attach_current_thread(&status)) { + return; + } + + //Call java ... + m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallbackAndActivity, m_javaMethodEwolCallbackKeyboardUpdate, _showIt); + // manage execption : + java_check_exception(m_JavaVirtualMachinePointer); + java_detach_current_thread(status); + } + void KeyboardShow(void) { SendJavaKeyboardUpdate(JNI_TRUE); }; + void KeyboardHide(void) { SendJavaKeyboardUpdate(JNI_FALSE); }; + + // mode 0 : auto; 1 landscape, 2 portrait + void ForceOrientation(ewol::orientation_te _orientation) + { + #ifndef __ANDROID_PERMISSION__SET_ORIENTATION__ + EWOL_ERROR("C->java : call set orientation without Allow application to do it ... Break..."); + return; + #else + int status; + if(!java_attach_current_thread(&status)) { + return; + } + jint param = (jint)_orientation; + + //Call java ... + m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallbackAndActivity, m_javaMethodEwolCallbackOrientationUpdate, param); + + // manage execption : + java_check_exception(m_JavaVirtualMachinePointer); + java_detach_current_thread(status); + #endif + } + + void SetTitle(etk::UString& _title) + { + EWOL_DEBUG("C->java : send message to the java : \"" << _title << "\""); + if (m_javaApplicationType == appl_application) { + int status; + if(!java_attach_current_thread(&status)) { + return; + } + etk::Char tmpChar = _title.c_str(); + //Call java ... + jstring title = m_JavaVirtualMachinePointer->NewStringUTF(tmpChar); + m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallbackAndActivity, m_javaMethodEwolActivitySetTitle, title); + m_JavaVirtualMachinePointer->DeleteLocalRef(title); + // manage execption : + java_check_exception(m_JavaVirtualMachinePointer); + java_detach_current_thread(status); + } else { + EWOL_ERROR("C->java : can not set title on appliation that is not real application"); + } + } + + + + void SendSystemMessage(const char* _dataString) + { + EWOL_DEBUG("C->java : send message to the java : \"" << _dataString << "\""); + int status; + if(!java_attach_current_thread(&status)) { + return; + } + EWOL_DEBUG("C->java : 222"); + if (NULL == _dataString) { + EWOL_ERROR("C->java : No data to send ..."); + return; + } + EWOL_DEBUG("C->java : 333"); + // create the string to the java + jstring jstr = m_JavaVirtualMachinePointer->NewStringUTF(_dataString); + if (jstr == 0) { + EWOL_ERROR("C->java : Out of memory" ); + return; + } + EWOL_DEBUG("C->java : 444"); + // create argument list + jobjectArray args = m_JavaVirtualMachinePointer->NewObjectArray(1, m_javaDefaultClassString, jstr); + if (args == 0) { + EWOL_ERROR("C->java : Out of memory" ); + return; + } + EWOL_DEBUG("C->java : 555"); + //Call java ... + m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallbackAndActivity, m_javaMethodEwolCallbackEventNotifier, args); + + EWOL_DEBUG("C->java : 666"); + java_check_exception(m_JavaVirtualMachinePointer); + java_detach_current_thread(status); + } + public: + void OS_SetInputMotion(int _pointerID, const vec2& _pos) + { + ewol::eContext::OS_SetInputMotion(_pointerID, vec2(_pos.x(),m_currentHeight-_pos.y()) ); + } + + void OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos) + { + ewol::eContext::OS_SetInputState(_pointerID, _isDown, vec2(_pos.x(),m_currentHeight-_pos.y()) ); + } + + void OS_SetMouseMotion(int _pointerID, const vec2& _pos) + { + ewol::eContext::OS_SetMouseMotion(_pointerID, vec2(_pos.x(),m_currentHeight-_pos.y()) ); + } + + void OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos) + { + ewol::eContext::OS_SetMouseState(_pointerID, _isDown, vec2(_pos.x(),m_currentHeight-_pos.y()) ); + } + void ANDROID_SetKeyboard(uniChar_t _myChar, bool _isDown, bool _isARepeateKey=false) + { + OS_SetKeyboard(m_guiKeyBoardSpecialKeyMode, _myChar, _isDown, _isARepeateKey); + } + void OS_Resize(const vec2& _size) + { + m_currentHeight = _size.y(); + ewol::eContext::OS_Resize(_size); + } +}; + +static etk::Vector s_listInstance; + +extern "C" { - switch (clipboardID) + // JNI OnLoad + JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* _jvm, void* _reserved) { - case ewol::clipBoard::clipboardSelection: - // NOTE : nothing to do : Windows deas ot supported Middle button - break; - case ewol::clipBoard::clipboardStd: - // Request the clipBoard : - if (false == l_clipBoardOwnerStd) { - // TODO : Inform the OS that we have the current buffer of copy ... - l_clipBoardOwnerStd = true; - } - break; - default: - EWOL_ERROR("Request an unknow ClipBoard ..."); - break; + // get the java virtual machine handle ... + g_JavaVM = _jvm; + EWOL_DEBUG("JNI-> load the jvm ..." ); + return JNI_VERSION_1_6; } -} + // JNI OnUnLoad + JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* _vm, void *_reserved) + { + g_JavaVM = NULL; + EWOL_DEBUG("JNI-> Un-load the jvm ..." ); + } + + /* Call to initialize the graphics state */ + void Java_org_ewol_Ewol_paramSetArchiveDir(JNIEnv* _env, jclass _cls, jint _mode, jstring _myString) + { + esize_t _id=0; + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + // direct setting of the date in the string system ... + jboolean isCopy; + const char* str = _env->GetStringUTFChars(_myString, &isCopy); + s_listInstance[_id]->SetArchiveDir(_mode, str); + if (isCopy == JNI_TRUE) { + // from here str is reset ... + _env->ReleaseStringUTFChars(_myString, str); + str = NULL; + } + } + + // TODO : Return the local ID ... + void Java_org_ewol_Ewol_setJavaVirtualMachineStart(JNIEnv* _env, jclass _classBase, jobject _objCallback) + { + AndroidContext* tmpContext = new AndroidContext(_env, _classBase, _objCallback, AndroidContext::appl_application); + if (NULL == tmpContext) { + EWOL_ERROR("Can not allocate the main context instance"); + // TODO : return -1; + } + // TODO : Change this ==> this generate the new ID ... + if (s_listInstance.Size()>0) { + // note : For now : memory leek and errors ... + s_listInstance[0] = tmpContext; + } else { + // for future case : all time this ... + s_listInstance.PushBack(tmpContext); + // esize_t newID = s_listInstance.Size(); + // return newID; + } + } + + // TODO : Return the local ID ... + void Java_org_ewol_Ewol_setJavaVirtualMachineStartWallpaperEngine(JNIEnv* _env, jclass _classBase, jobject _objCallback) + { + AndroidContext* tmpContext = new AndroidContext(_env, _classBase, _objCallback, AndroidContext::appl_wallpaper); + if (NULL == tmpContext) { + EWOL_ERROR("Can not allocate the main context instance"); + // TODO : return -1; + } + // TODO : Change this ==> this generate the new ID ... + if (s_listInstance.Size()>0) { + // note : For now : memory leek and errors ... + s_listInstance[0] = tmpContext; + } else { + // for future case : all time this ... + s_listInstance.PushBack(tmpContext); + // esize_t newID = s_listInstance.Size(); + // return newID; + } + } + + + void Java_org_ewol_Ewol_setJavaVirtualMachineStop(JNIEnv* _env, jclass _cls) + { + EWOL_DEBUG("*******************************************"); + EWOL_DEBUG("** Remove JVM Pointer **"); + EWOL_DEBUG("*******************************************"); + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + s_listInstance[_id]->UnInit(_env); + delete(s_listInstance[_id]); + s_listInstance[_id]=NULL; + } + void Java_org_ewol_Ewol_touchEvent(JNIEnv* _env, jobject _thiz ) + { + EWOL_DEBUG(" ==> Touch Event"); + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + java_check_exception(_env); + } + + void Java_org_ewol_Ewol_onCreate(JNIEnv* _env, jobject _thiz ) + { + EWOL_DEBUG("*******************************************"); + EWOL_DEBUG("** Activity On Create **"); + EWOL_DEBUG("*******************************************"); + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + //s_listInstance[_id]->Init(); + } + + void Java_org_ewol_Ewol_onStart(JNIEnv* _env, jobject _thiz) + { + EWOL_DEBUG("*******************************************"); + EWOL_DEBUG("** Activity On Start **"); + EWOL_DEBUG("*******************************************"); + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + //SendSystemMessage(" testmessages ... "); + } + void Java_org_ewol_Ewol_onReStart(JNIEnv* _env, jobject _thiz) + { + EWOL_DEBUG("*******************************************"); + EWOL_DEBUG("** Activity On Re-Start **"); + EWOL_DEBUG("*******************************************"); + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + } + void Java_org_ewol_Ewol_onResume(JNIEnv* _env, jobject _thiz) + { + EWOL_DEBUG("*******************************************"); + EWOL_DEBUG("** Activity On Resume **"); + EWOL_DEBUG("*******************************************"); + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + } + void Java_org_ewol_Ewol_onPause(JNIEnv* _env, jobject _thiz) + { + EWOL_DEBUG("*******************************************"); + EWOL_DEBUG("** Activity On Pause **"); + EWOL_DEBUG("*******************************************"); + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + // All the openGl has been destroyed ... + s_listInstance[_id]->GetResourcesManager().ContextHasBeenDestroyed(); + } + void Java_org_ewol_Ewol_onStop(JNIEnv* _env, jobject _thiz) + { + EWOL_DEBUG("*******************************************"); + EWOL_DEBUG("** Activity On Stop **"); + EWOL_DEBUG("*******************************************"); + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + } + void Java_org_ewol_Ewol_onDestroy(JNIEnv* _env, jobject _thiz) + { + EWOL_DEBUG("*******************************************"); + EWOL_DEBUG("** Activity On Destroy **"); + EWOL_DEBUG("*******************************************"); + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + //s_listInstance[_id]->UnInit(); + } + + + + /* ********************************************************************************************** + * ** IO section : + * ********************************************************************************************** */ + void Java_org_ewol_Ewol_inputEventMotion(JNIEnv* _env, jobject _thiz, jint _pointerID, jfloat _x, jfloat _y ) + { + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + s_listInstance[_id]->OS_SetInputMotion(_pointerID+1, vec2(_x,_y)); + } + + void Java_org_ewol_Ewol_inputEventState(JNIEnv* _env, jobject _thiz, jint _pointerID, jboolean _isUp, jfloat _x, jfloat _y) + { + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + s_listInstance[_id]->OS_SetInputState(_pointerID+1, _isUp, vec2(_x,_y)); + } + + void Java_org_ewol_Ewol_mouseEventMotion(JNIEnv* _env, jobject _thiz, jint _pointerID, jfloat _x, jfloat _y) + { + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + s_listInstance[_id]->OS_SetMouseMotion(_pointerID+1, vec2(_x,_y)); + } + + void Java_org_ewol_Ewol_mouseEventState(JNIEnv* _env, jobject _thiz, jint _pointerID, jboolean _isUp, jfloat _x, jfloat _y) + { + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + s_listInstance[_id]->OS_SetMouseState(_pointerID+1, _isUp, vec2(_x,_y)); + } + + void Java_org_ewol_Ewol_unknowEvent(JNIEnv* _env, jobject _thiz, jint _pointerID) + { + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + EWOL_DEBUG("Unknown IO event : " << _pointerID << " ???"); + } + + void Java_org_ewol_Ewol_keyboardEventMove(JNIEnv* _env, jobject _thiz, jint _type, jboolean _isdown) + { + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + EWOL_DEBUG("IO keyboard Move event : \"" << _type << "\" is down=" << _isdown); + } + + void Java_org_ewol_Ewol_keyboardEventKey(JNIEnv* _env, jobject _thiz, jint _uniChar, jboolean _isdown) + { + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + EWOL_DEBUG("IO keyboard Key event : \"" << _uniChar << "\" is down=" << _isdown); + s_listInstance[_id]->ANDROID_SetKeyboard(_uniChar, _isdown); + } + + void Java_org_ewol_Ewol_displayPropertyMetrics(JNIEnv* _env, jobject _thiz, jfloat _ratioX, jfloat _ratioY) + { + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + // set the internal system ratio properties ... + ewol::dimension::SetPixelRatio(vec2(_ratioX,_ratioY), ewol::Dimension::Inch); + } + + // TODO : Set a return true or false if we want to grep this event ... + void Java_org_ewol_Ewol_keyboardEventKeySystem(JNIEnv* _env, jobject _thiz, jint _keyVal, jboolean _isdown) + { + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + switch (_keyVal) { + case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_VOLUME_UP: + EWOL_DEBUG("IO keyboard Key System \"VOLUME_UP\" is down=" << _isdown); + break; + case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_VOLUME_DOWN: + EWOL_DEBUG("IO keyboard Key System \"VOLUME_DOWN\" is down=" << _isdown); + break; + case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_MENU: + EWOL_DEBUG("IO keyboard Key System \"MENU\" is down=" << _isdown); + break; + case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_CAMERA: + EWOL_DEBUG("IO keyboard Key System \"CAMERA\" is down=" << _isdown); + break; + case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_HOME: + EWOL_DEBUG("IO keyboard Key System \"HOME\" is down=" << _isdown); + break; + case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_POWER: + EWOL_DEBUG("IO keyboard Key System \"POWER\" is down=" << _isdown); + break; + default: + EWOL_DEBUG("IO keyboard Key System event : \"" << _keyVal << "\" is down=" << _isdown); + break; + } + } + + + /* ********************************************************************************************** + * ** Renderer section : + * ********************************************************************************************** */ + void Java_org_ewol_Ewol_renderInit(JNIEnv* _env, jobject _thiz) + { + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + + } + + void Java_org_ewol_Ewol_renderResize( JNIEnv* _env, jobject _thiz, jint _w, jint _h ) + { + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + s_listInstance[_id]->OS_Resize(vec2(_w, _h)); + } + + // TODO : Return tur or foalse to not redraw when the under draw has not be done (processing gain of time) + void Java_org_ewol_Ewol_renderDraw(JNIEnv* _env, jobject _thiz) + { + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + s_listInstance[_id]->OS_Draw(true); + } + + void Java_org_ewol_Ewol_audioPlayback(JNIEnv* _env, void* _reserved, jshortArray _location, jint _frameRate, jint _nbChannels) + { + esize_t _id = 0; // uint + if( _id>=s_listInstance.Size() + || NULL==s_listInstance[_id] ) { + EWOL_ERROR("Call C With an incorrect instance"); + // TODO : Generate error in java to stop the current instance + return; + } + // Get the short* pointer from the Java array + jboolean isCopy; + jshort* dst = _env->GetShortArrayElements(_location, &isCopy); + if (NULL != dst) { + ewol::audio::GetData(dst, _frameRate, _nbChannels); + } + //APPL_DEBUG("IO Audio event request: Frames=" << frameRate << " channels=" << nbChannels); + // TODO : Understand why it did not work corectly ... + //if (isCopy == JNI_TRUE) { + // Release the short* pointer + _env->ReleaseShortArrayElements(_location, dst, 0); + //} + } +}; -void guiInterface::Stop(void) +int ewol::Run(int _argc, const char *_argv[]) { - // TODO : send a message to the android system to stop ... + // Never call but needed ... } - -// java system to send message : -void SendSystemMessage(const char * dataString); -void SendJavaKeyboardUpdate(bool showIt); - -void guiInterface::KeyboardShow(void) -{ - // send a message at the java : - SendJavaKeyboardUpdate(true); -} - -void guiInterface::KeyboardHide(void) -{ - // send a message at the java : - SendJavaKeyboardUpdate(false); -} - -void guiInterface::ChangeSize(ivec2 size) -{ - // The size can not be change on android platform -} - -void guiInterface::ChangePos(ivec2 size) -{ - // The position can not be change on Android platform -} - -void guiInterface::GetAbsPos(ivec2& size) -{ - size.setValue(0,0); -} - -void guiInterface::ForceOrientation(ewol::orientation_te orientation) -{ - SendJavaOrientationUpdate((int32_t)orientation); -} - -void guiInterface::GrabPointerEvents(bool isGrabbed, vec2 forcedPosition) -{ - // nothing to do ... -} - -void guiInterface::SetCursor(ewol::cursorDisplay_te newCursor) -{ - // nothing to do ... -} - -void guiInterface::SetIcon(etk::UString inputFile) -{ - // nothing to do ... -} - - diff --git a/sources/ewol/renderer/Windows/Context.cpp b/sources/ewol/renderer/Windows/Context.cpp index fecb53f0..946aa799 100644 --- a/sources/ewol/renderer/Windows/Context.cpp +++ b/sources/ewol/renderer/Windows/Context.cpp @@ -40,7 +40,7 @@ int64_t ewol::GetTime(void) #define __class__ "ContextWindows" -class WindowsContext : public eContext +class WindowsContext : public ewol::eContext { private: int32_t m_currentHeight = 0; diff --git a/sources/ewol/renderer/eContext.h b/sources/ewol/renderer/eContext.h index a64bc0d6..279e1e75 100644 --- a/sources/ewol/renderer/eContext.h +++ b/sources/ewol/renderer/eContext.h @@ -133,25 +133,25 @@ namespace ewol void ProcessEvents(void); public: - void SetArchiveDir(int _mode, const char* _str); + virtual void SetArchiveDir(int _mode, const char* _str); - void OS_SetInputMotion(int _pointerID, const vec2& _pos); - void OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos); + virtual void OS_SetInputMotion(int _pointerID, const vec2& _pos); + virtual void OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos); - void OS_SetMouseMotion(int _pointerID, const vec2& _pos); - void OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos); + virtual void OS_SetMouseMotion(int _pointerID, const vec2& _pos); + virtual void OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos); - void OS_SetKeyboard(ewol::SpecialKey& _special, - uniChar_t _myChar, - bool _isDown, - bool _isARepeateKey=false); - void OS_SetKeyboardMove(ewol::SpecialKey& _special, - ewol::keyEvent::keyboard_te _move, - bool _isDown, - bool _isARepeateKey=false); + virtual void OS_SetKeyboard(ewol::SpecialKey& _special, + uniChar_t _myChar, + bool _isDown, + bool _isARepeateKey=false); + virtual void OS_SetKeyboardMove(ewol::SpecialKey& _special, + ewol::keyEvent::keyboard_te _move, + bool _isDown, + bool _isARepeateKey=false); - void OS_SetClipBoard(ewol::clipBoard::clipboardListe_te _clipboardID); + virtual void OS_SetClipBoard(ewol::clipBoard::clipboardListe_te _clipboardID); void RequestUpdateSize(void); @@ -204,7 +204,7 @@ namespace ewol * @brief The OS inform that the current windows has change his size. * @param[in] _size new size of the windows. */ - void OS_Resize(const vec2& _size); + virtual void OS_Resize(const vec2& _size); /** * @brief The application request a change of his curent size. * @param[in] _size new Requested size of the windows.