Skip to content

Commit

Permalink
extend report protocol methods, fix initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
benedekkupper committed Dec 9, 2023
1 parent 037acfc commit 689ce0c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hid-rp/hid/report.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace hid
constexpr bool operator !=(const selector& rhs) const = default;

private:
std::array<std::uint8_t, 2> storage_;
std::array<std::uint8_t, 2> storage_{};
};

struct id_base
Expand Down
28 changes: 28 additions & 0 deletions hid-rp/hid/report_protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,40 @@ struct report_protocol_properties
{
return std::max(max_input_size, std::max(max_output_size, max_feature_size));
}
constexpr size_type max_report_size(report::type type) const
{
switch (type)
{
case report::type::INPUT:
return max_input_size;
case report::type::OUTPUT:
return max_output_size;
case report::type::FEATURE:
return max_feature_size;
default:
return 0;
}
}

constexpr bool uses_report_ids() const { return max_report_id() >= report::id::min(); }
constexpr report::id::type max_report_id() const
{
return std::max(max_input_id, std::max(max_output_id, max_feature_id));
}
constexpr report::id::type max_report_id(report::type type) const
{
switch (type)
{
case report::type::INPUT:
return max_input_id;
case report::type::OUTPUT:
return max_output_id;
case report::type::FEATURE:
return max_feature_id;
default:
return 0;
}
}

/// @brief Define the report protocol properties, with no report ID use.
/// @param max_input_size: The size of the longest INPUT report in bytes, including the report
Expand Down

0 comments on commit 689ce0c

Please sign in to comment.