Merge pull request #915 from Heap-Hop/master

Fix physical keyboard
This commit is contained in:
RustDesk 2022-07-04 16:14:41 +08:00 committed by GitHub
commit 37b5a08f87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 10 deletions

View File

@ -43,7 +43,7 @@
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode|navigation"
android:exported="true" android:exported="true"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
android:launchMode="singleTop" android:launchMode="singleTop"

View File

@ -724,13 +724,17 @@ class FFI {
static void inputKey(String name, {bool? down, bool? press}) { static void inputKey(String name, {bool? down, bool? press}) {
if (!ffiModel.keyboard()) return; if (!ffiModel.keyboard()) return;
setByName( final Map<String, String> out = Map();
'input_key', out['name'] = name;
json.encode(modify({ // default: down = false
'name': name, if (down == true) {
'down': (down ?? false).toString(), out['down'] = "true";
'press': (press ?? true).toString() }
}))); // default: press = true
if (press != false) {
out['press'] = "true";
}
setByName('input_key', json.encode(modify(out)));
} }
static void moveMouse(double x, double y) { static void moveMouse(double x, double y) {

View File

@ -343,9 +343,14 @@ class _RemotePageState extends State<RemotePage> {
onKey: (data, e) { onKey: (data, e) {
final key = e.logicalKey; final key = e.logicalKey;
if (e is RawKeyDownEvent) { if (e is RawKeyDownEvent) {
if (e.repeat) { if (e.repeat &&
!e.isAltPressed &&
!e.isControlPressed &&
!e.isShiftPressed &&
!e.isMetaPressed) {
sendRawKey(e, press: true); sendRawKey(e, press: true);
} else { } else {
sendRawKey(e, down: true);
if (e.isAltPressed && !FFI.alt) { if (e.isAltPressed && !FFI.alt) {
FFI.alt = true; FFI.alt = true;
} else if (e.isControlPressed && !FFI.ctrl) { } else if (e.isControlPressed && !FFI.ctrl) {
@ -355,7 +360,6 @@ class _RemotePageState extends State<RemotePage> {
} else if (e.isMetaPressed && !FFI.command) { } else if (e.isMetaPressed && !FFI.command) {
FFI.command = true; FFI.command = true;
} }
sendRawKey(e, down: true);
} }
} }
// [!_showEdit] workaround for soft-keyboard's control_key like Backspace / Enter // [!_showEdit] workaround for soft-keyboard's control_key like Backspace / Enter