diff --git a/HidPkg/UefiHidDxeV2/src/pointer/absolute_pointer.rs b/HidPkg/UefiHidDxeV2/src/pointer/absolute_pointer.rs index 15e65fc773..59fdbc5b23 100644 --- a/HidPkg/UefiHidDxeV2/src/pointer/absolute_pointer.rs +++ b/HidPkg/UefiHidDxeV2/src/pointer/absolute_pointer.rs @@ -16,7 +16,7 @@ use rust_advanced_logger_dxe::{debugln, DEBUG_ERROR, DEBUG_INFO, DEBUG_WARN}; use crate::boot_services::UefiBootServices; -use super::PointerHidHandler; +use super::{PointerHidHandler, BUTTON_MAX, BUTTON_MIN, DIGITIZER_SWITCH_MAX, DIGITIZER_SWITCH_MIN}; // FFI context // Safety: a pointer to PointerHidHandler is included in the context so that it can be reclaimed in the absolute_pointer @@ -129,7 +129,11 @@ impl PointerContext { debugln!(DEBUG_INFO, "No z-axis usages found in the report descriptor."); } - let button_count = pointer_handler.supported_usages.iter().filter(|x| x.page() == super::BUTTON_PAGE).count(); + let button_count = pointer_handler + .supported_usages + .iter() + .filter(|x| matches!((**x).into(), BUTTON_MIN..=BUTTON_MAX | DIGITIZER_SWITCH_MIN..=DIGITIZER_SWITCH_MAX)) + .count(); if button_count > 1 { mode.attributes |= 0x01; // alternate button exists. diff --git a/HidPkg/UefiHidDxeV2/src/pointer/mod.rs b/HidPkg/UefiHidDxeV2/src/pointer/mod.rs index 3a37ebd5cb..c352d0ebe4 100644 --- a/HidPkg/UefiHidDxeV2/src/pointer/mod.rs +++ b/HidPkg/UefiHidDxeV2/src/pointer/mod.rs @@ -35,9 +35,10 @@ const GENERIC_DESKTOP_X: u32 = 0x00010030; const GENERIC_DESKTOP_Y: u32 = 0x00010031; const GENERIC_DESKTOP_Z: u32 = 0x00010032; const GENERIC_DESKTOP_WHEEL: u32 = 0x00010038; -const BUTTON_PAGE: u16 = 0x0009; const BUTTON_MIN: u32 = 0x00090001; const BUTTON_MAX: u32 = 0x00090020; //Per spec, the Absolute Pointer protocol supports a 32-bit button state field. +const DIGITIZER_SWITCH_MIN: u32 = 0x000d0042; +const DIGITIZER_SWITCH_MAX: u32 = 0x000d0046; // number of points on the X/Y axis for this implementation. const AXIS_RESOLUTION: u64 = 1024; @@ -127,6 +128,11 @@ impl PointerHidHandler { report_data.relevant_fields.push(field_handler); self.supported_usages.insert(field.usage); } + DIGITIZER_SWITCH_MIN..=DIGITIZER_SWITCH_MAX => { + let field_handler = ReportFieldWithHandler { field: field.clone(), report_handler: Self::button_handler }; + report_data.relevant_fields.push(field_handler); + self.supported_usages.insert(field.usage); + } _ => (), //other usages irrelevant } } @@ -197,15 +203,15 @@ impl PointerHidHandler { // handles button inputs fn button_handler(&mut self, field: VariableField, report: &[u8]) { - let shift: u32 = field.usage.into(); - if !(BUTTON_MIN..=BUTTON_MAX).contains(&shift) { - return; - } + let shift = match field.usage.into() { + x @ BUTTON_MIN..=BUTTON_MAX => x - BUTTON_MIN, + x @ DIGITIZER_SWITCH_MIN..=DIGITIZER_SWITCH_MAX => x - DIGITIZER_SWITCH_MIN, + _ => return, + }; if let Some(button_value) = field.field_value(report) { let button_value = button_value as u32; - let shift = shift - BUTTON_MIN; if shift > u32::BITS { return; } diff --git a/MfciPkg/MfciDxe/Test/MfciVerifyPolicyAndChangeHostTest.c b/MfciPkg/MfciDxe/Test/MfciVerifyPolicyAndChangeHostTest.c index f6bce6c2bd..7dac1b6d64 100644 --- a/MfciPkg/MfciDxe/Test/MfciVerifyPolicyAndChangeHostTest.c +++ b/MfciPkg/MfciDxe/Test/MfciVerifyPolicyAndChangeHostTest.c @@ -85,25 +85,11 @@ UnitTestSetVariable ( IN VOID *Data ); -EFI_STATUS -EFIAPI -UnitTestLocateProtocol ( - IN EFI_GUID *Protocol, - IN VOID *Registration OPTIONAL, - OUT VOID **Interface - ); - EFI_RUNTIME_SERVICES mMockRuntime = { .GetVariable = UnitTestGetVariable, .SetVariable = UnitTestSetVariable, }; -EFI_BOOT_SERVICES mBootSvc = { - .LocateProtocol = UnitTestLocateProtocol -}; - -EFI_BOOT_SERVICES *gBS = &mBootSvc; - extern BOOLEAN mVarPolicyRegistered; typedef struct { @@ -181,17 +167,6 @@ MFCI_UT_VERIFY_CONTEXT mMfciVerifyContext05 = { } }; -EFI_STATUS -EFIAPI -UnitTestLocateProtocol ( - IN EFI_GUID *Protocol, - IN VOID *Registration OPTIONAL, - OUT VOID **Interface - ) -{ - return EFI_SUCCESS; -} - /** A mocked version of GetVariable. diff --git a/MfciPkg/MfciDxe/Test/MfciVerifyPolicyAndChangeRoTHostTest.c b/MfciPkg/MfciDxe/Test/MfciVerifyPolicyAndChangeRoTHostTest.c index bb2b71db8a..01fc27fb0a 100644 --- a/MfciPkg/MfciDxe/Test/MfciVerifyPolicyAndChangeRoTHostTest.c +++ b/MfciPkg/MfciDxe/Test/MfciVerifyPolicyAndChangeRoTHostTest.c @@ -52,8 +52,6 @@ EFI_RUNTIME_SERVICES mMockRuntime = { .SetVariable = UnitTestSetVariable, }; -EFI_BOOT_SERVICES *gBS = NULL; - extern MFCI_POLICY_TYPE mCurrentPolicy; extern BOOLEAN mVarPolicyRegistered; diff --git a/MsCorePkg/MacAddressEmulationDxe/Test/MacAddressEmulationDxeHostTest.inf b/MsCorePkg/MacAddressEmulationDxe/Test/MacAddressEmulationDxeHostTest.inf index ca6b916b49..ab9a0060ab 100644 --- a/MsCorePkg/MacAddressEmulationDxe/Test/MacAddressEmulationDxeHostTest.inf +++ b/MsCorePkg/MacAddressEmulationDxe/Test/MacAddressEmulationDxeHostTest.inf @@ -41,7 +41,6 @@ BaseMemoryLib DebugLib MemoryAllocationLib - UefiLib UefiBootServicesTableLib UnitTestLib diff --git a/pip-requirements.txt b/pip-requirements.txt index e6db59c708..2b0f649b2b 100644 --- a/pip-requirements.txt +++ b/pip-requirements.txt @@ -13,7 +13,7 @@ ## edk2-pytool-library==0.21.6 -edk2-pytool-extensions==0.27.5 +edk2-pytool-extensions==0.27.6 antlr4-python3-runtime==4.13.1 regex==2024.5.15 pygount==1.8.0