diff --git a/Library/OcAppleEventLib/AppleEventInternal.h b/Library/OcAppleEventLib/AppleEventInternal.h index 7d013e23..b436e642 100644 --- a/Library/OcAppleEventLib/AppleEventInternal.h +++ b/Library/OcAppleEventLib/AppleEventInternal.h @@ -21,7 +21,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include -#include +#include // EventCreateKeyStrokePollEvent EFI_STATUS @@ -161,4 +161,6 @@ InternalSetKeyDelays ( IN UINT16 KeySubsequentDelay ); +extern UINT32 mPointerScale; + #endif // APPLE_EVENT_INTERNAL_H_ diff --git a/Library/OcAppleEventLib/OcAppleEventLib.c b/Library/OcAppleEventLib/OcAppleEventLib.c index 397c3998..946e4c7f 100644 --- a/Library/OcAppleEventLib/OcAppleEventLib.c +++ b/Library/OcAppleEventLib/OcAppleEventLib.c @@ -509,14 +509,33 @@ InternalUnregisterHandlers ( } } +UINT32 +EFIAPI +OcEventExSetPointerScale ( + IN OUT OC_APPLE_EVENT_EX_PROTOCOL *This, + IN UINT32 Scale + ) +{ + UINT32 OldScale; + + OldScale = mPointerScale; + mPointerScale = Scale; + + return OldScale; +} + // mAppleEventProtocol -STATIC APPLE_EVENT_PROTOCOL mAppleEventProtocol = { - APPLE_EVENT_PROTOCOL_REVISION, - EventRegisterHandler, - EventUnregisterHandler, - EventSetCursorPosition, - EventSetEventName, - EventIsCapsLockOn +STATIC OC_APPLE_EVENT_EX_PROTOCOL mAppleEventProtocol = { + OC_APPLE_EVENT_EX_PROTOCOL_REVISION, + OcEventExSetPointerScale, + { + APPLE_EVENT_PROTOCOL_REVISION, + EventRegisterHandler, + EventUnregisterHandler, + EventSetCursorPosition, + EventSetEventName, + EventIsCapsLockOn + } }; // AppleEventUnload @@ -536,11 +555,13 @@ AppleEventUnload ( InternalUnregisterHandlers (); InternalCancelPollEvents (); - Status = gBS->UninstallProtocolInterface ( - gImageHandle, - &gAppleEventProtocolGuid, - (VOID *)&mAppleEventProtocol - ); + Status = gBS->UninstallMultipleProtocolInterfaces ( + gImageHandle, + &gAppleEventProtocolGuid, + (VOID *)&mAppleEventProtocol.AppleEvent, + &gOcAppleEventExProtocolGuid, + &mAppleEventProtocol + ); return Status; } @@ -565,7 +586,6 @@ OcAppleEventInstallProtocol ( { EFI_STATUS Status; APPLE_EVENT_PROTOCOL *Protocol; - EFI_HANDLE NewHandle; DEBUG ((DEBUG_VERBOSE, "OcAppleEventInstallProtocol\n")); @@ -590,16 +610,14 @@ OcAppleEventInstallProtocol ( InternalSetKeyDelays (KeyInitialDelay, KeySubsequentDelay); - // - // Apple code supports unloading, ours does not. - // - NewHandle = NULL; - Status = gBS->InstallProtocolInterface ( - &NewHandle, - &gAppleEventProtocolGuid, - EFI_NATIVE_INTERFACE, - (VOID *)&mAppleEventProtocol - ); + Status = gBS->InstallMultipleProtocolInterfaces ( + &gImageHandle, + &gAppleEventProtocolGuid, + &mAppleEventProtocol.AppleEvent, + &gOcAppleEventExProtocolGuid, + &mAppleEventProtocol, + NULL + ); if (!EFI_ERROR (Status)) { InternalCreateQueueEvent (); @@ -614,5 +632,5 @@ OcAppleEventInstallProtocol ( } DEBUG ((DEBUG_INFO, "OCAE: Installed\n")); - return &mAppleEventProtocol; + return &mAppleEventProtocol.AppleEvent; } diff --git a/Library/OcAppleEventLib/OcAppleEventLib.inf b/Library/OcAppleEventLib/OcAppleEventLib.inf index 826cbea2..08df15f0 100644 --- a/Library/OcAppleEventLib/OcAppleEventLib.inf +++ b/Library/OcAppleEventLib/OcAppleEventLib.inf @@ -44,6 +44,7 @@ [Protocols] gAppleEventProtocolGuid ## SOMETIMES_PRODUCES + gOcAppleEventExProtocolGuid ## SOMETIMES_PRODUCES gAppleKeyMapDatabaseProtocolGuid ## SOMETIMES_CONSUMES gAppleKeyMapAggregatorProtocolGuid ## SOMETIMES_CONSUMES gEfiConsoleControlProtocolGuid ## SOMETIMES_CONSUMES diff --git a/Library/OcAppleEventLib/PointerHandler.c b/Library/OcAppleEventLib/PointerHandler.c index 75d19197..dfb768f0 100644 --- a/Library/OcAppleEventLib/PointerHandler.c +++ b/Library/OcAppleEventLib/PointerHandler.c @@ -46,6 +46,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define POINTER_POLL_FREQUENCY EFI_TIMER_PERIOD_MILLISECONDS (10) #define MAX_POINTER_POLL_FREQUENCY EFI_TIMER_PERIOD_MILLISECONDS (80) +GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mPointerScale = 1; + STATIC UINT16 mMaximumDoubleClickSpeed = 75; // 374 for 2 ms STATIC UINT16 mMaximumClickDuration = 15; // 74 for 2 ms @@ -708,9 +710,11 @@ InternalSimplePointerPollNotifyFunction ( UiScaleX = InternalGetUiScaleData ((INT64)State.RelativeMovementX); UiScaleX = MultS64x64 (UiScaleX, (INT64) mMaxPointerResolutionX); + UiScaleX = MultS64x64 (UiScaleX, mPointerScale); UiScaleY = InternalGetUiScaleData ((INT64)State.RelativeMovementY); UiScaleY = MultS64x64 (UiScaleY, (INT64) mMaxPointerResolutionY); + UiScaleY = MultS64x64 (UiScaleY, mPointerScale); if (SimplePointer->Mode->ResolutionX > 0) { UiScaleX = DivS64x64Remainder (