UPDDMultitouch: Implement multi-touch in macOS using the UPDD API #1382
+1,480
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request implements multi-touch support for macOS applications and plug-ins using the UPDD, a third party macOS touch driver from Touch-Base, which supports a wide array of different touch screen models.
I'm a developer for Touch-Base, and we've received many requests from macOS users who want to get multi-touch support working in various third party apps and plug-ins that were developed with JUCE. The difficulty is that macOS doesn't have a native representation of touch events from a touch screen, unlike for example Windows or iOS, so JUCE doesn't currently support multi-touch on macOS at all. This pull request implements multi-touch support using the UPDD API, the driver's low level programming interface, allowing full multi-touch support in JUCE applications and plug-ins on macOS systems that have the UPDD installed.
A few technical details about this PR:
The UPDD API functions are loaded dynamically at runtime with
dlopen
/dlsym
, since it's not possible to know whether the UPDD is installed until runtime. In the case it's not installed, there's no change in behavior, and JUCE will report that multi-touch is not supported as before.When the UPDD is installed, this implementation connects to the driver and listens for touch events from it, and then translates those into JUCE touch events and delivers them to the appropriate Component via the ComponentPeer API.
Because this requires loading a dynamic library that will not be signed by the same developer as the host application, any standalone macOS application that is notarized or otherwise has hardened runtime enabled will need to include a runtime exception disabling library validation if it wants to have multi-touch support. (This will already be the case in any application that loads plug-ins, such as a DAW that loads VSTs.)
I've tested this PR both in a standalone JUCE application as well as a VST and AU plug-in running in various DAWs on macOS. Hopefully the way I included my changes is acceptable, since I had to make a few guesses about how to best integrate it into JUCE. I'm happy to make any changes required for it be merged.