Skip to content

Commit

Permalink
Initial draft for PS module
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinGC94 committed Nov 27, 2022
1 parent 9c921e2 commit 7f8bed0
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 2 deletions.
46 changes: 46 additions & 0 deletions PsViveTool/Commands/GetViveFeatureCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System.Collections.Generic;
using System.Management.Automation;
using Albacore.ViVe;
using Albacore.ViVe.NativeStructs;
using Albacore.ViVe.NativeEnums;
using PsViveTool.Types;

namespace PsViveTool.Commands
{
[Cmdlet(VerbsCommon.Get, "ViveFeature")]
[OutputType(typeof(ViveFeature))]
public sealed class GetViveFeatureCommand : Cmdlet
{
[Parameter()]
public uint[] FeatureId { get; set; }

[Parameter()]
public RTL_FEATURE_CONFIGURATION_TYPE ConfigType { get; set; } = RTL_FEATURE_CONFIGURATION_TYPE.Runtime;

protected override void EndProcessing()
{
IList<RTL_FEATURE_CONFIGURATION> featuresToOutput;
if (FeatureId.Length == 0)
{
featuresToOutput = FeatureManager.QueryAllFeatureConfigurations(ConfigType);
}
else
{
featuresToOutput = new List<RTL_FEATURE_CONFIGURATION>(FeatureId.Length);
foreach (var id in FeatureId)
{
var foundFeature = FeatureManager.QueryFeatureConfiguration(id, ConfigType);
if (foundFeature != null)
{
featuresToOutput.Add((RTL_FEATURE_CONFIGURATION)foundFeature);
}
}
}

foreach (var feature in featuresToOutput)
{
WriteObject(new ViveFeature(feature));
}
}
}
}
26 changes: 26 additions & 0 deletions PsViveTool/Commands/SetViveFeatureCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Collections.Generic;
using System.Management.Automation;
using Albacore.ViVe;
using Albacore.ViVe.NativeStructs;
using Albacore.ViVe.NativeEnums;
using PsViveTool.Types;

namespace PsViveTool.Commands
{
[Cmdlet(VerbsCommon.Set, "ViveFeature")]
public sealed class SetViveFeatureCommand : Cmdlet
{
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = "SetByFeatureId")]
public uint[] FeatureId { get; set; }

[Parameter(Mandatory = true, ParameterSetName = "SetByFeatureName")]
public string[] FeatureName { get; set; }

[Parameter(Mandatory = true)]
public RTL_FEATURE_ENABLED_STATE FeatureState { get; set; }

protected override void EndProcessing()
{
}
}
}
15 changes: 15 additions & 0 deletions PsViveTool/PsViveTool.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="PowerShellStandard.Library" Version="5.1.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ViVe\ViVe.csproj" />
</ItemGroup>

</Project>
27 changes: 27 additions & 0 deletions PsViveTool/Types/ViveFeature.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Albacore.ViVe.NativeEnums;
using Albacore.ViVe.NativeStructs;

namespace PsViveTool.Types
{
internal class ViveFeature
{
public ViveFeature(RTL_FEATURE_CONFIGURATION featureStruct)
{
FeatureName = "";
FeatureId = featureStruct.FeatureId;
Priority = featureStruct.Priority;
State = featureStruct.EnabledState;
Variant = featureStruct.Variant;
PayloadKind = featureStruct.VariantPayloadKind;
Payload = featureStruct.VariantPayload;
}

public string FeatureName { get; set; }
public uint FeatureId { get; set; }
public RTL_FEATURE_CONFIGURATION_PRIORITY Priority { get; set; }
public RTL_FEATURE_ENABLED_STATE State { get; set; }
public uint Variant { get; set; }
public RTL_FEATURE_VARIANT_PAYLOAD_KIND PayloadKind { get; set; }
public uint Payload { get; set; }
}
}
10 changes: 8 additions & 2 deletions ViVe.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29306.81
# Visual Studio Version 17
VisualStudioVersion = 17.5.33103.201
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ViVe", "ViVe\ViVe.csproj", "{80DCDA4D-8022-4740-8CCF-459DD3FE6F72}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ViVeTool", "ViVeTool\ViVeTool.csproj", "{4DAAB723-3613-4133-AE54-646133538E44}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PsViveTool", "PsViveTool\PsViveTool.csproj", "{6F529E05-B81C-4447-B7DA-E7E2BC2E2E85}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,6 +23,10 @@ Global
{4DAAB723-3613-4133-AE54-646133538E44}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4DAAB723-3613-4133-AE54-646133538E44}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4DAAB723-3613-4133-AE54-646133538E44}.Release|Any CPU.Build.0 = Release|Any CPU
{6F529E05-B81C-4447-B7DA-E7E2BC2E2E85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6F529E05-B81C-4447-B7DA-E7E2BC2E2E85}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6F529E05-B81C-4447-B7DA-E7E2BC2E2E85}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6F529E05-B81C-4447-B7DA-E7E2BC2E2E85}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit 7f8bed0

Please sign in to comment.