Only call wakeup test once

Ensures that wakeup check does not occur multiple times and possibly
create new event handlers on every HID packet.
This commit is contained in:
pixl 2023-05-12 17:23:04 -04:00
parent f85cd5ba62
commit a361f206ff
No known key found for this signature in database
GPG Key ID: 1866C148CD593B6E
3 changed files with 10 additions and 3 deletions

View File

@ -184,7 +184,6 @@ void Device::sleep() {
void Device::wakeup() {
std::lock_guard<std::mutex> lock(_state_lock);
logPrintf(INFO, "%s:%d woke up.", _path.c_str(), _index);
reconfigure();
@ -192,6 +191,8 @@ void Device::wakeup() {
_awake = true;
_ipc_interface->notifyStatus();
}
logPrintf(INFO, "%s:%d woke up.", _path.c_str(), _index);
}
void Device::reconfigure() {

View File

@ -159,19 +159,25 @@ void ReceiverMonitor::enumerate() {
void ReceiverMonitor::waitForDevice(hidpp::DeviceIndex index) {
auto handler_id = std::make_shared<EventHandlerLock<raw::RawDevice>>();
auto executed = std::make_shared<bool>(false);
*handler_id = _receiver->rawDevice()->addEventHandler(
{[index](const std::vector<uint8_t>& report) -> bool {
return report[Offset::DeviceIndex] == index;
},
[self_weak = _self, index, handler_id](
[self_weak = _self, index, handler_id, executed](
[[maybe_unused]] const std::vector<uint8_t>& report) {
if (*executed)
return;
hidpp::DeviceConnectionEvent event{};
event.withPayload = false;
event.linkEstablished = true;
event.index = index;
event.fromTimeoutCheck = true;
*executed = true;
run_task([self_weak, event, handler_id]() {
*handler_id = {};
if (auto self = self_weak.lock()) {

View File

@ -63,7 +63,7 @@ RemapButton::RemapButton(Device* dev) : DeviceFeature(dev),
if ((action->reprogFlags() & hidpp20::ReprogControls::RawXYDiverted) &&
(!_reprog_controls->supportsRawXY() ||
!(info.additionalFlags & hidpp20::ReprogControls::RawXY)))
logPrintf(WARN, "%s: Cannot divert raw XY movements for CID 0x%02x",
logPrintf(WARN, "%s: 'Cannot divert raw XY movements for CID 0x%02x",
_device->name().c_str(), info.controlID);
report.flags |= action->reprogFlags();