Skip to content

Commit

Permalink
Merge branch 'release/202311' into personal/magravel/Review_AdvancedL…
Browse files Browse the repository at this point in the history
…oggerDxe.Task-4098346
  • Loading branch information
magravel authored Jun 21, 2024
2 parents e7fbc3b + e7d98c9 commit 40a36b5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 37 deletions.
8 changes: 6 additions & 2 deletions HidPkg/UefiHidDxeV2/src/pointer/absolute_pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
18 changes: 12 additions & 6 deletions HidPkg/UefiHidDxeV2/src/pointer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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;
}
Expand Down
25 changes: 0 additions & 25 deletions MfciPkg/MfciDxe/Test/MfciVerifyPolicyAndChangeHostTest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions MfciPkg/MfciDxe/Test/MfciVerifyPolicyAndChangeRoTHostTest.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ EFI_RUNTIME_SERVICES mMockRuntime = {
.SetVariable = UnitTestSetVariable,
};

EFI_BOOT_SERVICES *gBS = NULL;

extern MFCI_POLICY_TYPE mCurrentPolicy;
extern BOOLEAN mVarPolicyRegistered;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
BaseMemoryLib
DebugLib
MemoryAllocationLib
UefiLib
UefiBootServicesTableLib
UnitTestLib

Expand Down
2 changes: 1 addition & 1 deletion pip-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 40a36b5

Please sign in to comment.