mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 15:14:38 +01:00
Revert "hidraw: ratbag_hidraw_has_report() can also match the usage and usage page"
This reverts commit d5a20efd8b.
The API is horrible. Better having 2 additional functions to get
the usage and usage pageof the report.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
@@ -781,7 +781,7 @@ etekcity_probe(struct ratbag_device *device, const struct ratbag_id id)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (!ratbag_hidraw_has_report(device, ETEKCITY_REPORT_ID_KEY_MAPPING, 0, 0)) {
|
||||
if (!ratbag_hidraw_has_report(device, ETEKCITY_REPORT_ID_KEY_MAPPING)) {
|
||||
ratbag_close_hidraw(device);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ hidpp10drv_fill_from_profile(struct ratbag_device *device, struct hidpp10_device
|
||||
static int
|
||||
hidpp10drv_test_hidraw(struct ratbag_device *device)
|
||||
{
|
||||
return ratbag_hidraw_has_report(device, REPORT_ID_SHORT, 0, 0);
|
||||
return ratbag_hidraw_has_report(device, REPORT_ID_SHORT);
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -434,7 +434,7 @@ hidpp20drv_20_probe(struct ratbag_device *device, const struct ratbag_id id)
|
||||
static int
|
||||
hidpp20drv_test_hidraw(struct ratbag_device *device)
|
||||
{
|
||||
return ratbag_hidraw_has_report(device, REPORT_ID_LONG, 0, 0);
|
||||
return ratbag_hidraw_has_report(device, REPORT_ID_LONG);
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -917,7 +917,7 @@ roccat_probe(struct ratbag_device *device, const struct ratbag_id id)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (!ratbag_hidraw_has_report(device, ROCCAT_REPORT_ID_KEY_MAPPING, 0, 0)) {
|
||||
if (!ratbag_hidraw_has_report(device, ROCCAT_REPORT_ID_KEY_MAPPING)) {
|
||||
ratbag_close_hidraw(device);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
@@ -280,53 +280,17 @@ ratbag_open_hidraw(struct ratbag_device *device)
|
||||
return __ratbag_find_hidraw(device, hidraw_match_all, false);
|
||||
}
|
||||
|
||||
static inline int
|
||||
ratbag_hidraw_match_report(struct ratbag_hid_report *report,
|
||||
unsigned int report_id,
|
||||
unsigned int usage_page,
|
||||
unsigned int usage)
|
||||
{
|
||||
if (usage && usage != report->usage)
|
||||
return 0;
|
||||
|
||||
if (usage_page && usage_page != report->usage_page)
|
||||
return 0;
|
||||
|
||||
return report->report_id == report_id;
|
||||
}
|
||||
|
||||
int
|
||||
ratbag_hidraw_has_report(struct ratbag_device *device,
|
||||
unsigned int report_id,
|
||||
unsigned int usage_page,
|
||||
unsigned int usage)
|
||||
ratbag_hidraw_has_report(struct ratbag_device *device, unsigned int report_id)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
if (report_id == 0)
|
||||
if (ratbag_hidraw_match_report(&device->hidraw.reports[0],
|
||||
report_id,
|
||||
usage_page,
|
||||
usage)) {
|
||||
log_debug(device->ratbag,
|
||||
"found matching report ID (0) with 0x%04x | 0x%04x\n",
|
||||
device->hidraw.reports[0].usage_page,
|
||||
device->hidraw.reports[0].usage);
|
||||
return 1;
|
||||
}
|
||||
return device->hidraw.reports[0].report_id == report_id;
|
||||
|
||||
for (i = 0; i < device->hidraw.num_reports; i++) {
|
||||
if (ratbag_hidraw_match_report(&device->hidraw.reports[i],
|
||||
report_id,
|
||||
usage_page,
|
||||
usage)) {
|
||||
log_debug(device->ratbag,
|
||||
"found matching report ID (%d) with 0x%04x | 0x%04x\n",
|
||||
report_id,
|
||||
device->hidraw.reports[i].usage_page,
|
||||
device->hidraw.reports[i].usage);
|
||||
if (device->hidraw.reports[i].report_id == report_id)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -120,16 +120,11 @@ int ratbag_hidraw_read_input_report(struct ratbag_device *device, uint8_t *buf,
|
||||
* Tells if a given device has the specified report ID.
|
||||
*
|
||||
* @param device the ratbag device which hidraw node is opened
|
||||
* @param report_id the report ID we inquire about (0 means no report ID)
|
||||
* @param usage_page the usage page we want to match with (0 ignores the match)
|
||||
* @param usage the usage we want to match with (0 ignores the match)
|
||||
* @param report_id the report ID we inquire about
|
||||
*
|
||||
* @return 1 if the device has the given report id, 0 otherwise
|
||||
*/
|
||||
int
|
||||
ratbag_hidraw_has_report(struct ratbag_device *device,
|
||||
unsigned int report_id,
|
||||
unsigned int usage_page,
|
||||
unsigned int usage);
|
||||
ratbag_hidraw_has_report(struct ratbag_device *device, unsigned int report_id);
|
||||
|
||||
#endif /* LIBRATBAG_HIDRAW_H */
|
||||
|
||||
Reference in New Issue
Block a user