mirror of
https://github.com/PixlOne/logiops.git
synced 2025-07-13 12:52:42 +08:00
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:
parent
f85cd5ba62
commit
a361f206ff
@ -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() {
|
||||
|
@ -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()) {
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user