Skip to content

An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.

tmp commit

dignowd6f1abad959e
diff --git a/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/InputService.kt b/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/InputService.kt
index 905a2734d..8e14a590d 100644
--- a/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/InputService.kt
+++ b/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/InputService.kt
@@ -26,6 +26,13 @@ const val WHEEL_BUTTON_UP = 34
const val WHEEL_DOWN = 523331
const val WHEEL_UP = 963
+const val TOUCH_SCALE_START = 1
+const val TOUCH_SCALE = 2
+const val TOUCH_SCALE_END = 3
+const val TOUCH_PAN_START = 4
+const val TOUCH_PAN_UPDATE = 5
+const val TOUCH_PAN_END = 6
+
const val WHEEL_STEP = 120
const val WHEEL_DURATION = 50L
const val LONG_TAP_DELAY = 200L
@@ -167,6 +174,30 @@ class InputService : AccessibilityService() {
}
}
+ @RequiresApi(Build.VERSION_CODES.N)
+ fun onTouchInput(mask: Int, _x: Int, _y: Int) {
+ val x = max(0, _x)
+ val y = max(0, _y)
+ when (mask) {
+ TOUCH_PAN_UPDATE -> {
+ mouseX += x * SCREEN_INFO.scale
+ mouseY += y * SCREEN_INFO.scale
+ continueGesture(mouseX, mouseY)
+ }
+ TOUCH_PAN_START -> {
+ mouseX = x * SCREEN_INFO.scale
+ mouseY = y * SCREEN_INFO.scale
+ startGesture(mouseX, mouseY)
+ }
+ TOUCH_PAN_END -> {
+ mouseX = x * SCREEN_INFO.scale
+ mouseY = y * SCREEN_INFO.scale
+ endGesture(mouseX, mouseY)
+ }
+ else -> {}
+ }
+ }
+
@RequiresApi(Build.VERSION_CODES.N)
private fun consumeWheelActions() {
if (isWheelActionsPolling) {
diff --git a/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainService.kt b/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainService.kt
index 78e4e451e..f32203703 100644
--- a/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainService.kt
+++ b/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainService.kt
@@ -71,17 +71,26 @@ class MainService : Service() {
@Keep
@RequiresApi(Build.VERSION_CODES.N)
- fun rustMouseInput(mask: Int, x: Int, y: Int) {
+ fun rustPointerInput(kind: String, mask: Int, x: Int, y: Int) {
// turn on screen with LIFT_DOWN when screen off
- if (!powerManager.isInteractive && mask == LIFT_DOWN) {
+ if (!powerManager.isInteractive && (kind == "touch" || mask == LIFT_DOWN)) {
if (wakeLock.isHeld) {
- Log.d(logTag,"Turn on Screen, WakeLock release")
+ Log.d(logTag, "Turn on Screen, WakeLock release")
wakeLock.release()
}
Log.d(logTag,"Turn on Screen")
wakeLock.acquire(5000)
} else {
- InputService.ctx?.onMouseInput(mask,x,y)
+ when (name) {
+ "touch" -> {
+ InputService.ctx?.onTouchInput(mask, x, y)
+ }
+ "mouse" -> {
+ InputService.ctx?.onMouseInput(mask, x, y)
+ }
+ else -> {
+ }
+ }
}
}
diff --git a/libs/scrap/src/android/ffi.rs b/libs/scrap/src/android/ffi.rs
index 6855fd3f6..3801bbc87 100644
--- a/libs/scrap/src/android/ffi.rs
+++ b/libs/scrap/src/android/ffi.rs
@@ -154,7 +154,7 @@ pub extern "system" fn Java_com_carriez_flutter_1hbb_MainService_init(
}
}
-pub fn call_main_service_mouse_input(mask: i32, x: i32, y: i32) -> JniResult<()> {
+pub fn call_main_service_pointer_input(kind: String, mask: i32, x: i32, y: i32) -> JniResult<()> {
if let (Some(jvm), Some(ctx)) = (
JVM.read().unwrap().as_ref(),
MAIN_SERVICE_CTX.read().unwrap().as_ref(),
@@ -162,9 +162,9 @@ pub fn call_main_service_mouse_input(mask: i32, x: i32, y: i32) -> JniResult<()>
let mut env = jvm.attach_current_thread_as_daemon()?;
env.call_method(
ctx,
- "rustMouseInput",
+ "rustPointerInput",
"(III)V",
- &[JValue::Int(mask), JValue::Int(x), JValue::Int(y)],
+ &[JValue(kind), JValue::Int(mask), JValue::Int(x), JValue::Int(y)],
)?;
return Ok(());
} else {
diff --git a/src/server/connection.rs b/src/server/connection.rs
index e32a4c1c3..913c831da 100644
--- a/src/server/connection.rs
+++ b/src/server/connection.rs
@@ -1546,8 +1546,10 @@ impl Connection {
match msg.union {
Some(message::Union::MouseEvent(me)) => {
#[cfg(any(target_os = "android", target_os = "ios"))]
- if let Err(e) = call_main_service_mouse_input(me.mask, me.x, me.y) {
- log::debug!("call_main_service_mouse_input fail:{}", e);
+ if let Err(e) =
+ call_main_service_pointer_input("mouse".to_string(), me.mask, me.x, me.y)
+ {
+ log::debug!("call_main_service_pointer_input fail:{}", e);
}
#[cfg(not(any(target_os = "android", target_os = "ios")))]
if self.peer_keyboard_enabled() {
@@ -1559,8 +1561,40 @@ impl Connection {
self.input_mouse(me, self.inner.id());
}
}
- Some(message::Union::PointerDeviceEvent(pde)) =>
- {
+ Some(message::Union::PointerDeviceEvent(pde)) => {
+ #[cfg(any(target_os = "android", target_os = "ios"))]
+ if let Err(e) = match pde.union {
+ Some(pointer_device_event::Union::TouchEvent(touch)) => match touch.union {
+ Some(touch_event::Union::PanStart(pan_start)) => {
+ call_main_service_pointer_input(
+ "touch".to_string(),
+ 4,
+ pan_start.x,
+ pan_start.y,
+ )
+ }
+ Some(touch_event::Union::PanUpdate(pan_start)) => {
+ call_main_service_pointer_input(
+ "touch".to_string(),
+ 5,
+ pan_start.x,
+ pan_start.y,
+ )
+ }
+ Some(touch_event::Union::PanEnd(pan_start)) => {
+ call_main_service_pointer_input(
+ "touch".to_string(),
+ 6,
+ pan_start.x,
+ pan_start.y,
+ )
+ }
+ _ => Ok(()),
+ },
+ _ => Ok(()),
+ } {
+ log::debug!("call_main_service_pointer_input fail:{}", e);
+ }
#[cfg(not(any(target_os = "android", target_os = "ios")))]
if self.peer_keyboard_enabled() {
MOUSE_MOVE_TIME.store(get_time(), Ordering::SeqCst);