Compare commits

...

33 Commits
1.2 ... master

Author SHA1 Message Date
c6bd342e87 Merge remote-tracking branch 'origin/master' 2024-02-12 01:37:32 +01:00
82e14c8b9e Use do-while instead of convoluted setups. 2024-02-12 01:37:28 +01:00
3fe43b6e63 Use do-while instead of convoluted setups. 2024-02-12 01:23:44 +01:00
4c7a3c9069 Serial only on Windows check 2024-02-12 01:23:07 +01:00
fcb5bf0a68 Cleanup 2024-02-12 01:22:46 +01:00
3659e357f2 Dependency Update
Less convoluted json.
2024-02-11 23:38:04 +01:00
eb732aad13 Update Dependency GlaxLogger 2024-02-10 20:56:06 +01:00
66afd442da Update Dependencies 2024-02-10 20:50:44 +01:00
2182e08f5e Log 2024-02-10 20:41:23 +01:00
3871fbc76e Update dependencies 2024-02-04 17:50:10 +01:00
2bd2e5ba0a Add Open Shock Serial 2024-01-20 21:41:47 +01:00
d59543297a Update README.md 2024-01-19 03:14:53 +01:00
92cc79f707 Improved Setup
Update Dependency
2024-01-19 03:08:03 +01:00
6778375f43 Fix Dependency 2024-01-19 02:22:17 +01:00
0dcee037fc Update Readme 2024-01-19 02:22:12 +01:00
ee0ca69475 Fix wrong order of parameters 2024-01-19 02:13:25 +01:00
18d3b6bf66 Update Dependency Cshocker
Update Dependency CS2GSI
Update README
OpenShock now automatically gets shockerIds
2024-01-19 02:06:26 +01:00
d040995051 Dictionary 2024-01-19 01:55:21 +01:00
dbb0bcd89f ConfigurationValid() tobeimplemented 2024-01-19 01:55:15 +01:00
968c3a5c37 Add PiShockHttp 2024-01-19 01:43:04 +01:00
4039455bfd Update Dependecy CShocker 2024-01-19 01:42:47 +01:00
b196f62111 Update Readme... 2024-01-18 18:16:50 +01:00
b085de2b39 Update Readme 2024-01-18 18:16:10 +01:00
ba8b76bfba Update Readme 2024-01-18 18:15:11 +01:00
0f62e9e9c9 Fix setup 2024-01-18 00:21:51 +01:00
41a433bf3f Version 3:
CS2GSI and CShocker libraries
More extensive options for Events
Setup on first start
2024-01-18 00:06:39 +01:00
fa6a8d4e15 Update Dependency, Readme 2024-01-16 04:43:07 +01:00
96443f3c0a Update Readme 2024-01-16 01:36:06 +01:00
c7b9b6bc35 Update Readme 2024-01-16 01:35:25 +01:00
4e30b7f9d8 Update Readme 2024-01-16 01:22:53 +01:00
9f961f2c65 Add OnDamageTaken 2024-01-16 01:20:41 +01:00
f01d721281 Add Overwrite to Shocker.Control for intensity and duration 2024-01-16 01:20:28 +01:00
6a862fa814 Use CS2GSI 2024-01-16 00:53:01 +01:00
19 changed files with 553 additions and 586 deletions

View File

@ -4,5 +4,8 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=appmanifest/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=freezetime/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=libraryfolders/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=NYAA/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=OpenCS2hock/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Sharecode/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=steamapps/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=steamid/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -1,3 +1,10 @@
<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/AddReferences/RecentPaths/=C_003A_005CUsers_005CGlax_005CRiderProjects_005CCShocker_005CCShocker_005Cbin_005CDebug_005Cnet7_002E0_005CCShocker_002Edll/@EntryIndexedValue">True</s:Boolean>
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt;&#xD;
&lt;Assembly Path="C:\Users\Glax\RiderProjects\CShocker\CShocker\bin\Debug\net7.0\CShocker.dll" /&gt;&#xD;
&lt;/AssemblyExplorer&gt;</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=b6376c03_002D06ba_002D424d_002Db00f_002Dbee38277f47a/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
&lt;Solution /&gt;&#xD;
&lt;/SessionState&gt;</s:String>
<s:Boolean x:Key="/Default/ResxEditorPersonal/Initialized/@EntryValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -1,72 +0,0 @@
using Newtonsoft.Json.Linq;
namespace OpenCS2hock;
internal class CS2MessageHandler
{
internal delegate void CS2EventHandler();
internal event CS2EventHandler? OnKill;
internal event CS2EventHandler? OnDeath;
internal event CS2EventHandler? OnRoundStart;
internal event CS2EventHandler? OnRoundEnd;
internal event CS2EventHandler? OnRoundWin;
internal event CS2EventHandler? OnRoundLoss;
internal void HandleCS2Message(string message, string mySteamId)
{
JObject messageJson = JObject.Parse(message);
string? previousSteamId = messageJson.SelectToken("previously.player.steamid", false)?.Value<string>();
string? currentSteamId = messageJson.SelectToken("player.steamid", false)?.Value<string>();
RoundState currentRoundState = ParseRoundStateFromString(messageJson.SelectToken("round.phase", false)?.Value<string>());
RoundState previousRoundState = ParseRoundStateFromString(messageJson.SelectToken("previously.round.phase", false)?.Value<string>());
if(previousRoundState == RoundState.Over && currentRoundState == RoundState.Live)
OnRoundStart?.Invoke();
if(previousRoundState == RoundState.Live && currentRoundState == RoundState.FreezeTime)
OnRoundEnd?.Invoke();
if(previousRoundState == RoundState.Live && currentRoundState == RoundState.Over)
OnRoundEnd?.Invoke();
Team playerTeam = ParseTeamFromString(messageJson.SelectToken("player.team", false)?.Value<string>());
Team winnerTeam = ParseTeamFromString(messageJson.SelectToken("round.win_team", false)?.Value<string>());
if(winnerTeam != Team.None && playerTeam != Team.None && playerTeam == winnerTeam)
OnRoundWin?.Invoke();
else if(winnerTeam != Team.None && playerTeam != Team.None && playerTeam != winnerTeam)
OnRoundLoss?.Invoke();
int? previousDeaths = messageJson.SelectToken("previously.player.match_stats.deaths", false)?.Value<int>();
int? currentDeaths = messageJson.SelectToken("player.match_stats.deaths", false)?.Value<int>();
if(previousSteamId is null && currentSteamId == mySteamId && currentDeaths > previousDeaths)
OnDeath?.Invoke();
int? previousKills = messageJson.SelectToken("previously.player.match_stats.kills", false)?.Value<int>();
int? currentKills = messageJson.SelectToken("player.match_stats.kills", false)?.Value<int>();
if(previousSteamId is null && currentSteamId == mySteamId && currentKills > previousKills)
OnKill?.Invoke();
}
private RoundState ParseRoundStateFromString(string? str)
{
return str switch
{
"live" => RoundState.Live,
"freezetime" => RoundState.FreezeTime,
"over" => RoundState.Over,
_ => RoundState.Unknown
};
}
private Team ParseTeamFromString(string? str)
{
return str switch
{
"T" => Team.T,
"CT" => Team.CT,
_ => Team.None
};
}
private enum RoundState {FreezeTime, Live, Over, Unknown}
private enum Team {T, CT, None}
}

