From c8fd8212752b4d0465f9713c4a52c2b3eb9e08a2 Mon Sep 17 00:00:00 2001 From: Alex Martens Date: Mon, 15 Jul 2024 19:58:54 -0700 Subject: [PATCH] Add unit_exponent to collection spec (#68) --- macros/src/lib.rs | 15 +++++++++++++-- macros/src/spec.rs | 5 +++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 85dadab..9ca3069 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -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 @@ -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(); diff --git a/macros/src/spec.rs b/macros/src/spec.rs index 798e4a0..f746e5c 100644 --- a/macros/src/spec.rs +++ b/macros/src/spec.rs @@ -53,6 +53,7 @@ pub struct GroupSpec { pub usage_page: Option, pub collection: Option, pub logical_min: Option, + pub unit_exponent: Option, // Local items pub usage: Vec, @@ -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);