Browse Source

Adding Logitech G903 V2 to the Logitech common controller to resolve #1946

merge-requests/881/head
Chris M 2 months ago
committed by Adam Honse
parent
commit
d0cb93dec4
  1. 10
      60-openrgb.rules
  2. 4
      Controllers/LogitechController/LogitechControllerDetect.cpp
  3. 188
      Controllers/LogitechController/LogitechProtocolCommon.cpp
  4. 82
      Controllers/LogitechController/LogitechProtocolCommon.h
  5. 29
      Controllers/LogitechController/RGBController_LogitechLightspeed.cpp

10
60-openrgb.rules

@ -409,10 +409,12 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c087", TAG+="uacces
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="4070", TAG+="uaccess", TAG+="G703_Virtual"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c090", TAG+="uaccess", TAG+="G703_Hero"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="4086", TAG+="uaccess", TAG+="G703_Hero_Virtual"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c081", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="4053", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c086", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="4067", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c081", TAG+="uaccess", TAG+="G900_wired"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="4053", TAG+="uaccess", TAG+="G900_wireless"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c086", TAG+="uaccess", TAG+="G903_wired"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c091", TAG+="uaccess", TAG+="G903_V2_wired"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="4067", TAG+="uaccess", TAG+="G903_wireless"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="4087", TAG+="uaccess", TAG+="G903_V2_wireless"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c539", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c085", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c08c", TAG+="uaccess"

4
Controllers/LogitechController/LogitechControllerDetect.cpp