View File

@ -0,0 +1,59 @@
using CShocker.Devices.Abstract;
using CShocker.Devices.Additional;
using CShocker.Shockers.Abstract;
using CShocker.Shockers.Additional;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
namespace OpenCS2hock;
public struct Configuration
{
public LogLevel LogLevel = LogLevel.Information;
public List<ShockerAction> ShockerActions { get; init; }
public List<Api> Apis { get; init; }
public Dictionary<int, Shocker> Shockers { get; init; }
public Configuration()
{
ShockerActions = new ();
Apis = new();
Shockers = new();
}
public override string ToString()
{
return $"Loglevel: {Enum.GetName(typeof(LogLevel), LogLevel)}\n" +
$"Apis:\n{string.Join("\n---\n", Apis)}\n" +
$"Shockers:\n{string.Join("\n---\n", Shockers)}\n" +
$"Actions:\n{string.Join("\n---\n", ShockerActions)}\n";
}
internal static Configuration GetConfigurationFromFile(string? path = null, ILogger? logger = null)
{
string settingsFilePath = path ?? "config.json";
Configuration c;
if (!File.Exists(settingsFilePath))
c = Setup.Run().SaveConfiguration();
else
c = JsonConvert.DeserializeObject<Configuration>(File.ReadAllText(settingsFilePath), new ApiJsonConverter(), new ShockerJsonConverter());
if (!c.ConfigurationValid())
throw new Exception("Configuration validation failed.");
return c;
}
internal Configuration SaveConfiguration(string? path = null)
{
string settingsFilePath = path ?? "config.json";
File.WriteAllText(settingsFilePath, JsonConvert.SerializeObject(this, Formatting.Indented));
return this;
}
private bool ConfigurationValid()
{
return true; //TODO Check values
}
}

View File

@ -1,17 +0,0 @@
namespace OpenCS2hock;
internal class ConfiguredInteger
{
private readonly int _min, _max;
internal ConfiguredInteger(int min = 0, int max = 50)
{
this._min = min;
this._max = max;
}
internal int GetValue()
{
return Random.Shared.Next(_min, _max);
}
}

View File

@ -1,51 +0,0 @@
using System.Net;
using System.Text;
namespace OpenCS2hock;
internal class GSIServer
{
private HttpListener HttpListener { get; init; }
internal delegate void OnMessageEventHandler(string content);
internal event OnMessageEventHandler? OnMessage;
private bool _keepRunning = true;
internal bool IsRunning { get; private set; }
internal GSIServer(int port)
{
HttpListener = new HttpListener();
HttpListener.Prefixes.Add($"http://127.0.0.1:{port}/");
HttpListener.Start();
Thread connectionListener = new (HandleConnection);
connectionListener.Start();
IsRunning = true;
}
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 (HttpStatusCode.Accepted);
context.Response.OutputStream.Write(Encoding.UTF8.GetBytes(responseMessage.ToString()));
StreamReader reader = new (request.InputStream, request.ContentEncoding);
string content = await reader.ReadToEndAsync();
OnMessage?.Invoke(content);
}
HttpListener.Close();
IsRunning = false;
}
internal void Dispose()
{
_keepRunning = false;
}
}

View File

