From 825967b140562e20ad8c7eaba854480ac66d9226 Mon Sep 17 00:00:00 2001 From: pixl Date: Mon, 13 Jul 2020 22:42:23 -0400 Subject: [PATCH] TODO cleanup: Add PowerSwitchLocation enum --- src/logid/backend/dj/Receiver.cpp | 7 +++++-- src/logid/backend/dj/Receiver.h | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/logid/backend/dj/Receiver.cpp b/src/logid/backend/dj/Receiver.cpp index a79c5bf..0377778 100644 --- a/src/logid/backend/dj/Receiver.cpp +++ b/src/logid/backend/dj/Receiver.cpp @@ -191,7 +191,11 @@ struct Receiver::ExtendedPairingInfo for(uint8_t i = 0; i < 4; i++) info.reportTypes[i] = response[i + 4]; - info.powerSwitchLocation = response[8] & 0xf; + uint8_t psl = response[8] & 0xf; + if(psl > 0xc) + info.powerSwitchLocation = PowerSwitchLocation::Reserved; + else + info.powerSwitchLocation = static_cast(psl); return info; } @@ -325,7 +329,6 @@ Receiver::ConnectionStatusEvent Receiver::connectionStatusEvent(Report& report) void Receiver::listen() { if(!_raw_device->isListening()) - ///TODO: Kill RawDevice? _raw_device->listenAsync(); if(_raw_device->eventHandlers().find("RECV_HIDPP") == diff --git a/src/logid/backend/dj/Receiver.h b/src/logid/backend/dj/Receiver.h index 12d1e1b..96b74db 100644 --- a/src/logid/backend/dj/Receiver.h +++ b/src/logid/backend/dj/Receiver.h @@ -126,11 +126,28 @@ namespace dj DeviceType::DeviceType deviceType; }; + enum class PowerSwitchLocation : uint8_t + { + Reserved = 0x0, + Base = 0x1, + TopCase = 0x2, + TopRightEdge = 0x3, + Other = 0x4, + TopLeft = 0x5, + BottomLeft = 0x6, + TopRight = 0x7, + BottomRight = 0x8, + TopEdge = 0x9, + RightEdge = 0xa, + LeftEdge = 0xb, + BottomEdge = 0xc + }; + struct ExtendedPairingInfo { uint32_t serialNumber; uint8_t reportTypes[4]; - uint8_t powerSwitchLocation; ///TODO: Make enum + PowerSwitchLocation powerSwitchLocation; }; struct PairingInfo getPairingInfo(hidpp::DeviceIndex index);