@@ -69,6 +69,7 @@ typedef bool (*LogiLedRestoreLighting_t)();
6969typedef void (*LogiLedShutdown_t)();
7070typedef bool (*LogiLedGetSdkVersion_t)(int *, int *, int *);
7171typedef bool (*LogiLedSetLightingForKeyWithKeyName_t)(int , int , int , int );
72+ typedef bool (*LogiLedSetZone_t)(int , int , int , int , int );
7273
7374static LogiLedInit_t g_LedInit = NULL ;
7475static LogiLedInitWithName_t g_LedInitWithName = NULL ;
@@ -78,6 +79,7 @@ static LogiLedSaveCurrentLighting_t g_LedSave = NULL;
7879static LogiLedRestoreLighting_t g_LedRestore = NULL ;
7980static LogiLedShutdown_t g_LedShutdown = NULL ;
8081static LogiLedGetSdkVersion_t g_LedGetVersion = NULL ;
82+ static LogiLedSetZone_t g_LedSetZone = NULL ;
8183
8284// --- LogitechLED ---
8385
@@ -137,6 +139,7 @@ void LogitechLED::Close()
137139 g_LedInit = NULL ;
138140 g_LedSetLighting = NULL ;
139141 g_LedShutdown = NULL ;
142+ g_LedSetZone = NULL ;
140143}
141144
142145bool LogitechLED::IsAvailable () const
@@ -432,51 +435,44 @@ bool LogitechLED::TrySDK()
432435
433436 Sleep (500 );
434437
435- // Exhaustive scan: try many device type + zone combinations
436- FARPROC pZone = GetProcAddress (m_sdkDll, " LogiLedSetLightingForTargetZone " );
437- if (pZone && g_LedSetTarget)
438+ g_LedSetZone = (LogiLedSetZone_t) GetProcAddress (m_sdkDll, " LogiLedSetLightingForTargetZone " );
439+
440+ if (g_LedSetZone && g_LedSetTarget)
438441 {
439- typedef bool (*SetZone_t)( int , int , int , int , int );
440- SetZone_t setZone = (SetZone_t)pZone ;
442+ // Target device type 0x8 (responded OK in previous tests)
443+ g_LedSetTarget ( 0x8 ) ;
441444
442- // Try device types: known bitmasks + higher values + 0xFF
443- int deviceTypes[] = { 0x01 , 0x02 , 0x04 , 0x07 , 0x08 , 0x10 , 0x20 ,
444- 0x40 , 0x80 , 0xFF , 0x0100 , 0x0200 , -1 };
445+ // Test: light up zone 0 and 1 with bright green (RPM LED color)
446+ bool z0 = g_LedSetZone (0x8 , 0 , 0 , 100 , 0 );
447+ bool z1 = g_LedSetZone (0x8 , 1 , 0 , 100 , 0 );
448+ Log (" devType=0x8 zone0(green) -> %s, zone1(green) -> %s" , z0 ? " OK" : " FAIL" , z1 ? " OK" : " FAIL" );
445449
446- for ( int di = 0 ; deviceTypes[di] != - 1 ; di++ )
450+ if (z0 || z1 )
447451 {
448- g_LedSetTarget (deviceTypes[di]);
449- for (int zone = 0 ; zone < 10 ; zone++)
450- {
451- bool zok = setZone (deviceTypes[di], zone, 100 , 100 , 100 );
452- if (zok)
453- {
454- Log (" *** HIT *** SetZone(devType=0x%X, zone=%d) -> OK" , deviceTypes[di], zone);
455- Sleep (500 );
456- }
457- }
458- }
452+ Log (" *** Activating LED SDK with devType=0x8 ***" );
453+ Log (" Waiting 2s to check if LEDs are visible..." );
454+ Sleep (2000 );
459455
460- // Also try SetZone with ordinal device types (0, 1, 2, 3, 4, 5)
461- for (int dt = 0 ; dt <= 5 ; dt++)
462- {
463- for (int zone = 0 ; zone < 10 ; zone++)
464- {
465- bool zok = setZone (dt, zone, 100 , 100 , 100 );
466- if (zok)
467- Log (" *** HIT *** SetZone(ordinal=%d, zone=%d) -> OK" , dt, zone);
468- }
456+ // Clear
457+ g_LedSetZone (0x8 , 0 , 0 , 0 , 0 );
458+ g_LedSetZone (0x8 , 1 , 0 , 0 , 0 );
459+
460+ m_method = METHOD_SDK;
461+ m_available = true ;
462+ Log (" === LED CONTROL ACTIVE (LED SDK devType=0x8) ===" );
463+ return true ;
469464 }
470465 }
471466
472- // Don't activate LED SDK - it doesn 't control wheel LEDs
473- Log (" LED SDK scan complete (keyboard/mouse only) " );
467+ // devType=0x8 didn 't work, clean up
468+ Log (" LED SDK: no usable zones found " );
474469 if (g_LedShutdown) g_LedShutdown ();
475470 FreeLibrary (m_sdkDll);
476471 m_sdkDll = NULL ;
477472 g_LedInit = NULL ;
478473 g_LedSetLighting = NULL ;
479474 g_LedShutdown = NULL ;
475+ g_LedSetZone = NULL ;
480476 return false ;
481477}
482478
@@ -743,21 +739,34 @@ bool LogitechLED::SetLEDs(BYTE ledMask)
743739 return SetLEDsFromPercent (numLeds / 5.0 );
744740 }
745741
746- if (m_method == METHOD_SDK && g_LedSetLighting )
742+ if (m_method == METHOD_SDK && g_LedSetZone )
747743 {
744+ // Map 5-bit LED mask to devType=0x8 zones 0-1
745+ // Zone 0 = lower LEDs (green), Zone 1 = upper LEDs (red)
748746 int numLeds = 0 ;
749747 for (int i = 0 ; i < 5 ; i++)
750748 if (ledMask & (1 << i)) numLeds++;
751749
752- int pct = numLeds * 20 ;
753- bool ok = g_LedSetLighting (pct, pct, pct);
750+ // Zone 0: green intensity based on LED count (first 3 LEDs)
751+ // Zone 1: red intensity for high RPM (last 2 LEDs)
752+ int greenPct = 0 , redPct = 0 ;
753+ if (numLeds >= 1 ) greenPct = 33 ;
754+ if (numLeds >= 2 ) greenPct = 66 ;
755+ if (numLeds >= 3 ) greenPct = 100 ;
756+ if (numLeds >= 4 ) redPct = 50 ;
757+ if (numLeds >= 5 ) redPct = 100 ;
758+
759+ g_LedSetTarget (0x8 );
760+ bool z0 = g_LedSetZone (0x8 , 0 , 0 , greenPct, 0 );
761+ bool z1 = g_LedSetZone (0x8 , 1 , redPct, 0 , 0 );
754762
755763 g_setLedsCallCount++;
756- if (g_setLedsCallCount <= 20 || !ok)
757- Log (" SetLEDs(0x%02X) [LedSDK pct=%d] -> %s (#%d)" ,
758- ledMask, pct, ok ? " OK" : " FAIL" , g_setLedsCallCount);
764+ if (g_setLedsCallCount <= 20 || (!z0 && !z1))
765+ Log (" SetLEDs(0x%02X) [SDK 0x8 g=%d r=%d] -> z0=%s z1=%s (#%d)" ,
766+ ledMask, greenPct, redPct,
767+ z0 ? " OK" : " FAIL" , z1 ? " OK" : " FAIL" , g_setLedsCallCount);
759768
760- return ok ;
769+ return z0 || z1 ;
761770 }
762771
763772 if (m_handle == INVALID_HANDLE_VALUE) return false ;
0 commit comments