@ -1,59 +0,0 @@
using Microsoft.Win32;
using Newtonsoft.Json;
namespace OpenCS2hock;
public static class Installer
{
internal static Settings GetSettings(string? path = null)
{
string settingsFilePath = path ?? "config.json";
if (!File.Exists(settingsFilePath))
File.WriteAllText(settingsFilePath, JsonConvert.SerializeObject(new Settings(), Formatting.Indented));
return JsonConvert.DeserializeObject<Settings>(File.ReadAllText(settingsFilePath));
}
internal static List<Shocker> GetShockers(Settings settings)
{
List<Shocker> shockers = new();
shockers.Add(new OpenShock(settings.OpenShockSettings.Endpoint, settings.OpenShockSettings.ApiKey,
settings.OpenShockSettings.Shockers,
new ConfiguredInteger(settings.IntensityRange.Min, settings.IntensityRange.Max),
new ConfiguredInteger(settings.DurationRange.Min, settings.DurationRange.Max)));
return shockers;
}
internal static void InstallGsi()
{
string installLocation = Path.Combine(GetInstallDirectory(), "game\\csgo\\cfg\\gamestate_integration_opencs2hock.cfg");
File.WriteAllText(installLocation, Resources.GSI_CFG_Content);
}
private 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;
}
}

View File

@ -1,69 +1,76 @@
namespace OpenCS2hock;
using Microsoft.Extensions.Logging;
using CS2GSI;
using GlaxLogger;
using CS2Event = CS2GSI.CS2Event;
namespace OpenCS2hock;
// ReSharper disable once InconsistentNaming
public class OpenCS2hock
{
private GSIServer GSIServer { get; init; }
private readonly CS2MessageHandler _cs2MessageHandler;
private readonly List<Shocker> _shockers;
private readonly Settings _settings;
private readonly CS2GSI.CS2GSI _cs2GSI;
private readonly Configuration _configuration;
private readonly Logger? _logger;
public OpenCS2hock(string? settingsPath = null)
public OpenCS2hock(string? configPath = null, bool editConfig = false, Logger? logger = null)
{
_settings = Installer.GetSettings(settingsPath);
this._shockers = Installer.GetShockers(_settings);
Console.WriteLine(_settings);
Installer.InstallGsi();
this._cs2MessageHandler = new CS2MessageHandler();
this._logger = logger;
this._logger?.Log(LogLevel.Information, "Starting OpenCS2hock...");
this._logger?.Log(LogLevel.Information, "Loading Configuration...");
this._configuration = Configuration.GetConfigurationFromFile(configPath, this._logger);
if(editConfig)
Setup.EditConfig(ref this._configuration);
this._logger?.Log(LogLevel.Information, $"Loglevel set to {_configuration.LogLevel}");
this._logger?.UpdateLogLevel(_configuration.LogLevel);
this._logger?.Log(LogLevel.Information, _configuration.ToString());
this._cs2GSI = new CS2GSI.CS2GSI(_logger);
this.SetupEventHandlers();
this.GSIServer = new GSIServer(3000);
this.GSIServer.OnMessage += OnGSIMessage;
Thread runningThread = new(() =>
{
while (GSIServer.IsRunning)
Thread.Sleep(10);
});
runningThread.Start();
while(this._cs2GSI.IsRunning)
Thread.Sleep(10);
}
private void SetupEventHandlers()
{
foreach (Shocker shocker in this._shockers)
this._logger?.Log(LogLevel.Information, "Setting up EventHandlers...");
foreach (ShockerAction shockerAction in this._configuration.ShockerActions)
{
foreach (KeyValuePair<string, string> kv in _settings.Actions)
{
switch (kv.Key)
switch (shockerAction.TriggerEvent)
{
case "OnKill":
this._cs2MessageHandler.OnKill += () => shocker.Control(Settings.StringToAction(kv.Value));
break;
case "OnDeath":
this._cs2MessageHandler.OnDeath += () => shocker.Control(Settings.StringToAction(kv.Value));
break;
case "OnRoundStart":
this._cs2MessageHandler.OnRoundStart += () => shocker.Control(Settings.StringToAction(kv.Value));
break;
case "OnRoundEnd":
this._cs2MessageHandler.OnRoundEnd += () => shocker.Control(Settings.StringToAction(kv.Value));
break;
case "OnRoundLoss":
this._cs2MessageHandler.OnRoundLoss += () => shocker.Control(Settings.StringToAction(kv.Value));
break;
case "OnRoundWin":
this._cs2MessageHandler.OnRoundWin += () => shocker.Control(Settings.StringToAction(kv.Value));
break;
case CS2Event.OnKill: this._cs2GSI.OnKill += args => EventHandler(args, shockerAction); break;
case CS2Event.OnHeadshot: this._cs2GSI.OnHeadshot += args => EventHandler(args, shockerAction); break;
case CS2Event.OnDeath: this._cs2GSI.OnDeath += args => EventHandler(args, shockerAction); break;
case CS2Event.OnFlashed: this._cs2GSI.OnFlashed += args => EventHandler(args, shockerAction); break;
case CS2Event.OnBurning: this._cs2GSI.OnBurning += args => EventHandler(args, shockerAction); break;
case CS2Event.OnSmoked: this._cs2GSI.OnSmoked += args => EventHandler(args, shockerAction); break;
case CS2Event.OnRoundStart: this._cs2GSI.OnRoundStart += args => EventHandler(args,shockerAction); break;
case CS2Event.OnRoundOver: this._cs2GSI.OnRoundOver += args => EventHandler(args, shockerAction); break;
case CS2Event.OnRoundWin: this._cs2GSI.OnRoundWin += args => EventHandler(args, shockerAction); break;
case CS2Event.OnRoundLoss: this._cs2GSI.OnRoundLoss += args => EventHandler(args, shockerAction); break;
case CS2Event.OnDamageTaken: this._cs2GSI.OnDamageTaken += args => EventHandler(args, shockerAction); break;
case CS2Event.OnMatchStart: this._cs2GSI.OnMatchStart += args => EventHandler(args, shockerAction); break;
case CS2Event.OnMatchOver: this._cs2GSI.OnMatchOver += args => EventHandler(args, shockerAction); break;
case CS2Event.OnMoneyChange: this._cs2GSI.OnMoneyChange += args => EventHandler(args, shockerAction); break;
case CS2Event.OnHealthChange: this._cs2GSI.OnHealthChange += args => EventHandler(args, shockerAction); break;
case CS2Event.OnArmorChange: this._cs2GSI.OnArmorChange += args => EventHandler(args, shockerAction); break;
case CS2Event.OnHelmetChange: this._cs2GSI.OnHelmetChange += args => EventHandler(args, shockerAction); break;
case CS2Event.OnEquipmentValueChange: this._cs2GSI.OnEquipmentValueChange += args => EventHandler(args, shockerAction); break;
case CS2Event.OnTeamChange: this._cs2GSI.OnTeamChange += args => EventHandler(args, shockerAction); break;
case CS2Event.OnPlayerChange: this._cs2GSI.OnPlayerChange += args => EventHandler(args, shockerAction); break;
case CS2Event.OnHalfTime: this._cs2GSI.OnHalfTime += args => EventHandler(args, shockerAction); break;
case CS2Event.OnFreezeTime: this._cs2GSI.OnFreezeTime += args => EventHandler(args, shockerAction); break;
case CS2Event.OnBombPlanted: this._cs2GSI.OnBombPlanted += args => EventHandler(args, shockerAction); break;
case CS2Event.OnBombDefused: this._cs2GSI.OnBombDefused += args => EventHandler(args, shockerAction); break;
case CS2Event.OnBombExploded: this._cs2GSI.OnBombExploded += args => EventHandler(args, shockerAction); break;
case CS2Event.AnyEvent: this._cs2GSI.AnyEvent += args => EventHandler(args, shockerAction); break;
case CS2Event.AnyMessage: this._cs2GSI.AnyMessage += args => EventHandler(args, shockerAction); break;
default: this._logger?.Log(LogLevel.Debug, $"CS2Event {nameof(shockerAction.TriggerEvent)} unknown."); break;
}
}
}
}
private void OnGSIMessage(string content)
private void EventHandler(CS2EventArgs cs2EventArgs, ShockerAction shockerAction)
{
Directory.CreateDirectory(Path.Combine(Environment.CurrentDirectory, "CS2Events"));
string fileName = Path.Combine(Environment.CurrentDirectory, "CS2Events" ,$"{DateTime.Now.ToLongTimeString().Replace(':','.')}.json");
File.WriteAllText(fileName, content);
_cs2MessageHandler.HandleCS2Message(content, _settings.SteamId);
this._logger?.Log(LogLevel.Information, $"Action {shockerAction}\nEventArgs: {cs2EventArgs}");
shockerAction.Execute(_configuration.Shockers, cs2EventArgs);
}
}

