From a63af3065b1c5cd90fb5c91fb4d7d0b4f0cf1b35 Mon Sep 17 00:00:00 2001 From: RoboPhred Date: Sat, 25 Jul 2020 18:47:14 -0700 Subject: [PATCH] Combine sixaxis input with game input --- CHANGELOG.md | 4 ++++ src/OrientationInjector.cs | 2 +- src/SixAxisPlugin.cs | 2 +- src/ThrustInjector.cs | 2 +- src/VectorUtils.cs | 18 ++++++++++++++++++ 5 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 src/VectorUtils.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index b7549db..a14053a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changes +## 1.0.2 + +- Combine sixaxis input with existing game input. + ## 1.0.1 - Remove log interceptor; allow crash logs to function normally. diff --git a/src/OrientationInjector.cs b/src/OrientationInjector.cs index 5a17fbc..e0b85c0 100644 --- a/src/OrientationInjector.cs +++ b/src/OrientationInjector.cs @@ -48,7 +48,7 @@ static Vector3 ApplySixAxisRotation(Vector3 vector) { // TODO: Merge our input with existing input var rotation = new Vector3(InputHandler.RZ, InputHandler.RX, -InputHandler.RY); - return rotation; + return VectorUtils.Average(rotation, vector); } } } diff --git a/src/SixAxisPlugin.cs b/src/SixAxisPlugin.cs index d00ffe3..c8e91ba 100644 --- a/src/SixAxisPlugin.cs +++ b/src/SixAxisPlugin.cs @@ -5,7 +5,7 @@ namespace RoboPhredDev.Shipbreaker.SixAxis { - [BepInPlugin("net.robophreddev.shipbreaker.SixAxis", "Six Axis Joystick support for Shipbreaker", "1.0.1.0")] + [BepInPlugin("net.robophreddev.shipbreaker.SixAxis", "Six Axis Joystick support for Shipbreaker", "1.0.2.0")] public class SixAxisPlugin : BaseUnityPlugin { public static SixAxisPlugin Instance; diff --git a/src/ThrustInjector.cs b/src/ThrustInjector.cs index 7e79253..9ae14f1 100644 --- a/src/ThrustInjector.cs +++ b/src/ThrustInjector.cs @@ -50,7 +50,7 @@ static Vector3 ApplySixAxisTranslation(Vector3 vector) { // var translation = new Vector3(-InputHandler.X, -InputHandler.Z, InputHandler.Y); var translation = new Vector3(InputHandler.X, -InputHandler.Z, -InputHandler.Y); - return translation; + return VectorUtils.Average(translation, vector); } } } diff --git a/src/VectorUtils.cs b/src/VectorUtils.cs new file mode 100644 index 0000000..1550c15 --- /dev/null +++ b/src/VectorUtils.cs @@ -0,0 +1,18 @@ + +using UnityEngine; + +namespace RoboPhredDev.Shipbreaker.SixAxis +{ + static class VectorUtils + { + public static Vector3 Average(Vector3 a, Vector3 b) + { + return new Vector3 + { + x = (a.x + b.x) / 2.0f, + y = (a.y + b.y) / 2.0f, + z = (a.z + b.z) / 2.0f + }; + } + } +} \ No newline at end of file