mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2026-08-01 14:19:12 -06:00
Even more cleanup!
This commit is contained in:
parent
f732916f8a
commit
ddd0178a7d
4 changed files with 8 additions and 69 deletions
|
|
@ -8,7 +8,6 @@ import android.view.*;
|
|||
|
||||
import java.util.*;
|
||||
import net.kdt.pojavlaunch.utils.*;
|
||||
import org.lwjgl.glfw.*;
|
||||
|
||||
public class AWTCanvasView extends TextureView implements TextureView.SurfaceTextureListener, Runnable {
|
||||
public static final int AWT_CANVAS_WIDTH = 720;
|
||||
|
|
@ -19,7 +18,6 @@ public class AWTCanvasView extends TextureView implements TextureView.SurfaceTex
|
|||
private int mWidth, mHeight;
|
||||
private boolean mIsDestroyed = false;
|
||||
private final TextPaint mFpsPaint;
|
||||
private boolean mAttached = false;
|
||||
private boolean mDrawing;
|
||||
|
||||
// Temporary count fps https://stackoverflow.com/a/13729241
|
||||
|
|
@ -80,20 +78,14 @@ public class AWTCanvasView extends TextureView implements TextureView.SurfaceTex
|
|||
canvas = surface.lockCanvas(null);
|
||||
canvas.drawRGB(0, 0, 0);
|
||||
|
||||
if (!mAttached) {
|
||||
mAttached = CallbackBridge.nativeAttachThreadToOther(true, MainActivity.isInputStackCall);
|
||||
} else {
|
||||
int[] rgbArray = JREUtils.renderAWTScreenFrame(/* canvas, mWidth, mHeight */);
|
||||
mDrawing = rgbArray != null;
|
||||
if (rgbArray != null) {
|
||||
|
||||
canvas.save();
|
||||
|
||||
canvas.drawBitmap(rgbArray, 0, AWT_CANVAS_WIDTH, 0, 0, AWT_CANVAS_WIDTH, AWT_CANVAS_HEIGHT, true, null);
|
||||
canvas.restore();
|
||||
}
|
||||
int[] rgbArray = JREUtils.renderAWTScreenFrame(/* canvas, mWidth, mHeight */);
|
||||
mDrawing = rgbArray != null;
|
||||
if (rgbArray != null) {
|
||||
canvas.save();
|
||||
canvas.drawBitmap(rgbArray, 0, AWT_CANVAS_WIDTH, 0, 0, AWT_CANVAS_WIDTH, AWT_CANVAS_HEIGHT, true, null);
|
||||
canvas.restore();
|
||||
}
|
||||
canvas.drawText("FPS: " + (Math.round(fps() * 10) / 10) + ", attached=" + mAttached + ", drawing=" + mDrawing, 0, 20, mFpsPaint);
|
||||
canvas.drawText("FPS: " + (Math.round(fps() * 10) / 10) + ", drawing=" + mDrawing, 0, 20, mFpsPaint);
|
||||
surface.unlockCanvasAndPost(canvas);
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
|
|
|
|||
|
|
@ -2,18 +2,13 @@ package org.lwjgl.glfw;
|
|||
|
||||
import net.kdt.pojavlaunch.*;
|
||||
import android.content.*;
|
||||
import android.telecom.Call;
|
||||
import android.view.Choreographer;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CallbackBridge {
|
||||
public static Choreographer sChoreographer = Choreographer.getInstance();
|
||||
private static boolean isGrabbing = false;
|
||||
private static final ArrayList<GrabListener> grabListeners = new ArrayList<>();
|
||||
|
||||
public static final int ANDROID_TYPE_GRAB_STATE = 0;
|
||||
|
||||
public static final int CLIPBOARD_COPY = 2000;
|
||||
public static final int CLIPBOARD_PASTE = 2001;
|
||||
|
|
@ -22,7 +17,6 @@ public class CallbackBridge {
|
|||
public static volatile int windowWidth, windowHeight;
|
||||
public static volatile int physicalWidth, physicalHeight;
|
||||
public static float mouseX, mouseY;
|
||||
private static boolean threadAttached;
|
||||
public volatile static boolean holdingAlt, holdingCapslock, holdingCtrl,
|
||||
holdingNumlock, holdingShift;
|
||||
|
||||
|
|
@ -38,10 +32,6 @@ public class CallbackBridge {
|
|||
|
||||
|
||||
public static void sendCursorPos(float x, float y) {
|
||||
if (!threadAttached) {
|
||||
threadAttached = CallbackBridge.nativeAttachThreadToOther(true, MainActivity.isInputStackCall);
|
||||
}
|
||||
|
||||
mouseX = x;
|
||||
mouseY = y;
|
||||
nativeSendCursorPos(mouseX, mouseY);
|
||||
|
|
@ -226,7 +216,6 @@ public class CallbackBridge {
|
|||
}
|
||||
|
||||
public static native void nativeSetUseInputStackQueue(boolean useInputStackQueue);
|
||||
public static native boolean nativeAttachThreadToOther(boolean isAndroid, boolean isUsePushPoll);
|
||||
|
||||
private static native boolean nativeSendChar(char codepoint);
|
||||
// GLFW: GLFWCharModsCallback deprecated, but is Minecraft still use?
|
||||
|
|
@ -238,8 +227,6 @@ public class CallbackBridge {
|
|||
private static native void nativeSendScroll(double xoffset, double yoffset);
|
||||
private static native void nativeSendScreenSize(int width, int height);
|
||||
public static native void nativeSetWindowAttrib(int attrib, int value);
|
||||
|
||||
public static native boolean nativeIsGrabbing();
|
||||
static {
|
||||
System.loadLibrary("pojavexec");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ struct pojav_environ_s {
|
|||
bool force_vsync;
|
||||
atomic_size_t eventCounter;
|
||||
GLFWInputEvent events[8000];
|
||||
float grabCursorX, grabCursorY, lastCursorX, lastCursorY;
|
||||
double cursorX, cursorY, cLastX, cLastY;
|
||||
jmethodID method_accessAndroidClipboard;
|
||||
jmethodID method_onGrabStateChanged;
|
||||
|
|
@ -49,7 +48,7 @@ struct pojav_environ_s {
|
|||
JavaVM* dalvikJavaVMPtr;
|
||||
JNIEnv* dalvikJNIEnvPtr_ANDROID;
|
||||
long showingWindow;
|
||||
bool isInputReady, isCursorEntered, isPrepareGrabPos, isUseStackQueueCall;
|
||||
bool isInputReady, isCursorEntered, isUseStackQueueCall;
|
||||
int savedWidth, savedHeight;
|
||||
#define ADD_CALLBACK_WWIN(NAME) \
|
||||
GLFW_invoke_##NAME##_func* GLFW_invoke_##NAME;
|
||||
|
|
|
|||
|
|
@ -203,16 +203,6 @@ Java_org_lwjgl_glfw_CallbackBridge_nativeSetUseInputStackQueue(__attribute__((un
|
|||
pojav_environ->isUseStackQueueCall = (int) use_input_stack_queue;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeAttachThreadToOther(__attribute__((unused)) JNIEnv* env, __attribute__((unused)) jclass clazz, jboolean isAndroid, jboolean __attribute__((unused)) isUseStackQueueBool) {
|
||||
#ifdef DEBUG
|
||||
LOGD("Debug: JNI attaching thread, isUseStackQueue=%d\n", isUseStackQueueBool);
|
||||
#endif
|
||||
if (pojav_environ->isUseStackQueueCall && isAndroid) {
|
||||
pojav_environ->isPrepareGrabPos = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeClipboard(JNIEnv* env, __attribute__((unused)) jclass clazz, jint action, jbyteArray copySrc) {
|
||||
#ifdef DEBUG
|
||||
LOGD("Debug: Clipboard access is going on\n", pojav_environ->isUseStackQueueCall);
|
||||
|
|
@ -251,21 +241,12 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSetInputRead
|
|||
return pojav_environ->isUseStackQueueCall;
|
||||
}
|
||||
|
||||
static void updateGrabCursor(float xset, float yset) {
|
||||
if (pojav_environ->isGrabbing == JNI_TRUE) {
|
||||
pojav_environ->grabCursorX = xset; // pojav_environ->savedWidth / 2;
|
||||
pojav_environ->grabCursorY = yset; // pojav_environ->savedHeight / 2;
|
||||
pojav_environ->isPrepareGrabPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSetGrabbing(__attribute__((unused)) JNIEnv* env, __attribute__((unused)) jclass clazz, jboolean grabbing) {
|
||||
JNIEnv *dalvikEnv;
|
||||
(*pojav_environ->dalvikJavaVMPtr)->AttachCurrentThread(pojav_environ->dalvikJavaVMPtr, &dalvikEnv, NULL);
|
||||
(*dalvikEnv)->CallStaticVoidMethod(dalvikEnv, pojav_environ->bridgeClazz, pojav_environ->method_onGrabStateChanged, grabbing);
|
||||
(*pojav_environ->dalvikJavaVMPtr)->DetachCurrentThread(pojav_environ->dalvikJavaVMPtr);
|
||||
pojav_environ->isGrabbing = grabbing;
|
||||
updateGrabCursor((float)pojav_environ->cursorX, (float)pojav_environ->cursorY);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendChar(__attribute__((unused)) JNIEnv* env, __attribute__((unused)) jclass clazz, jchar codepoint /* jint codepoint */) {
|
||||
|
|
@ -321,30 +302,12 @@ JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendCursorPos(__
|
|||
}
|
||||
}
|
||||
|
||||
if (pojav_environ->isGrabbing) {
|
||||
if (!pojav_environ->isPrepareGrabPos) {
|
||||
pojav_environ->grabCursorX += x - pojav_environ->lastCursorX;
|
||||
pojav_environ->grabCursorY += y - pojav_environ->lastCursorY;
|
||||
}
|
||||
|
||||
pojav_environ->lastCursorX = x;
|
||||
pojav_environ->lastCursorY = y;
|
||||
|
||||
if (pojav_environ->isPrepareGrabPos) {
|
||||
pojav_environ->isPrepareGrabPos = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pojav_environ->isUseStackQueueCall) {
|
||||
pojav_environ->GLFW_invoke_CursorPos((void*) pojav_environ->showingWindow, (double) (x), (double) (y));
|
||||
} else {
|
||||
pojav_environ->cursorX = x;
|
||||
pojav_environ->cursorY = y;
|
||||
}
|
||||
|
||||
pojav_environ->lastCursorX = x;
|
||||
pojav_environ->lastCursorY = y;
|
||||
}
|
||||
}
|
||||
#define max(a,b) \
|
||||
|
|
@ -367,8 +330,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendKey(__attrib
|
|||
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSendMouseButton(__attribute__((unused)) JNIEnv* env, __attribute__((unused)) jclass clazz, jint button, jint action, jint mods) {
|
||||
if (pojav_environ->isInputReady) {
|
||||
if (button == -1) {
|
||||
// Notify to prepare set new grab pos
|
||||
pojav_environ->isPrepareGrabPos = true;
|
||||
} else if (pojav_environ->GLFW_invoke_MouseButton) {
|
||||
if (pojav_environ->isUseStackQueueCall) {
|
||||
sendData(EVENT_TYPE_MOUSE_BUTTON, button, action, mods, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue