update mobile mouse scroll

This commit is contained in:
csf 2022-05-12 20:05:59 +08:00
parent 3a66d52c2d
commit cfd4fd492b
2 changed files with 11 additions and 5 deletions

View File

@ -691,11 +691,9 @@ class FFI {
sendMouse('up', button);
}
static void scroll(double y) {
var y2 = y.round();
if (y2 == 0) return;
static void scroll(int y) {
setByName('send_mouse',
json.encode(modify({'type': 'wheel', 'y': y2.toString()})));
json.encode(modify({'type': 'wheel', 'y': y.toString()})));
}
static void reconnect() {

View File

@ -32,6 +32,7 @@ class _RemotePageState extends State<RemotePage> {
double _bottom = 0;
String _value = '';
double _scale = 1;
double _mouseScrollIntegral = 0; // mouse scroll speed controller
var _more = true;
var _fn = false;
@ -544,7 +545,14 @@ class _RemotePageState extends State<RemotePage> {
onThreeFingerVerticalDragUpdate: FFI.ffiModel.isPeerAndroid
? null
: (d) {
FFI.scroll(d.delta.dy / 2);
_mouseScrollIntegral += d.delta.dy / 4;
if (_mouseScrollIntegral > 1) {
FFI.scroll(1);
_mouseScrollIntegral = 0;
} else if (_mouseScrollIntegral < -1) {
FFI.scroll(-1);
_mouseScrollIntegral = 0;
}
});
}