这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@AlphaBs
Copy link
Contributor

@AlphaBs AlphaBs commented Mar 22, 2024

add some gestures of Samsung Galaxy Tab trackpad (SEC-EFDT970).

  • tap to left click
  • long tap to drag
  • two-finger tap to right click
  • two-finger scroll

tested on Samsung Galaxy Tab S8+ (SM-X800), Android 14, OneUI 6.0

I also recorded MotionEvents when I gesture:

move
action: ACTION_HOVER_MOVE, flags: 40, state: 0

tap
action: ACTION_HOVER_EXIT, flags: 40, state: 0 
action: ACTION_DOWN, flags: 0, state: 0
action: ACTION_UP, flags: 40, state: 0
action: ACTION_HOVER_ENTER, flags: 40, state: 0

long tap
action: ACTION_HOVER_EXIT, flags: 40, state: 0
action: ACTION_DOWN, flags: 0, state: 0
action: ACTION_MOVE, flags: 0, state: 0 <- drag
action: ACTION_MOVE, flags: 2000000, state: 0 <- randomly
action: ACTION_UP, flags: 40, state: 0
action: ACTION_HOVER_ENTER, flags: 40, state: 0

two-finger tap
action: ACTION_HOVER_EXIT, flags: 40, state: 0
action: ACTION_DOWN, flags: 40, state: 2
action: ACTION_BUTTON_PRESS, flags: 0, state: 2
action: ACTION_BUTTON_RELEASE, flags: 0, state: 0
action: ACTION_UP, flags: 40, state: 0
action: ACTION_HOVER_ENTER, flags: 40, state: 0

two-finger scroll
action: ACTION_HOVER_EXIT, flags: 40, state: 0
action: ACTION_DOWN, flags: 10000040, state: 0
action: ACTION_MOVE, flags: 10000040, state: 0 <- scroll
action: ACTION_MOVE, flags: 12000040, state: 0 <- randomly
action: ACTION_UP, flags: 40, state: 0
action: ACTION_HOVER_ENTER, flags: 40, state: 0

press left button
action: ACTION_HOVER_EXIT, flags: 40, state: 0
action: ACTION_DOWN, flags: 0, state: 1
action ACTION_BUTTON_PRESS, flags: 0, state: 1
action ACTION_BUTTON_RELEASE, flags: 0, state: 0
action ACTION_UP, flags: 40, state: 0
action ACTION_HOVER_ENTER, flags: 40, state: 0
action ACTION_HOVER_EXIT, flags: 40, state: 0 <- hand off

press right button
action: ACTION_HOVER_EXIT, flags: 40, state: 0
action: ACTION_DOWN, flags: 0, state: 2
action: ACTION_BUTTON_PRESS, flags: 0, state: 2
action: ACTION_BUTTON_RELEASE, flags: 0, state: 0
action: ACTION_UP, flags: 40, state: 0
action ACTION_HOVER_ENTER, flags: 40, state: 0
action: ACTION_HOVER_EXIT, flags: 40, state: 0

AlphaBs added 3 commits March 22, 2024 02:37
tap, long tap, two-finger tap, two-finger scroll
tested on SM-X800, with EFDT970
@twaik
Copy link
Member

twaik commented Mar 22, 2024

I did not dive deep to changes but I already can say that kt will break support for other dex devices. Replacing one constant (0x14000000) with another one (0x10000000) is not an option.
Not going to be merged in the current state.

@AlphaBs
Copy link
Contributor Author

AlphaBs commented Mar 22, 2024

okay do we need completely different way to detect gestures? or just hasFlags(e, 0x10000000) || hasFlags(e, 0x14000000) is enough? (looks like logically same code?)

@twaik
Copy link
Member

twaik commented Mar 22, 2024

Again, I did not dive deep to the code. But it will be the first step.

@AlphaBs
Copy link
Contributor Author

AlphaBs commented Mar 22, 2024

I reverted the constant

@twaik
Copy link
Member

twaik commented Mar 22, 2024

Ok, I need to test this on my device and request test from one other guy.

@twaik
Copy link
Member

twaik commented Mar 22, 2024

