Skip to content

Commit

Permalink
Dynamic KDL, full ACPI lights support.
Browse files Browse the repository at this point in the history
  • Loading branch information
T-Troll committed Oct 12, 2021
1 parent db9874c commit c3b6d90
Show file tree
Hide file tree
Showing 14 changed files with 163 additions and 92 deletions.
60 changes: 44 additions & 16 deletions AlienFX-SDK/AlienFX_SDK/AlienFX_SDK.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#define WIN32_LEAN_AND_MEAN
#include "AlienFX_SDK.h"
#include <Setupapi.h>
#include <iostream>
extern "C" {
#include <hidclass.h>
#include <hidsdi.h>
#include <acpiioct.h>
#ifndef NOACPILIGHTS
#include "alienfan-low.h"
#endif
}

#pragma comment(lib, "setupapi.lib")
#pragma comment(lib, "hid.lib")

namespace AlienFX_SDK {
Expand Down Expand Up @@ -118,6 +117,22 @@ namespace AlienFX_SDK {
return;
}

bool Functions::SetAcpiColor(byte mask, byte r, byte g, byte b) {
#ifndef NOACPILIGHTS
PACPI_EVAL_OUTPUT_BUFFER resName = NULL;
PACPI_EVAL_INPUT_BUFFER_COMPLEX_EX acpiargs = NULL;
acpiargs = (PACPI_EVAL_INPUT_BUFFER_COMPLEX_EX) PutIntArg(NULL, r);
acpiargs = (PACPI_EVAL_INPUT_BUFFER_COMPLEX_EX) PutIntArg(acpiargs, g);
acpiargs = (PACPI_EVAL_INPUT_BUFFER_COMPLEX_EX) PutIntArg(acpiargs, b);
acpiargs = (PACPI_EVAL_INPUT_BUFFER_COMPLEX_EX) PutIntArg(acpiargs, mask);
if (EvalAcpiMethodArgs(devHandle, "\\_SB.AMW1.SETC", acpiargs, (PVOID *) &resName)) {
free(resName);
return true;
}
#endif
return false;
}

//Use this method for general devices pid = -1 for full scan
int Functions::AlienFXInitialize(int vid, int pidd) {
GUID guid;
Expand Down Expand Up @@ -262,11 +277,13 @@ namespace AlienFX_SDK {
} break;
case API_L_ACPI:
{
#ifndef NOACPILIGHTS
PACPI_EVAL_OUTPUT_BUFFER resName = NULL;
if (!inSet && EvalAcpiMethod(devHandle, "\\_SB.AMW1.ICPC", (PVOID *) &resName)) {
free(resName);
result = true;
}
#endif
} break;
default: return false;
}
Expand Down Expand Up @@ -297,11 +314,13 @@ namespace AlienFX_SDK {
} break;
case API_L_ACPI:
{
#ifndef NOACPILIGHTS
PACPI_EVAL_OUTPUT_BUFFER resName = NULL;
if (EvalAcpiMethod(devHandle, "\\_SB.AMW1.RCPC", (PVOID *) &resName)) {
free(resName);
res = true;
}
#endif
} break;
default: return false;
}
Expand Down Expand Up @@ -365,16 +384,7 @@ namespace AlienFX_SDK {
case API_L_ACPI:
{
unsigned mask = 1 << index;
PACPI_EVAL_OUTPUT_BUFFER resName = NULL;
PACPI_EVAL_INPUT_BUFFER_COMPLEX_EX acpiargs = NULL;
acpiargs = (PACPI_EVAL_INPUT_BUFFER_COMPLEX_EX) PutIntArg(NULL, r);
acpiargs = (PACPI_EVAL_INPUT_BUFFER_COMPLEX_EX) PutIntArg(acpiargs, g);
acpiargs = (PACPI_EVAL_INPUT_BUFFER_COMPLEX_EX) PutIntArg(acpiargs, b);
acpiargs = (PACPI_EVAL_INPUT_BUFFER_COMPLEX_EX) PutIntArg(acpiargs, mask);
if (EvalAcpiMethodArgs(devHandle, "\\_SB.AMW1.SETC", acpiargs, (PVOID *) &resName)) {
free(resName);
return true;
}
val = SetAcpiColor(mask, r, g, b);
} break;
default: return false;
}
Expand Down Expand Up @@ -442,11 +452,18 @@ namespace AlienFX_SDK {
val = HidD_SetOutputReport(devHandle, buffer, length);
Loop();
} break;
default:
case API_L_ACPI:
{
byte fmask = 0;
for (int nc = 0; nc < numLights; nc++)
val = SetColor(lights[nc], r, g, b);
}
fmask |= 1 << lights[nc];
val = SetAcpiColor(fmask, r, g, b);
} break;
//default:
//{
// for (int nc = 0; nc < numLights; nc++)
// val = SetColor(lights[nc], r, g, b);
//}
}
return val;
}
Expand Down Expand Up @@ -915,6 +932,17 @@ namespace AlienFX_SDK {
AlienfxWaitForReady();
return res;
} break;
case API_L_ACPI:
if (!brightness)
// it should be SetMode here, but i have no testing yet.
for (int i = 0; i < mappings->size(); i++) {
mapping cur = mappings->at(i);
if (cur.devid == pid) {
if (cur.lightid || power)
SetColor(cur.lightid, 0, 0, 0);
}
}
break;
}
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions AlienFX-SDK/AlienFX_SDK/AlienFX_SDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ namespace AlienFX_SDK
// support function for mask-based devices (v1-v3)
void SetMaskAndColor(int index, byte* buffer, byte r1, byte g1, byte b1, byte r2 = 0, byte g2 = 0, byte b2 = 0);

