Skip to content

Commit

Permalink
Combine sixaxis input with game input
Browse files Browse the repository at this point in the history
  • Loading branch information
RoboPhred committed Jul 26, 2020
1 parent f469d52 commit a63af30
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/OrientationInjector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/SixAxisPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ThrustInjector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
18 changes: 18 additions & 0 deletions src/VectorUtils.cs
Original file line number Diff line number Diff line change
@@ -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
};
}
}
}

0 comments on commit a63af30

Please sign in to comment.