View File

@ -6,24 +6,13 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>OpenCS2Hock</RootNamespace>
<IsPackable>false</IsPackable>
</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>
<ItemGroup>
<PackageReference Include="CS2GSI" Version="1.0.7" />
<PackageReference Include="CShocker" Version="2.3.1" />
<PackageReference Include="GlaxLogger" Version="1.0.6" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

View File

@ -1,44 +0,0 @@
using System.Net.Http.Headers;
using System.Text;
namespace OpenCS2hock;
internal class OpenShock : Shocker
{
protected override void ControlInternal(ControlAction action, string shockerId, int intensity, int duration)
{
HttpRequestMessage request = new (HttpMethod.Post, $"{Endpoint}/1/shockers/control")
{
Headers =
{
UserAgent = { new ProductInfoHeaderValue("OpenCS2hock", "1") },
Accept = { new MediaTypeWithQualityHeaderValue("application/json") }
},
Content = new StringContent(@"[ { "+
$"\"id\": \"{shockerId}\"," +
$"\"type\": {ControlActionToByte(action)},"+
$"\"intensity\": {intensity},"+
$"\"duration\": {duration}"+
"}]", Encoding.UTF8, new MediaTypeHeaderValue("application/json"))
};
request.Headers.Add("OpenShockToken", ApiKey);
HttpResponseMessage response = this.HttpClient.Send(request);
Console.WriteLine($"{request.RequestUri} response: {response.StatusCode}");
}
private byte ControlActionToByte(ControlAction action)
{
return action switch
{
ControlAction.Beep => 3,
ControlAction.Vibrate => 2,
ControlAction.Shock => 1,
_ => 0
};
}
internal OpenShock(string endpoint, string apiKey, string[] shockerIds, ConfiguredInteger intensity, ConfiguredInteger duration) : base(endpoint, apiKey, shockerIds, intensity, duration)
{
}
}

View File

@ -1,9 +1,12 @@
namespace OpenCS2hock;
using GlaxLogger;
using Microsoft.Extensions.Logging;
namespace OpenCS2hock;
public class Program
{
public static void Main(string[] args)
{
OpenCS2hock openCS2Hock = new OpenCS2hock();
OpenCS2hock openCS2Hock = new OpenCS2hock(editConfig: true, logger: new Logger(LogLevel.Information));
}
}

