Skip to content

Commit 6242ef9

Browse files
committed
Merge branch 'dev'
2 parents 2d60231 + 30172a7 commit 6242ef9

File tree

13 files changed

+218
-174
lines changed

13 files changed

+218
-174
lines changed

VRCOSC.Desktop/VRCOSC.Desktop.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
<ApplicationIcon>game.ico</ApplicationIcon>
77
<ApplicationManifest>app.manifest</ApplicationManifest>
88
<Version>0.0.0</Version>
9-
<FileVersion>2023.1022.0</FileVersion>
9+
<FileVersion>2023.1220.0</FileVersion>
1010
<Title>VRCOSC</Title>
1111
<Authors>VolcanicArts</Authors>
1212
<Company>VolcanicArts</Company>
1313
<Nullable>enable</Nullable>
14-
<AssemblyVersion>2023.1022.0</AssemblyVersion>
14+
<AssemblyVersion>2023.1220.0</AssemblyVersion>
1515
</PropertyGroup>
1616
<ItemGroup Label="Project References">
1717
<ProjectReference Include="..\VRCOSC.Game\VRCOSC.Game.csproj" />

VRCOSC.Game/ChatBox/Clips/Clip.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,6 @@ private void removeInvalidStates(List<ClipState> localStates)
214214
var currentStates = AssociatedModules.Where(moduleName => appManager.ModuleManager.GetModule(moduleName)!.Enabled.Value && chatBoxManager.StateValues.ContainsKey(moduleName) && chatBoxManager.StateValues[moduleName] is not null).Select(moduleName => chatBoxManager.StateValues[moduleName]).ToList();
215215
currentStates.Sort();
216216

