13
13
import org .jetbrains .annotations .Nullable ;
14
14
import org .lwjgl .glfw .GLFW ;
15
15
import org .lwjgl .glfw .GLFWCursorPosCallback ;
16
- import org .lwjgl .glfw .GLFWKeyCallback ;
17
- import org .lwjgl .glfw .GLFWMouseButtonCallback ;
18
16
import org .lwjgl .glfw .GLFWScrollCallback ;
19
17
20
18
public class IdleHandler {
@@ -26,10 +24,8 @@ public class IdleHandler {
26
24
private static Vec3 prevPosition = Vec3 .ZERO ;
27
25
private static Vec3 prevLookAngle = Vec3 .ZERO ;
28
26
29
- private static @ Nullable GLFWKeyCallback previousKeyCallback ;
30
27
private static @ Nullable GLFWScrollCallback previousScrollCallback ;
31
28
private static @ Nullable GLFWCursorPosCallback previousCursorPosCallback ;
32
- private static @ Nullable GLFWMouseButtonCallback previousMouseClickCallback ;
33
29
34
30
public static void init () {
35
31
if (active ) {
@@ -57,10 +53,7 @@ public static void init() {
57
53
58
54
public static void setWindow (long address ) {
59
55
if (active ) {
60
- previousKeyCallback = GLFW .glfwSetKeyCallback (address , IdleHandler ::onKey );
61
- previousScrollCallback = GLFW .glfwSetScrollCallback (address , IdleHandler ::onScroll );
62
56
previousCursorPosCallback = GLFW .glfwSetCursorPosCallback (address , IdleHandler ::onMove );
63
- previousMouseClickCallback = GLFW .glfwSetMouseButtonCallback (address , IdleHandler ::onPress );
64
57
}
65
58
}
66
59
@@ -111,39 +104,13 @@ private static void checkPlayerActivity() {
111
104
prevLookAngle = lookAngle ;
112
105
}
113
106
114
- // Keyboard events
115
-
116
- private static void onKey (long address , int key , int scancode , int action , int mods ) {
117
- onActivity ();
118
-
119
- if (previousKeyCallback != null ) {
120
- previousKeyCallback .invoke (address , key , scancode , action , mods );
121
- }
122
- }
123
-
124
107
// Mouse events
125
108
126
- private static void onScroll (long address , double xOffset , double yOffset ) {
127
- onActivity ();
128
-
129
- if (previousScrollCallback != null ) {
130
- previousScrollCallback .invoke (address , xOffset , yOffset );
131
- }
132
- }
133
-
134
109
private static void onMove (long address , double x , double y ) {
135
110
onActivity ();
136
111
137
112
if (previousCursorPosCallback != null ) {
138
113
previousCursorPosCallback .invoke (address , x , y );
139
114
}
140
115
}
141
-
142
- private static void onPress (long address , int button , int action , int mods ) {
143
- onActivity ();
144
-
145
- if (previousMouseClickCallback != null ) {
146
- previousMouseClickCallback .invoke (address , button , action , mods );
147
- }
148
- }
149
116
}
0 commit comments