@ -72,6 +72,7 @@ using namespace std::chrono_literals;
#define LOGITECH_G703_HERO_LIGHTSPEED_PID 0xC090
#define LOGITECH_G900_LIGHTSPEED_PID 0xC081
#define LOGITECH_G903_LIGHTSPEED_PID 0xC086
#define LOGITECH_G903_LIGHTSPEED_HERO_PID 0xC091
#define LOGITECH_G_PRO_PID 0xC085
#define LOGITECH_G_PRO_HERO_PID 0xC08C
#define LOGITECH_G_PRO_WIRELESS_PID 0xC088
@ -109,6 +110,7 @@ using namespace std::chrono_literals;
#define LOGITECH_G703_HERO_LIGHTSPEED_VIRTUAL_PID 0x4086
#define LOGITECH_G900_LIGHTSPEED_VIRTUAL_PID 0x4053
#define LOGITECH_G903_LIGHTSPEED_VIRTUAL_PID 0x4067
#define LOGITECH_G903_LIGHTSPEED_VIRTUAL_HERO_PID 0x4087
#define LOGITECH_G_PRO_WIRELESS_VIRTUAL_PID 0x4079
#define LOGITECH_POWERPLAY_MAT_VIRTUAL_PID 0x405F
@ -794,6 +796,7 @@ REGISTER_HID_DETECTOR_IPU("Logitech G703 Wireless Gaming Mouse",
REGISTER_HID_DETECTOR_IPU("Logitech G703 Hero Wireless Gaming Mouse", DetectLogitechWireless, LOGITECH_VID, LOGITECH_G703_HERO_LIGHTSPEED_VIRTUAL_PID, 2, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech G900 Wireless Gaming Mouse", DetectLogitechWireless, LOGITECH_VID, LOGITECH_G900_LIGHTSPEED_VIRTUAL_PID, 2, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech G903 Wireless Gaming Mouse", DetectLogitechWireless, LOGITECH_VID, LOGITECH_G903_LIGHTSPEED_VIRTUAL_PID, 2, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech G903 Hero Wireless Gaming Mouse", DetectLogitechWireless, LOGITECH_VID, LOGITECH_G903_LIGHTSPEED_VIRTUAL_HERO_PID, 2, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech G Pro Wireless Gaming Mouse", DetectLogitechWireless, LOGITECH_VID, LOGITECH_G_PRO_WIRELESS_VIRTUAL_PID, 2, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech Powerplay Mat", DetectLogitechWireless, LOGITECH_VID, LOGITECH_POWERPLAY_MAT_VIRTUAL_PID, 2, 0xFF00, 2);
@ -812,5 +815,6 @@ REGISTER_HID_DETECTOR_IPU("Logitech G703 Wireless Gaming Mouse (wired)",
REGISTER_HID_DETECTOR_IPU("Logitech G703 Hero Wireless Gaming Mouse (wired)", DetectLogitechWired, LOGITECH_VID, LOGITECH_G703_HERO_LIGHTSPEED_PID, 1, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech G900 Wireless Gaming Mouse (wired)", DetectLogitechWired, LOGITECH_VID, LOGITECH_G900_LIGHTSPEED_PID, 1, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech G903 Wireless Gaming Mouse (wired)", DetectLogitechWired, LOGITECH_VID, LOGITECH_G903_LIGHTSPEED_PID, 1, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech G903 Hero Wireless Gaming Mouse (wired)", DetectLogitechWired, LOGITECH_VID, LOGITECH_G903_LIGHTSPEED_HERO_PID, 1, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech G Pro Wireless Gaming Mouse (wired)", DetectLogitechWired, LOGITECH_VID, LOGITECH_G_PRO_WIRELESS_PID, 2, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech G733 Gaming Headset", DetectLogitechWired, LOGITECH_VID, LOGITECH_G733_PID, 2, 0xFF43, 514);

188
Controllers/LogitechController/LogitechProtocolCommon.cpp

@ -242,13 +242,21 @@ bool logitech_device::connected()
}
}
uint8_t logitech_device::getLEDinfo()
uint8_t logitech_device::getLED_count()
{
return leds.size();
}
logitech_led logitech_device::getLED_info(uint8_t LED_num)
{
/*-----------------------------------------------------------------*\
| Get all info about the LEDs and Zones |
\*-----------------------------------------------------------------*/
return leds.size();
if(!(LED_num < 0 || LED_num > leds.size()))
{
return leds[LED_num];
}
}
void logitech_device::flushReadQueue()
@ -331,6 +339,29 @@ uint8_t logitech_device::getFeatureIndex(uint16_t feature_page)
return feature_index;
}
uint16_t logitech_device::getFeaturePage(uint8_t feature_index)
{
/*-----------------------------------------------------------------*\
| Get the feature page from the feature_list |
| Return the mapped feature page given the feature index |
| for this device or else return 0 |
\*-----------------------------------------------------------------*/
rvrse_features rvrse_feature_list = reverse_map(feature_list);
rvrse_features::iterator find_page = rvrse_feature_list.find(feature_index);
if (find_page == rvrse_feature_list.end())
{
LOG_DEBUG("[%s] Feature index %02X not found!", device_name.c_str(), feature_index);
//TODO: Handle cache miss
return 0;
}
else
{
return find_page->second;
}
}
int logitech_device::getDeviceFeatureList()
{
int result = 0;
@ -454,6 +485,7 @@ void logitech_device::getRGBconfig()
| Then use it to get the name for this device |
\*-----------------------------------------------------------------*/
hid_device* dev_use2 = getDevice(2);
uint16_t feature_page = getFeaturePage(RGB_feature_index);
uint8_t led_response = 0;
uint8_t led_counter = 0;
@ -469,40 +501,130 @@ void logitech_device::getRGBconfig()
longFAPrequest get_count;
get_count.init(device_index, RGB_feature_index, LOGITECH_CMD_RGB_EFFECTS_GET_COUNT);
result = hid_write(dev_use2, get_count.buffer, get_count.size());
do
if(feature_page == LOGITECH_HIDPP_PAGE_RGB_EFFECTS1)
{
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
LOG_DEBUG("[%s] LED Count - %02X : %04X %04X %04X %04X %02X %02X %02X %02X %02X %02X %02X", device_name.c_str(),
response.data[0], (response.data[1] << 8 | response.data[2]), (response.data[3] << 8 | response.data[4]), (response.data[5] << 8 | response.data[6]),
(response.data[7] << 8 | response.data[8]), response.data[9], response.data[10], response.data[11], response.data[12], response.data[13], response.data[14], response.data[15]);
} while ((result == 20) && (get_count.feature_index != response.feature_index) && (get_count.feature_command != response.feature_command));
result = hid_write(dev_use2, get_count.buffer, get_count.size());
do
{
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
LOG_DEBUG("[%s] FP8070 - LED Count - %02X : %04X %04X %04X %04X %02X %02X %02X %02X %02X %02X %02X", device_name.c_str(),
response.data[0], (response.data[1] << 8 | response.data[2]), (response.data[3] << 8 | response.data[4]), (response.data[5] << 8 | response.data[6]),
(response.data[7] << 8 | response.data[8]), response.data[9], response.data[10], response.data[11], response.data[12], response.data[13], response.data[14], response.data[15]);
} while ((result == 20) && (get_count.feature_index != response.feature_index) && (get_count.feature_command != response.feature_command));
led_response = response.data[0];
get_count.feature_command = LOGITECH_CMD_RGB_EFFECTS_GET_INFO;
do
{
get_count.data[0] = leds.size();
result = hid_write(dev_use2, get_count.buffer, get_count.size());
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
LOG_DEBUG("[%s] FP8070 - LED %02i - %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", device_name.c_str(), get_count.data[0],
response.data[0], response.data[1], response.data[2], response.data[3], response.data[4], response.data[5], response.data[6], response.data[7],
response.data[8], response.data[9], response.data[10], response.data[11], response.data[12], response.data[13], response.data[14], response.data[15]);
if( result == 20 &&
get_count.feature_index == response.feature_index &&
get_count.feature_command == response.feature_command &&
response.data[0] != 0x10 &&
response.data[1] != 0x02
)
{
//If the response is the correct length (i.e. no USB error) and is for the RGB_feature_index and LOGITECH_CMD_RGB_EFFECTS_GET_INFO and no error occured with the led_counter then bump the counter
logitech_led new_led;
new_led.location = response.data[1] << 8 | response.data[2];
new_led.fx_count = response.data[3];
for(uint8_t i = 0; i < new_led.fx_count; i++)
{
blankFAPmessage fx_response;
fx_response.init();
longFAPrequest get_effect;
get_effect.init(device_index, RGB_feature_index, LOGITECH_CMD_RGB_EFFECTS_GET_CONTROL);
led_response = response.data[0];
get_effect.data[0] = get_count.data[0];
get_effect.data[1] = i;
result = hid_write(dev_use2, get_effect.buffer, get_effect.size());
result = hid_read_timeout(dev_use2, fx_response.buffer, fx_response.size(), LOGITECH_PROTOCOL_TIMEOUT);
LOG_DEBUG("[%s] FP8070 - LED %02i Effect %02X - %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", device_name.c_str(), get_count.data[0], i,
fx_response.data[0], fx_response.data[1], fx_response.data[2], fx_response.data[3], fx_response.data[4], fx_response.data[5], fx_response.data[6], fx_response.data[7],
fx_response.data[8], fx_response.data[9], fx_response.data[10], fx_response.data[11], fx_response.data[12], fx_response.data[13], fx_response.data[14], fx_response.data[15]);
get_count.feature_command = LOGITECH_CMD_RGB_EFFECTS_GET_INFO;
do
logitech_fx new_fx;
new_fx.index = i;
new_fx.mode = *reinterpret_cast<LOGITECH_DEVICE_MODE*>(fx_response.data[2] << 8 | fx_response.data[3]);
new_fx.speed = fx_response.data[6] << 8 | fx_response.data[7];
new_led.fx.push_back(new_fx);
}
leds.emplace(response.data[0], new_led);
}
} while ((result == 20) && (get_count.feature_index == response.feature_index) && (get_count.feature_command == response.feature_command) && (response.data[0] != 0x10) && (response.data[1] != 0x02));
}
else if(feature_page == LOGITECH_HIDPP_PAGE_RGB_EFFECTS2)
{
//TODO: Push this info into a vector for later enumeration by the RGBController
get_count.data[0] = leds.size();
get_count.data[0] = 0xFF;
get_count.data[1] = 0xFF;
get_count.data[2] = 0;
get_count.data[3] = 0;
get_count.data[4] = 0;
result = hid_write(dev_use2, get_count.buffer, get_count.size());
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
LOG_DEBUG("[%s] LED %02i - %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", device_name.c_str(), led_counter,
response.data[0], response.data[1], response.data[2], response.data[3], response.data[4], response.data[5], response.data[6], response.data[7],
response.data[8], response.data[9], response.data[10], response.data[11], response.data[12], response.data[13], response.data[14], response.data[15]);
if(result == 20 && get_count.feature_index == response.feature_index && get_count.feature_command == response.feature_command && response.data[0] != 0x10 && response.data[1] != 0x02)
LOG_DEBUG("[%s] FP8071 - LED Count - %02X : %02X %02X %04X %04X %04X %02X %02X %02X %02X %02X %02X %02X", device_name.c_str(),
response.data[2], response.data[0], response.data[1], (response.data[3] << 8 | response.data[4]), (response.data[5] << 8 | response.data[6]),
(response.data[7] << 8 | response.data[8]), response.data[9], response.data[10], response.data[11], response.data[12], response.data[13], response.data[14], response.data[15]);
led_response = response.data[2];
for(size_t i = 0; i < led_response; i++)
{
//If the response is the correct length (i.e. no USB error) and is for the RGB_feature_index and LOGITECH_CMD_RGB_EFFECTS_GET_INFO and no error occured with the led_counter then bump the counter
get_count.data[0] = i;
get_count.data[1] = 0xFF;
get_count.data[2] = 0;
result = hid_write(dev_use2, get_count.buffer, get_count.size());
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
LOG_DEBUG("[%s] FP8071 - LED %02i - %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", device_name.c_str(), led_counter,
response.data[0], response.data[1], response.data[2], response.data[3], response.data[4], response.data[5], response.data[6], response.data[7],
response.data[8], response.data[9], response.data[10], response.data[11], response.data[12], response.data[13], response.data[14], response.data[15]);
logitech_led new_led;
new_led.value = response.data[0];
new_led.param1 = response.data[1];
new_led.param2 = response.data[2];
new_led.param3 = response.data[3];
new_led.location = response.data[2] << 8 | response.data[3];
new_led.fx_count = response.data[4];
for(uint8_t i = 0; i < new_led.fx_count; i++)
{
blankFAPmessage fx_response;
fx_response.init();
longFAPrequest get_effect;
get_effect.init(device_index, RGB_feature_index, LOGITECH_CMD_RGB_EFFECTS_GET_INFO);
get_effect.data[0] = get_count.data[0];
get_effect.data[1] = i;
result = hid_write(dev_use2, get_effect.buffer, get_effect.size());
result = hid_read_timeout(dev_use2, fx_response.buffer, fx_response.size(), LOGITECH_PROTOCOL_TIMEOUT);
LOG_DEBUG("[%s] FP8071 - LED %02i Effect %02X - %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", device_name.c_str(), get_count.data[0], i,
fx_response.data[0], fx_response.data[1], fx_response.data[2], fx_response.data[3], fx_response.data[4], fx_response.data[5], fx_response.data[6], fx_response.data[7],
fx_response.data[8], fx_response.data[9], fx_response.data[10], fx_response.data[11], fx_response.data[12], fx_response.data[13], fx_response.data[14], fx_response.data[15]);
logitech_fx new_fx;
leds.push_back(new_led);
new_fx.index = i;
new_fx.mode = *reinterpret_cast<LOGITECH_DEVICE_MODE*>(fx_response.data[2] << 8 | fx_response.data[3]);
new_fx.speed = fx_response.data[6] << 8 | fx_response.data[7];
new_led.fx.push_back(new_fx);
}
leds.emplace(response.data[0], new_led);
}
} while ((result == 20) && (get_count.feature_index == response.feature_index) && (get_count.feature_command == response.feature_command) && (response.data[0] != 0x10) && (response.data[1] != 0x02));
}
/*get_count.feature_command = LOGITECH_CMD_RGB_EFFECTS_GET_STATE;
for(std::size_t i = 0; i < feature_count; i++ )
@ -575,13 +697,13 @@ uint8_t logitech_device::setDirectMode(bool direct)
uint8_t logitech_device::setMode(uint8_t mode, uint16_t speed, uint8_t zone, uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness, bool bright_cycle_swap)
{
int result = 0;
/*-----------------------------------------------------------------*\
| Check the usage map for usage2 (0x11 Long FAP Message) then |
| set the device mode via LOGITECH_CMD_RGB_EFFECTS_SET_CONTROL |
\*-----------------------------------------------------------------*/
hid_device* dev_use2 = getDevice(2);
hid_device* dev_use2 = getDevice(2);
uint16_t feature_page = getFeaturePage(RGB_feature_index);
int result = 0;
if(dev_use2)
{
@ -595,7 +717,7 @@ uint8_t logitech_device::setMode(uint8_t mode, uint16_t speed, uint8_t zone, uin
| Set the mode via the RGB_feature_index |
\*-----------------------------------------------------------------*/
longFAPrequest set_mode;
set_mode.init(device_index, RGB_feature_index, LOGITECH_CMD_RGB_EFFECTS_SET_CONTROL);
set_mode.init(device_index, RGB_feature_index, ((feature_page == LOGITECH_HIDPP_PAGE_RGB_EFFECTS1) ? LOGITECH_CMD_RGB_EFFECTS_SET_CONTROL : LOGITECH_CMD_RGB_EFFECTS_GET_INFO));
set_mode.data[0] = zone;
set_mode.data[1] = mode;
@ -606,9 +728,10 @@ uint8_t logitech_device::setMode(uint8_t mode, uint16_t speed, uint8_t zone, uin
speed *= 100;
if(mode == 1) //Static
{
set_mode.data[5] = zone;
set_mode.data[5] = 0x02; //zone;
set_mode.data[16] = 0x01;
}
else if(mode == 2) //Spectrum Cycle
else if(mode == 2) //Spectrum Cycle - LOGITECH_DEVICE_LED_SPECTRUM
{
if(bright_cycle_swap)
{
@ -618,7 +741,7 @@ uint8_t logitech_device::setMode(uint8_t mode, uint16_t speed, uint8_t zone, uin
set_mode.data[8] = speed & 0xFF;
set_mode.data[9] = brightness;
}
else if(mode == 3) //Breathing
else if(mode == 3) //Breathing - LOGITECH_DEVICE_LED_BREATHING
{
if(bright_cycle_swap)
{
@ -626,6 +749,7 @@ uint8_t logitech_device::setMode(uint8_t mode, uint16_t speed, uint8_t zone, uin
}
set_mode.data[5] = speed >> 8;
set_mode.data[6] = speed & 0xFF;
//set_mode.data[7] = curve_type; //Value 0-6: Default, Sine, Square, Triangle, Sawtooth, Reverse_Sawtooth, Exponent
set_mode.data[8] = brightness;
}

82
Controllers/LogitechController/LogitechProtocolCommon.h

@ -54,15 +54,35 @@
enum LOGITECH_DEVICE_TYPE
{
LOGITECH_DEVICE_TYPE_KEYBOARD = 0,
LOGITECH_DEVICE_TYPE_REMOTECONTROL =1,
LOGITECH_DEVICE_TYPE_NUMPAD = 2,
LOGITECH_DEVICE_TYPE_MOUSE = 3,
LOGITECH_DEVICE_TYPE_MOUSEPAD = 4,
LOGITECH_DEVICE_TYPE_TRACKBALL = 5,
LOGITECH_DEVICE_TYPE_PRESENTER = 6,
LOGITECH_DEVICE_TYPE_RECEIVER = 7,
LOGITECH_DEVICE_TYPE_HEADSET = 8
LOGITECH_DEVICE_TYPE_KEYBOARD = 0,
LOGITECH_DEVICE_TYPE_REMOTECONTROL = 1,
LOGITECH_DEVICE_TYPE_NUMPAD = 2,
LOGITECH_DEVICE_TYPE_MOUSE = 3,
LOGITECH_DEVICE_TYPE_MOUSEPAD = 4,
LOGITECH_DEVICE_TYPE_TRACKBALL = 5,
LOGITECH_DEVICE_TYPE_PRESENTER = 6,
LOGITECH_DEVICE_TYPE_RECEIVER = 7,
LOGITECH_DEVICE_TYPE_HEADSET = 8
};
enum LOGITECH_DEVICE_MODE
{
LOGITECH_DEVICE_LED_OFF = 0x0000,
LOGITECH_DEVICE_LED_ON = 0x0001,
LOGITECH_DEVICE_LED_SPECTRUM = 0x0003,
LOGITECH_DEVICE_LED_WAVE = 0x0004,
LOGITECH_DEVICE_LED_STAR = 0x0005,
LOGITECH_DEVICE_LED_BREATHING = 0x000A,
LOGITECH_DEVICE_LED_RIPPLE = 0x000B,
LOGITECH_DEVICE_LED_CUSTOM = 0x000C
};
static const char* logitech_led_locations[] = {
"Unknown",
"Primary",
"Logo",
"Left",
"Right"
};
// Used for: {GET,SET}_REGISTER_{REQ,RSP}, SET_LONG_REGISTER_RSP, GET_LONG_REGISTER_REQ
@ -175,17 +195,39 @@ union blankFAPmessage
};
};
struct logitech_led
template<typename K, typename V>
static std::map<V, K> reverse_map(const std::map<K, V>& map)
{
std::map<V, K> reversed_map;
for(const std::pair<K, V>& entry : map)
{
reversed_map[entry.second] = entry.first;
}
return reversed_map;
}
struct logitech_fx
{
uint8_t value;
uint8_t param1;
uint8_t param2;
uint8_t param3;
uint8_t index;
uint16_t speed; //period
LOGITECH_DEVICE_MODE mode;
};
typedef std::map<uint8_t, hid_device*> usages;
typedef std::map<uint16_t, uint8_t> features;
typedef std::map<uint16_t, uint8_t> wireless_map;
typedef std::map<uint8_t, hid_device*> usages;
typedef std::map<uint16_t, uint8_t> features;
typedef std::map<uint8_t, uint16_t> rvrse_features;
typedef std::map<uint16_t, uint8_t> wireless_map;
typedef std::vector<logitech_fx> leds_fx;
struct logitech_led
{
uint16_t location;
uint8_t fx_count;
leds_fx fx;
};
int getWirelessDevice(usages _usages, uint16_t pid, wireless_map *wireless_devices); //Helper function needed outside of class
@ -215,15 +257,17 @@ public:
bool is_valid();
void flushReadQueue();
uint8_t getFeatureIndex(uint16_t feature_page);
uint8_t getLEDinfo();
uint8_t getLED_count();
logitech_led getLED_info(uint8_t LED_num);
uint8_t setDirectMode(bool direct);
uint8_t setMode(uint8_t mode, uint16_t speed, uint8_t zone, uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness, bool bright_cycle_swap);
int getDeviceName();
private:
std::vector<logitech_led> leds;
std::map<uint8_t, logitech_led> leds;
std::shared_ptr<std::mutex> mutex;
hid_device* getDevice(uint8_t usage_index);
uint16_t getFeaturePage(uint8_t feature_index);
int getDeviceFeatureList();
void getRGBconfig();
void initialiseDevice();

29
Controllers/LogitechController/RGBController_LogitechLightspeed.cpp

@ -115,14 +115,33 @@ RGBController_LogitechLightspeed::~RGBController_LogitechLightspeed()
void RGBController_LogitechLightspeed::SetupZones()
{
uint8_t LED_count = logitech->lightspeed->getLEDinfo();
const std::string zone_string = "Zone";
const std::string led_string = "LED";
uint8_t led_count = logitech->lightspeed->getLED_count();
if(LED_count > 0)
if(led_count > 0)
{
for(size_t i = 0; i < LED_count; i++)
for(size_t i = 0; i < led_count; i++)
{
zone Lightspeed_logo_zone;
Lightspeed_logo_zone.name = "Zone " + std::to_string(i);
led Lightspeed_logo_led;
logitech_led new_led = logitech->lightspeed->getLED_info(i);
if(new_led.location < sizeof(logitech_led_locations) )
{
Lightspeed_logo_zone.name = logitech_led_locations[new_led.location];
Lightspeed_logo_zone.name.append(" ");
Lightspeed_logo_led.name = Lightspeed_logo_zone.name;
Lightspeed_logo_led.name.append(led_string);
Lightspeed_logo_zone.name.append(zone_string);
}
else
{
std::string name = " " + std::to_string(i);
Lightspeed_logo_zone.name = zone_string + name;
Lightspeed_logo_led.name = led_string + name;
}
Lightspeed_logo_zone.type = ZONE_TYPE_SINGLE;
Lightspeed_logo_zone.leds_min = 1;
Lightspeed_logo_zone.leds_max = 1;
@ -130,8 +149,6 @@ void RGBController_LogitechLightspeed::SetupZones()
Lightspeed_logo_zone.matrix_map = NULL;
zones.push_back(Lightspeed_logo_zone);
led Lightspeed_logo_led;
Lightspeed_logo_led.name = "LED " + std::to_string(i);
Lightspeed_logo_led.value = i;
leds.push_back(Lightspeed_logo_led);
}

Loading…
Cancel
Save