|
14 | 14 | import androidx.annotation.Nullable; |
15 | 15 |
|
16 | 16 | import org.libsdl.app.SDLActivity; |
| 17 | +import org.libsdl.app.SDLSurface; |
17 | 18 |
|
18 | 19 | import java.lang.ref.WeakReference; |
19 | 20 | import java.nio.ByteBuffer; |
@@ -60,7 +61,7 @@ public static void sendCursorPos(float x, float y) { |
60 | 61 | mouseY = y; |
61 | 62 | nativeSendCursorPos(mouseX, mouseY); |
62 | 63 | // HOVER_MOVE and MOVE are equivalent in SDL |
63 | | - SDLActivity.onNativeMouse(0, MotionEvent.ACTION_MOVE, x, y, true); |
| 64 | + SDLActivity.onNativeMouse(0, MotionEvent.ACTION_MOVE, x, y, false); |
64 | 65 | } |
65 | 66 |
|
66 | 67 | /** |
@@ -122,7 +123,7 @@ public static void sendMouseButton(int button, boolean status) { |
122 | 123 | public static void sendMouseKeycode(int button, int modifiers, boolean isDown) { |
123 | 124 | // if (isGrabbing()) DEBUG_STRING.append("MouseGrabStrace: " + android.util.Log.getStackTraceString(new Throwable()) + "\n"); |
124 | 125 | nativeSendMouseButton(button, isDown ? 1 : 0, modifiers); |
125 | | - SDLActivity.onNativeMouse(button, isDown ? MotionEvent.ACTION_DOWN : MotionEvent.ACTION_UP, mouseX, mouseY, true); |
| 126 | + SDLActivity.onNativeMouse(button, isDown ? MotionEvent.ACTION_DOWN : MotionEvent.ACTION_UP, mouseX, mouseY, false); |
126 | 127 | } |
127 | 128 |
|
128 | 129 | public static void sendMouseKeycode(int keycode) { |
@@ -167,6 +168,31 @@ public static boolean isGrabbing() { |
167 | 168 | } |
168 | 169 | } |
169 | 170 |
|
| 171 | + // Notification types |
| 172 | + private static final int SDL = 0; |
| 173 | + |
| 174 | + // Notification actions |
| 175 | + private static final int INIT = 0; |
| 176 | + /** |
| 177 | + * Used for any sort of notification that needs to be given from the JRE side |
| 178 | + * @return if notification successful |
| 179 | + */ |
| 180 | + // Called from JRE side via jni |
| 181 | + @SuppressWarnings("unused") |
| 182 | + @Keep |
| 183 | + public static boolean notifyLauncher(int type, int... action) { |
| 184 | + switch (type) { |
| 185 | + case SDL: |
| 186 | + if (action[0] == INIT) { |
| 187 | + MinecraftGLSurface.sdlEnabled = true; |
| 188 | + // Notifies SDL of native surface res which is needed for proper input handling |
| 189 | + SDLActivity.getSDLSurface().surfaceChanged(); |
| 190 | + Logger.appendToLog("Amethyst-Android: SDL support enabled!"); |
| 191 | + return true; |
| 192 | + } |
| 193 | + } |
| 194 | + return false; |
| 195 | + } |
170 | 196 |
|
171 | 197 | public static int getCurrentMods() { |
172 | 198 | int currMods = 0; |
|
0 commit comments