-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0dc3c0b
commit ab592d7
Showing
9 changed files
with
1,051 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Newtonsoft.Json; | ||
using SWICD.Pages; | ||
using SWICD.Services; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SWICD.ApiControllers | ||
{ | ||
public class ApiController : ControllerBase | ||
{ | ||
[HttpGet] | ||
[Route("/config")] | ||
public async Task<IActionResult> GetConfig() | ||
{ | ||
return Content(JsonConvert.SerializeObject(ControllerService.Instance.Configuration), "text/json"); | ||
} | ||
|
||
[HttpGet] | ||
[Route("/driver/status")] | ||
public async Task<IActionResult> GetStatus() | ||
{ | ||
return Content(JsonConvert.SerializeObject(new | ||
{ | ||
ControllerService.Instance.EmulationEnabled, | ||
ControllerService.Instance.FailedInit, | ||
ControllerService.Instance.DecisionExecutable, | ||
ControllerService.Instance.LizardMouseEnabled, | ||
ControllerService.Instance.LizardButtonsEnabled, | ||
ControllerService.Instance.Started | ||
}), "text/json"); | ||
} | ||
|
||
[HttpGet] | ||
[Route("/driver/control/stop")] | ||
public async Task<IActionResult> StopDriver() | ||
{ | ||
MainWindow.Instance.Dispatcher.Invoke(() => ControllerService.Instance.Stop()); | ||
ContentResult result = Content(JsonConvert.SerializeObject(new | ||
{ | ||
Started = ControllerService.Instance.Started, | ||
}), "text/json"); | ||
|
||
if (!ControllerService.Instance.Started) | ||
result.StatusCode = 500; | ||
|
||
return result; | ||
} | ||
|
||
[HttpGet] | ||
[Route("/driver/control/start")] | ||
public async Task<IActionResult> StartDriver() | ||
{ | ||
MainWindow.Instance.Dispatcher.Invoke(() => ControllerService.Instance.Start()); | ||
ContentResult result = Content(JsonConvert.SerializeObject(new | ||
{ | ||
Started = ControllerService.Instance.Started, | ||
}), "text/json"); | ||
|
||
if (!ControllerService.Instance.Started) | ||
result.StatusCode = 500; | ||
|
||
return result; | ||
} | ||
|
||
[HttpGet] | ||
[Route("/gui/show")] | ||
public async Task<IActionResult> ShowGui() | ||
{ | ||
MainWindow.Instance.Dispatcher.Invoke(() => { | ||
MainWindow.Instance.Show(); | ||
MainWindow.Instance.Focus(); | ||
}); | ||
ContentResult result = Content(JsonConvert.SerializeObject(new | ||
{ | ||
Visible = MainWindow.Instance.IsVisible, | ||
}), "text/json"); | ||
|
||
return result; | ||
} | ||
|
||
[HttpGet] | ||
[Route("/gui/hide")] | ||
public async Task<IActionResult> HideGui() | ||
{ | ||
MainWindow.Instance.Dispatcher.Invoke(() => MainWindow.Instance.Hide()); | ||
ContentResult result = Content(JsonConvert.SerializeObject(new | ||
{ | ||
Visible = MainWindow.Instance.IsVisible, | ||
}), "text/json"); | ||
|
||
return result; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,122 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/> | ||
</startup> | ||
</configuration> | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /> | ||
</startup> | ||
<runtime> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-1.2.3.0" newVersion="1.2.3.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.ComponentModel.Annotations" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-1.4.3.0" newVersion="1.4.3.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Security.Cryptography.Cng" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.3.1.0" newVersion="4.3.1.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Extensions.FileProviders.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Net.Http.Headers" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.AspNetCore.Http.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.AspNetCore.Http.Extensions" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.AspNetCore.Hosting.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Extensions.Options" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.AspNetCore.Http.Features" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.Extensions.WebEncoders" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.AspNetCore.Routing" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.AspNetCore.Routing.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.AspNetCore.Mvc.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.AspNetCore.Authentication.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.AspNetCore.Mvc.Core" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Microsoft.AspNetCore.Mvc.ApiExplorer" publicKeyToken="adb9793829ddae60" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
</runtime> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.