I pick up an old project of 2012 that modified mouse event in a mirrored window (horizontally flipped) to adjust mouse coordination using CGEventTapCreate. The project might work at that moment. But it does not work now. After several debug attempts, I found the 3rd parameter with kCGEventTapOptionDefault causes CGEventTapCreate to return rull. After changing it to kCGEventTapOptionListenOnly the function returns a valid CFMachPortRef like <NSMachPort: 0x600003705380> though I want an active filter event tap.
I tried to run my app under command line with root permission using sudo but didn't work.
I've set user permission on accessibility panel.
Here is the code:
// Create event tap for mouse events
CGEventMask mouseMask = ( CGEventMaskBit(kCGEventLeftMouseDown)
|CGEventMaskBit(kCGEventLeftMouseUp)
|CGEventMaskBit(kCGEventRightMouseDown)
|CGEventMaskBit(kCGEventRightMouseUp)
|CGEventMaskBit(kCGEventMouseMoved)
|CGEventMaskBit(kCGEventLeftMouseDragged)
|CGEventMaskBit(kCGEventRightMouseDragged));
mouseTap = CGEventTapCreate(kCGSessionEventTap,
kCGHeadInsertEventTap,kCGEventTapOptionDefault,
mouseMask,(CGEventTapCallBack) eventTapFunction, (__bridge void *)self);
I compiled the app on macOS Catalina from a 2015 macbook pro. Any thing I can do to fix the issue?