You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Android: Hardware keyboard connection status callback
Adds a DisplayServer method to register hardware keyboard connection change callback.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ public class GodotInputHandler implements InputManager.InputDeviceListener, Sens
|
||||
|
||||
private int cachedRotation = -1;
|
||||
private boolean overrideVolumeButtons = false;
|
||||
private boolean hasHardwareKeyboardConfig = false;
|
||||
|
||||
public GodotInputHandler(Context context, Godot godot) {
|
||||
this.godot = godot;
|
||||
@@ -105,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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,6 +147,9 @@ public class GodotInputHandler implements InputManager.InputDeviceListener, Sens
|
||||
}
|
||||
|
||||
boolean hasHardwareKeyboard() {
|
||||
if (hasHardwareKeyboardConfig) {
|
||||
return true;
|
||||
}
|
||||
return !mHardwareKeyboardIds.isEmpty();
|
||||
}
|
||||
|
||||
@@ -797,5 +804,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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user