217-
if (!currentStates.Any()) return;
218-
219217
foreach (var clipState in localStates.ToImmutableList())
220218
{
221219
var clipStateStates = clipState.StateNames;

VRCOSC.Game/OSC/VRChat/VRChatOscClient.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Net.Http;
77
using System.Threading.Tasks;
88
using Newtonsoft.Json;
9+
using osu.Framework.IO.Network;
910
using osu.Framework.Logging;
1011
using VRC.OSCQuery;
1112
using VRCOSC.Game.OSC.Client;
@@ -72,7 +73,8 @@ public void Reset()
7273
{
7374
if (QueryPort is null) return null;
7475

75-
var url = $"http://127.0.0.1:{QueryPort}/avatar/parameters/{parameterName}";
76+
var parameterNameEncoded = UrlEncoding.UrlEncode(parameterName);
77+
var url = $"http://127.0.0.1:{QueryPort}/avatar/parameters/{parameterNameEncoded}";
7678

7779
var response = await client.GetAsync(new Uri(url));
7880
var content = await response.Content.ReadAsStringAsync();

VRCOSC.Game/OpenVR/OVRHelper.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) VolcanicArts. Licensed under the GPL-3.0 License.
1+
// Copyright (c) VolcanicArts. Licensed under the GPL-3.0 License.
22
// See the LICENSE file in the repository root for full license text.
33

44
using System;
@@ -108,6 +108,8 @@ internal static IEnumerable<uint> GetIndexesForTrackedDeviceClass(ETrackedDevice
108108

109109
internal static bool GetBoolTrackedDeviceProperty(uint index, ETrackedDeviceProperty property)
110110
{
111+
if (index == Valve.VR.OpenVR.k_unTrackedDeviceIndexInvalid) return default;
112+
111113
var error = new ETrackedPropertyError();
112114
var value = Valve.VR.OpenVR.System.GetBoolTrackedDeviceProperty(index, property, ref error);
113115

@@ -119,6 +121,8 @@ internal static bool GetBoolTrackedDeviceProperty(uint index, ETrackedDeviceProp
119121

120122
internal static int GetInt32TrackedDeviceProperty(uint index, ETrackedDeviceProperty property)
121123
{
124+
if (index == Valve.VR.OpenVR.k_unTrackedDeviceIndexInvalid) return default;
125+
122126
var error = new ETrackedPropertyError();
123127
var value = Valve.VR.OpenVR.System.GetInt32TrackedDeviceProperty(index, property, ref error);
124128

@@ -130,6 +134,8 @@ internal static int GetInt32TrackedDeviceProperty(uint index, ETrackedDeviceProp
130134

131135
internal static float GetFloatTrackedDeviceProperty(uint index, ETrackedDeviceProperty property)
132136
{
137+
if (index == Valve.VR.OpenVR.k_unTrackedDeviceIndexInvalid) return default;
138+
133139
var error = new ETrackedPropertyError();
134140
var value = Valve.VR.OpenVR.System.GetFloatTrackedDeviceProperty(index, property, ref error);
135141

@@ -143,6 +149,8 @@ internal static float GetFloatTrackedDeviceProperty(uint index, ETrackedDevicePr
143149

144150
internal static string GetStringTrackedDeviceProperty(uint index, ETrackedDeviceProperty property)
145151
{
152+
if (index == Valve.VR.OpenVR.k_unTrackedDeviceIndexInvalid) return string.Empty;
153+
146154
var error = new ETrackedPropertyError();
147155
sb.Clear();
148156
Valve.VR.OpenVR.System.GetStringTrackedDeviceProperty(index, property, sb, Valve.VR.OpenVR.k_unMaxPropertyStringSize, ref error);

VRCOSC.Game/Providers/Hardware/IComponent.cs renamed to VRCOSC.Game/Providers/Hardware/Components.cs

Lines changed: 16 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -3,80 +3,50 @@
33

44
using System;
55
using System.Collections.Generic;
6+
using System.Linq;
67
using LibreHardwareMonitor.Hardware;
78

89
namespace VRCOSC.Game.Providers.Hardware;
910

10-
public class SensorInfoList
11-
{
12-
public readonly List<SensorInfo> InfoList = new();
13-
14-
public SensorInfoList(SensorType type, params string[] names)
15-
{
16-
foreach (var name in names) InfoList.Add(new SensorInfo(type, name));
17-
}
18-
}
11+
public record SensorPair(SensorType Type, string Name);
1912

2013
public class SensorInfo
2114
{
22-
public readonly string Name;
23-
public readonly SensorType Type;
15+
public readonly List<SensorPair> Pairs = new();
2416

25-
public SensorInfo(SensorType type, string name)
17+
public SensorInfo(SensorType type, params string[] names)
2618
{
27-
Type = type;
28-
Name = name;
19+
foreach (var name in names) Pairs.Add(new SensorPair(type, name));
2920
}
3021
}
3122

3223
public abstract class HardwareComponent
3324
{
3425
protected virtual SensorInfo LoadInfo => throw new NotImplementedException();
3526

36-
public readonly int Id;
37-
3827
public float Usage { get; private set; }
3928

40-
protected HardwareComponent(int id)
41-
{
42-
Id = id;
43-
}
44-
45-
protected bool GetIntValue(ISensor sensor, SensorInfoList infoList, out int value)
29+
protected static bool GetIntValue(ISensor sensor, SensorInfo info, out int value)
4630
{
47-
foreach (var info in infoList.InfoList)
31+
if (!GetFloatValue(sensor, info, out var floatValue))
4832
{
49-
if (!GetIntValue(sensor, info, out var intValue)) continue;
50-
51-
value = intValue;
33+
value = (int)MathF.Round(floatValue);
5234
return true;
5335
}
5436

5537
value = 0;
5638
return false;
5739
}
5840

59-
protected bool GetIntValue(ISensor sensor, SensorInfo info, out int value)
41+
protected static bool GetFloatValue(ISensor sensor, SensorInfo info, out float value)
6042
{
61-
if (GetFloatValue(sensor, info, out var valueFloat))
62-
{
63-
value = (int)Math.Round(valueFloat);
64-
return true;
65-
}
66-
67-
value = 0;
68-
return false;
69-
}
70-
71-
protected bool GetFloatValue(ISensor sensor, SensorInfo info, out float value)
72-
{
73-
if (sensor.Name == info.Name && sensor.SensorType == info.Type)
43+
if (info.Pairs.Any(pair => sensor.SensorType == pair.Type && sensor.Name == pair.Name))
7444
{
7545
value = sensor.Value ?? 0f;
7646
return true;
7747
}
7848

79-
value = 0f;
49+
value = 0;
8050
return false;
8151
}
8252

@@ -90,16 +60,11 @@ public abstract class CPU : HardwareComponent
9060
{
9161
protected override SensorInfo LoadInfo => new(SensorType.Load, "CPU Total");
9262
protected virtual SensorInfo PowerInfo => throw new NotImplementedException();
93-
protected virtual SensorInfoList TemperatureInfo => throw new NotImplementedException();
63+
protected virtual SensorInfo TemperatureInfo => throw new NotImplementedException();
9464

9565
public int Power { get; private set; }
9666
public int Temperature { get; private set; }
9767

98-
protected CPU(int id)
99-
: base(id)
100-
{
101-
}
102-
10368
public override void Update(ISensor sensor)
10469
{
10570
base.Update(sensor);
@@ -111,24 +76,14 @@ public override void Update(ISensor sensor)
11176
public class IntelCPU : CPU
11277
{
11378
protected override SensorInfo PowerInfo => new(SensorType.Power, "CPU Package");
114-
protected override SensorInfoList TemperatureInfo => new(SensorType.Temperature, "CPU Package");
115-
116-
public IntelCPU(int id)
117-
: base(id)
118-
{
119-
}
79+
protected override SensorInfo TemperatureInfo => new(SensorType.Temperature, "CPU Package");
12080
}
12181

12282
// ReSharper disable once InconsistentNaming
12383
public class AMDCPU : CPU
12484
{
12585
protected override SensorInfo PowerInfo => new(SensorType.Power, "Package");
126-
protected override SensorInfoList TemperatureInfo => new(SensorType.Temperature, "Core (Tdie)", "Core (Tctl/Tdie)", "CPU Cores");
127-
128-
public AMDCPU(int id)
129-
: base(id)
130-
{
131-
}
86+
protected override SensorInfo TemperatureInfo => new(SensorType.Temperature, "Core (Tdie)", "Core (Tctl/Tdie)", "CPU Cores");
13287
}
13388

13489
public class GPU : HardwareComponent
@@ -137,7 +92,7 @@ public class GPU : HardwareComponent
13792
private readonly SensorInfo powerInfo = new(SensorType.Power, "GPU Package");
13893
private readonly SensorInfo temperatureInfo = new(SensorType.Temperature, "GPU Core");
13994
private readonly SensorInfo memoryFreeInfo = new(SensorType.SmallData, "GPU Memory Free");
140-
private readonly SensorInfo memoryUsedINfo = new(SensorType.SmallData, "GPU Memory Used");
95+
private readonly SensorInfo memoryUsedInfo = new(SensorType.SmallData, "GPU Memory Used", "D3D Dedicated Memory Used");
14196
private readonly SensorInfo memoryTotalInfo = new(SensorType.SmallData, "GPU Memory Total");
14297

14398
public int Power { get; private set; }
@@ -147,18 +102,13 @@ public class GPU : HardwareComponent
147102
public float MemoryTotal { get; private set; }
148103
public float MemoryUsage => MemoryUsed / MemoryTotal;
149104

150-
public GPU(int id)
151-
: base(id)
152-
{
153-
}
154-
155105
public override void Update(ISensor sensor)
156106
{
157107
base.Update(sensor);
158108
if (GetIntValue(sensor, powerInfo, out var powerValue)) Power = powerValue;
159109
if (GetIntValue(sensor, temperatureInfo, out var temperatureValue)) Temperature = temperatureValue;
160110
if (GetFloatValue(sensor, memoryFreeInfo, out var memoryFreeValue)) MemoryFree = memoryFreeValue;
161-
if (GetFloatValue(sensor, memoryUsedINfo, out var memoryUsedValue)) MemoryUsed = memoryUsedValue;
111+
if (GetFloatValue(sensor, memoryUsedInfo, out var memoryUsedValue)) MemoryUsed = memoryUsedValue;
162112
if (GetFloatValue(sensor, memoryTotalInfo, out var memoryTotalValue)) MemoryTotal = memoryTotalValue;
163113
}
164114
}
@@ -173,11 +123,6 @@ public class RAM : HardwareComponent
173123
public float Available { get; private set; }
174124
public float Total => Used + Available;
175125

176-
public RAM()
177-
: base(0)
178-
{
179-
}
180-
181126
public override void Update(ISensor sensor)
182127
{
183128
base.Update(sensor);

0 commit comments

Comments
 (0)