tmp commit
Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
parent
933c99110c
commit
d6f1abad95
@ -26,6 +26,13 @@ const val WHEEL_BUTTON_UP = 34
|
|||||||
const val WHEEL_DOWN = 523331
|
const val WHEEL_DOWN = 523331
|
||||||
const val WHEEL_UP = 963
|
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_STEP = 120
|
||||||
const val WHEEL_DURATION = 50L
|
const val WHEEL_DURATION = 50L
|
||||||
const val LONG_TAP_DELAY = 200L
|
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)
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
private fun consumeWheelActions() {
|
private fun consumeWheelActions() {
|
||||||
if (isWheelActionsPolling) {
|
if (isWheelActionsPolling) {
|
||||||
|
@ -71,17 +71,26 @@ class MainService : Service() {
|
|||||||
|
|
||||||
@Keep
|
@Keep
|
||||||
@RequiresApi(Build.VERSION_CODES.N)
|
@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
|
// 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) {
|
if (wakeLock.isHeld) {
|
||||||
Log.d(logTag,"Turn on Screen, WakeLock release")
|
Log.d(logTag, "Turn on Screen, WakeLock release")
|
||||||
wakeLock.release()
|
wakeLock.release()
|
||||||
}
|
}
|
||||||
Log.d(logTag,"Turn on Screen")
|
Log.d(logTag,"Turn on Screen")
|
||||||
wakeLock.acquire(5000)
|
wakeLock.acquire(5000)
|
||||||
} else {
|
} else {
|
||||||
InputService.ctx?.onMouseInput(mask,x,y)
|
when (name) {
|
||||||
|
"touch" -> {
|
||||||
|
InputService.ctx?.onTouchInput(mask, x, y)
|
||||||
|
}
|
||||||
|
"mouse" -> {
|
||||||
|
InputService.ctx?.onMouseInput(mask, x, y)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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)) = (
|
if let (Some(jvm), Some(ctx)) = (
|
||||||
JVM.read().unwrap().as_ref(),
|
JVM.read().unwrap().as_ref(),
|
||||||
MAIN_SERVICE_CTX.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()?;
|
let mut env = jvm.attach_current_thread_as_daemon()?;
|
||||||
env.call_method(
|
env.call_method(
|
||||||
ctx,
|
ctx,
|
||||||
"rustMouseInput",
|
"rustPointerInput",
|
||||||
"(III)V",
|
"(III)V",
|
||||||
&[JValue::Int(mask), JValue::Int(x), JValue::Int(y)],
|
&[JValue(kind), JValue::Int(mask), JValue::Int(x), JValue::Int(y)],
|
||||||
)?;
|
)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
} else {
|
} else {
|
||||||
|
@ -1546,8 +1546,10 @@ impl Connection {
|
|||||||
match msg.union {
|
match msg.union {
|
||||||
Some(message::Union::MouseEvent(me)) => {
|
Some(message::Union::MouseEvent(me)) => {
|
||||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||||
if let Err(e) = call_main_service_mouse_input(me.mask, me.x, me.y) {
|
if let Err(e) =
|
||||||
log::debug!("call_main_service_mouse_input fail:{}", 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")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
if self.peer_keyboard_enabled() {
|
if self.peer_keyboard_enabled() {
|
||||||
@ -1559,8 +1561,40 @@ impl Connection {
|
|||||||
self.input_mouse(me, self.inner.id());
|
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")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
if self.peer_keyboard_enabled() {
|
if self.peer_keyboard_enabled() {
|
||||||
MOUSE_MOVE_TIME.store(get_time(), Ordering::SeqCst);
|
MOUSE_MOVE_TIME.store(get_time(), Ordering::SeqCst);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user