Skip to content

Commit

Permalink
Add additional Legion Go System Model for detection (83E1) (Valkirie#313
Browse files Browse the repository at this point in the history
)

* Add additional Legion Go System Model for detection (83E1)

* Add support for Win32_ComputerSystem:Model => SystemModel

Now we can pull Legion Go System Model value: 83E1
  • Loading branch information
Valkirie authored Jun 10, 2024
1 parent 18f970a commit 410759d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
14 changes: 13 additions & 1 deletion HandheldCompanion/Devices/IDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ public static IDevice GetCurrent()
var ManufacturerName = MotherboardInfo.Manufacturer.ToUpper();
var ProductName = MotherboardInfo.Product;
var SystemName = MotherboardInfo.SystemName;
var SystemModel = MotherboardInfo.SystemModel;
var Version = MotherboardInfo.Version;
var Processor = MotherboardInfo.ProcessorName;
var NumberOfCores = MotherboardInfo.NumberOfCores;
Expand Down Expand Up @@ -482,9 +483,20 @@ public static IDevice GetCurrent()
switch (ProductName)
{
case "LNVNB161216":
case "83E1":
device = new LegionGo();
break;

// Weird...
case "INVALID":
{
switch (SystemModel)
{
case "83E1":
device = new LegionGo();
break;
}
}
break;
}
}
break;
Expand Down
15 changes: 14 additions & 1 deletion HandheldCompanion/Misc/MotherboardInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ public static class MotherboardInfo
private static ManagementObjectCollection? displayCollection;

private static readonly ManagementObjectSearcher videoControllerSearcher = new("root\\CIMV2", "SELECT * FROM Win32_VideoController");
private static ManagementObjectCollection? videoControllerCollection;
private static ManagementObjectCollection? videoControllerCollection;

private static readonly ManagementObjectSearcher computerSearcher = new("root\\CIMV2", "SELECT * FROM Win32_ComputerSystem");
private static ManagementObjectCollection? computerCollection;

private static object cacheLock = new();
private static Dictionary<string, object> cache = new();
Expand All @@ -47,6 +50,7 @@ static MotherboardInfo()
{ "processor", new(processorCollection, processorSearcher) },
{ "display", new(displayCollection, displaySearcher) },
{ "video", new(videoControllerCollection, videoControllerSearcher) },
{ "computer", new(computerCollection, computerSearcher) },
};

// unused
Expand Down Expand Up @@ -108,6 +112,15 @@ public static string Model
{
return Convert.ToString(queryCacheValue("baseboard", "Model"));
}
}

// unused
public static string SystemModel
{
get
{
return Convert.ToString(queryCacheValue("computer", "Model"));
}
}

public static int NumberOfCores
Expand Down

0 comments on commit 410759d

Please sign in to comment.