From dc3571249f59d3aa0bfd867596bb7121373c8ee9 Mon Sep 17 00:00:00 2001 From: lvs1974 Date: Fri, 8 Jan 2021 12:26:26 +0100 Subject: [PATCH] fix issue with registering of services matched by property name "RM,deliverNotifications" - #1415 --- Changelog.md | 2 ++ VoodooPS2Controller/VoodooPS2Controller.cpp | 38 +++++++++++++-------- VoodooPS2Controller/VoodooPS2Controller.h | 7 ++-- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/Changelog.md b/Changelog.md index e0de332a..e3c05d8d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ VoodooPS2 Changelog ============================ +#### 2.2.1 +- Fix issue with registering of services matched by property name "RM,deliverNotifications". It solves issue with broadcasting timestamp for the last pressed key and handling of QuietTimeAfterTyping [see bug #1415](https://github.com/acidanthera/bugtracker/issues/1415) #### 2.2.0 - Added VoodooRmi compatibility to allow external touchpad resets diff --git a/VoodooPS2Controller/VoodooPS2Controller.cpp b/VoodooPS2Controller/VoodooPS2Controller.cpp index edaf3657..5a2dc300 100644 --- a/VoodooPS2Controller/VoodooPS2Controller.cpp +++ b/VoodooPS2Controller/VoodooPS2Controller.cpp @@ -603,20 +603,22 @@ bool ApplePS2Controller::start(IOService * provider) propertyMatch = propertyMatching(_deliverNotification, kOSBooleanTrue); if (propertyMatch != NULL) { - IOServiceMatchingNotificationHandler notificationHandler = OSMemberFunctionCast(IOServiceMatchingNotificationHandler, this, &ApplePS2Controller::notificationHandler); + IOServiceMatchingNotificationHandler notificationHandlerPublish = OSMemberFunctionCast(IOServiceMatchingNotificationHandler, this, &ApplePS2Controller::notificationHandlerPublish); // // Register notifications for availability of any IOService objects wanting to consume our message events // _publishNotify = addMatchingNotification(gIOFirstPublishNotification, propertyMatch, - notificationHandler, + notificationHandlerPublish, this, 0, 10000); + IOServiceMatchingNotificationHandler notificationHandlerTerminate = OSMemberFunctionCast(IOServiceMatchingNotificationHandler, this, &ApplePS2Controller::notificationHandlerTerminate); + _terminateNotify = addMatchingNotification(gIOTerminatedNotification, propertyMatch, - notificationHandler, + notificationHandlerTerminate, this, 0, 10000); @@ -1972,23 +1974,29 @@ void ApplePS2Controller::uninstallPowerControlAction( PS2DeviceType deviceType ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void ApplePS2Controller::notificationHandlerGated(IOService * newService, IONotifier * notifier) +void ApplePS2Controller::notificationHandlerPublishGated(IOService * newService, IONotifier * notifier) { - if (notifier == _publishNotify) { - IOLog("%s: Notification consumer published: %s\n", getName(), newService->getName()); - _notificationServices->setObject(newService); - } - - if (notifier == _terminateNotify) { - IOLog("%s: Notification consumer terminated: %s\n", getName(), newService->getName()); - _notificationServices->removeObject(newService); - } + IOLog("%s: Notification consumer published: %s\n", getName(), newService->getName()); + _notificationServices->setObject(newService); } -bool ApplePS2Controller::notificationHandler(void * refCon, IOService * newService, IONotifier * notifier) +bool ApplePS2Controller::notificationHandlerPublish(void * refCon, IOService * newService, IONotifier * notifier) { assert(_cmdGate != nullptr); - _cmdGate->runAction(OSMemberFunctionCast(IOCommandGate::Action, this, &ApplePS2Controller::notificationHandlerGated), newService, notifier); + _cmdGate->runAction(OSMemberFunctionCast(IOCommandGate::Action, this, &ApplePS2Controller::notificationHandlerPublishGated), newService, notifier); + return true; +} + +void ApplePS2Controller::notificationHandlerTerminateGated(IOService * newService, IONotifier * notifier) +{ + IOLog("%s: Notification consumer terminated: %s\n", getName(), newService->getName()); + _notificationServices->removeObject(newService); +} + +bool ApplePS2Controller::notificationHandlerTerminate(void * refCon, IOService * newService, IONotifier * notifier) +{ + assert(_cmdGate != nullptr); + _cmdGate->runAction(OSMemberFunctionCast(IOCommandGate::Action, this, &ApplePS2Controller::notificationHandlerTerminateGated), newService, notifier); return true; } diff --git a/VoodooPS2Controller/VoodooPS2Controller.h b/VoodooPS2Controller/VoodooPS2Controller.h index a388135c..90ef1fd4 100644 --- a/VoodooPS2Controller/VoodooPS2Controller.h +++ b/VoodooPS2Controller/VoodooPS2Controller.h @@ -292,8 +292,11 @@ class EXPORT ApplePS2Controller : public IOService static void interruptHandlerMouse(OSObject*, void* refCon, IOService*, int); static void interruptHandlerKeyboard(OSObject*, void* refCon, IOService*, int); - void notificationHandlerGated(IOService * newService, IONotifier * notifier); - bool notificationHandler(void * refCon, IOService * newService, IONotifier * notifier); + void notificationHandlerPublishGated(IOService * newService, IONotifier * notifier); + bool notificationHandlerPublish(void * refCon, IOService * newService, IONotifier * notifier); + + void notificationHandlerTerminateGated(IOService * newService, IONotifier * notifier); + bool notificationHandlerTerminate(void * refCon, IOService * newService, IONotifier * notifier); void dispatchMessageGated(int* message, void* data);