Skip to content

Commit

Permalink
fix bug: represent cid as uint16_t
Browse files Browse the repository at this point in the history
The function ReprogControlsV4::setControlReporting() erroneously took
cid as uint8_t. Because of that, reports contained only lower byte
of any cid, so any ReprogControls request for such cid resulted
in error response. Lack of error response handling in this library
led to timeout.

E.g.:
```
[DEBUG] Configuring button: 0x103
[RAWREPORT] /dev/hidraw1 OUT: 11 ff 08 32 00 03 22 01 03 00 00 00 00 00 00 00 00 00 00 00
[RAWREPORT] /dev/hidraw1 IN:  11 ff ff 08 32 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00
```
We can see only lower byte (03) of `cid` present. Thus we get an error
response (with feature id `ff`), but the logiops keeps waiting for
response with feature id `08` and hence eventually timeouts.
  • Loading branch information
wprzytula committed Nov 7, 2023
1 parent 94f6dba commit 700070c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/logid/backend/hidpp20/features/ReprogControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ ReprogControls::ControlInfo ReprogControls::getControlIdInfo(uint16_t cid) {
return report;
}

void ReprogControls::setControlReporting(uint8_t cid, ControlInfo info) {
void ReprogControls::setControlReporting(uint16_t cid, ControlInfo info) {
// This function does not exist pre-v4 and cannot be emulated, ignore.
(void) cid;
(void) info; // Suppress unused warnings
Expand Down Expand Up @@ -173,7 +173,7 @@ ReprogControls::ControlInfo ReprogControlsV4::getControlReporting(uint16_t cid)
return info;
}

void ReprogControlsV4::setControlReporting(uint8_t cid, ControlInfo info) {
void ReprogControlsV4::setControlReporting(uint16_t cid, ControlInfo info) {
std::vector<uint8_t> params(5);
params[0] = (cid >> 8) & 0xff;
params[1] = cid & 0xff;
Expand Down
4 changes: 2 additions & 2 deletions src/logid/backend/hidpp20/features/ReprogControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace logid::backend::hidpp20 {
[[nodiscard]] virtual ControlInfo getControlReporting(uint16_t cid);

// Only controlId (for remap) and flags will be read
virtual void setControlReporting(uint8_t cid, ControlInfo info);
virtual void setControlReporting(uint16_t cid, ControlInfo info);

[[nodiscard]] static std::set<uint16_t> divertedButtonEvent(const hidpp::Report& report);

Expand Down Expand Up @@ -162,7 +162,7 @@ namespace logid::backend::hidpp20 {

[[nodiscard]] ControlInfo getControlReporting(uint16_t cid) override;

void setControlReporting(uint8_t cid, ControlInfo info) override;
void setControlReporting(uint16_t cid, ControlInfo info) override;

explicit ReprogControlsV4(Device* dev);

Expand Down

0 comments on commit 700070c

Please sign in to comment.