diff --git a/Install Driver/App.config b/Install Driver/App.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/Install Driver/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Install Driver/Install Driver.csproj b/Install Driver/Install Driver.csproj new file mode 100644 index 0000000..260ea6b --- /dev/null +++ b/Install Driver/Install Driver.csproj @@ -0,0 +1,58 @@ + + + + + Debug + AnyCPU + {6C663B31-ED95-43CA-9CCA-D2349F8E491E} + Exe + Install_Driver + Install Driver + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + app.manifest + + + + + + + + + + + + + + + + + + + Designer + + + + \ No newline at end of file diff --git a/Install Driver/Program.cs b/Install Driver/Program.cs new file mode 100644 index 0000000..4dc642d --- /dev/null +++ b/Install Driver/Program.cs @@ -0,0 +1,77 @@ +namespace Install_Driver { + class Program { + static void Main (string[] args) { + InstallDriver(); + SetupFirewall(); + } + + static void InstallDriver() { + var driverInstallerDir = System.IO.Path.Combine( + System.Environment.CurrentDirectory, + "Scp Driver Installer" + ); + + RunCommand(new System.Diagnostics.ProcessStartInfo { + FileName = System.IO.Path.Combine( + driverInstallerDir, + "ScpDriverInstaller.exe" + ), + Arguments = "--install --quiet", + WorkingDirectory = driverInstallerDir, + }); + } + + static void SetupFirewall() { + RunCommand(new System.Diagnostics.ProcessStartInfo { + FileName = "netsh", + Arguments = "advfirewall firewall add rule name=\"XArcade XInput\" dir=in action=allow protocol=TCP localport=32123", + }, true); + + RunCommand(new System.Diagnostics.ProcessStartInfo { + FileName = "netsh", + Arguments = "http add urlacl url=http://+:32123/ user=Everyone", + }, true); + } + + static System.Diagnostics.Process RunCommand (System.Diagnostics.ProcessStartInfo startInfo, bool allowFail = false) { + System.Console.WriteLine($"Running '{startInfo.FileName} {startInfo.Arguments}'"); + + startInfo.UseShellExecute = false; + startInfo.RedirectStandardOutput = true; + startInfo.RedirectStandardError = true; + + var proc = new System.Diagnostics.Process { + StartInfo = startInfo, + }; + + proc.OutputDataReceived += (sender, e) => System.Console.WriteLine(e.Data); + proc.ErrorDataReceived += (sender, e) => System.Console.WriteLine(e.Data); + + try { + proc.Start(); + } catch (System.Exception err) { + System.Console.WriteLine(err.Message); + WaitAndExit(1); + } + + proc.BeginOutputReadLine(); + proc.BeginErrorReadLine(); + proc.WaitForExit(); + + if (!allowFail && proc.ExitCode > 0) { + System.Console.WriteLine($"Command exited with code {proc.ExitCode}"); + WaitAndExit(proc.ExitCode); + } + + return proc; + } + + static void WaitAndExit(int exitCode) { + if (exitCode > 0) { + System.Console.WriteLine("Press any key to continue"); + System.Console.ReadKey(); + } + System.Environment.Exit(exitCode); + } + } +} diff --git a/Install Driver/Properties/AssemblyInfo.cs b/Install Driver/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5dde510 --- /dev/null +++ b/Install Driver/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Install Driver")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Install Driver")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("6c663b31-ed95-43ca-9cca-d2349f8e491e")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Install Driver/app.manifest b/Install Driver/app.manifest new file mode 100644 index 0000000..ea9713b --- /dev/null +++ b/Install Driver/app.manifest @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/XArcade XInput.sln b/XArcade XInput.sln index 4256b34..b2f83cb 100644 --- a/XArcade XInput.sln +++ b/XArcade XInput.sln @@ -4,6 +4,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XArcade XInput", "XArcade XInput\XArcade XInput.csproj", "{2A7F171B-F9E0-42DE-B116-9F9FF812CAAA}" + ProjectSection(ProjectDependencies) = postProject + {6C663B31-ED95-43CA-9CCA-D2349F8E491E} = {6C663B31-ED95-43CA-9CCA-D2349F8E491E} + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Install Driver", "Install Driver\Install Driver.csproj", "{6C663B31-ED95-43CA-9CCA-D2349F8E491E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +20,10 @@ Global {2A7F171B-F9E0-42DE-B116-9F9FF812CAAA}.Debug|Any CPU.Build.0 = Debug|Any CPU {2A7F171B-F9E0-42DE-B116-9F9FF812CAAA}.Release|Any CPU.ActiveCfg = Release|Any CPU {2A7F171B-F9E0-42DE-B116-9F9FF812CAAA}.Release|Any CPU.Build.0 = Release|Any CPU + {6C663B31-ED95-43CA-9CCA-D2349F8E491E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6C663B31-ED95-43CA-9CCA-D2349F8E491E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6C663B31-ED95-43CA-9CCA-D2349F8E491E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6C663B31-ED95-43CA-9CCA-D2349F8E491E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/XArcade XInput/XArcade XInput.csproj b/XArcade XInput/XArcade XInput.csproj index 91656e6..951cb2e 100644 --- a/XArcade XInput/XArcade XInput.csproj +++ b/XArcade XInput/XArcade XInput.csproj @@ -68,21 +68,24 @@ - + - + - + - - - - + + + + + + {6c663b31-ed95-43ca-9cca-d2349f8e491e} + Install Driver + - - - - + + + diff --git a/install.bat b/install.bat deleted file mode 100644 index 07aa48d..0000000 --- a/install.bat +++ /dev/null @@ -1,9 +0,0 @@ -REM Install ScpDriver -REM Prefer pushd / popd to cd, since it handles network paths. -pushd "%~dp0\Scp Driver Installer" -ScpDriverInstaller.exe --install --quiet -popd - -REM Setup firewall -netsh advfirewall firewall add rule name="XArcade XInput" dir=in action=allow protocol=TCP localport=32123 -netsh http add urlacl url=http://+:32123/ user=Everyone diff --git a/script/build.bat b/script/build.bat index 22438f1..3cb2e8b 100644 --- a/script/build.bat +++ b/script/build.bat @@ -1,7 +1,5 @@ @echo off -call script\create-install-exe.bat - REM Build webapp rd /S /Q webapp\build\ pushd webapp\ @@ -14,6 +12,7 @@ call script\get-scp-driver-installer.bat REM "Clean" isn't a total clean. del /F /S /Q "XArcade XInput"\bin +rd /S /Q "XArcade XInput"\bin REM Build Project nuget restore diff --git a/script/create-install-exe.bat b/script/create-install-exe.bat deleted file mode 100644 index 1af82d2..0000000 --- a/script/create-install-exe.bat +++ /dev/null @@ -1,2 +0,0 @@ -del /F /S /Q "Installer Driver.exe" -vendor\Bat_To_Exe_Converter.exe /bat install.bat /exe "Install Driver.exe" /uac-admin /productversion %APPVEYOR_BUILD_VERSION% /productname "%APPVEYOR_PROJECT_NAME%" /workdir 0 /overwrite \ No newline at end of file diff --git a/script/get-scp-driver-installer.bat b/script/get-scp-driver-installer.bat index 77340ad..d875f92 100644 --- a/script/get-scp-driver-installer.bat +++ b/script/get-scp-driver-installer.bat @@ -4,5 +4,5 @@ rd /S /Q "Scp Driver Installer" curl -L https://github.com/mogzol/ScpDriverInterface/releases/download/1.1/ScpDriverInterface_v1.1.zip --output "Scp Driver Installer.zip" 7z x -o"ScpDriverTemp" "Scp Driver Installer.zip" move /Y "ScpDriverTemp\Driver Installer" "Scp Driver Installer" -rd /S /Q ScpDriverTemp "Scp Driver Installer.zip" +rd /S /Q ScpDriverTemp del /F /S /Q "Scp Driver Installer.zip" \ No newline at end of file diff --git a/vendor/Bat_To_Exe_Converter.exe b/vendor/Bat_To_Exe_Converter.exe deleted file mode 100755 index dcd85e3..0000000 Binary files a/vendor/Bat_To_Exe_Converter.exe and /dev/null differ