View File

@ -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 &quot;OpenCS2hock&quot;
///{
///&quot;uri&quot; &quot;http://127.0.0.1:3000&quot;
///&quot;timeout&quot; &quot;5.0&quot;
///&quot;buffer&quot; &quot;0.1&quot;
///&quot;throttle&quot; &quot;0.5&quot;
///&quot;heartbeat&quot; &quot;60.0&quot;
///&quot;output&quot;
/// {
/// &quot;precision_time&quot; &quot;3&quot;
/// &quot;precision_position&quot; &quot;1&quot;
/// &quot;precision_vector&quot; &quot;3&quot;
/// }
///&quot;data&quot;
/// {
/// &quot;provider&quot; &quot;1&quot; // general info about client being listened to: game name, appid, client steamid, etc.
/// &quot;map&quot; &quot;1&quot; // map, gamemode, and current match phase (&apos;warmup&apos;, &apos;intermission&apos;, &apos;gameover&apos;, &apos;live&apos;) and current score
/// [rest of string was truncated]&quot;;.
/// </summary>
internal static string GSI_CFG_Content {
get {
return ResourceManager.GetString("GSI_CFG_Content", resourceCulture);
}
}
}
}

View File

@ -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>

View File

@ -1,68 +0,0 @@
using Newtonsoft.Json;
namespace OpenCS2hock;
public struct Settings
{
public string SteamId = "";
public OpenShockSettings OpenShockSettings = new()
{
Endpoint = "https://api.shocklink.net",
ApiKey = "",
Shockers = Array.Empty<string>()
};
public Range IntensityRange = new ()
{
Min = 20,
Max = 60
};
public Range DurationRange = new()
{
Min = 1000,
Max = 1000
};
public Dictionary<string, string> Actions = new()
{
{"OnKill", "Nothing"},
{"OnDeath", "Shock"},
{"OnRoundStart", "Vibrate"},
{"OnRoundEnd", "Nothing"},
{"OnRoundWin", "Beep"},
{"OnRoundLoss", "Nothing"}
};
public Settings()
{
}
public override string ToString()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
internal static Shocker.ControlAction StringToAction(string str)
{
return str.ToLower() switch
{
"shock" => Shocker.ControlAction.Shock,
"vibrate" => Shocker.ControlAction.Vibrate,
"beep" => Shocker.ControlAction.Beep,
_ => Shocker.ControlAction.Nothing
};
}
}
public struct OpenShockSettings
{
public string Endpoint, ApiKey;
public string[] Shockers;
}
public struct Range
{
public short Min, Max;
}

263
OpenCS2hock/Setup.cs Normal file
View File

