22 #ifndef _ANDROID_JNI_H_ 23 #define _ANDROID_JNI_H_ 26 #include <semaphore.h> 29 #include "common/fs.h" 30 #include "common/archive.h" 31 #include "common/array.h" 32 #include "common/ustr.h" 46 static bool assets_updated;
49 static sem_t pause_sem;
51 static int surface_changeid;
52 static int egl_surface_width;
53 static int egl_surface_height;
54 static int egl_bits_per_pixel;
56 static bool virt_keyboard_state;
58 static int32 gestures_insets[4];
59 static int32 cutout_insets[4];
61 static jint onLoad(JavaVM *vm);
63 static inline JNIEnv *getEnv() {
64 JNIEnv *env = (JNIEnv*) pthread_getspecific(_env_tls);
72 static void attachThread();
73 static void detachThread();
75 static void setReadyForEvents(
bool ready);
76 static void wakeupForQuit();
83 typedef float DPIValues[3];
84 static void getDPI(DPIValues &values);
87 static bool hasTextInClipboard();
90 static bool isConnectionLimited();
91 static void showVirtualKeyboard(
bool enable);
92 static void showOnScreenControls(
int enableMask);
93 static void setTouchMode(
int touchMode);
94 static int getTouchMode();
95 static void setOrientation(
int touchMode);
101 static jint getAndroidSDKVersionId();
104 static inline bool haveSurface();
105 static inline bool swapBuffers();
106 static bool initSurface();
107 static void deinitSurface();
108 static int eglVersion() {
112 return fetchEGLVersion();
115 static void setAudioPause();
116 static void setAudioPlay();
117 static void setAudioStop();
119 static inline int writeAudio(JNIEnv *env, jbyteArray &data,
int offset,
132 static pthread_key_t _env_tls;
136 static jobject _jobj;
137 static jobject _jobj_audio_track;
138 static jobject _jobj_egl;
139 static jobject _jobj_egl_display;
140 static jobject _jobj_egl_surface;
142 static int _egl_version;
147 static bool _ready_for_events;
149 static jmethodID _MID_getDPI;
150 static jmethodID _MID_displayMessageOnOSD;
151 static jmethodID _MID_openUrl;
152 static jmethodID _MID_hasTextInClipboard;
153 static jmethodID _MID_getTextFromClipboard;
154 static jmethodID _MID_setTextInClipboard;
155 static jmethodID _MID_isConnectionLimited;
156 static jmethodID _MID_setWindowCaption;
157 static jmethodID _MID_showVirtualKeyboard;
158 static jmethodID _MID_showOnScreenControls;
159 static jmethodID _MID_setTouchMode;
160 static jmethodID _MID_getTouchMode;
161 static jmethodID _MID_setOrientation;
162 static jmethodID _MID_getScummVMBasePath;
163 static jmethodID _MID_getScummVMConfigPath;
164 static jmethodID _MID_getScummVMLogPath;
165 static jmethodID _MID_setCurrentGame;
166 static jmethodID _MID_getSysArchives;
167 static jmethodID _MID_getAllStorageLocations;
168 static jmethodID _MID_initSurface;
169 static jmethodID _MID_deinitSurface;
170 static jmethodID _MID_eglVersion;
171 static jmethodID _MID_getNewSAFTree;
172 static jmethodID _MID_getSAFTrees;
173 static jmethodID _MID_findSAFTree;
174 static jmethodID _MID_exportBackup;
175 static jmethodID _MID_importBackup;
177 static jmethodID _MID_EGL10_eglSwapBuffers;
179 static jmethodID _MID_AudioTrack_flush;
180 static jmethodID _MID_AudioTrack_pause;
181 static jmethodID _MID_AudioTrack_play;
182 static jmethodID _MID_AudioTrack_stop;
183 static jmethodID _MID_AudioTrack_write;
185 static const JNINativeMethod _natives[];
187 static void throwByName(JNIEnv *env,
const char *name,
const char *msg);
188 static void throwRuntimeException(JNIEnv *env,
const char *msg);
191 static void create(JNIEnv *env, jobject
self, jobject asset_manager,
192 jobject egl, jobject egl_display,
193 jobject at, jint audio_sample_rate,
194 jint audio_buffer_size,
195 jboolean assets_updated_);
196 static void destroy(JNIEnv *env, jobject
self);
198 static void setSurface(JNIEnv *env, jobject
self, jint width, jint height, jint bpp);
199 static jint main(JNIEnv *env, jobject
self, jobjectArray args);
201 static void pushEvent(JNIEnv *env, jobject
self,
int type,
int arg1,
202 int arg2,
int arg3,
int arg4,
int arg5,
int arg6);
203 static void updateTouch(JNIEnv *env, jobject
self,
int action,
int ptr,
int x,
int y);
204 static void setupTouchMode(JNIEnv *env, jobject
self, jint oldValue, jint newValue);
205 static void syncVirtkeyboardState(JNIEnv *env, jobject
self, jboolean newState);
206 static void setPause(JNIEnv *env, jobject
self, jboolean value);
208 static void systemInsetsUpdated(JNIEnv *env, jobject
self, jintArray gestureInsets, jintArray systemInsets, jintArray cutoutInsets);
210 static jstring getNativeVersionInfo(JNIEnv *env, jobject
self);
214 static JNIEnv *fetchEnv();
215 static int fetchEGLVersion();
218 inline bool JNI::haveSurface() {
219 return _jobj_egl_surface != 0;
222 inline bool JNI::swapBuffers() {
223 JNIEnv *env = JNI::getEnv();
225 return env->CallBooleanMethod(_jobj_egl, _MID_EGL10_eglSwapBuffers,
226 _jobj_egl_display, _jobj_egl_surface);
229 inline int JNI::writeAudio(JNIEnv *env, jbyteArray &data,
int offset,
int size) {
230 return env->CallIntMethod(_jobj_audio_track, _MID_AudioTrack_write, data,
Definition: archive.h:141
Definition: archive.h:330
Definition: jni-android.h:40
Definition: formatinfo.h:28
Definition: android.h:100