feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -77,7 +77,6 @@ import org.godotengine.godot.xr.XRMode
|
|||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.InputStream
|
||||
import java.lang.Exception
|
||||
import java.security.MessageDigest
|
||||
import java.util.*
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
|
@ -714,11 +713,15 @@ class Godot(private val context: Context) {
|
|||
val longPressEnabled = java.lang.Boolean.parseBoolean(GodotLib.getGlobal("input_devices/pointing/android/enable_long_press_as_right_click"))
|
||||
val panScaleEnabled = java.lang.Boolean.parseBoolean(GodotLib.getGlobal("input_devices/pointing/android/enable_pan_and_scale_gestures"))
|
||||
val rotaryInputAxisValue = GodotLib.getGlobal("input_devices/pointing/android/rotary_input_scroll_axis")
|
||||
val overrideVolumeButtons = java.lang.Boolean.parseBoolean(GodotLib.getGlobal("input_devices/pointing/android/override_volume_buttons"))
|
||||
val scrollDeadzoneDisabled = java.lang.Boolean.parseBoolean(GodotLib.getGlobal("input_devices/pointing/android/disable_scroll_deadzone"))
|
||||
|
||||
runOnUiThread {
|
||||
renderView?.inputHandler?.apply {
|
||||
enableLongPress(longPressEnabled)
|
||||
enablePanningAndScalingGestures(panScaleEnabled)
|
||||
setOverrideVolumeButtons(overrideVolumeButtons)
|
||||
disableScrollDeadzone(scrollDeadzoneDisabled)
|
||||
try {
|
||||
setRotaryInputAxis(Integer.parseInt(rotaryInputAxisValue))
|
||||
} catch (e: NumberFormatException) {
|
||||
|
|
|
|||
|
|
@ -268,6 +268,11 @@ public class GodotLib {
|
|||
*/
|
||||
public static native void onNightModeChanged();
|
||||
|
||||
/**
|
||||
* Invoked on the hardware keyboard connected/disconnected.
|
||||
*/
|
||||
public static native void hardwareKeyboardConnected(boolean connected);
|
||||
|
||||
/**
|
||||
* Invoked on the file picker closed.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -265,13 +265,6 @@ public class GodotEditText extends EditText {
|
|||
}
|
||||
|
||||
public boolean hasHardwareKeyboard() {
|
||||
Configuration config = getResources().getConfiguration();
|
||||
boolean hasHardwareKeyboardConfig = config.keyboard != Configuration.KEYBOARD_NOKEYS &&
|
||||
config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO;
|
||||
if (hasHardwareKeyboardConfig) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return mRenderView.getInputHandler().hasHardwareKeyboard();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ internal class GodotGestureHandler(private val inputHandler: GodotInputHandler)
|
|||
*/
|
||||
var panningAndScalingEnabled = false
|
||||
|
||||
var scrollDeadzoneDisabled = false
|
||||
|
||||
private var nextDownIsDoubleTap = false
|
||||
private var dragInProgress = false
|
||||
private var scaleInProgress = false
|
||||
|
|
@ -153,7 +155,7 @@ internal class GodotGestureHandler(private val inputHandler: GodotInputHandler)
|
|||
if (contextClickInProgress) {
|
||||
inputHandler.handleMouseEvent(event, event.actionMasked, MotionEvent.BUTTON_SECONDARY, false)
|
||||
return true
|
||||
} else if (!scaleInProgress) {
|
||||
} else if (scrollDeadzoneDisabled && !scaleInProgress) {
|
||||
// The 'onScroll' event is triggered with a long delay.
|
||||
// Force the 'InputEventScreenDrag' event earlier here.
|
||||
// We don't toggle 'dragInProgress' here so that the scaling logic can override the drag operation if needed.
|
||||
|
|
@ -191,7 +193,7 @@ internal class GodotGestureHandler(private val inputHandler: GodotInputHandler)
|
|||
distanceY: Float
|
||||
): Boolean {
|
||||
if (scaleInProgress) {
|
||||
if (dragInProgress || lastDragX != 0.0f || lastDragY != 0.0f) {
|
||||
if (dragInProgress || (scrollDeadzoneDisabled && (lastDragX != 0.0f || lastDragY != 0.0f))) {
|
||||
if (originEvent != null) {
|
||||
// Cancel the drag
|
||||
inputHandler.handleMotionEvent(originEvent, MotionEvent.ACTION_CANCEL)
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ import androidx.annotation.NonNull;
|
|||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* Handles input related events for the {@link GodotRenderView} view.
|
||||
|
|
@ -83,11 +84,13 @@ public class GodotInputHandler implements InputManager.InputDeviceListener, Sens
|
|||
/**
|
||||
* Used to decide whether mouse capture can be enabled.
|
||||
*/
|
||||
private int lastSeenToolType = MotionEvent.TOOL_TYPE_UNKNOWN;
|
||||
private AtomicInteger lastSeenToolType = new AtomicInteger(MotionEvent.TOOL_TYPE_UNKNOWN);
|
||||
|
||||
private int rotaryInputAxis = ROTARY_INPUT_VERTICAL_AXIS;
|
||||
|
||||
private int cachedRotation = -1;
|
||||
private boolean overrideVolumeButtons = false;
|
||||
private boolean hasHardwareKeyboardConfig = false;
|
||||
|
||||
public GodotInputHandler(Context context, Godot godot) {
|
||||
this.godot = godot;
|
||||
|
|
@ -103,6 +106,9 @@ public class GodotInputHandler implements InputManager.InputDeviceListener, Sens
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
this.scaleGestureDetector.setStylusScaleEnabled(true);
|
||||
}
|
||||
Configuration config = context.getResources().getConfiguration();
|
||||
hasHardwareKeyboardConfig = config.keyboard != Configuration.KEYBOARD_NOKEYS &&
|
||||
config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -112,6 +118,13 @@ public class GodotInputHandler implements InputManager.InputDeviceListener, Sens
|
|||
this.gestureDetector.setIsLongpressEnabled(enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable scroll deadzone. This is false by default.
|
||||
*/
|
||||
public void disableScrollDeadzone(boolean disable) {
|
||||
this.godotGestureHandler.setScrollDeadzoneDisabled(disable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable multi-fingers pan & scale gestures. This is false by default.
|
||||
* <p>
|
||||
|
|
@ -136,7 +149,14 @@ public class GodotInputHandler implements InputManager.InputDeviceListener, Sens
|
|||
rotaryInputAxis = axis;
|
||||
}
|
||||
|
||||
public void setOverrideVolumeButtons(boolean value) {
|
||||
overrideVolumeButtons = value;
|
||||
}
|
||||
|
||||
boolean hasHardwareKeyboard() {
|
||||
if (hasHardwareKeyboardConfig) {
|
||||
return true;
|
||||
}
|
||||
return !mHardwareKeyboardIds.isEmpty();
|
||||
}
|
||||
|
||||
|
|
@ -149,7 +169,8 @@ public class GodotInputHandler implements InputManager.InputDeviceListener, Sens
|
|||
}
|
||||
|
||||
public boolean canCapturePointer() {
|
||||
return lastSeenToolType == MotionEvent.TOOL_TYPE_MOUSE;
|
||||
return lastSeenToolType.get() == MotionEvent.TOOL_TYPE_MOUSE ||
|
||||
lastSeenToolType.get() == MotionEvent.TOOL_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
public void onPointerCaptureChange(boolean hasCapture) {
|
||||
|
|
@ -157,10 +178,6 @@ public class GodotInputHandler implements InputManager.InputDeviceListener, Sens
|
|||
}
|
||||
|
||||
public boolean onKeyUp(final int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int source = event.getSource();
|
||||
if (isKeyEventGameDevice(source)) {
|
||||
// Check if the device exists
|
||||
|
|
@ -178,14 +195,14 @@ public class GodotInputHandler implements InputManager.InputDeviceListener, Sens
|
|||
handleKeyEvent(physical_keycode, unicode, key_label, false, event.getRepeatCount() > 0);
|
||||
};
|
||||
|
||||
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
|
||||
return overrideVolumeButtons;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onKeyDown(final int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int source = event.getSource();
|
||||
|
||||
final int deviceId = event.getDeviceId();
|
||||
|
|
@ -206,11 +223,15 @@ public class GodotInputHandler implements InputManager.InputDeviceListener, Sens
|
|||
handleKeyEvent(physical_keycode, unicode, key_label, true, event.getRepeatCount() > 0);
|
||||
}
|
||||
|
||||
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
|
||||
return overrideVolumeButtons;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onTouchEvent(final MotionEvent event) {
|
||||
lastSeenToolType = getEventToolType(event);
|
||||
lastSeenToolType.set(getEventToolType(event));
|
||||
|
||||
this.scaleGestureDetector.onTouchEvent(event);
|
||||
if (this.gestureDetector.onTouchEvent(event)) {
|
||||
|
|
@ -236,7 +257,7 @@ public class GodotInputHandler implements InputManager.InputDeviceListener, Sens
|
|||
}
|
||||
|
||||
public boolean onGenericMotionEvent(MotionEvent event) {
|
||||
lastSeenToolType = getEventToolType(event);
|
||||
lastSeenToolType.set(getEventToolType(event));
|
||||
|
||||
if (event.isFromSource(InputDevice.SOURCE_JOYSTICK) && event.getActionMasked() == MotionEvent.ACTION_MOVE) {
|
||||
// Check if the device exists
|
||||
|
|
@ -790,5 +811,12 @@ public class GodotInputHandler implements InputManager.InputDeviceListener, Sens
|
|||
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
updateCachedRotation();
|
||||
|
||||
boolean newHardwareKeyboardConfig = newConfig.keyboard != Configuration.KEYBOARD_NOKEYS &&
|
||||
newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO;
|
||||
if (hasHardwareKeyboardConfig != newHardwareKeyboardConfig) {
|
||||
hasHardwareKeyboardConfig = newHardwareKeyboardConfig;
|
||||
GodotLib.hardwareKeyboardConnected(hasHardwareKeyboard());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ internal class AssetData(context: Context, private val filePath: String, accessF
|
|||
}
|
||||
|
||||
fun fileLastModified(path: String) = 0L
|
||||
fun fileLastAccessed(path: String) = 0L
|
||||
fun fileSize(path: String) = -1L
|
||||
|
||||
fun delete(path: String) = false
|
||||
|
||||
|
|
|
|||
|
|
@ -132,6 +132,24 @@ internal abstract class DataAccess {
|
|||
}
|
||||
}
|
||||
|
||||
fun fileLastAccessed(storageScope: StorageScope, context: Context, path: String): Long {
|
||||
return when(storageScope) {
|
||||
StorageScope.APP -> FileData.fileLastAccessed(path)
|
||||
StorageScope.ASSETS -> AssetData.fileLastAccessed(path)
|
||||
StorageScope.SHARED -> MediaStoreData.fileLastAccessed(context, path)
|
||||
StorageScope.UNKNOWN -> 0L
|
||||
}
|
||||
}
|
||||
|
||||
fun fileSize(storageScope: StorageScope, context: Context, path: String): Long {
|
||||
return when(storageScope) {
|
||||
StorageScope.APP -> FileData.fileSize(path)
|
||||
StorageScope.ASSETS -> AssetData.fileSize(path)
|
||||
StorageScope.SHARED -> MediaStoreData.fileSize(context, path)
|
||||
StorageScope.UNKNOWN -> -1L
|
||||
}
|
||||
}
|
||||
|
||||
fun removeFile(storageScope: StorageScope, context: Context, path: String): Boolean {
|
||||
return when(storageScope) {
|
||||
StorageScope.APP -> FileData.delete(path)
|
||||
|
|
|
|||
|
|
@ -228,6 +228,21 @@ class FileAccessHandler(val context: Context) {
|
|||
}
|
||||
}
|
||||
|
||||
fun fileLastAccessed(filepath: String?): Long {
|
||||
val storageScope = storageScopeIdentifier.identifyStorageScope(filepath)
|
||||
if (storageScope == StorageScope.UNKNOWN) {
|
||||
return 0L
|
||||
}
|
||||
|
||||
return try {
|
||||
filepath?.let {
|
||||
DataAccess.fileLastAccessed(storageScope, context, it)
|
||||
} ?: 0L
|
||||
} catch (e: SecurityException) {
|
||||
0L
|
||||
}
|
||||
}
|
||||
|
||||
fun fileResize(fileId: Int, length: Long): Int {
|
||||
if (!hasFileId(fileId)) {
|
||||
return Error.FAILED.toNativeValue()
|
||||
|
|
@ -236,6 +251,21 @@ class FileAccessHandler(val context: Context) {
|
|||
return files[fileId].resize(length).toNativeValue()
|
||||
}
|
||||
|
||||
fun fileSize(filepath: String?): Long {
|
||||
val storageScope = storageScopeIdentifier.identifyStorageScope(filepath)
|
||||
if (storageScope == StorageScope.UNKNOWN) {
|
||||
return -1L
|
||||
}
|
||||
|
||||
return try {
|
||||
filepath?.let {
|
||||
DataAccess.fileSize(storageScope, context, it)
|
||||
} ?: -1L
|
||||
} catch (e: SecurityException) {
|
||||
-1L
|
||||
}
|
||||
}
|
||||
|
||||
fun fileGetPosition(fileId: Int): Long {
|
||||
if (!hasFileId(fileId)) {
|
||||
return 0L
|
||||
|
|
|
|||
|
|
@ -30,10 +30,16 @@
|
|||
|
||||
package org.godotengine.godot.io.file
|
||||
|
||||
import android.os.*
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.RandomAccessFile
|
||||
import java.nio.channels.FileChannel
|
||||
import java.nio.file.attribute.BasicFileAttributes
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.FileSystems
|
||||
import java.nio.file.Path
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
* Implementation of [DataAccess] which handles regular (not scoped) file access and interactions.
|
||||
|
|
@ -59,6 +65,30 @@ internal class FileData(filePath: String, accessFlag: FileAccessFlags) : DataAcc
|
|||
}
|
||||
}
|
||||
|
||||
fun fileLastAccessed(filepath: String): Long {
|
||||
return try {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
Files.readAttributes<BasicFileAttributes>(FileSystems.getDefault().getPath(filepath), BasicFileAttributes::class.java).lastAccessTime().to(TimeUnit.SECONDS)
|
||||
} else {
|
||||
0L
|
||||
}
|
||||
} catch (e: SecurityException) {
|
||||
0L
|
||||
}
|
||||
}
|
||||
|
||||
fun fileSize(filepath: String): Long {
|
||||
return try {
|
||||
if (File(filepath).isFile) {
|
||||
File(filepath).length()
|
||||
} else {
|
||||
-1L
|
||||
}
|
||||
} catch (e: SecurityException) {
|
||||
-1L
|
||||
}
|
||||
}
|
||||
|
||||
fun delete(filepath: String): Boolean {
|
||||
return try {
|
||||
File(filepath).delete()
|
||||
|
|
|
|||
|
|
@ -212,6 +212,20 @@ internal class MediaStoreData(context: Context, filePath: String, accessFlag: Fi
|
|||
return dataItem.dateModified.toLong() / 1000L
|
||||
}
|
||||
|
||||
fun fileLastAccessed(@Suppress("UNUSED_PARAMETER") context: Context, @Suppress("UNUSED_PARAMETER") path: String): Long {
|
||||
return 0L
|
||||
}
|
||||
|
||||
fun fileSize(context: Context, path: String): Long {
|
||||
val result = queryByPath(context, path)
|
||||
if (result.isEmpty()) {
|
||||
return -1L
|
||||
}
|
||||
|
||||
val dataItem = result[0]
|
||||
return dataItem.size.toLong()
|
||||
}
|
||||
|
||||
fun rename(context: Context, from: String, to: String): Boolean {
|
||||
// Ensure the source exists.
|
||||
val sources = queryByPath(context, from)
|
||||
|
|
|
|||
|
|
@ -90,6 +90,9 @@ object GameMenuUtils {
|
|||
@JvmStatic
|
||||
external fun playMainScene()
|
||||
|
||||
@JvmStatic
|
||||
external fun setDebugMuteAudio(enabled: Boolean)
|
||||
|
||||
/**
|
||||
* Returns [GameEmbedMode] stored in the editor settings.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue