Skip to content

Commit

Permalink
Add unit_exponent to collection spec (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
newAM authored Jul 16, 2024
1 parent 76325c3 commit c8fd821
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
15 changes: 13 additions & 2 deletions macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,9 @@ use packer::{gen_serializer, uses_report_ids};
/// Note: Parameters are a tuple, so make sure you have a trailing comma if you only have one
/// parameter.
///
/// The valid parameters are `collection`, `usage_page`, `usage`, `usage_min`, `usage_max`, and
/// `report_id`. These simply configure parameters that apply to contained items in the report.
/// The valid parameters are `collection`, `usage_page`, `usage`, `usage_min`, `usage_max`,
/// `unit_exponent`, and `report_id`.
/// These simply configure parameters that apply to contained items in the report.
/// Use of the `collection` parameter automatically creates a collection feature for all items
/// which are contained within it, and other parameters specified in the same collection-spec
/// apply to the collection, not directly to the elements of the collection (ie: defining a
Expand Down Expand Up @@ -535,6 +536,16 @@ impl DescCompilation {
false,
);
}
if let Some(unit_exponent) = spec.unit_exponent {
self.emit_item(
elems,
ItemType::Global.into(),
GlobalItemKind::UnitExponent.into(),
unit_exponent as isize,
false,
false,
);
}

for name in spec.clone() {
let f = spec.get(name.clone()).unwrap();
Expand Down
5 changes: 5 additions & 0 deletions macros/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub struct GroupSpec {
pub usage_page: Option<u32>,
pub collection: Option<u32>,
pub logical_min: Option<u32>,
pub unit_exponent: Option<u32>,

// Local items
pub usage: Vec<u32>,
Expand Down Expand Up @@ -113,6 +114,10 @@ impl GroupSpec {
self.collection = Some(val);
Ok(())
}
"unit_exponent" => {
self.unit_exponent = Some(val);
Ok(())
}
// Local items.
"usage" => {
self.usage.push(val);
Expand Down

0 comments on commit c8fd821

Please sign in to comment.