Skip to content

Commit 08c9e65

Browse files
Fix MSVC warnings in Corsair Wireless V2 support (#564)
* fix(corsair): silence MSVC narrowing warnings * style(corsair): format wireless V2 implementation
1 parent 3a10399 commit 08c9e65

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

‎lib/devices/corsair_void_v2w.hpp‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CorsairVoidV2W : public CorsairDevice {
3131
static constexpr std::array<uint16_t, 3> SUPPORTED_PRODUCT_IDS {
3232
0x2a08, // VOID WIRELESS V2 (receiver)
3333
0x2a02, // VIRTUOSO MAX WIRELESS (receiver)
34-
0x0a97 // HS80 MAX Wireless (receiver)
34+
0x0a97 // HS80 MAX Wireless (receiver)
3535
};
3636

3737
std::vector<uint16_t> getProductIds() const override
@@ -51,7 +51,7 @@ class CorsairVoidV2W : public CorsairDevice {
5151

5252
// Override capability as this device needs the interface_id = 4
5353
constexpr capability_detail
54-
getCapabilityDetail(enum capabilities cap) const override
54+
getCapabilityDetail([[maybe_unused]] enum capabilities cap) const override
5555
{
5656
return { .usagepage = 0, .usageid = 0, .interface_id = 4 };
5757
}
@@ -99,10 +99,9 @@ class CorsairVoidV2W : public CorsairDevice {
9999
uint16_t battery_level_vendor = static_cast<uint16_t>(battery_response[4] | (battery_response[5] << 8));
100100

101101
const uint16_t battery_level_vendor_max = 1000;
102-
const int battery_level_max_attempts = 3;
102+
const int battery_level_max_attempts = 3;
103103

104-
for (int attempt = 0; attempt < battery_level_max_attempts &&
105-
(battery_level_vendor == 0 || battery_level_vendor > battery_level_vendor_max); ++attempt) {
104+
for (int attempt = 0; attempt < battery_level_max_attempts && (battery_level_vendor == 0 || battery_level_vendor > battery_level_vendor_max); ++attempt) {
106105
if (auto result = writeHID(device_handle, battery_request, MSG_SIZE_WRITE); !result) {
107106
return result.error();
108107
}
@@ -122,7 +121,7 @@ class CorsairVoidV2W : public CorsairDevice {
122121
};
123122
}
124123

125-
status = BATTERY_AVAILABLE;
124+
status = BATTERY_AVAILABLE;
126125
int level = static_cast<int>(battery_level_vendor / 10);
127126

128127
// Get the microphone mute state
@@ -158,12 +157,12 @@ class CorsairVoidV2W : public CorsairDevice {
158157
constexpr uint8_t CORSAIR_MIN = 0;
159158
constexpr uint16_t CORSAIR_MAX = 1000;
160159

161-
// Map from 0-128 to 200-255
162-
uint16_t mapped_level = map(level, 0, 128, CORSAIR_MIN, CORSAIR_MAX);
163-
uint16_t sidetone_value = round_to_multiples(mapped_level, 10);
164-
uint8_t low_byte = sidetone_value & 0xFF;
165-
uint8_t high_byte = (sidetone_value >> 8) & 0xFF;
166-
auto init_result = initializeDevice(device_handle);
160+
// Map from 0-128 to 0-1000
161+
uint16_t mapped_level = map<uint16_t>(level, 0, 128, CORSAIR_MIN, CORSAIR_MAX);
162+
auto sidetone_value = round_to_multiples(mapped_level, 10);
163+
uint8_t low_byte = static_cast<uint8_t>(sidetone_value & 0xFF);
164+
uint8_t high_byte = static_cast<uint8_t>((sidetone_value >> 8) & 0xFF);
165+
auto init_result = initializeDevice(device_handle);
167166
if (init_result.valueOr(0) == 0) {
168167
return DeviceError::deviceOffline("Headset not connected to wireless receiver");
169168
}

0 commit comments

Comments
 (0)