1 /* xscreensaver, Copyright (c) 2016 Jamie Zawinski <jwz@jwz.org>
3 * Permission to use, copy, modify, distribute, and sell this software and its
4 * documentation for any purpose is hereby granted without fee, provided that
5 * the above copyright notice appear in all copies and that both that
6 * copyright notice and this permission notice appear in supporting
7 * documentation. No representations are made about the suitability of this
8 * software for any purpose. It is provided "as is" without express or
12 #ifndef __JWXYZ_ANDROID_H__
13 #define __JWXYZ_ANDROID_H__
16 #include "../hacks/fps.h"
18 #include <android/log.h>
22 /* Keep synchronized with check-configs.pl and jwxyz.java. */
27 struct xscreensaver_function_table *xsft;
36 EGLDisplay egl_display;
38 EGLContext egl_window_ctx, egl_xlib_ctx;
39 Drawable current_drawable;
40 Bool ignore_rotation_p;
42 unsigned long frame_count;
44 double next_frame_time; // time_t in milliseconds of when to tick the frame
45 struct event_queue *event_queue;
48 struct jwxyz_Drawable {
49 enum { WINDOW, PIXMAP } type;
51 EGLSurface egl_surface;
54 struct running_hack *rh;
55 int last_mouse_x, last_mouse_y;
63 extern void do_logv(int prio, const char *fmt, va_list args);
65 extern void Log(const char *format, ...); // TODO: GCC can verify printf strings.
66 #define Logv(format, args) (do_logv(ANDROID_LOG_INFO, format, args))
68 extern void prepare_context (struct running_hack *rh);
71 // Methods of the Java class org.jwz.jwxyz that are implemented in C.
73 JNIEXPORT void JNICALL
74 Java_org_jwz_xscreensaver_jwxyz_nativeInit (JNIEnv *, jobject thiz,
75 jstring jhack, jint api,
79 JNIEXPORT void JNICALL
80 Java_org_jwz_xscreensaver_jwxyz_nativeResize (JNIEnv *, jobject thiz,
81 jint w, jint h, jdouble rot);
83 JNIEXPORT void JNICALL
84 Java_org_jwz_xscreensaver_jwxyz_nativeRender (JNIEnv *, jobject thiz);
86 JNIEXPORT void JNICALL
87 Java_org_jwz_xscreensaver_jwxyz_nativeDone (JNIEnv *, jobject thiz);
89 JNIEXPORT void JNICALL
90 Java_org_jwz_xscreensaver_jwxyz_allnativeSettings (JNIEnv *, jobject thiz,
93 jint draw, jstring key);
95 JNIEXPORT jboolean JNICALL
96 Java_org_jwz_xscreensaver_jwxyz_ignoreRotation (JNIEnv *, jobject thiz);
98 JNIEXPORT jboolean JNICALL
99 Java_org_jwz_xscreensaver_jwxyz_suppressRotationAnimation (JNIEnv *,
102 JNIEXPORT void JNICALL
103 Java_org_jwz_xscreensaver_jwxyz_sendButtonEvent (JNIEnv *, jobject thiz,
104 int x, int y, jboolean down);
106 JNIEXPORT void JNICALL
107 Java_org_jwz_xscreensaver_jwxyz_sendMotionEvent (JNIEnv *, jobject thiz,
110 JNIEXPORT void JNICALL
111 Java_org_jwz_xscreensaver_jwxyz_sendKeyEvent (JNIEnv *, jobject thiz,
115 #endif // __JWXYZ_ANDROID_H__