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

Touch input #1736

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Touch input #1736

wants to merge 2 commits into from

Conversation

torkeldanielsson
Copy link

@torkeldanielsson torkeldanielsson commented Jul 22, 2020

This PR proposes to add the generic API from the touch branch for receiving touch input.

There exists at least the following efforts, since at least 2013 (!), to add touch to GLFW:

Now, I have a customer who needs touch to work in our application (voysys.se) so I need touch to work (which it does) at least in a fork for us. Platform for my project is Windows. I added a few hours to the work package to be able to make this PR with these changes to the upstream. (If it is merged is of course an open question for the maintainers/community.)

After reading through the previous efforts on touch, above, I came to the conclusion that I like the callback api in the touch branch. It is based on WM_TOUCH, which is available from windows 7. The effort in PR #532 to add Wayland support indicates that the approach will work for other platforms too. Raw touch points with id, state (press/move/release), and position are passed in. It is up to the user to add inertia, gestures, whatever. I think this is a clean, sane low level api for touch and that it is the right approach. Because who knows what people want to do with the touches.

What I have done:

  • Rebased the touch branch on the latest upstream/master
  • Updated comments, defines, styling, etc to be in line with what the current standards seems to be (hope I got it right?)
  • Added a "glfwTouchInputSupported" to check for touch support (I'm open for removing this one - I took inspiration from the raw mouse support test function but that actually works slightly differently in that it is a per platform true/false thing. Touch is a platform, OS-version and also "does the user actually have a touch screen" question. Right now this function answers the platform and OS-version questions, but it doesn't know if the user has a touch screen.)
  • Used this to build a simple pan+zoom touch interface in our application
  • (I squashed the individual commits, because rebasing was easier this way and they did not build individually anyway)

I have tested this now on my laptop which has a touchscreen (surface book 2) and starting next week I will run tests on the target displays which are external multitouch monitors.

[2020-11-02] Update: this is running and working well on customer's site for a few months. Touch is the only input used, on two external touch monitors per pc. No issues has been reported.

@elmindreda elmindreda self-assigned this Jul 24, 2020
@elmindreda elmindreda added enhancement Feature suggestions and PRs input Keyboard, joystick or mouse Windows Win32 specific (not Cygwin or WSL) labels Jul 24, 2020
@elmindreda elmindreda added this to Todo in Queue Jul 29, 2020
@pbouffard
Copy link

Would this enable gestures like pinch-to-zoom, two-finger panning, etc on Macs?

@torkeldanielsson
Copy link
Author

Would this enable gestures like pinch-to-zoom, two-finger panning, etc on Macs?

No, for a number of reasons:

  • Touch function in this PR is Windows only
  • This PR adds "raw" touches, so for pinch and pan that needs to be handled on a higher level
  • This PR is touch as in touch-screen, not as in touch-pad (I am not aware of any mac with touch screens, not sure how macos handles connected external touch screens)

@zesinger
Copy link

zesinger commented Jan 18, 2021

@torkeldanielsson Thanks a lot for this. ATM I am working on a home made virtual jukebox UI and use GLFW. I'll control it via a 10" touch screen with a mini PC (Windows 10) and I just need the touch press and release (with coordinates) functions and it seems to be available in your code.
I am new at github. Are there 64-bits glf3w.lib and glf3w.dll available to go with the headers you share here https://github.com/torkeldanielsson/glfw/tree/touch/include/GLFW ? And basic documentation on how to initialize and set the callback functions?
Thanks again
David

@raysan5
Copy link

raysan5 commented Jan 18, 2021

Hi, in case it can be useful for someone, for raylib I created a single-file gestures.h module to manage gestures for the multiple platforms, receiving simple touch events.

@torkeldanielsson
Copy link
Author

torkeldanielsson commented Jan 19, 2021

@torkeldanielsson Thanks a lot for this. ATM I am working on a home made virtual jukebox UI and use GLFW. I'll control it via a 10" touch screen with a mini PC (Windows 10) and I just need the touch press and release (with coordinates) functions and it seems to be available in your code.
I am new at github. Are there 64-bits glf3w.lib and glf3w.dll available to go with the headers you share here https://github.com/torkeldanielsson/glfw/tree/touch/include/GLFW ? And basic documentation on how to initialize and set the callback functions?
Thanks again
David

This is a PR (pull request), which is a set of suggested changes to the master GLFW repository. The .lib/.dll files are created as part of the release process, which is done from time to time based on the master. To use this version you need to clone my GLFW fork, check out this branch, and then build it. This PR includes documentation for the functionality that is added, you can see this by clicking on the "files changed" tab above.

@zesinger
Copy link

To use this version you need to clone my GLFW fork, check out this branch, and then build it. This PR includes documentation for the functionality that is added, you can see this by clicking on the "files changed" tab above.

OK I am going to try to understand how to build it with visual studio 2017.
Thanks a lot to take time to answer.
David

@elmindreda elmindreda moved this from Todo to Now in Queue Aug 16, 2021
@blakat360
Copy link

Any news on this - currently use glfw as windowing system for a client that recently requested pinch to zoom support. Having this pulled into a release and not hacked into the build would be a massive plus.

@ws909
Copy link

ws909 commented Jan 19, 2022

It might be possible to capture touch input in macOS as well. Catalina introduced Sidecar, that can turn iPads into a secondary screen for Macs. I believe I read in the past that the iPad can be used to capture touch events, as well. In that case, glfwTouchInputSupported can take a monitor as an argument, to test it for the monitor itself. Hopefully, an iPad in Sidecar should be reported as another monitor? Nonetheless, Apple Pencil events can be captured by macOS, on the iPad. Unsure how, but I believe it's with this framework: https://developer.apple.com/documentation/pencilkit

@lucasjinreal
Copy link

Anyupdates? I need pin to zoom touch on Mac touchpad. This is support very well in XCode's 3D file viewer.

@elmindreda elmindreda moved this from Now to Urgent in Queue Mar 1, 2023
xfangfang added a commit to xfangfang/glfw that referenced this pull request Mar 27, 2023
@elmindreda elmindreda moved this from Urgent to Todo in Queue Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature suggestions and PRs input Keyboard, joystick or mouse Windows Win32 specific (not Cygwin or WSL)
Projects
Queue
Todo
Development

Successfully merging this pull request may close these issues.

None yet

8 participants