Support for input cursor movement from keyboard

New class: TrackedTextField. This class keeps track of the pointer in the text field. The hidden text field now has 40 placeholder spaces and the pointer is placed at the middle. When typing, placeholder spaces won't get removed as before. Autocorrect seem to be broken a bit for now.

Additional changes:
- Added missing GLFW functions (array version of other functions)
- Hotbar handling: doubled barWidth and barHeight

Bug fix:
- Touching onto the hotbar breaks the handling of on-screen tap/long-press gestures
This commit is contained in:
khanhduytran0 committed 2022-01-11 13:58:16 +07:00
1 parent 51b55b0e07
commit 82dc17cd9c
3 files changed
+240 -109

No files matched your search

+147 -49
View File
@@ -835,29 +835,18 @@ public class GLFW
}
width.put(internalGetWindow(window).width);
height.put(internalGetWindow(window).height);
}
public static void glfwGetFramebufferSize(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") int[] width, @Nullable @NativeType("int *") int[] height) {
if (CHECKS) {
// check(window);
checkSafe(width, 1);
checkSafe(height, 1);
}
width[0] = internalGetWindow(window).width;
height[0] = internalGetWindow(window).height;
}
@Nullable
@Nullable
@NativeType("GLFWmonitor **")
public static PointerBuffer glfwGetMonitors() {
PointerBuffer pBuffer = PointerBuffer.allocateDirect(1);
pBuffer.put(glfwGetPrimaryMonitor());
return pBuffer;
pBuffer.put(glfwGetPrimaryMonitor());
return pBuffer;
}
public static long glfwGetPrimaryMonitor() {
// Prevent NULL check
// Prevent NULL check
return 1L;
}
@@ -885,44 +874,17 @@ public class GLFW
height.put(mGLFWWindowHeight);
}
public static void glfwGetMonitorPos(@NativeType("GLFWmonitor *") long monitor, @Nullable @NativeType("int *") int[] xpos, @Nullable @NativeType("int *") int[] ypos) {
if (CHECKS) {
// check(monitor);
checkSafe(xpos, 1);
checkSafe(ypos, 1);
}
xpos[0] = 0;
ypos[0] = 0;
}
/** Array version of: {@link #glfwGetMonitorWorkarea GetMonitorWorkarea} */
public static void glfwGetMonitorWorkarea(@NativeType("GLFWmonitor *") long monitor, @Nullable @NativeType("int *") int[] xpos, @Nullable @NativeType("int *") int[] ypos, @Nullable @NativeType("int *") int[] width, @Nullable @NativeType("int *") int[] height) {
if (CHECKS) {
// check(monitor);
checkSafe(xpos, 1);
checkSafe(ypos, 1);
checkSafe(width, 1);
checkSafe(height, 1);
}
xpos[0] = 0;
ypos[0] = 0;
width[0] = mGLFWWindowWidth;
height[0] = mGLFWWindowHeight;
}
@NativeType("GLFWmonitor *")
public static long glfwGetWindowMonitor(@NativeType("GLFWwindow *") long window) {
return internalGetWindow(window).monitor;
}
public static void glfwSetWindowMonitor(@NativeType("GLFWwindow *") long window, @NativeType("GLFWmonitor *") long monitor, int xpos, int ypos, int width, int height, int refreshRate) {
GLFWWindowProperties properties = internalGetWindow(window);
properties.monitor = monitor;
properties.x = xpos;
properties.y = ypos;
internalChangeMonitorSize(width, height);
public static void glfwSetWindowMonitor(@NativeType("GLFWwindow *") long window, @NativeType("GLFWmonitor *") long monitor, int xpos, int ypos, int width, int height, int refreshRate) {
GLFWWindowProperties properties = internalGetWindow(window);
properties.monitor = monitor;
properties.x = xpos;
properties.y = ypos;
internalChangeMonitorSize(width, height);
}
public static int glfwGetWindowAttrib(@NativeType("GLFWwindow *") long window, int attrib) {
@@ -1317,4 +1279,140 @@ return false;
public static boolean glfwGetGamepadState(int jid, GLFWGamepadState state) {
return false;
}
/** Array version of: {@link #glfwGetVersion GetVersion} */
public static void glfwGetVersion(@Nullable @NativeType("int *") int[] major, @Nullable @NativeType("int *") int[] minor, @Nullable @NativeType("int *") int[] rev) {
if (CHECKS) {
checkSafe(major, 1);
checkSafe(minor, 1);
checkSafe(rev, 1);
}
major[0] = GLFW_VERSION_MAJOR;
minor[0] = GLFW_VERSION_MINOR;
rev[0] = GLFW_VERSION_REVISION;
}
/** Array version of: {@link #glfwGetMonitorPos GetMonitorPos} */
public static void glfwGetMonitorPos(@NativeType("GLFWmonitor *") long monitor, @Nullable @NativeType("int *") int[] xpos, @Nullable @NativeType("int *") int[] ypos) {
if (CHECKS) {
// check(monitor);
checkSafe(xpos, 1);
checkSafe(ypos, 1);
}
xpos[0] = 0;
ypos[0] = 0;
}
/** Array version of: {@link #glfwGetMonitorWorkarea GetMonitorWorkarea} */
public static void glfwGetMonitorWorkarea(@NativeType("GLFWmonitor *") long monitor, @Nullable @NativeType("int *") int[] xpos, @Nullable @NativeType("int *") int[] ypos, @Nullable @NativeType("int *") int[] width, @Nullable @NativeType("int *") int[] height) {
if (CHECKS) {
// check(monitor);
checkSafe(xpos, 1);
checkSafe(ypos, 1);
checkSafe(width, 1);
checkSafe(height, 1);
}
xpos[0] = 0;
ypos[0] = 0;
width[0] = mGLFWWindowWidth;
height[0] = mGLFWWindowHeight;
}
/** Array version of: {@link #glfwGetMonitorPhysicalSize GetMonitorPhysicalSize} */
/*
public static void glfwGetMonitorPhysicalSize(@NativeType("GLFWmonitor *") long monitor, @Nullable @NativeType("int *") int[] widthMM, @Nullable @NativeType("int *") int[] heightMM) {
long __functionAddress = Functions.GetMonitorPhysicalSize;
if (CHECKS) {
check(monitor);
checkSafe(widthMM, 1);
checkSafe(heightMM, 1);
}
invokePPPV(monitor, widthMM, heightMM, __functionAddress);
}
*/
/** Array version of: {@link #glfwGetMonitorContentScale GetMonitorContentScale} */
/*
public static void glfwGetMonitorContentScale(@NativeType("GLFWmonitor *") long monitor, @Nullable @NativeType("float *") float[] xscale, @Nullable @NativeType("float *") float[] yscale) {
long __functionAddress = Functions.GetMonitorContentScale;
if (CHECKS) {
check(monitor);
checkSafe(xscale, 1);
checkSafe(yscale, 1);
}
invokePPPV(monitor, xscale, yscale, __functionAddress);
}
*/
/** Array version of: {@link #glfwGetWindowPos GetWindowPos} */
public static void glfwGetWindowPos(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") int[] xpos, @Nullable @NativeType("int *") int[] ypos) {
if (CHECKS) {
// check(window);
checkSafe(xpos, 1);
checkSafe(ypos, 1);
}
xpos[0] = 0;
ypos[0] = 0;
}
/** Array version of: {@link #glfwGetWindowSize GetWindowSize} */
public static void glfwGetWindowSize(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") int[] width, @Nullable @NativeType("int *") int[] height) {
if (CHECKS) {
// check(window);
checkSafe(width, 1);
checkSafe(height, 1);
}
width[0] = internalGetWindow(window).width;
height[0] = internalGetWindow(window).height;
}
/** Array version of: {@link #glfwGetFramebufferSize GetFramebufferSize} */
public static void glfwGetFramebufferSize(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") int[] width, @Nullable @NativeType("int *") int[] height) {
if (CHECKS) {
// check(window);
checkSafe(width, 1);
checkSafe(height, 1);
}
width[0] = internalGetWindow(window).width;
height[0] = internalGetWindow(window).height;
}
/** Array version of: {@link #glfwGetWindowFrameSize GetWindowFrameSize} */
public static void glfwGetWindowFrameSize(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") int[] left, @Nullable @NativeType("int *") int[] top, @Nullable @NativeType("int *") int[] right, @Nullable @NativeType("int *") int[] bottom) {
if (CHECKS) {
// check(window);
checkSafe(left, 1);
checkSafe(top, 1);
checkSafe(right, 1);
checkSafe(bottom, 1);
}
left[0] = top[0] = 0;
right[0] = internalGetWindow(window).width;
bottom[0] = internalGetWindow(window).height;
}
/** Array version of: {@link #glfwGetWindowContentScale GetWindowContentScale} */
/*
public static void glfwGetWindowContentScale(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("float *") float[] xscale, @Nullable @NativeType("float *") float[] yscale) {
long __functionAddress = Functions.GetWindowContentScale;
if (CHECKS) {
check(window);
checkSafe(xscale, 1);
checkSafe(yscale, 1);
}
invokePPPV(window, xscale, yscale, __functionAddress);
}
*/
/** Array version of: {@link #glfwGetCursorPos GetCursorPos} */
public static void glfwGetCursorPos(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("double *") double[] xpos, @Nullable @NativeType("double *") double[] ypos) {
if (CHECKS) {
// check(window);
checkSafe(xpos, 1);
checkSafe(ypos, 1);
}
xpos[0] = mGLFWCursorX;
ypos[0] = mGLFWCursorY;
}
}