@ -0,0 +1,263 @@
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using CShocker.Devices.Abstract;
using CShocker.Devices.Additional;
using CShocker.Devices.APIs;
using CShocker.Ranges;
using CShocker.Shockers;
using CShocker.Shockers.Abstract;
using Microsoft.Extensions.Logging;
using CS2Event = CS2GSI.CS2Event;
namespace OpenCS2hock;
public static class Setup
{
internal static Configuration Run()
{
Console.Clear();
Console.WriteLine("Running first-time setup.");
Configuration c = new();
AddApisWorkflow(ref c);
Console.Clear();
AddActionsWorkflow(ref c);
return c;
}
internal static void EditConfig(ref Configuration c)
{
ConsoleKey? pressedKey = null;
while (pressedKey is not ConsoleKey.X && pressedKey is not ConsoleKey.Q)
{
Console.Clear();
Console.WriteLine("Config Edit Mode.\n");
Console.WriteLine("1) LogLevel");
Console.WriteLine("2) Add API");
Console.WriteLine("3) Refresh Shockers (OpenShock)");
Console.WriteLine("4) Add Action");
Console.WriteLine("\nq) Quit Edit Mode");
pressedKey = Console.ReadKey().Key;
switch (pressedKey)
{
case ConsoleKey.D1:
string[] levels = Enum.GetNames<LogLevel>();
int selected;
do
{
Console.Clear();
Console.WriteLine("New LogLevel:");
for (int i = 0; i < levels.Length; i++)
Console.WriteLine($"{i}) {levels[i]}");
} while (!int.TryParse(Console.ReadKey().KeyChar.ToString(), out selected) || selected < 0 || selected >= levels.Length);
Console.WriteLine();//NewLine after Input
c.LogLevel = Enum.Parse<LogLevel>(levels[selected]);
break;
case ConsoleKey.D2:
AddApisWorkflow(ref c);
break;
case ConsoleKey.D3:
// ReSharper disable once PossibleInvalidCastExceptionInForeachLoop Only returning OpenShockApi Objects
foreach (OpenShockApi api in c.Apis.Where(a => a is OpenShockApi))
{
Configuration configuration = c;
foreach(OpenShockShocker s in api.GetShockers().Where(s => !configuration.Shockers.ContainsValue(s)))
c.Shockers.Add(c.Shockers.Any() ? c.Shockers.Keys.Max() + 1 : 0, s);
}
break;
case ConsoleKey.D4:
AddActionsWorkflow(ref c);
break;
}
}
c.SaveConfiguration();
}
private static void AddApisWorkflow(ref Configuration c)
{
Console.WriteLine("Adding APIs.");
bool addApis = true;
while (c.Apis.Count < 1 || addApis)
{
Console.Clear();
AddShockerApi(ref c);
Console.WriteLine("Add another Api (Y/N):");
addApis = Console.ReadKey().Key == ConsoleKey.Y;
Console.WriteLine();//NewLine after Input
}
}
private static void AddActionsWorkflow(ref Configuration c)
{
Console.WriteLine("Adding Actions.");
bool addAction = true;
while (c.ShockerActions.Count < 1 || addAction)
{
Console.Clear();
AddAction(ref c);
Console.WriteLine("Add another Action (Y/N):");
addAction = Console.ReadKey().Key == ConsoleKey.Y;
Console.WriteLine();//NewLine after Input
}
}
private static void AddShockerApi(ref Configuration c)
{
Console.WriteLine("Select API:");
Console.WriteLine("1) OpenShock (HTTP)");
Console.WriteLine("2) OpenShock (Serial Windows Only)");
Console.WriteLine("3) PiShock (HTTP) NotImplemented"); //TODO
Console.WriteLine("4) PiShock (Serial Windows Only) NotImplemented"); //TODO
char selectedChar = Console.ReadKey().KeyChar;
int selected;
while (!int.TryParse(selectedChar.ToString(), out selected) || selected < 1 || selected > 4)
selectedChar = Console.ReadKey().KeyChar;
Console.WriteLine();//NewLine after Input
string apiUri, apiKey;
Api? api = null;
switch (selected)
{
case 1: //OpenShock (HTTP)
apiUri = QueryString("OpenShock API-Endpoint (https://api.shocklink.net):", "https://api.shocklink.net");
apiKey = QueryString("OpenShock API-Key:","");
api = new OpenShockHttp(apiKey, apiUri);
foreach(OpenShockShocker shocker in ((OpenShockHttp)api).GetShockers())
c.Shockers.Add(c.Shockers.Any() ? c.Shockers.Keys.Max() + 1 : 0, shocker);
goto default;
case 2: //OpenShock (Serial)
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
throw new PlatformNotSupportedException("Serial is only supported on Windows.");
apiUri = QueryString("OpenShock API-Endpoint (https://api.shocklink.net):", "https://api.shocklink.net");
apiKey = QueryString("OpenShock API-Key:","");
SerialPortInfo serialPort = SelectSerialPort();
api = new OpenShockSerial(serialPort, apiKey, apiUri);
foreach (OpenShockShocker shocker in ((OpenShockSerial)api).GetShockers())
c.Shockers.Add(c.Shockers.Any() ? c.Shockers.Keys.Max() + 1 : 0, shocker);
goto default;
case 3: //PiShock (HTTP)
goto default;
case 4: //PiShock (Serial)
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
throw new PlatformNotSupportedException("Serial is only supported on Windows.");
goto default;
default:
if (api is null)
throw new NotImplementedException();
c.Apis.Add(api);
break;
}
}
[SupportedOSPlatform("windows")]
private static SerialPortInfo SelectSerialPort()
{
List<SerialPortInfo> serialPorts = SerialHelper.GetSerialPorts();
int selectedPort;
do
{
Console.Clear();
for(int i = 0; i < serialPorts.Count; i++)
Console.WriteLine($"{i}) {serialPorts[i]}");
Console.WriteLine($"Select Serial Port [0-{serialPorts.Count-1}]:");
} while (!int.TryParse(Console.ReadLine(), out selectedPort) || selectedPort < 0 || selectedPort >= serialPorts.Count);
Console.WriteLine();//NewLine after Input
return serialPorts[selectedPort];
}
private static void AddAction(ref Configuration c)
{
CS2Event triggerEvent = GetTrigger();
int shockerId = GetShockerId(c.Shockers);
ControlAction action = GetControlAction();
bool useEventArgsValue = QueryBool("Try using EventArgs to control Intensity (within set limits)?", false);
IntegerRange intensityRange = GetIntegerRange(0, 100, "%");
IntegerRange durationRange = GetIntegerRange(0, 30000, "ms");
c.ShockerActions.Add(new(triggerEvent, shockerId, action, useEventArgsValue, intensityRange, durationRange));
}
private static int GetShockerId(Dictionary<int, Shocker> shockersDict)
{
List<Shocker> shockers = shockersDict.Values.ToList();
int selectedShockerIndex;
do
{
Console.Clear();
Console.WriteLine("Select Shocker:");
for (int i = 0; i < shockers.Count; i++)
Console.WriteLine($"{i}) {shockers[i]}");
} while (!int.TryParse(Console.ReadLine(), out selectedShockerIndex) || selectedShockerIndex < 0 || selectedShockerIndex > shockersDict.Count);
Console.WriteLine();//NewLine after Input
Shocker shocker = shockers[selectedShockerIndex];
return shockersDict.First(s => s.Value == shocker).Key;
}
private static IntegerRange GetIntegerRange(int min, int max, string? unit = null)
{
Regex rangeRex = new (@"([0-9]{1,5})\-([0-9]{1,5})");
string intensityRangeStr;
do
{
intensityRangeStr = QueryString($"Range ({min}-{max}) {(unit is null ? "" : $"in {unit}")}:", "0-100");
} while (!rangeRex.IsMatch(intensityRangeStr));
return new IntegerRange(short.Parse(rangeRex.Match(intensityRangeStr).Groups[1].Value), short.Parse(rangeRex.Match(intensityRangeStr).Groups[2].Value));
}
private static CS2Event GetTrigger()
{
string[] eventNames = Enum.GetNames(typeof(CS2Event));
int selectedIndex;
do
{
Console.Clear();
Console.WriteLine("Select CS2 Trigger-Event:");
for (int i = 0; i < eventNames.Length; i++)
Console.WriteLine($"{i}) {eventNames[i]}");
} while (!int.TryParse(Console.ReadLine(), out selectedIndex) || selectedIndex < 0 || selectedIndex >= eventNames.Length);
return Enum.Parse<CS2Event>(eventNames[selectedIndex]);
}
private static ControlAction GetControlAction()
{
string[] actionNames = Enum.GetNames(typeof(ControlAction));
int selectedIndex;
do
{
Console.Clear();
Console.WriteLine("Select Action:");
for (int i = 0; i < actionNames.Length; i++)
Console.WriteLine($"{i}) {actionNames[i]}");
} while (!int.TryParse(Console.ReadLine(), out selectedIndex) || selectedIndex < 0 || selectedIndex >= actionNames.Length);
return Enum.Parse<ControlAction>(actionNames[selectedIndex]);
}
private static bool QueryBool(string queryString, bool defaultResult)
{
Console.WriteLine(queryString);
char userInput = Console.ReadKey().KeyChar;
Console.WriteLine();//NewLine after Input
return bool.TryParse(userInput.ToString(), out bool ret) ? ret : defaultResult;
}
private static string QueryString(string queryString, string defaultResult)
{
Console.WriteLine(queryString);
string? userInput = Console.ReadLine();
return userInput?.Length > 0 ? userInput : defaultResult;
}
}