Ok, it works fine on Samsung Galaxy S20 FE (SM-G780F).

@twaik
Copy link
Member

twaik commented Mar 22, 2024

Can you please investigate why it does not work with Capture external mouse when possible?

@AlphaBs
Copy link
Contributor Author

AlphaBs commented Mar 22, 2024

Sure, but my device behaves very strangely (inversed X/Y axis, can't use any gestures) when I turn that option on, even before the PR code.

@twaik
Copy link
Member

twaik commented Mar 22, 2024

AFAIK it should be handled by HardwareMouseListener. And I am not sure why it inverts X/Y axis, I probably will implement options like External mouse rotation to сompensate this. But gestures are still unhandled and I do not really have resources to fix this. If you fix it (in another PR) and it will not break existing mice support I will merge it.

Co-authored-by: Twaik Yont <twaikyont@gmail.com>
@AlphaBs
Copy link
Contributor Author

AlphaBs commented Mar 22, 2024

I'm just curious, why trackpad need captured pointer? I'm not sure what the expected behavior is.

@twaik
Copy link
Member

twaik commented Mar 22, 2024

The "Captured Pointer" feature offers several advantages. Firstly, the navigation and status bars do not appear when the mouse touches the top or bottom edges of the screen. Secondly, Android sends relative mouse events instead of the absolute ones typical in regular mode. This is particularly important in scenarios like 3D games or 3D editors, or in any other situation where an X11 application manipulates the cursor's position, and this behavior needs to be taken into account.

@AlphaBs
Copy link
Contributor Author

AlphaBs commented Mar 23, 2024

in my device, just removing below code fixes the issue.

TouchInputHandler.java:

// Regular touchpads and Dex touchpad send events as finger too,
// but they should be handled as touchscreens with trackpad mode.
if  (mTouchpadHandler != null && (event.getSource() & InputDevice.SOURCE_TOUCHPAD) == InputDevice.SOURCE_TOUCHPAD) {
    return mTouchpadHandler.handleTouchEvent(view, view, event);
}

With trackpad mode, all gestures including tap, long tap to drag, two-finger tap, two-finger scroll, even three-finger tap are handled well.
With direct touch mode, pinch to zoom and multi touch are available.

but X/Y axis are still ininverted. It looks like Android or my trackpad is reporting the wrong MotionEvent. As you said we might need an option to invert this.

@AlphaBs
Copy link
Contributor Author

AlphaBs commented Mar 23, 2024

MotionEvent from my touchpad with captured pointer should be handled by mInputStrategy and gesture detectors. I don't know why it was handled by mHMListener. Maybe there was an another touchpad that should be handled by HardwareMouseListener? I don't have another touchpad I can't test futher.

press the left button with one finger and move to drag with the other
@twaik
Copy link
Member

twaik commented Mar 24, 2024

There is no two-finger drag feature in the original code. I will not merge it.

@twaik
Copy link
Member

twaik commented Mar 24, 2024

Or it is only for the case of Dex? Yeah, it seems like yes.

@AlphaBs
Copy link
Contributor Author

AlphaBs commented Mar 24, 2024

My device supports two-finger dragging. I can use this gesture in any android app, not just termux-x11.
This gesture is useful when I need to drag a very long distance accurately.
And I was able to achieve this by simply keeping the onTap state when ACTION_BUTTON_PRESS. (the real event is ACTION_HOVER_EXIT -> ACTION_DOWN -> ACTION_BUTTON_PRESS -> ACTION_MOVE(dragging) -> ACTION_BUTTON_RELEASE -> ACTION_UP)
Is this a potential backwards compatibility breaker?

@twaik
Copy link
Member

twaik commented Mar 24, 2024

I am not really sure about this. Need some check.

@AlphaBs
Copy link
Contributor Author

AlphaBs commented Mar 24, 2024

Or it is only for the case of Dex? Yeah, it seems like yes.

yes! Is there anything else I need to do before it merges?

@twaik
Copy link
Member

twaik commented Mar 24, 2024

Currenly I have to do some checks on real device.

@twaik
Copy link
Member

twaik commented Mar 24, 2024

Probably that is safe, but I can not reproduce two-finger drag behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants