Add physical_scancode (keyboard layout independent keycodes) to InputEventKey and InputMap.

Fix non-latin keyboard layout keycodes on Linux/X11 (fallback to physical keycodes).
This commit is contained in:
bruvzg 2021-03-07 17:16:42 +02:00
parent 63391f645c
commit dab4cf3ed6
No known key found for this signature in database
GPG key ID: 009E1BFE42239B95
28 changed files with 458 additions and 35 deletions

View file

@ -1056,8 +1056,8 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
int keyCode;
if ((keyCode = cc[i]) != 0) {
// Simulate key down and up...
GodotLib.key(0, keyCode, true);
GodotLib.key(0, keyCode, false);
GodotLib.key(0, 0, keyCode, true);
GodotLib.key(0, 0, keyCode, false);
}
}
}

View file

@ -138,7 +138,7 @@ public class GodotLib {
/**
* Forward regular key events from the main thread to the GL thread.
*/
public static native void key(int p_scancode, int p_unicode_char, boolean p_pressed);
public static native void key(int p_keycode, int p_scancode, int p_unicode_char, boolean p_pressed);
/**
* Forward game device's key events from the main thread to the GL thread.

View file

@ -109,11 +109,12 @@ public class GodotInputHandler implements InputDeviceListener {
});
}
} else {
final int scanCode = event.getScanCode();
final int chr = event.getUnicodeChar(0);
queueEvent(new Runnable() {
@Override
public void run() {
GodotLib.key(keyCode, chr, false);
GodotLib.key(keyCode, scanCode, chr, false);
}
});
};
@ -154,11 +155,12 @@ public class GodotInputHandler implements InputDeviceListener {
});
}
} else {
final int scanCode = event.getScanCode();
final int chr = event.getUnicodeChar(0);
queueEvent(new Runnable() {
@Override
public void run() {
GodotLib.key(keyCode, chr, true);
GodotLib.key(keyCode, scanCode, chr, true);
}
});
}

View file

@ -98,8 +98,8 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
@Override
public void run() {
for (int i = 0; i < count; ++i) {
GodotLib.key(KeyEvent.KEYCODE_DEL, 0, true);
GodotLib.key(KeyEvent.KEYCODE_DEL, 0, false);
GodotLib.key(KeyEvent.KEYCODE_DEL, KeyEvent.KEYCODE_DEL, 0, true);
GodotLib.key(KeyEvent.KEYCODE_DEL, KeyEvent.KEYCODE_DEL, 0, false);
if (mHasSelection) {
mHasSelection = false;
@ -127,8 +127,8 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
// Return keys are handled through action events
continue;
}
GodotLib.key(0, key, true);
GodotLib.key(0, key, false);
GodotLib.key(0, 0, key, true);
GodotLib.key(0, 0, key, false);
}
}
});
@ -144,8 +144,8 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
public void run() {
for (int i = 0; i < characters.length(); i++) {
final int ch = characters.codePointAt(i);
GodotLib.key(0, ch, true);
GodotLib.key(0, ch, false);
GodotLib.key(0, 0, ch, true);
GodotLib.key(0, 0, ch, false);
}
}
});
@ -153,8 +153,8 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
if (pActionID == EditorInfo.IME_ACTION_DONE) {
// Enter key has been pressed
GodotLib.key(KeyEvent.KEYCODE_ENTER, 0, true);
GodotLib.key(KeyEvent.KEYCODE_ENTER, 0, false);
GodotLib.key(KeyEvent.KEYCODE_ENTER, KeyEvent.KEYCODE_ENTER, 0, true);
GodotLib.key(KeyEvent.KEYCODE_ENTER, KeyEvent.KEYCODE_ENTER, 0, false);
this.mView.requestFocus();
return true;