Open Charmandrigo opened 4 years ago
Interesting. To implement this, I will need help from someone with an iPad pro (and mac development experience,) since I don't have one myself.
Hey! I have an iPad the supports sidecar and some mac development experience.
Please let me know how I can help!
I think this documentation from apple might be helpful in implementing this: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/HandlingTabletEvents/HandlingTabletEvents.html#//apple_ref/doc/uid/10000060i-CH10-SW1
Would you be able to help me understand where the tablet event code is in your project, I've had a bit of a look around and found it hard to find. I only found this: https://github.com/drawpile/Drawpile/blob/b49ed959718830357f66e6548f023d192d007c0b/src/mobile/quick/canvasinputarea.cpp . I think this is for only mobile though?
Then I can try implementing the tablet events with preprocessor directives to check if its running on macOS.
Hello, and thank you!
The canvas input handling is done here: https://github.com/drawpile/Drawpile/blob/master/src/desktop/scene/canvasview.cpp
However, this all relies on Qt's tablet events, which abstract the underlying native events. If you need access to the native events, you may need to create a native event filter. Here's how it's done on X11: https://github.com/drawpile/Drawpile/blob/master/src/desktop/bundled/kis_tablet/kis_xi2_event_filter.cpp
And it's activated in the main function: https://github.com/drawpile/Drawpile/blob/master/src/desktop/main.cpp#L290
I don't really get what a native event filter is, could you please explain the concept to me?
A native event filter is a class that intercepts native events. It lets you handle platform specific events before they're converted to Qt's internal events and handed to the rest of the application. In the example I linked, it's used to grab native XInput tablet events and handle them in custom code, since Qt's built-in tablet support is not very good.
I'm not actually sure what it takes to support Sidecar, so I don't know if you even need a native event handler.
Apple introduced a feature on MacOS Catalina called Sidecar, allows using an iPad pro as a drawing tablet. a few optimizations that could be added to Drawpile is adding specific drawpile shortcuts to the touchbar feature, as well as support of iPad gestures and Tablet Events. https://www.apple.com/macos/catalina/docs/Sidecar_Tech_Brief_Oct_2019.pdf