From 9e0feb0b64c14c97eccea3905923dbcc7acbaab5 Mon Sep 17 00:00:00 2001 From: dignow Date: Thu, 10 Aug 2023 01:02:27 +0800 Subject: [PATCH] tmp debug Signed-off-by: dignow --- flutter/lib/models/input_model.dart | 8 +++---- src/flutter_ffi.rs | 33 ++++++++++++++--------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/flutter/lib/models/input_model.dart b/flutter/lib/models/input_model.dart index 9b1ec4437..5f851c54d 100644 --- a/flutter/lib/models/input_model.dart +++ b/flutter/lib/models/input_model.dart @@ -585,8 +585,8 @@ class InputModel { late final dynamic evtValue; if (type == 'pan_update') { evtValue = { - 'x': '${x.toInt()}', - 'y': '${y.toInt()}', + 'x': x.toInt(), + 'y': y.toInt(), }; } else { final isMoveTypes = ['pan_start', 'pan_end']; @@ -601,8 +601,8 @@ class InputModel { return; } evtValue = { - 'x': '${pos.x}', - 'y': '${pos.y}', + 'x': pos.x, + 'y': pos.y, }; } diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs index cf5d23397..c6f8ca774 100644 --- a/src/flutter_ffi.rs +++ b/src/flutter_ffi.rs @@ -1179,30 +1179,29 @@ pub fn session_send_pointer(session_id: SessionID, msg: String) { let command = m.get("command").is_some(); match (m.get("k"), m.get("v")) { (Some(k), Some(v)) => match k.as_str() { - Some("touch") => match v.as_str() { - Some("scale") => match v.get("v") { + Some("touch") => match v.get("t").and_then(|t| t.as_str()) { + Some("scale") => match v.get("v").and_then(|s| s.as_i64()) { Some(scale) => { - if let Some(scale) = scale.as_i64() { - if let Some(session) = SESSIONS.read().unwrap().get(&session_id) { - session.send_touch_scale(scale as _, alt, ctrl, shift, command); - } + if let Some(session) = SESSIONS.read().unwrap().get(&session_id) { + session.send_touch_scale(scale as _, alt, ctrl, shift, command); } } None => {} }, - Some(pan_event) => match (v.get("x"), v.get("y")) { - (Some(x), Some(y)) => { - if let Some(x) = x.as_i64() { - if let Some(y) = y.as_i64() { - if let Some(session) = SESSIONS.read().unwrap().get(&session_id) - { - session.send_touch_pan_event( - pan_event, x as _, y as _, alt, ctrl, shift, command, - ); - } + Some(pan_event) => match v.get("v") { + Some(v) => match ( + v.get("x").and_then(|x| x.as_i64()), + v.get("y").and_then(|y| y.as_i64()), + ) { + (Some(x), Some(y)) => { + if let Some(session) = SESSIONS.read().unwrap().get(&session_id) { + session.send_touch_pan_event( + pan_event, x as _, y as _, alt, ctrl, shift, command, + ); } } - } + _ => {} + }, _ => {} }, _ => {}