diff --git a/Core/Config/ConfigService.cs b/Core/Config/ConfigService.cs index 64ae528..b196308 100644 --- a/Core/Config/ConfigService.cs +++ b/Core/Config/ConfigService.cs @@ -1,6 +1,7 @@ using System; using System.IO; using NetJoy.Core.Utils; +using NetJoy.Core.Utils.General; using Nett; namespace NetJoy.Core.Config diff --git a/Core/NetJoy/Client/Handling/JoyHandler.cs b/Core/NetJoy/Client/Handling/JoyHandler.cs index 3003a5f..346aaeb 100644 --- a/Core/NetJoy/Client/Handling/JoyHandler.cs +++ b/Core/NetJoy/Client/Handling/JoyHandler.cs @@ -4,10 +4,8 @@ using Nefarius.ViGEm.Client.Targets; using Nefarius.ViGEm.Client.Targets.Xbox360; using NetJoy.Core.NetJoy.Packets; -using NetJoy.Core.Utils; using NetJoy.Core.Utils.Controller; -using SharpDX.DirectInput; -using vJoyInterfaceWrap; +using NetJoy.Core.Utils.General; using static System.Int16; namespace NetJoy.Core.NetJoy.Client.Handling diff --git a/Core/NetJoy/Client/NetJoyClient.cs b/Core/NetJoy/Client/NetJoyClient.cs index e7af2fb..dd74879 100644 --- a/Core/NetJoy/Client/NetJoyClient.cs +++ b/Core/NetJoy/Client/NetJoyClient.cs @@ -1,13 +1,11 @@ using System; -using System.Diagnostics; using System.Net; using System.Net.Sockets; using System.Threading; using System.Threading.Tasks; -using NetJoy.Core.Config; using NetJoy.Core.NetJoy.Client.Handling; using NetJoy.Core.NetJoy.Packets; -using NetJoy.Core.Utils; +using NetJoy.Core.Utils.General; using Newtonsoft.Json; using Encoding = System.Text.Encoding; @@ -15,19 +13,12 @@ namespace NetJoy.Core.NetJoy.Client { public class NetJoyClient { - private readonly Configuration _configuration; // the config file - private Socket _client; //the client socket private JoyHandler _joyHandler; // the joystick handler instance // ManualResetEvent instances signal completion. private readonly ManualResetEvent _connectDone = new ManualResetEvent(false); - - public NetJoyClient(Configuration configuration) - { - _configuration = configuration; - } - + /// /// Start the net joy client /// diff --git a/Core/NetJoy/NetJoyManager.cs b/Core/NetJoy/NetJoyManager.cs index f3bcc4f..cb13bf4 100644 --- a/Core/NetJoy/NetJoyManager.cs +++ b/Core/NetJoy/NetJoyManager.cs @@ -1,7 +1,4 @@ -using System; -using System.Threading; -using System.Threading.Tasks; -using NetJoy.Core.Config; +using System.Threading.Tasks; using NetJoy.Core.NetJoy.Client; using NetJoy.Core.NetJoy.Server; using NetJoy.Core.Utils; @@ -10,14 +7,11 @@ namespace NetJoy.Core.NetJoy { public class NetJoyManager { - - private readonly Configuration _config; private readonly NetJoyServer _server; private readonly NetJoyClient _client; - public NetJoyManager(Configuration config, NetJoyServer server, NetJoyClient client) + public NetJoyManager(NetJoyServer server, NetJoyClient client) { - _config = config; _server = server; _client = client; } diff --git a/Core/NetJoy/Server/NetJoyServer.cs b/Core/NetJoy/Server/NetJoyServer.cs index 9485cbd..9191e0d 100644 --- a/Core/NetJoy/Server/NetJoyServer.cs +++ b/Core/NetJoy/Server/NetJoyServer.cs @@ -7,6 +7,7 @@ using NetJoy.Core.Config; using NetJoy.Core.NetJoy.Packets; using NetJoy.Core.Utils; +using NetJoy.Core.Utils.General; using Newtonsoft.Json; using SharpDX.DirectInput; diff --git a/Core/NetJoy/Server/NgrokUtils.cs b/Core/NetJoy/Server/NgrokUtils.cs index eac2599..1cbaadd 100644 --- a/Core/NetJoy/Server/NgrokUtils.cs +++ b/Core/NetJoy/Server/NgrokUtils.cs @@ -3,6 +3,7 @@ using System.Net; using NetJoy.Core.Config; using NetJoy.Core.Utils; +using NetJoy.Core.Utils.General; using Newtonsoft.Json.Linq; namespace NetJoy.Core.NetJoy.Server @@ -20,31 +21,31 @@ public void Start() { - //get the address string for ngrock + //get the address string for Ngrock var address = GetNgrok(); //if we already have an instance skip the spawning process if (address != null) { - Logger.Debug("Found existing ngrock instance @" + address); + Logger.Debug("Found existing Ngrock instance @" + address); return; } //log that we couldn't find any instances - Logger.Debug("No existing ngrock instances. Spawning new instance."); + Logger.Debug("No existing Ngrock instances. Spawning new instance."); //spawn a new ngrok instance - SpawnNgrock(_port); + SpawnNgrock(); //log that we created a new ngrock instance - Logger.Debug("Spawned ngrock instance @" + GetNgrok()); + Logger.Debug("Spawned Ngrock instance @" + GetNgrok()); } /// /// Get data about the Ngrok instance from the local webserver /// /// - public string GetNgrok() + private string GetNgrok() { var wr = WebRequest.Create("http://127.0.0.1:4040/api/tunnels"); @@ -82,21 +83,8 @@ public string GetNgrok() } - //process for killing ngrok instances - private readonly Process _taskKill = new Process - { - StartInfo = new ProcessStartInfo() - { - UseShellExecute = false, - CreateNoWindow = true, - FileName = "taskkill.exe", - RedirectStandardOutput = true, - Arguments = "/f /im \"ngrok.exe\"" - } - }; - //Process for creating new ngrok instances - private void SpawnNgrock(int port) + private void SpawnNgrock() { new Process { diff --git a/Core/Utils/Controller/ControllerUtils.cs b/Core/Utils/Controller/ControllerUtils.cs index 5935b60..a42b076 100644 --- a/Core/Utils/Controller/ControllerUtils.cs +++ b/Core/Utils/Controller/ControllerUtils.cs @@ -3,7 +3,7 @@ namespace NetJoy.Core.Utils.Controller { - public class ControllerUtils + public static class ControllerUtils { /// /// Get the Xbox360Button for the given string diff --git a/Core/Utils/General/Logger.cs b/Core/Utils/General/Logger.cs index 4616a73..5eee24b 100644 --- a/Core/Utils/General/Logger.cs +++ b/Core/Utils/General/Logger.cs @@ -1,6 +1,6 @@ using System; -namespace NetJoy.Core.Utils +namespace NetJoy.Core.Utils.General { public static class Logger { diff --git a/Core/Utils/General/Prompts.cs b/Core/Utils/General/Prompts.cs index 8609cfc..45b315c 100644 --- a/Core/Utils/General/Prompts.cs +++ b/Core/Utils/General/Prompts.cs @@ -1,4 +1,5 @@ using System; +using NetJoy.Core.Utils.General; namespace NetJoy.Core.Utils { diff --git a/NetJoy.csproj b/NetJoy.csproj index bac88fb..008e957 100644 --- a/NetJoy.csproj +++ b/NetJoy.csproj @@ -6,12 +6,6 @@ 9 - - - ..\..\..\..\..\Program Files\vJoy\x64\vJoyInterfaceWrap.dll - - - diff --git a/README.md b/README.md index b7cce40..2ca3328 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,7 @@ NetJoy is a bundled client/server application that can send joystick/controller from one computer to another remotely over the network. # Support -Currently the only supported platform is windows but linux support -is planned in the near future! This is due to using the windows binaries for "ngrok" and "taskkill". - +Currently the only supported platform is Windows, Linux is planned in the future! # Example Config ````toml @@ -23,13 +21,14 @@ port = 6069 > EXTRA STEP FOR SERVERS * Open config.toml and set isServer to true. * Change port to your desired port number. -* configure ngrok to use your ngrok token [FROM HERE](https://ngrok.com/) by running +* configure ngrok using your ngrok token [FROM HERE](https://ngrok.com/) by running the below code in the NeyJoy Directory ``` +cd PATH_TO_NETJOY_FOLDER ngrok authtoken TOKEN_GOES_HERE ``` > EXTRA STEP FOR CLIENTS -* Install vJoy from [here](http://vjoystick.sourceforge.net/site/index.php/download-a-install/download) +* Install ViGEm from [here](https://github.com/ViGEm/ViGEmBus) * Complete install & restart > Both Clients & Servers -* Run NetJoy.exe & follow instructions. +* Run NetJoy.exe & follow instructions in the application for setting up your server/client.