// Support functions for ACPI calls
bool SetAcpiColor(byte mask, byte r, byte g, byte b);

public:

bool inSet = false;
Expand Down
1 change: 0 additions & 1 deletion AlienFX-SDK/AlienFX_SDK/AlienFX_SDK.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="AlienFX_SDK.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="AlienFX_SDK.cpp" />
Expand Down
3 changes: 0 additions & 3 deletions AlienFX-SDK/AlienFX_SDK/AlienFX_SDK.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="AlienFX_SDK.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down
Binary file removed AlienFX-SDK/AlienFX_SDK/targetver.h
Binary file not shown.
9 changes: 5 additions & 4 deletions AlienFX-SDK/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ This SDK not only fixes up its issue and performs better but is written from scr

Please checkout Sample App for reference.

**Currently tested on AW13/R2, AW13/R3, AWM14x, AW15R2/R3, AW17R3/R4, AWm15/R1-R4, AWm17/R1, Dell G5/G7, but should work at any alienware laptop.**
**Currently tested on AW13/R2, AW13/R3, AWM14x, AW15R2/R3, AW17R3/R4, AWm15/R1-R4, AWm17/R1, Dell G5/G7, AWAurora/R7, but should work at any alienware laptop or desktop.**

### Supported device API versions:
- ACPI-controlled lights - 3 lights, 8 bit/color (v0) - using this API require low-level ACPI driver and library from [Alienfan](https://github.com/T-Troll/alienfan-tools) project.
- 9 bytes 8 bit/color, reportID 2 control (v1)
- 9 bytes 4 bit/color, reportID 2 control (v2)
- 12 bytes 8 bit/color, reportID 2 control (v3)
Expand All @@ -23,9 +24,9 @@ Some notebooks have 2 devices - APIv4 (for logo, power button, etc) and APIv5 fo
- Change light color
- Change multiply lights color
- Change light hardware effect (except APIv5)
- Change multiply lights hardware effects (except APIv5, emulation at APIv1-v3)
- Hardware-backed global light off/on/dim
- Global hardware effects (APIv5)
- Change multiply lights hardware effects (except APIv5)
- Hardware-backed global light off/on/dim (dim is software for APIv0-v3 and should be done by application)
- Global hardware light effects (APIv5)

### Initialization
```C++
Expand Down
88 changes: 57 additions & 31 deletions Install/Install.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
"SccProvider" = "8:"
"Hierarchy"
{
"Entry"
{
"MsmKey" = "8:_015851A88B2E497E6C19EE42E0C66BC8"
"OwnerKey" = "8:_799E46A9DE84423E9A42E8A667B8B40B"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_0207635732654CE6A87615796F8EEC39"
Expand Down Expand Up @@ -45,12 +51,6 @@
}
"Entry"
{
"MsmKey" = "8:_62778E3B93EA66E8423CFE35D880654B"
"OwnerKey" = "8:_AB07B12C770D4D4A9DE7E3A7F6280FFF"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_6351900FB5424C86AB017CEAB765135D"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
Expand All @@ -69,12 +69,6 @@
}
"Entry"
{
"MsmKey" = "8:_82E4C2532EEB39831247EDB4B6D917DC"
"OwnerKey" = "8:_AB07B12C770D4D4A9DE7E3A7F6280FFF"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_8533FAE6D43944078DAC051060E0DCFF"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
Expand Down Expand Up @@ -105,6 +99,18 @@
}
"Entry"
{
"MsmKey" = "8:_D22F61038ABB17E9902DAEEECA02B4EB"
"OwnerKey" = "8:_799E46A9DE84423E9A42E8A667B8B40B"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_E5943F519A7605D4A75B1464669B4546"
"OwnerKey" = "8:_799E46A9DE84423E9A42E8A667B8B40B"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_F531AEA8DF1F4306933CABB0BA61FBC4"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
Expand Down Expand Up @@ -196,6 +202,26 @@
}
"File"
{
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_015851A88B2E497E6C19EE42E0C66BC8"
{
"SourcePath" = "8:msdelta.dll"
"TargetName" = "8:msdelta.dll"
"Tag" = "8:"
"Folder" = "8:_77CCC7F3944A4B009D9231F8B41DFD6D"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_0207635732654CE6A87615796F8EEC39"
{
"SourcePath" = "8:..\\Doc\\alienfx-gui.md"
Expand Down Expand Up @@ -256,12 +282,12 @@
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_62778E3B93EA66E8423CFE35D880654B"
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_6351900FB5424C86AB017CEAB765135D"
{
"SourcePath" = "8:SETUPAPI.dll"
"TargetName" = "8:SETUPAPI.dll"
"SourcePath" = "8:..\\Doc\\LightFX.md"
"TargetName" = "8:LightFX.md"
"Tag" = "8:"
"Folder" = "8:_77CCC7F3944A4B009D9231F8B41DFD6D"
"Folder" = "8:_F547A8D6D49C432390AEA0D6A0C1CA97"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
Expand All @@ -272,16 +298,16 @@
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:TRUE"
"IsDependency" = "11:TRUE"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_6351900FB5424C86AB017CEAB765135D"
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_D22F61038ABB17E9902DAEEECA02B4EB"
{
"SourcePath" = "8:..\\Doc\\LightFX.md"
"TargetName" = "8:LightFX.md"
"SourcePath" = "8:RPCRT4.dll"
"TargetName" = "8:RPCRT4.dll"
"Tag" = "8:"
"Folder" = "8:_F547A8D6D49C432390AEA0D6A0C1CA97"
"Folder" = "8:_77CCC7F3944A4B009D9231F8B41DFD6D"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
Expand All @@ -293,15 +319,15 @@
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_82E4C2532EEB39831247EDB4B6D917DC"
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_E5943F519A7605D4A75B1464669B4546"
{
"SourcePath" = "8:HID.DLL"
"TargetName" = "8:HID.DLL"
"SourcePath" = "8:ntdll.dll"
"TargetName" = "8:ntdll.dll"
"Tag" = "8:"
"Folder" = "8:_39E2774D52CE4B619039352379796769"
"Folder" = "8:_77CCC7F3944A4B009D9231F8B41DFD6D"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
Expand All @@ -312,7 +338,7 @@
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:TRUE"
"Exclude" = "11:FALSE"
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
Expand Down Expand Up @@ -425,15 +451,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:AlienFX Tools"
"ProductCode" = "8:{F3F246EA-2C3E-4640-97A3-6245524517AE}"
"PackageCode" = "8:{1CA886A1-6619-4740-8C0A-1CE6D40BC598}"
"ProductCode" = "8:{BD48E611-1CB4-42DF-93CC-0BD3D779E16E}"
"PackageCode" = "8:{BE48C49F-9215-47C4-AAC7-B785E9AADAE5}"
"UpgradeCode" = "8:{EFC2D182-AE5E-4585-92D3-0759F77F59AA}"
"AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:5.0.3"
"ProductVersion" = "8:5.0.4"
"Manufacturer" = "8:T-Troll"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:https://github.com/T-Troll/alienfx-tools/discussions"
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Run any tool you need from this folder or start menu!
- `Alienware 17R5` (API v3)
- `Alienware 13R2` (API v2)
- `Alienware M14x` (API v1)
- `Alienware Arena R7` (API v0 (ACPI))

This tools can also support other Dell/Alienware devices:
- APIv0 - ACPI-controlled lights, 3 lights, 8-bit color,
Expand Down Expand Up @@ -93,4 +94,5 @@ Spectrum Analyzer is based on Tnbuig's [Spectrum-Analyzer-15.6.11](https://githu
FFT subroutine utilizes [Kiss FFT](https://sourceforge.net/projects/kissfft/) library.
DXGi Screen capture based on Bryal's [DXGCap](https://github.com/bryal/DXGCap) example.
Per-Key RGB devices testing and a lot of support by [rirozizo](https://github.com/rirozizo).
Aurora R7 testing by [Raoul Duke](https://github.com/raould).
Special thanks to [PhSMu](https://github.com/PhSMu) for ideas, testing and artwork.
10 changes: 8 additions & 2 deletions alienfan-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ NB: You should have hwacc.sys into the same folder.
- `Dell G5 SE` (AMD)
- 4 Power modes (one secret, but you can select it)
- 2 Temperature sensors
- `Alienware Aurora R7`
- 3 Lights
- 3 Fans
- 3 Temperature sensors
- 2 Power modes

## `alienfan-gui` usage

Expand Down Expand Up @@ -115,7 +120,7 @@ Avaliable commands:
- `setfans=<fan1>,<fan2>...` - Set fans RPM boost level (0..100 - in percent). Fan1 is for CPU fan, Fan2 for GPU one. Number of arguments should be the same as number of fans application detect
- `resetcolor` - Reset color system
- `setcolor=<mask>,r,g,b` - Set light(s) defined by mask to color
- `setcolormode=<mode>,<flag>` - Set light system mode
- `setcolormode=<brightness>,<flag>` - Set light system brightness and mode. Valid brightness values are 1,3,4,6,7,9,10,12,13,15.
- `direct=<id>,<subid>[,val,val]` - Issue direct Alienware interface command (see below)
- `directgpu=<id>,<value>` - Issue direct GPU interface command (see below)

Expand Down Expand Up @@ -167,6 +172,7 @@ MIT. You can use these tools for any non-commercial or commercial use, modify it
Idea, code and hardware support by T-Troll.
ACPI driver based on kdshk's [WindowsHwAccess](https://github.com/kdshk/WindowsHwAccess).
Kernel loading hack based on hfiref0x's [KDU](https://github.com/hfiref0x/KDU)
Special thanks to [DavidLapous](https://github.com/DavidLapous) for inspiration and advices!
Special thanks to [DavidLapous](https://github.com/DavidLapous) for inspiration and advices!
Thanks to [Raoul Duke](https://github.com/raould) for Aurora R7 testing.


Loading

0 comments on commit c3b6d90

Please sign in to comment.