Skip to content

Commit

Permalink
add middle mouse support and add show cursor option for debugging rem…
Browse files Browse the repository at this point in the history
…apper
  • Loading branch information
komefai committed Apr 1, 2018
1 parent 591f2d1 commit 4431edb
Show file tree
Hide file tree
Showing 5 changed files with 239 additions and 130 deletions.
1 change: 1 addition & 0 deletions PS4Macro/Classes/Remapping/BindingsContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class BindingsContainer
public bool MouseInvertYAxis { get; set; }
public int LeftMouseMapping { get; set; }
public int RightMouseMapping { get; set; }
public int MiddleMouseMapping { get; set; }

public static void Serialize(string path, BindingsContainer container)
{
Expand Down
35 changes: 33 additions & 2 deletions PS4Macro/Classes/Remapping/Remapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ public class Remapper
public int CursorOverflowY { get; private set; }
public bool LeftMouseDown { get; private set; }
public bool RightMouseDown { get; private set; }
public bool MiddleMouseDown { get; private set; }
public double MouseSpeedX { get; private set; }
public double MouseSpeedY { get; private set; }

public bool EnableMouseInput { get; set; }
public bool DebugCursor { get; set; }
public double MouseSensitivity { get; set; }
public double MouseDecayRate { get; set; }
public double MouseDecayThreshold { get; set; }
Expand All @@ -81,6 +83,7 @@ public class Remapper
public bool MouseInvertYAxis { get; set; }
public int LeftMouseMapping { get; set; }
public int RightMouseMapping { get; set; }
public int MiddleMouseMapping { get; set; }

public MacroPlayer MacroPlayer { get; private set; }
public bool UsingMacroPlayer { get; private set; }
Expand All @@ -96,6 +99,7 @@ public Remapper()
IsCursorShowing = true;

EnableMouseInput = false;
DebugCursor = false;
MouseSensitivity = 1;
MouseDecayRate = 1.2;
MouseDecayThreshold = 0.1;
Expand All @@ -106,6 +110,7 @@ public Remapper()
MouseInvertYAxis = false;
LeftMouseMapping = 11; // R2
RightMouseMapping = 10; // L2
MiddleMouseMapping = 9; // L1

MacroPlayer = new MacroPlayer();

Expand Down Expand Up @@ -212,6 +217,21 @@ public void OnReceiveData(ref DualShockState state)
}
}

// Middle mouse
var middleMap = MappingsDataBinding.ElementAtOrDefault(MiddleMouseMapping);
if (middleMap != null)
{
if (MiddleMouseDown)
{
RemapperUtility.SetValue(CurrentState, middleMap.Property, middleMap.Value);
}
else
{
var defaultValue = RemapperUtility.GetValue(checkState, middleMap.Property);
RemapperUtility.SetValue(CurrentState, middleMap.Property, defaultValue);
}
}

// Mouse moved
if (CurrentMouseStroke != null && CurrentMouseStroke.DidMoved)
{
Expand Down Expand Up @@ -370,7 +390,7 @@ public void OnMouseEvent(object sender, GlobalMouseHookEventArgs e)
if (EnableMouseInput)
{
// Hide cursor
if (IsCursorShowing)
if (!DebugCursor && IsCursorShowing)
{
ShowCursorAndToolbar(false);
}
Expand All @@ -380,7 +400,7 @@ public void OnMouseEvent(object sender, GlobalMouseHookEventArgs e)
else
{
// Show cursor
if (!IsCursorShowing)
if (!DebugCursor && !IsCursorShowing)
{
ShowCursorAndToolbar(true);
}
Expand Down Expand Up @@ -415,6 +435,17 @@ public void OnMouseEvent(object sender, GlobalMouseHookEventArgs e)
RightMouseDown = false;
e.Handled = focusedWindow;
}
// Middle mouse
else if (e.MouseState == GlobalMouseHook.MouseState.MiddleButtonDown)
{
MiddleMouseDown = true;
e.Handled = focusedWindow;
}
else if (e.MouseState == GlobalMouseHook.MouseState.MiddleButtonUp)
{
MiddleMouseDown = false;
e.Handled = focusedWindow;
}
// Mouse move
else if (e.MouseState == GlobalMouseHook.MouseState.Move)
{
Expand Down
Loading

0 comments on commit 4431edb

Please sign in to comment.