I am using HIDStylusDriver to handle stylus input:
I have a touch screen and I want to:
- Control the screen. I can enable the extension and control the touch screen successfully.
- Draw on this screen. To do this, I need to send X,Y coordinates to StylusApp (AppKit), but I am unable to do this in Swift.
I am able to log the X,Y coordinates with the default code:
static void printStylus(IOHIDDigitizerStylusData *data)
{
os_log(OS_LOG_DEFAULT, "dispatch stylus: id: %d x: %d y: %d range: %d tip: %d barrel: %d invert: %d erase: %d tp: %d tx: %d ty: %d tw: %d tc: %d pc: %d rc: %d",
data->identifier, data->x, data->y, data->inRange, data->tip, data->barrelSwitch, data->invert, data->eraser, data->tipPressure,
data->tiltX, data->tiltY, data->twist, data->tipChanged, data->positionChanged, data->rangeChanged);
}
But I don’t know how to send it to AppKit to Pen.
What I have tried: I have researched communication between the driver and the client (source), but it seems the HID driver doesn’t support communication to the client app—and thus I can’t send X,Y coordinates to the Stylus App (AppKit) to Pen/Draw—because I can’t override the HIDStylusDriver.
What I expecting: I want to send X,Y coordinates from HIDStylusDriver to Stylus App (AppKit) to Pen/Draw.