fix: android, back function (#10843)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou 2025-02-20 01:02:24 +08:00 committed by GitHub
parent 965cc6af26
commit 2e89a33210
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 2 deletions

View file

@ -35,10 +35,15 @@ import hbb.MessageOuterClass.KeyEvent
import hbb.MessageOuterClass.KeyboardMode
import hbb.KeyEventConverter
// const val BUTTON_UP = 2
// const val BUTTON_BACK = 0x08
const val LEFT_DOWN = 9
const val LEFT_MOVE = 8
const val LEFT_UP = 10
const val RIGHT_UP = 18
// (BUTTON_BACK << 3) | BUTTON_UP
const val BACK_UP = 66
const val WHEEL_BUTTON_DOWN = 33
const val WHEEL_BUTTON_UP = 34
const val WHEEL_DOWN = 523331
@ -142,6 +147,11 @@ class InputService : AccessibilityService() {
return
}
if (mask == BACK_UP) {
performGlobalAction(GLOBAL_ACTION_BACK)
return
}
// long WHEEL_BUTTON_DOWN -> GLOBAL_ACTION_RECENTS
if (mask == WHEEL_BUTTON_DOWN) {
timer.purge()

View file

@ -18,7 +18,7 @@ import '../common.dart';
import '../consts.dart';
/// Mouse button enum.
enum MouseButtons { left, right, wheel }
enum MouseButtons { left, right, wheel, back }
const _kMouseEventDown = 'mousedown';
const _kMouseEventUp = 'mouseup';
@ -155,6 +155,8 @@ extension ToString on MouseButtons {
return 'right';
case MouseButtons.wheel:
return 'wheel';
case MouseButtons.back:
return 'back';
}
}
}
@ -1426,7 +1428,18 @@ class InputModel {
}
}
void onMobileBack() => tap(MouseButtons.right);
void onMobileBack() {
final minBackButtonVersion = "1.3.8";
final peerVersion =
parent.target?.ffiModel.pi.version ?? minBackButtonVersion;
var btn = MouseButtons.back;
// For compatibility with old versions
if (versionCmp(peerVersion, minBackButtonVersion) < 0) {
btn = MouseButtons.right;
}
tap(btn);
}
void onMobileHome() => tap(MouseButtons.wheel);
Future<void> onMobileApps() async {
sendMouse('down', MouseButtons.wheel);