View File

@ -1,37 +0,0 @@
namespace OpenCS2hock;
internal abstract class Shocker
{
protected readonly HttpClient HttpClient;
protected readonly string ApiKey,Endpoint;
private readonly string[] _shockerIds;
private readonly ConfiguredInteger _intensity, _duration;
internal enum ControlAction { Beep, Vibrate, Shock, Nothing }
internal void Control(ControlAction action, string? shockerId = null)
{
int intensity = _intensity.GetValue();
int duration = _duration.GetValue();
Console.WriteLine($"{action} {intensity} {duration}");
if (action is ControlAction.Nothing)
return;
if(shockerId is null)
foreach (string shocker in _shockerIds)
ControlInternal(action, shocker, intensity, duration);
else
ControlInternal(action, shockerId, intensity, duration);
}
protected abstract void ControlInternal(ControlAction action, string shockerId, int intensity, int duration);
protected Shocker(string endpoint, string apiKey, string[] shockerIds, ConfiguredInteger intensity, ConfiguredInteger duration)
{
this.Endpoint = endpoint;
this.ApiKey = apiKey;
this.HttpClient = new HttpClient();
this._shockerIds = shockerIds;
this._intensity = intensity;
this._duration = duration;
}
}

View File

@ -0,0 +1,64 @@
using CS2GSI;
using CShocker.Devices.Additional;
using CShocker.Ranges;
using CShocker.Shockers.Abstract;
namespace OpenCS2hock;
public struct ShockerAction
{
public CS2Event TriggerEvent;
// ReSharper disable thrice FieldCanBeMadeReadOnly.Global JsonDeserializer will throw a fit
public int ShockerId;
public ControlAction Action;
public bool ValueFromInput;
public IntegerRange IntensityRange, DurationRange;
public ShockerAction(CS2Event trigger, int shockerId, ControlAction action, bool valueFromInput, IntegerRange intensityRange, IntegerRange durationRange)
{
this.TriggerEvent = trigger;
this.ShockerId = shockerId;
this.Action = action;
this.ValueFromInput = valueFromInput;
this.IntensityRange = intensityRange;
this.DurationRange = durationRange;
}
public void Execute(Dictionary<int, Shocker> shockers, CS2EventArgs cs2EventArgs)
{
if (!shockers.ContainsKey(ShockerId))
return;
int intensity = ValueFromInput ? IntensityFromCS2Event(cs2EventArgs) : RandomValueFromRange(IntensityRange);
int duration = RandomValueFromRange(DurationRange);
shockers[ShockerId].Control(Action, intensity, duration);
}
private static int RandomValueFromRange(IntegerRange range)
{
return Random.Shared.Next(range.Min, range.Max);
}
private int IntensityFromCS2Event(CS2EventArgs cs2EventArgs)
{
return TriggerEvent switch
{
CS2Event.OnDamageTaken => MapInt(cs2EventArgs.ValueAsOrDefault<int>(), 0, 100, IntensityRange.Min, IntensityRange.Max),
CS2Event.OnArmorChange => MapInt(cs2EventArgs.ValueAsOrDefault<int>(), 0, 100, IntensityRange.Min, IntensityRange.Max),
_ => RandomValueFromRange(IntensityRange)
};
}
private int MapInt(int input, int fromLow, int fromHigh, int toLow, int toHigh)
{
int mappedValue = (input - fromLow) * (toHigh - toLow) / (fromHigh - fromLow) + toLow;
return mappedValue;
}
public override string ToString()
{
return $"Trigger Event: {Enum.GetName(typeof(CS2Event), this.TriggerEvent)}\n" +
$"ShockerId: {ShockerId}\n" +
$"Action: {Enum.GetName(typeof(ControlAction), this.Action)}\n" +
$"ValueFromInput: {ValueFromInput}";
}
}

View File

