Skip to content

Commit

Permalink
Add HID Keyboard support to UefiHidDxe
Browse files Browse the repository at this point in the history
  • Loading branch information
joschock committed Nov 3, 2023
1 parent 07533b7 commit 018886a
Show file tree
Hide file tree
Showing 8 changed files with 1,622 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ members = [
RustAdvancedLoggerDxe = {path = "AdvLoggerPkg/Crates/RustAdvancedLoggerDxe"}
RustBootServicesAllocatorDxe = {path = "MsCorePkg/Crates/RustBootServicesAllocatorDxe"}
HidIo = {path = "HidPkg/Crates/HidIo"}

hidparser = {git = "https://github.com/microsoft/mu_rust_hid.git", branch = "main"}
HiiKeyboardLayout = {path = "HidPkg/Crates/HiiKeyboardLayout"}

r-efi = "4.3.0"
rustversion = "1.0.14"
Expand Down
6 changes: 5 additions & 1 deletion HidPkg/Crates/HiiKeyboardLayout/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ use r_efi::{
};
use scroll::{ctx, Pread, Pwrite};

/// GUID for default keyboard layout.
pub const DEFAULT_KEYBOARD_LAYOUT_GUID: efi::Guid =
efi::Guid::from_fields(0x3a4d7a7c, 0x18a, 0x4b42, 0x81, 0xb3, &[0xdc, 0x10, 0xe3, 0xb5, 0x91, 0xbd]);

/// HII Keyboard Package List
/// Refer to UEFI spec version 2.10 section 33.3.1.2 which defines the generic header structure. This implementation
/// only supports HII Keyboard Packages; other HII package types (or mixes) are not supported.
Expand Down Expand Up @@ -465,7 +469,7 @@ macro_rules! key_descriptor {
#[rustfmt::skip]
pub fn get_default_keyboard_layout() -> HiiKeyboardLayout {
HiiKeyboardLayout {
guid: efi::Guid::from_fields(0x3a4d7a7c, 0x18a, 0x4b42, 0x81, 0xb3, &[0xdc, 0x10, 0xe3, 0xb5, 0x91, 0xbd]),
guid: DEFAULT_KEYBOARD_LAYOUT_GUID,
keys: vec![
key!(EfiKey::C1, 'a', 'A', '\0', '\0', NULL_MODIFIER, AFFECTED_BY_STANDARD_SHIFT | AFFECTED_BY_CAPS_LOCK),
key!(EfiKey::B5, 'b', 'B', '\0', '\0', NULL_MODIFIER, AFFECTED_BY_STANDARD_SHIFT | AFFECTED_BY_CAPS_LOCK),
Expand Down
1 change: 1 addition & 0 deletions HidPkg/UefiHidDxe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ test = false
[dependencies]
HidIo = {workspace=true}
hidparser = {workspace=true}
HiiKeyboardLayout = {workspace=true}
memoffset = {workspace=true}
r-efi = {workspace=true}
rustversion = {workspace=true}
Expand Down
3 changes: 2 additions & 1 deletion HidPkg/UefiHidDxe/src/driver_binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn initialize_driver_binding(image_handle: efi::Handle) -> Result<(), efi::S
stop: uefi_hid_driver_binding_stop,
version: 1,
image_handle: driver_binding_handle,
driver_binding_handle: driver_binding_handle,
driver_binding_handle,
}));

let status = (boot_services.install_protocol_interface)(
Expand All @@ -43,6 +43,7 @@ pub fn initialize_driver_binding(image_handle: efi::Handle) -> Result<(), efi::S
);

if status.is_error() {
drop(unsafe { Box::from_raw(driver_binding_ptr) });
return Err(status);
}

Expand Down
2 changes: 1 addition & 1 deletion HidPkg/UefiHidDxe/src/hid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use rust_advanced_logger_dxe::{debugln, DEBUG_ERROR, DEBUG_WARN};
use crate::{keyboard, keyboard::KeyboardContext, pointer, pointer::PointerContext, BOOT_SERVICES};

pub struct HidContext {
hid_io: *mut hid_io::protocol::Protocol,
pub hid_io: *mut hid_io::protocol::Protocol,
pub keyboard_context: *mut KeyboardContext,
pub pointer_context: *mut PointerContext,
}
Expand Down
Loading

0 comments on commit 018886a

Please sign in to comment.