summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xConfig.cs11
-rwxr-xr-xPlugin.cs251
2 files changed, 227 insertions, 35 deletions
diff --git a/Config.cs b/Config.cs
index 6cc4283..a5d42d5 100755
--- a/Config.cs
+++ b/Config.cs
@@ -1,4 +1,6 @@
-using SharpPluginLoader.Core.Configuration;
+#define SIMPLE_KEYBOARD_LAYER
+
+using SharpPluginLoader.Core.Configuration;
using SharpPluginLoader.Core.IO;
namespace MHWNewCamera
@@ -55,7 +57,7 @@ namespace MHWNewCamera
}
public String Name => "MHWNewCamera";
- public String Version => "3.0";
+ public String Version => "3.1";
private static Dictionary<string, Button> buttonMap = new Dictionary<string, Button>
{
@@ -94,6 +96,11 @@ namespace MHWNewCamera
public bool DisableMod { get; set; } = false;
+#if SIMPLE_KEYBOARD_LAYER
+ public bool EnableKeyboard { get; set; } = true;
+ public int KeyboardLookSensitivity { get; set; } = 19750;
+#endif
+
public bool EnableCombo { get; set; } = true;
public String FreeCameraCombo { get; set; } = "RStick,LT";
public bool DisableComboButton1UnlessButton2Held { get; set; } = false;
diff --git a/Plugin.cs b/Plugin.cs
index 96063ed..87c958b 100755
--- a/Plugin.cs
+++ b/Plugin.cs
@@ -1,6 +1,7 @@
//#define ADDR_ASSERTS
//#define HOOK_ORDER_ASSERTS
//#define LOG_DEBUG_MESSAGES
+#define SIMPLE_KEYBOARD_LAYER
using ImGuiNET;
using System.Numerics;
@@ -18,6 +19,7 @@ using System.Diagnostics;
// @TODO:
// - Bind to switch camera preset.
+// - More multiple controller testing.
// - Thoroughly test "Disable Mod".
// - Improve AOB scans.
// - Glass objects in research base and on the botanical research center table still fade.
@@ -89,6 +91,11 @@ namespace MHWNewCamera
private bool disableMod = false;
+#if SIMPLE_KEYBOARD_LAYER
+ private bool keyboardEnabled = false;
+ private int keyboardLookValue;
+#endif
+
private float cameraSpeed;
private float cameraSpeedModifier;
private float cameraSensitivity;
@@ -353,6 +360,12 @@ namespace MHWNewCamera
Config config = ConfigManager.GetConfig<Config>(this);
disableMod = config.DisableMod;
+
+#if SIMPLE_KEYBOARD_LAYER
+ keyboardEnabled = config.EnableKeyboard;
+ keyboardLookValue = config.KeyboardLookSensitivity;
+#endif
+
enableCombo = config.EnableCombo;
freeCameraCombo = Config.ParseCombo(config.FreeCameraCombo);
typedCombo = config.FreeCameraCombo.Replace(",", "+");
@@ -756,6 +769,32 @@ namespace MHWNewCamera
debugLog($"OnUpdate() @ {frameTick}");
#endif
+#if SIMPLE_KEYBOARD_LAYER
+ if (keyboardEnabled)
+ {
+ if (Input.IsPressed(Key.NumPad0))
+ {
+ enableFreeCamera = !enableFreeCamera;
+ }
+ if (Input.IsPressed(Key.NumPadPeriod))
+ {
+ if (uiToggled)
+ {
+ jmpOverUi.Disable();
+ }
+ else
+ {
+ jmpOverUi.Enable();
+ }
+ uiToggled = !uiToggled;
+ }
+ if (Input.IsPressed(Key.NumPadSlash))
+ {
+ forceOffDof = !forceOffDof;
+ }
+ }
+#endif
+
primaryPad = 0x0;
}
@@ -850,13 +889,17 @@ namespace MHWNewCamera
swapMinimapFollowsCamera.Disable();
}
+ private double adjustedZoomSpeed(float deltaTime)
+ {
+ return cameraZoomSpeed * deltaTime * cameraFov;
+ }
+
private void updateFreeCamera(Camera camera)
{
float deltaTime = camera.DeltaTime;
bool lockVerticalAndModifySpeed = buttonWasDown(Button.L2) || lockVerticalToggled;
double adjustedSpeed = cameraSpeed * deltaTime * (lockVerticalAndModifySpeed ? cameraSpeedModifier : 1.0f);
- double buttonOffset = adjustedSpeed / 2.0;
cameraFrameX = 0.0;
cameraFrameY = 0.0;
@@ -866,8 +909,7 @@ namespace MHWNewCamera
{
int PadLy = MemoryUtil.Read<int>(controllerAddr() + 0x1BC);
if (Math.Abs(PadLy) < stickDeadzone) PadLy = 0;
- double adjustedZoomSpeed = cameraZoomSpeed * deltaTime * cameraFov;
- double Ly = PadLy / (Int16.MaxValue / adjustedZoomSpeed);
+ double Ly = PadLy / (Int16.MaxValue / adjustedZoomSpeed(deltaTime));
cameraFov = Math.Clamp(cameraFov - Ly, 1.0, 179.0);
}
else if (!(unlockMovementHeld || unlockMovementToggled)) // Move camera.
@@ -876,6 +918,15 @@ namespace MHWNewCamera
if (Math.Abs(PadLy) < stickDeadzone) PadLy = 0;
int PadLx = MemoryUtil.Read<int>(controllerAddr() + 0x1B8);
if (Math.Abs(PadLx) < stickDeadzone) PadLx = 0;
+#if SIMPLE_KEYBOARD_LAYER
+ if (keyboardEnabled)
+ {
+ if (Input.IsDown(Key.Up)) PadLy += Int16.MaxValue;
+ if (Input.IsDown(Key.Down)) PadLy -= Int16.MaxValue;
+ if (Input.IsDown(Key.Left)) PadLx -= Int16.MaxValue;
+ if (Input.IsDown(Key.Right)) PadLx += Int16.MaxValue;
+ }
+#endif
double Lx = PadLx / (Int16.MaxValue / adjustedSpeed);
double Ly = PadLy / (Int16.MaxValue / adjustedSpeed);
@@ -943,28 +994,71 @@ namespace MHWNewCamera
{
if (buttonWasDown(Button.Up))
{
- cameraFrameY += buttonOffset;
+ cameraFrameY += adjustedSpeed / 2.0;
}
if (buttonWasDown(Button.Down))
{
- cameraFrameY -= buttonOffset;
+ cameraFrameY -= adjustedSpeed / 2.0;
}
if (buttonWasDown(Button.Left))
{
- cameraRoll -= buttonOffset / 2.0;
+ cameraRoll -= adjustedSpeed / 4.0;
}
if (buttonWasDown(Button.Right))
{
- cameraRoll += buttonOffset / 2.0;
+ cameraRoll += adjustedSpeed / 4.0;
}
}
}
+#if SIMPLE_KEYBOARD_LAYER
+ if (keyboardEnabled)
+ {
+ if (Input.IsDown(Key.NumPadMinus))
+ {
+ cameraFov = Math.Clamp(cameraFov - adjustedZoomSpeed(deltaTime), 1.0, 179.0);
+ }
+ if (Input.IsDown(Key.NumPadPlus))
+ {
+ cameraFov = Math.Clamp(cameraFov + adjustedZoomSpeed(deltaTime), 1.0, 179.0);
+ }
+ if (Input.IsPressed(Key.NumPadStar))
+ {
+ cameraRoll = (preDetachRoll != null) ? (double)preDetachRoll : 0.0f;
+ }
+ if (Input.IsDown(Key.NumPad7))
+ {
+ cameraFrameY += adjustedSpeed / 2.0;
+ }
+ if (Input.IsDown(Key.NumPad1))
+ {
+ cameraFrameY -= adjustedSpeed / 2.0;
+ }
+ if (Input.IsDown(Key.NumPad9))
+ {
+ cameraRoll += adjustedSpeed / 4.0;
+ }
+ if (Input.IsDown(Key.NumPad3))
+ {
+ cameraRoll -= adjustedSpeed / 4.0;
+ }
+ }
+#endif
+
// Camera look.
int PadRx = MemoryUtil.Read<int>(controllerAddr() + 0x1B0);
if (Math.Abs(PadRx) < stickDeadzone) PadRx = 0;
int PadRy = MemoryUtil.Read<int>(controllerAddr() + 0x1B4);
if (Math.Abs(PadRy) < stickDeadzone) PadRy = 0;
+#if SIMPLE_KEYBOARD_LAYER
+ if (keyboardEnabled)
+ {
+ if (Input.IsDown(Key.NumPad8)) PadRy += keyboardLookValue;
+ if (Input.IsDown(Key.NumPad2)) PadRy -= keyboardLookValue;
+ if (Input.IsDown(Key.NumPad4)) PadRx -= keyboardLookValue;
+ if (Input.IsDown(Key.NumPad6)) PadRx += keyboardLookValue;
+ }
+#endif
double adjustedSensitivity = cameraSensitivity * deltaTime * cameraFov;
double Rx = PadRx / (Int16.MaxValue / adjustedSensitivity);
double Ry = PadRy / (Int16.MaxValue / adjustedSensitivity);
@@ -1359,8 +1453,7 @@ namespace MHWNewCamera
#endif
Button b1 = 0u, b2 = 0u;
- // PadOld = 0x19C
- uint PadDown = 0u, PadTrg = 0u, PadRel = 0u, PadChg = 0u;
+ uint PadDown = 0u, PadTrg = 0u, PadRel = 0u, PadChg = 0u; // PadOld = 0x19C
if (enableCombo && freeCameraCombo != null)
{
b1 = freeCameraCombo[0];
@@ -1717,14 +1810,14 @@ namespace MHWNewCamera
ImGui.InputFloat("Far Clip", ref camera.FarClip);
if (freeCamera && i == vCameraViewportIndex)
{
- ImGui.DragFloat3("Position", ref cameraPosition, 0.45f);
+ ImGui.DragFloat3("Position", ref cameraPosition, 0.425f);
}
else
{
- ImGui.DragFloat3("Position", ref camera.Position, 0.45f);
+ ImGui.DragFloat3("Position", ref camera.Position, 0.425f);
}
- ImGui.DragFloat3("Target", ref camera.Target, 0.45f);
- ImGui.DragFloat3("Up", ref camera.Up, 0.45f);
+ ImGui.DragFloat3("Target", ref camera.Target, 0.425f);
+ ImGui.DragFloat3("Up", ref camera.Up, 0.425f);
ImGui.PushItemWidth(width * 0.15f);
ImGui.InputText("##Position Name", ref typedPositionName, 99);
ImGui.SameLine();
@@ -1794,15 +1887,18 @@ namespace MHWNewCamera
ConfigManager.SaveConfig<Config>(this);
}
}
- bool move = camera.Move;
- if (ImGui.Checkbox("Move", ref move))
- {
- camera.Move = move;
- }
- if (ImGui.BeginItemTooltip())
+ if (debug || !(freeCamera && i == vCameraViewportIndex))
{
- ImGui.Text("Uncheck this to allow manually overriding the camera position.\nIf your camera is frozen, make sure this is checked.");
- ImGui.EndTooltip();
+ bool move = camera.Move;
+ if (ImGui.Checkbox("Move", ref move))
+ {
+ camera.Move = move;
+ }
+ if (ImGui.BeginItemTooltip())
+ {
+ ImGui.Text("Uncheck this to allow manually overriding the camera position.\nIf your camera is frozen, make sure this is checked.");
+ ImGui.EndTooltip();
+ }
}
if (debug)
{
@@ -1816,17 +1912,17 @@ namespace MHWNewCamera
if (camera == vCamera)
{
float yaw = (float)cameraYaw;
- if (ImGui.DragFloat("Yaw", ref yaw, 0.25f))
+ if (ImGui.DragFloat("Yaw", ref yaw, 0.2f))
{
cameraYaw = yaw;
}
float pitch = (float)cameraPitch;
- if (ImGui.DragFloat("Pitch", ref pitch, 0.25f))
+ if (ImGui.DragFloat("Pitch", ref pitch, 0.2f))
{
cameraPitch = pitch;
}
float offsetRoll = (float)cameraRoll;
- if (ImGui.DragFloat("Roll", ref offsetRoll, 0.25f))
+ if (ImGui.DragFloat("Roll", ref offsetRoll, 0.2f))
{
cameraRoll = offsetRoll;
}
@@ -1835,9 +1931,9 @@ namespace MHWNewCamera
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f);
}
- ImGui.Text("Offset:");
+ ImGui.Text("Offsets");
float offsetForward = 0.0f;
- if (ImGui.DragFloat("Forward", ref offsetForward, 0.45f))
+ if (ImGui.DragFloat("Forward", ref offsetForward, 0.425f))
{
Quaternion forward = getForward(camera.Position, camera.Target);
forward = Quaternion.Normalize(forward);
@@ -1847,7 +1943,7 @@ namespace MHWNewCamera
cameraPosition = camera.Position;
}
float offsetRight = 0.0f;
- if (ImGui.DragFloat("Right", ref offsetRight, 0.45f))
+ if (ImGui.DragFloat("Right", ref offsetRight, 0.425f))
{
Quaternion forward = getForward(camera.Position, camera.Target);
Quaternion right = getRight(forward);
@@ -1857,6 +1953,12 @@ namespace MHWNewCamera
camera.Position.Z += right.Z * offsetRight;
cameraPosition = camera.Position;
}
+ float offsetUp = 0.0f;
+ if (ImGui.DragFloat("Up", ref offsetUp, 0.425f))
+ {
+ camera.Position.Y += offsetUp;
+ cameraPosition = camera.Position;
+ }
if (camera == pCamera && !freeCamera)
{
ImGui.PopStyleVar();
@@ -1979,7 +2081,7 @@ namespace MHWNewCamera
}
ImGui.PushID("Perspective");
- ImGui.PushItemWidth(width * 0.6f);
+ ImGui.PushItemWidth(width * 0.575f);
float singleFov = (float)cameraFov;
if (ImGui.DragFloat("Field of View", ref singleFov, 0.4f, 1.0f, 179.0f))
{
@@ -2118,7 +2220,7 @@ namespace MHWNewCamera
ImGui.PopID();
ImGui.PushID("Settings");
- ImGui.PushItemWidth(width * 0.6f);
+ ImGui.PushItemWidth(width * 0.575f);
ImGui.DragFloat("Camera Speed", ref cameraSpeed, 0.01f, 0.0f);
if (ImGui.BeginItemTooltip())
{
@@ -2152,7 +2254,7 @@ namespace MHWNewCamera
ImGui.Text("-1.0 = Wrap around (go upside down).");
ImGui.EndTooltip();
}
- ImGui.InputInt("Stick Deadzone", ref stickDeadzone, 10);
+ ImGui.DragInt("Stick Deadzone", ref stickDeadzone, 5, 0);
ImGui.PopItemWidth();
if (ImGui.Button("Default"))
{
@@ -2441,6 +2543,89 @@ namespace MHWNewCamera
}
ImGui.PopID();
+#if SIMPLE_KEYBOARD_LAYER
+ ImGui.PushID("Keyboard");
+ if (ImGui.CollapsingHeader("Keyboard"))
+ {
+ if (ImGui.Checkbox("Enable Keyboard", ref keyboardEnabled))
+ {
+ config.EnableKeyboard = keyboardEnabled;
+ ConfigManager.SaveConfig<Config>(this);
+ }
+ ImGui.PushItemWidth(width * 0.20f);
+ if (ImGui.DragInt("Keyboard Look Sensitivity", ref keyboardLookValue, 20, 0, Int16.MaxValue))
+ {
+ config.KeyboardLookSensitivity = keyboardLookValue;
+ ConfigManager.SaveConfig<Config>(this);
+ }
+ if (ImGui.BeginItemTooltip())
+ {
+ ImGui.Text("Value that gets sent as a simulated joystick movement. Range: [0, 32767].");
+ ImGui.EndTooltip();
+ }
+ ImGui.PopItemWidth();
+ if (ImGui.BeginTable("Keyboard Binds", 2, ImGuiTableFlags.SizingStretchProp | ImGuiTableFlags.Borders))
+ {
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("Num 0");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Toggle Free Camera");
+
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("Num 8/2/4/6");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Look");
+
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("Up/Down/Left/Right");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Move Camera");
+
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("Num 7/1");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Translate Up/Down");
+
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("Num 9/3");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Roll Camera");
+
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("Num *");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Reset Roll");
+
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("Num -/+");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Zoom");
+
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("Num .");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Toggle UI");
+
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("Num /");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Toggle Depth of Field");
+
+ ImGui.EndTable();
+ }
+ }
+ ImGui.PopID();
+#endif
+
ImGui.PushID("Player");
if (ImGui.CollapsingHeader("Player") && player != null)
{
@@ -2856,9 +3041,9 @@ namespace MHWNewCamera
ImGui.Separator();
ImGui.PushID("Camera");
ImGui.Text("Perspective Camera");
- ImGui.DragFloat("X Offset", ref cameraXOffset, 0.45f);
- ImGui.DragFloat("Y Offset", ref cameraYOffset, 0.45f);
- ImGui.DragFloat("Z Offset", ref cameraZOffset, 0.45f);
+ ImGui.DragFloat("X Offset", ref cameraXOffset, 0.425f);
+ ImGui.DragFloat("Y Offset", ref cameraYOffset, 0.425f);
+ ImGui.DragFloat("Z Offset", ref cameraZOffset, 0.425f);
ImGui.Text("Viewports");
for (int i = 0; i < 8; i++)
{