Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/PojavLauncher
Path: blob/v3_openjdk/app_pojavlauncher/src/main/jni/environ/environ.h
2128 views
1
//
2
// Created by maks on 24.09.2022.
3
//
4
5
#ifndef POJAVLAUNCHER_ENVIRON_H
6
#define POJAVLAUNCHER_ENVIRON_H
7
8
#include <ctxbridges/common.h>
9
#include <stdatomic.h>
10
#include <jni.h>
11
12
/* How many events can be handled at the same time */
13
#define EVENT_WINDOW_SIZE 8000
14
15
typedef struct {
16
int type;
17
int i1;
18
int i2;
19
int i3;
20
int i4;
21
} GLFWInputEvent;
22
23
typedef void GLFW_invoke_Char_func(void* window, unsigned int codepoint);
24
typedef void GLFW_invoke_CharMods_func(void* window, unsigned int codepoint, int mods);
25
typedef void GLFW_invoke_CursorEnter_func(void* window, int entered);
26
typedef void GLFW_invoke_CursorPos_func(void* window, double xpos, double ypos);
27
typedef void GLFW_invoke_Key_func(void* window, int key, int scancode, int action, int mods);
28
typedef void GLFW_invoke_MouseButton_func(void* window, int button, int action, int mods);
29
typedef void GLFW_invoke_Scroll_func(void* window, double xoffset, double yoffset);
30
31
typedef struct {
32
unsigned char buttons [15];
33
float axes[6];
34
} GLFWgamepadstate;
35
36
struct pojav_environ_s {
37
struct ANativeWindow* pojavWindow;
38
basic_render_window_t* mainWindowBundle;
39
int config_renderer;
40
bool force_vsync;
41
atomic_size_t eventCounter; // Count the number of events to be pumped out
42
GLFWInputEvent events[EVENT_WINDOW_SIZE];
43
size_t outEventIndex; // Point to the current event that has yet to be pumped out to MC
44
size_t outTargetIndex; // Point to the newt index to stop by
45
size_t inEventIndex; // Point to the next event that has to be filled
46
size_t inEventCount; // Count registered right before pumping OUT events. Used as a cache.
47
double cursorX, cursorY, cLastX, cLastY;
48
jmethodID method_accessAndroidClipboard;
49
jmethodID method_onGrabStateChanged;
50
jmethodID method_onDirectInputEnable;
51
jmethodID method_glftSetWindowAttrib;
52
jmethodID method_internalWindowSizeChanged;
53
jmethodID method_internalChangeMonitorSize;
54
jclass bridgeClazz;
55
jclass vmGlfwClass;
56
jboolean isGrabbing;
57
jbyte* keyDownBuffer;
58
jbyte* mouseDownBuffer;
59
JavaVM* runtimeJavaVMPtr;
60
JNIEnv* glfwThreadVmEnv;
61
JavaVM* dalvikJavaVMPtr;
62
long showingWindow;
63
bool isInputReady, isCursorEntered, isUseStackQueueCall, shouldUpdateMouse;
64
bool shouldUpdateMonitorSize, monitorSizeConsumed;
65
int savedWidth, savedHeight;
66
GLFWgamepadstate gamepadState;
67
#define ADD_CALLBACK_WWIN(NAME) \
68
GLFW_invoke_##NAME##_func* GLFW_invoke_##NAME;
69
ADD_CALLBACK_WWIN(Char);
70
ADD_CALLBACK_WWIN(CharMods);
71
ADD_CALLBACK_WWIN(CursorEnter);
72
ADD_CALLBACK_WWIN(CursorPos);
73
ADD_CALLBACK_WWIN(Key);
74
ADD_CALLBACK_WWIN(MouseButton);
75
ADD_CALLBACK_WWIN(Scroll);
76
77
#undef ADD_CALLBACK_WWIN
78
};
79
extern struct pojav_environ_s *pojav_environ;
80
81
#endif //POJAVLAUNCHER_ENVIRON_H
82
83