@ -1,23 +0,0 @@
"OpenCS2hock"
{
"uri" "http://127.0.0.1:3000"
"timeout" "2.0"
"buffer" "0.0"
"throttle" "0.1"
"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
}
}

125
README.md
View File

@ -1,49 +1,104 @@
Example `config.json`. Place next to executable. Will also be generated on first start.
```
# OpenCS2hock
![GitHub License](https://img.shields.io/github/license/c9glax/OpenCS2hock)
![GitHub Release](https://img.shields.io/github/v/release/c9glax/OpenCS2hock)
Electrifying your Counter-Strike experience. With [OpenShock](https://openshock.org/) and [PiShock](https://pishock.com/#/)! (Not Associated)
## How to use
Download [latest Release](https://github.com/C9Glax/OpenCS2hock/releases/latest) and execute.
Example `config.json`. Place next to executable. Will also be generated on first start.
```json
{
"SteamId": "<Your SteamId>",
"OpenShockSettings": {
"Endpoint": "https://api.shocklink.net",
"ApiKey": "<Your Shocklink API Key>",
"Shockers": [ "<Shocker Id> comma seperated" ]
},
"IntensityRange": {
"Min": 30,
"Max": 60
},
"DurationRange": {
"Min": 1000,
"Max": 1000
},
"Actions": {
"OnKill": "Beep",
"OnDeath": "Shock",
"OnRoundStart": "Nothing",
"OnRoundEnd": "Vibrate",
"OnRoundWin": "Nothing",
"OnRoundLoss": "Shock"
}
"LogLevel": 2,
"Shockers": [
{
"ShockerIds": [
"ID HERE"
],
"IntensityRange": {
"Min": 30,
"Max": 50
},
"DurationRange": {
"Min": 1000,
"Max": 1000
},
"ApiType": 0,
"Endpoint": "https://api.shocklink.net",
"ApiKey": "API KEY HERE"
}
],
"ShockerActions": [
{
"TriggerEvent": 2,
"ShockerIds": [
"SAME ID HERE"
],
"Action": 2,
"ValueFromInput": false
}
]
}
```
### SteamId
Your SteamId64 [here](https://steamid.io/lookup)
## LogLevel
[Levels](https://learn.microsoft.com/de-de/dotnet/api/microsoft.extensions.logging.loglevel?view=dotnet-plat-ext-8.0)
## Shockers
### ApiKey
For OpenShock get token [here](https://shocklink.net/#/dashboard/tokens)
- For OpenShock (HTTP) get token [here](https://shocklink.net/#/dashboard/tokens)
- For PiShock (HTTP) get information [here](https://apidocs.pishock.com/#header-authenticating)
### Shockers
List of Shocker-Ids, comma seperated. Get Id [here](https://shocklink.net/#/dashboard/shockers/own). Press the three dots -> Edit
### ApiType
CShocker [![Github](https://img.shields.io/badge/Github-8A2BE2)](https://github.com/C9Glax/cshocker) [here](https://github.com/C9Glax/CShocker/blob/master/CShocker/Shockers/Abstract/ShockerApi.cs)
Example `[ "ID-1", "ID-2" ]`
### ShockerIds
List of Shocker-Ids, comma seperated.
`[ "ID-1-asdasd", "ID-2-fghfgh" ]`
### Intensity Range
`0-100`
in percent
`0-100`
### Duration Range
in ms
- `0-30000` OpenShock
- `0-15000` PiShock
### Values for `Actions`
- Beep
- Shock
- Vibrate
### Username (PiShockHttp only)
For PiShock (HTTP) get information [here](https://apidocs.pishock.com/#header-authenticating)
### Sharecode (PiShockHttp only)
For PiShock (HTTP) get information [here](https://apidocs.pishock.com/#header-authenticating)
## ShockerActions
### TriggerEvent IDs
From CS2GSI [![Github](https://img.shields.io/badge/Github-8A2BE2)](https://github.com/C9Glax/CS2GSI) [here](https://github.com/C9Glax/CS2GSI/blob/master/CS2GSI/CS2Event.cs)
### ShockerIds
List of Shocker-Ids, comma seperated. (Same as in configured Shocker)
`[ "ID-1", "ID-2" ]`
### Actions
From CShocker [![Github](https://img.shields.io/badge/Github-8A2BE2)](https://github.com/C9Glax/cshocker) [here](https://github.com/C9Glax/CShocker/blob/master/CShocker/Shockers/ControlAction.cs)
### ValueFromInput
Use CS2GSI EventArgs value to determine Intensity (within configured IntensityRange)
# Using
### CS2GSI
[![GitHub License](https://img.shields.io/github/license/c9glax/CS2GSI)](https://img.shields.io/github/license/c9glax/CS2GSI/LICENSE)
[![NuGet Version](https://img.shields.io/nuget/v/CS2GSI)](https://www.nuget.org/packages/CS2GSI/)
[![Github](https://img.shields.io/badge/Github-8A2BE2)](https://github.com/C9Glax/CS2GSI)
[![GitHub Release](https://img.shields.io/github/v/release/c9glax/CS2GSI)](https://github.com/C9Glax/CS2GSI/releases/latest)
### CShocker
[![GitHub License](https://img.shields.io/github/license/c9glax/cshocker)](https://github.com/C9Glax/CShocker)
[![Github](https://img.shields.io/badge/Github-8A2BE2)](https://github.com/C9Glax/cshocker)
[![NuGet Version](https://img.shields.io/nuget/v/CShocker)](https://shields.io/badges/nu-get-version)