Skip to content

Commit

Permalink
Logitech fixes:
Browse files Browse the repository at this point in the history
- only initialize Logitech SDK once
- only save initial lighting on initialize
- simplify code (even though it's already the simplest wrapper of all the supported APIs)
  • Loading branch information
HunterZ committed Mar 13, 2018
1 parent a5d2835 commit 052d67b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
23 changes: 13 additions & 10 deletions UniLight/LLEDUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ namespace

bool initLLED()
{
if (!initialized) initialized = LogiLedInit();
if (initialized) return true;

// don't really care if this succeeds
LogiLedSaveCurrentLighting();
if (LogiLedInit())
{
LogiLedSaveCurrentLighting();
initialized = true;
}

return initialized;
}
Expand All @@ -38,16 +41,16 @@ namespace LLEDUtil
{
LogiLedRestoreLighting();

void LogiLedShutdown();
LogiLedShutdown();
}

bool LLEDUtilC::SetLLEDColor(unsigned char red, unsigned char green, unsigned char blue)
{
if (!initialized && !initLLED()) return false;

// target only RGB devices (as opposed to monochrome)
if (!LogiLedSetTargetDevice(LOGI_DEVICETYPE_PERKEY_RGB | LOGI_DEVICETYPE_RGB)) return false;

return LogiLedSetLighting(b2p(red), b2p(green), b2p(blue));
return
(
initLLED() &&
LogiLedSetTargetDevice(LOGI_DEVICETYPE_PERKEY_RGB | LOGI_DEVICETYPE_RGB) &&
LogiLedSetLighting(b2p(red), b2p(green), b2p(blue))
);
}
}
12 changes: 6 additions & 6 deletions UniLight/UniLight.vcxproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand Down Expand Up @@ -42,32 +42,32 @@
<ProjectGuid>{28F74A2D-E89D-4D21-A6E8-7A5C2EDBD870}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>UniLight</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down

0 comments on commit 052d67b

Please sign in to comment.