You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Merge pull request #62885 from madmiraal/fix-59931
This commit is contained in:
@@ -151,7 +151,7 @@ public class GodotLib {
|
||||
/**
|
||||
* Forward regular key events from the main thread to the GL thread.
|
||||
*/
|
||||
public static native void key(int p_keycode, int p_scancode, int p_unicode_char, boolean p_pressed);
|
||||
public static native void key(int p_keycode, int p_physical_keycode, int p_unicode, boolean p_pressed);
|
||||
|
||||
/**
|
||||
* Forward game device's key events from the main thread to the GL thread.
|
||||
|
||||
@@ -96,10 +96,14 @@ public class GodotInputHandler implements InputManager.InputDeviceListener {
|
||||
GodotLib.joybutton(godotJoyId, button, false);
|
||||
}
|
||||
} else {
|
||||
final int scanCode = event.getScanCode();
|
||||
final int chr = event.getUnicodeChar(0);
|
||||
GodotLib.key(keyCode, scanCode, chr, false);
|
||||
}
|
||||
// getKeyCode(): The physical key that was pressed.
|
||||
// Godot's keycodes match the ASCII codes, so for single byte unicode characters,
|
||||
// we can use the unmodified unicode character to determine Godot's keycode.
|
||||
final int keycode = event.getUnicodeChar(0);
|
||||
final int physical_keycode = event.getKeyCode();
|
||||
final int unicode = event.getUnicodeChar();
|
||||
GodotLib.key(keycode, physical_keycode, unicode, false);
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -131,9 +135,10 @@ public class GodotInputHandler implements InputManager.InputDeviceListener {
|
||||
GodotLib.joybutton(godotJoyId, button, true);
|
||||
}
|
||||
} else {
|
||||
final int scanCode = event.getScanCode();
|
||||
final int chr = event.getUnicodeChar(0);
|
||||
GodotLib.key(keyCode, scanCode, chr, true);
|
||||
final int keycode = event.getUnicodeChar(0);
|
||||
final int physical_keycode = event.getKeyCode();
|
||||
final int unicode = event.getUnicodeChar();
|
||||
GodotLib.key(keycode, physical_keycode, unicode, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -92,11 +92,9 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(final CharSequence pCharSequence, final int start, final int count, final int after) {
|
||||
//Log.d(TAG, "beforeTextChanged(" + pCharSequence + ")start: " + start + ",count: " + count + ",after: " + after);
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
GodotLib.key(KeyEvent.KEYCODE_DEL, KeyEvent.KEYCODE_DEL, 0, true);
|
||||
GodotLib.key(KeyEvent.KEYCODE_DEL, KeyEvent.KEYCODE_DEL, 0, false);
|
||||
GodotLib.key(0, KeyEvent.KEYCODE_DEL, 0, true);
|
||||
GodotLib.key(0, KeyEvent.KEYCODE_DEL, 0, false);
|
||||
|
||||
if (mHasSelection) {
|
||||
mHasSelection = false;
|
||||
@@ -107,8 +105,6 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
|
||||
|
||||
@Override
|
||||
public void onTextChanged(final CharSequence pCharSequence, final int start, final int before, final int count) {
|
||||
//Log.d(TAG, "onTextChanged(" + pCharSequence + ")start: " + start + ",count: " + count + ",before: " + before);
|
||||
|
||||
final int[] newChars = new int[count];
|
||||
for (int i = start; i < start + count; ++i) {
|
||||
newChars[i - start] = pCharSequence.charAt(i);
|
||||
@@ -119,8 +115,8 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
|
||||
// Return keys are handled through action events
|
||||
continue;
|
||||
}
|
||||
GodotLib.key(0, 0, key, true);
|
||||
GodotLib.key(0, 0, key, false);
|
||||
GodotLib.key(key, 0, key, true);
|
||||
GodotLib.key(key, 0, key, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,16 +127,16 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
|
||||
|
||||
for (int i = 0; i < characters.length(); i++) {
|
||||
final int ch = characters.codePointAt(i);
|
||||
GodotLib.key(0, 0, ch, true);
|
||||
GodotLib.key(0, 0, ch, false);
|
||||
GodotLib.key(ch, 0, ch, true);
|
||||
GodotLib.key(ch, 0, ch, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (pActionID == EditorInfo.IME_ACTION_DONE) {
|
||||
// Enter key has been pressed
|
||||
mRenderView.queueOnRenderThread(() -> {
|
||||
GodotLib.key(KeyEvent.KEYCODE_ENTER, KeyEvent.KEYCODE_ENTER, 0, true);
|
||||
GodotLib.key(KeyEvent.KEYCODE_ENTER, KeyEvent.KEYCODE_ENTER, 0, false);
|
||||
GodotLib.key(0, KeyEvent.KEYCODE_ENTER, 0, true);
|
||||
GodotLib.key(0, KeyEvent.KEYCODE_ENTER, 0, false);
|
||||
});
|
||||
mRenderView.getView().requestFocus();
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user