-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ipts: Move functions that check for report functions to protocol
- Loading branch information
Showing
4 changed files
with
73 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#ifndef IPTSD_IPTS_PROTOCOL_DESCRIPTOR_HPP | ||
#define IPTSD_IPTS_PROTOCOL_DESCRIPTOR_HPP | ||
|
||
#include <common/types.hpp> | ||
#include <hid/report.hpp> | ||
|
||
namespace iptsd::ipts::protocol::descriptor { | ||
|
||
namespace hid = iptsd::hid; | ||
|
||
constexpr u16 USAGE_PAGE_DIGITIZER = 0x000D; | ||
constexpr u16 USAGE_PAGE_VENDOR = 0xFF00; | ||
|
||
constexpr u8 USAGE_SCAN_TIME = 0x56; | ||
constexpr u8 USAGE_GESTURE_DATA = 0x61; | ||
constexpr u8 USAGE_SET_MODE = 0xC8; | ||
constexpr u8 USAGE_METADATA = 0x63; | ||
|
||
/*! | ||
* Checks if a given report contains touch data. | ||
* | ||
* @param[in] report The report to check. | ||
* @return Whether the report matches the properties for a touch data report. | ||
*/ | ||
inline bool is_touch_data(const hid::Report &report) | ||
{ | ||
return report.type() == hid::ReportType::Input && | ||
report.find_usage(USAGE_PAGE_DIGITIZER, USAGE_SCAN_TIME) && | ||
report.find_usage(USAGE_PAGE_DIGITIZER, USAGE_GESTURE_DATA); | ||
} | ||
|
||
/*! | ||
* Checks if a given report sets the mode of the device. | ||
* | ||
* @param[in] report The report to check. | ||
* @return Whether the report matches the properties for a modesetting report. | ||
*/ | ||
inline bool is_set_mode(const hid::Report &report) | ||
{ | ||
return report.type() == hid::ReportType::Feature && report.size() == 8 && | ||
report.find_usage(USAGE_PAGE_VENDOR, USAGE_SET_MODE); | ||
} | ||
|
||
/*! | ||
* Checks if a given report returns metadata for the device. | ||
* | ||
* @param[in] report The report to check. | ||
* @return Whether the report matches the properties for a metadata report. | ||
*/ | ||
inline bool is_metadata(const hid::Report &report) | ||
{ | ||
return report.type() == hid::ReportType::Feature && | ||
report.find_usage(USAGE_PAGE_DIGITIZER, USAGE_METADATA); | ||
} | ||
|
||
} // namespace iptsd::ipts::protocol::descriptor | ||
|
||
#endif // IPTSD_IPTS_PROTOCOL_DESCRIPTOR_HPP |