Compare commits
No commits in common. "3dabf95bb0ab85c19f9f2418c4db1362f2e97cd2" and "905a278bb1bda9fc4e3a3ca1d4bcc7970f623330" have entirely different histories.
3dabf95bb0
...
905a278bb1
@ -1,6 +0,0 @@
|
|||||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CS/@EntryIndexedValue">CS</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GSI/@EntryIndexedValue">GSI</s:String>
|
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=appmanifest/@EntryIndexedValue">True</s:Boolean>
|
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=libraryfolders/@EntryIndexedValue">True</s:Boolean>
|
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=steamapps/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
|
@ -1,3 +0,0 @@
|
|||||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
|
||||||
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=OpenCS2hock_002FResources/@EntryIndexedValue">True</s:Boolean>
|
|
||||||
<s:Boolean x:Key="/Default/ResxEditorPersonal/Initialized/@EntryValue">True</s:Boolean></wpf:ResourceDictionary>
|
|
@ -1,50 +0,0 @@
|
|||||||
using System.Net;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace OpenCS2hock;
|
|
||||||
|
|
||||||
public class GSIServer
|
|
||||||
{
|
|
||||||
private HttpListener HttpListener { get; init; }
|
|
||||||
public delegate void OnMessageEventHandler(string content);
|
|
||||||
public event OnMessageEventHandler? OnMessage;
|
|
||||||
|
|
||||||
private bool _keepRunning = true;
|
|
||||||
public bool IsRunning { get; private set; }
|
|
||||||
|
|
||||||
public GSIServer(int port)
|
|
||||||
{
|
|
||||||
HttpListener = new HttpListener();
|
|
||||||
HttpListener.Prefixes.Add($"http://127.0.0.1:{port}/");
|
|
||||||
HttpListener.Start();
|
|
||||||
|
|
||||||
Thread connectionListener = new (HandleConnection);
|
|
||||||
connectionListener.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void HandleConnection()
|
|
||||||
{
|
|
||||||
while (_keepRunning)
|
|
||||||
{
|
|
||||||
HttpListenerContext context = await HttpListener.GetContextAsync();
|
|
||||||
HttpListenerRequest request = context.Request;
|
|
||||||
|
|
||||||
Console.WriteLine($"[{request.HttpMethod}] {request.Url} - {request.UserAgent}");
|
|
||||||
|
|
||||||
HttpResponseMessage responseMessage = new HttpResponseMessage(HttpStatusCode.Accepted);
|
|
||||||
context.Response.OutputStream.Write(Encoding.UTF8.GetBytes(responseMessage.ToString()));
|
|
||||||
|
|
||||||
StreamReader reader = new StreamReader(request.InputStream, request.ContentEncoding);
|
|
||||||
string content = await reader.ReadToEndAsync();
|
|
||||||
Console.WriteLine(content);
|
|
||||||
OnMessage?.Invoke(content);
|
|
||||||
}
|
|
||||||
HttpListener.Close();
|
|
||||||
IsRunning = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void Dispose()
|
|
||||||
{
|
|
||||||
_keepRunning = false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
using Microsoft.Win32;
|
|
||||||
|
|
||||||
namespace OpenCS2hock;
|
|
||||||
|
|
||||||
public static class Installer
|
|
||||||
{
|
|
||||||
public static void InstallGsi()
|
|
||||||
{
|
|
||||||
string installLocation = Path.Combine(GetInstallDirectory(), "game\\csgo\\cfg\\gamestate_integration_opencs2hock.cfg");
|
|
||||||
File.WriteAllText(installLocation, Resources.GSI_CFG_Content);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetInstallDirectory(int appId = 730)
|
|
||||||
{
|
|
||||||
string steamInstallation =
|
|
||||||
#pragma warning disable CA1416 //Registry only available on Windows
|
|
||||||
(string)(Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Valve\Steam", "SteamPath", null) ??
|
|
||||||
#pragma warning restore CA1416
|
|
||||||
throw new DirectoryNotFoundException("No Steam Installation found."));
|
|
||||||
string libraryFolderFilepath = Path.Combine(steamInstallation, "steamapps\\libraryfolders.vdf");
|
|
||||||
string? libraryPath = null;
|
|
||||||
string? appManifestFolderPath = null;
|
|
||||||
foreach (string line in File.ReadAllLines(libraryFolderFilepath))
|
|
||||||
if (line.Contains("path"))
|
|
||||||
libraryPath = line.Split("\"").Last(split => split.Length > 0);
|
|
||||||
else if (line.Contains($"\"{appId}\""))
|
|
||||||
appManifestFolderPath = Path.Combine(libraryPath!, $"steamapps\\appmanifest_{appId}.acf");
|
|
||||||
|
|
||||||
string installationPath = "";
|
|
||||||
if (appManifestFolderPath is null)
|
|
||||||
throw new DirectoryNotFoundException($"No {appId} Installation found.");
|
|
||||||
foreach(string line in File.ReadAllLines(appManifestFolderPath))
|
|
||||||
if (line.Contains("installdir"))
|
|
||||||
installationPath = Path.Combine(libraryPath!, "steamapps\\common", line.Split("\"").Last(split => split.Length > 0));
|
|
||||||
|
|
||||||
return installationPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
namespace OpenCS2hock;
|
|
||||||
|
|
||||||
public class OpenCS2hock
|
|
||||||
{
|
|
||||||
private GSIServer GSIServer { get; init; }
|
|
||||||
private List<Shocker> _shockers = new();
|
|
||||||
|
|
||||||
public OpenCS2hock()
|
|
||||||
{
|
|
||||||
Installer.InstallGsi();
|
|
||||||
this.GSIServer = new GSIServer(3000);
|
|
||||||
this.GSIServer.OnMessage += OnGSIMessage;
|
|
||||||
|
|
||||||
Thread runningThread = new(() =>
|
|
||||||
{
|
|
||||||
while (GSIServer.IsRunning)
|
|
||||||
Thread.Sleep(10);
|
|
||||||
});
|
|
||||||
runningThread.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnGSIMessage(string content)
|
|
||||||
{
|
|
||||||
string fileName = Path.Combine(Environment.CurrentDirectory, $"{DateTime.Now.ToLongTimeString().Replace(':','.')}.json");
|
|
||||||
File.WriteAllText(fileName, content);
|
|
||||||
Console.WriteLine(fileName);
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,19 +8,4 @@
|
|||||||
<RootNamespace>OpenCS2Hock</RootNamespace>
|
<RootNamespace>OpenCS2Hock</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Update="Resources.resx">
|
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
|
||||||
</EmbeddedResource>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="Resources.Designer.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -4,6 +4,6 @@ public class Program
|
|||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
new OpenCS2hock();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
88
OpenCS2hock/Resources.Designer.cs
generated
88
OpenCS2hock/Resources.Designer.cs
generated
@ -1,88 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// This code was generated by a tool.
|
|
||||||
//
|
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
|
||||||
// the code is regenerated.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace OpenCS2hock {
|
|
||||||
using System;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
|
||||||
/// </summary>
|
|
||||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
|
||||||
// class via a tool like ResGen or Visual Studio.
|
|
||||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
|
||||||
// with the /str option, or rebuild your VS project.
|
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
|
||||||
internal class Resources {
|
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
||||||
internal Resources() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the cached ResourceManager instance used by this class.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
|
||||||
get {
|
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OpenCS2Hock.Resources", typeof(Resources).Assembly);
|
|
||||||
resourceMan = temp;
|
|
||||||
}
|
|
||||||
return resourceMan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides the current thread's CurrentUICulture property for all
|
|
||||||
/// resource lookups using this strongly typed resource class.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Globalization.CultureInfo Culture {
|
|
||||||
get {
|
|
||||||
return resourceCulture;
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
resourceCulture = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to "OpenCS2hock"
|
|
||||||
///{
|
|
||||||
///"uri" "http://127.0.0.1:3000"
|
|
||||||
///"timeout" "5.0"
|
|
||||||
///"buffer" "0.1"
|
|
||||||
///"throttle" "0.5"
|
|
||||||
///"heartbeat" "60.0"
|
|
||||||
///"output"
|
|
||||||
/// {
|
|
||||||
/// "precision_time" "3"
|
|
||||||
/// "precision_position" "1"
|
|
||||||
/// "precision_vector" "3"
|
|
||||||
/// }
|
|
||||||
///"data"
|
|
||||||
/// {
|
|
||||||
/// "provider" "1" // general info about client being listened to: game name, appid, client steamid, etc.
|
|
||||||
/// "map" "1" // map, gamemode, and current match phase ('warmup', 'intermission', 'gameover', 'live') and current score
|
|
||||||
/// [rest of string was truncated]";.
|
|
||||||
/// </summary>
|
|
||||||
internal static string GSI_CFG_Content {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("GSI_CFG_Content", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>1.3</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<data name="GSI_CFG_Content" type="System.Resources.ResXFileRef">
|
|
||||||
<value>gamestate_integration_opencs2hock.cfg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
|
@ -1,14 +0,0 @@
|
|||||||
namespace OpenCS2hock;
|
|
||||||
|
|
||||||
public abstract class Shocker
|
|
||||||
{
|
|
||||||
public string ApiKey, Endpoint;
|
|
||||||
public enum ControlAction { Beep, Vibrate, Shock }
|
|
||||||
public abstract void Control(ControlAction action, byte intensity, short duration);
|
|
||||||
|
|
||||||
public Shocker(string endpoint, string apiKey)
|
|
||||||
{
|
|
||||||
this.Endpoint = endpoint;
|
|
||||||
this.ApiKey = apiKey;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
"OpenCS2hock"
|
|
||||||
{
|
|
||||||
"uri" "http://127.0.0.1:3000"
|
|
||||||
"timeout" "5.0"
|
|
||||||
"buffer" "0.1"
|
|
||||||
"throttle" "0.5"
|
|
||||||
"heartbeat" "60.0"
|
|
||||||
"output"
|
|
||||||
{
|
|
||||||
"precision_time" "3"
|
|
||||||
"precision_position" "1"
|
|
||||||
"precision_vector" "3"
|
|
||||||
}
|
|
||||||
"data"
|
|
||||||
{
|
|
||||||
"provider" "1" // general info about client being listened to: game name, appid, client steamid, etc.
|
|
||||||
"map" "1" // map, gamemode, and current match phase ('warmup', 'intermission', 'gameover', 'live') and current score
|
|
||||||
"round" "1" // round phase ('freezetime', 'over', 'live'), bomb state ('planted', 'exploded', 'defused'), and round winner (if any)
|
|
||||||
"player_id" "1" // player name, clan tag, observer slot (ie key to press to observe this player) and team
|
|
||||||
"player_state" "1" // player state for this current round such as health, armor, kills this round, etc.
|
|
||||||
"player_match_stats" "1" // player stats this match such as kill, assists, score, deaths and MVPs
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user