Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Skia.WPF] Multi-Touch support #14393

Closed
lindexi opened this issue Nov 11, 2023 · 8 comments
Closed

[Skia.WPF] Multi-Touch support #14393

lindexi opened this issue Nov 11, 2023 · 8 comments
Assignees
Labels
difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/enhancement New feature or request platform/wpf 🪟 Categorizes an issue or PR as relevant to WPF project/input ⌨️ Categorizes an issue or PR as relevant to input (Button, CheckBox, Toggle, Scroll, Map, Numeric,...) project/pointers 🖱️ Categorizes an issue or PR as relevant to mouse/touch/pen pointers

Comments

@lindexi
Copy link
Contributor

lindexi commented Nov 11, 2023

What would you like to be added

Adding the multi-touch support to UNO.Skia.WPF.

Why is this needed

The original WPF has very good touch support. But that's what UNO.Skia.WPF is missing right now. See #4309

For which platform

Skia.WPF

Anything else we need to know?

WPF distinguishes WM_Pointer from Mouse and Stylus and Touch events.

@lindexi lindexi added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/enhancement New feature or request triage/untriaged Indicates an issue requires triaging or verification labels Nov 11, 2023
@lindexi
Copy link
Contributor Author

lindexi commented Nov 11, 2023

I'm delighted to be involved in the development of this feature, and I'm also quite familiar with the touch and ink modules of WPF.

@Youssef1313 Youssef1313 added project/pointers 🖱️ Categorizes an issue or PR as relevant to mouse/touch/pen pointers platform/wpf 🪟 Categorizes an issue or PR as relevant to WPF labels Nov 11, 2023
@MartinZikmund MartinZikmund added project/input ⌨️ Categorizes an issue or PR as relevant to input (Button, CheckBox, Toggle, Scroll, Map, Numeric,...) difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI and removed triage/untriaged Indicates an issue requires triaging or verification difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels Nov 13, 2023
@lindexi lindexi closed this as completed Feb 20, 2024
@Youssef1313
Copy link
Member

@lindexi I don't think this was implemented. So, re-opening it.

@Youssef1313 Youssef1313 reopened this Mar 2, 2024
@lindexi
Copy link
Contributor Author

lindexi commented Mar 2, 2024

Thank you @Youssef1313

@lindexi
Copy link
Contributor Author

lindexi commented Mar 3, 2024

After reviewing the source code of UNO, I believe we can modify the original method of only obtaining events from the Mouse, to simultaneously obtaining events from both the Stylus and Mouse. Moreover, when the Mouse determines that the current event is from the Stylus or Touch, it will automatically ignore the subsequent processing logic. According to the touch behavior of WPF, the Touch event is triggered first, then promoted to the Stylus event, and finally promoted to the Mouse event. At the same time, Pen messages will trigger the Stylus event first, and then be promoted to the Mouse event. This means that for simple processing, using the Stylus event can handle both Touch and Pen situations. When using the Stylus event, multi-touch support will be automatically enabled. Also, by using the GetPropertyValue method and passing in StylusPointProperties.Width and StylusPointProperties.Height, we can obtain the possible size of the touch, which can be used to fill in the Microsoft.UI.Input.PointerPointProperties.ContactRect attribute. This will be beneficial for WPF applications on touch screens using the UNO framework.

    private void MainWindow_StylusDown(object sender, StylusDownEventArgs e)
    {
        var stylusPointCollection = e.GetStylusPoints(this);
        var firstStylusPoint = stylusPointCollection.First();

        if (firstStylusPoint.HasProperty(StylusPointProperties.Width))
        {
            var width = firstStylusPoint.GetPropertyValue(StylusPointProperties.Width);
        }

        if (firstStylusPoint.HasProperty(StylusPointProperties.Height))
        {
            var height = firstStylusPoint.GetPropertyValue(StylusPointProperties.Height);
        }
    }

@MartinZikmund
Copy link
Member

I think the ability to distinguish input types is working since #15543 , but maybe the additional properties are missing?

@lindexi
Copy link
Contributor Author

lindexi commented Apr 20, 2024

@MartinZikmund Sorry for delay. As you can see, the WpfCorePointerInputSource will only add the Mouse events and it do not add any Stylus and Touch event. That means it can not handle the multi-touch events.

@lindexi
Copy link
Contributor Author

lindexi commented Apr 20, 2024

@MartinZikmund I create #16378 and could you review my code?

@MartinZikmund
Copy link
Member

The changes are merged now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/enhancement New feature or request platform/wpf 🪟 Categorizes an issue or PR as relevant to WPF project/input ⌨️ Categorizes an issue or PR as relevant to input (Button, CheckBox, Toggle, Scroll, Map, Numeric,...) project/pointers 🖱️ Categorizes an issue or PR as relevant to mouse/touch/pen pointers
Projects
None yet
Development

No branches or pull requests

3 participants