When working with Android sensors, it is necessary to know the current rotation of the screen from its "natural" orientation. Even if ZGE can specify either landscape or portrait orientation, "natural" orientation of each device can vary. Mobiles have usually portrait and tablets landscape orientation.
Android SDK provides the method Display.getRotation() which should be used for this purpose. I could implement its wrapper in ZGESensor library, but this would require usage of JNI and instantiation of another JVM, which is too cumbersome and not optimal for sure. (That's because NKD provides just a limited API and getRotation() was not included there.)
Ville, I expect that implementation of getScreenRotation() (or name it differently) function in ZGE would be technically more easier; similar to implementation of touchGet* functions. If so, I'm kindly asking you to add such a function to ZGE; it is really necessary for portable sensor-aware applications. Thanks.
getScreenRotation function for Android
Moderator: Moderators
How about if ZGE provides the current JVM instance to the loaded modules, would that make it simple for you to implement the function yourself? I'm thinking it would be useful for other things. ZGE could look for a function named "setJvmInstance" in any module it loads and if it exists then call it.
I currently knee deep in trying to implement GLES2 support. For latest progress of that see the source commits to Google Code.
I currently knee deep in trying to implement GLES2 support. For latest progress of that see the source commits to Google Code.
This looks interesting, however, I'm going to experiment with JNI's function GetJavaVM(). It can maybe help. In the case of success I'll add the getScreenRotation() function to ZGESensor library.VilleK wrote:How about if ZGE provides the current JVM instance to the loaded modules, would that make it simple for you to implement the function yourself? I'm thinking it would be useful for other things. ZGE could look for a function named "setJvmInstance" in any module it loads and if it exists then call it.
I'm not sure the function setJvmInstance() could set JVM in the form compatible with NDK's type JavaVM. If so, then it could help, if not, JNI must be used instead.
Hi Kjell,
I experimented with JNI and I think the only way to obtain ZGE application's JVM instance in library is to call a function you named setJvmInstance(). Its signature in C++ should be similar to JNI_OnLoad, maybe except of the "reserved" parameter:
BTW would it be possible to use standard JNI functions JNI_OnLoad and JNI_OnUnload instead of setJvmInstance?
I experimented with JNI and I think the only way to obtain ZGE application's JVM instance in library is to call a function you named setJvmInstance(). Its signature in C++ should be similar to JNI_OnLoad, maybe except of the "reserved" parameter:
Code: Select all
JNIEXPORT void setJvmInstance(JavaVM* vm);