Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mouse.x1Button and mouse.x2Button #197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 57 additions & 1 deletion FreePIE.Core.Plugins/MousePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class MousePlugin : Plugin
private bool leftPressed;
private bool rightPressed;
private bool middlePressed;
private bool x1Pressed;
private bool x2Pressed;
private GetPressedStrategy<int> getButtonPressedStrategy;
private SetPressedStrategy setButtonPressedStrategy;

Expand Down Expand Up @@ -170,6 +172,7 @@ private void SetButtonUp(int button)
public void SetButtonPressed(int index, bool pressed)
{
uint btn_flag = 0;
uint btn_data = 0;
if (index == 0)
{
if (pressed)
Expand Down Expand Up @@ -198,6 +201,47 @@ public void SetButtonPressed(int index, bool pressed)
}
rightPressed = pressed;
}
else if (index == 3)
{
if (pressed)
{
if (!x1Pressed)
{

btn_data = MouseKeyIO.XBUTTON1;
btn_flag = MouseKeyIO.MOUSEEVENTF_XDOWN;
}
}
else
{
if (x1Pressed)
{
btn_data = MouseKeyIO.XBUTTON1;
btn_flag = MouseKeyIO.MOUSEEVENTF_XUP;
}
}
x1Pressed = pressed;
}
else if (index == 4)
{
if (pressed)
{
if (!x2Pressed)
{
btn_data = MouseKeyIO.XBUTTON2;
btn_flag = MouseKeyIO.MOUSEEVENTF_XDOWN;
}
}
else
{
if (x2Pressed)
{
btn_data = MouseKeyIO.XBUTTON2;
btn_flag = MouseKeyIO.MOUSEEVENTF_XUP;
}
}
x2Pressed = pressed;
}
else
{
if (pressed)
Expand All @@ -216,7 +260,7 @@ public void SetButtonPressed(int index, bool pressed)
if (btn_flag != 0) {
var input = new MouseKeyIO.INPUT[1];
input[0].type = MouseKeyIO.INPUT_MOUSE;
input[0].mi = MouseInput(0, 0, 0, 0, btn_flag);
input[0].mi = MouseInput(0, 0, btn_data, 0, btn_flag);

MouseKeyIO.SendInput(1, input, Marshal.SizeOf(input[0].GetType()));
}
Expand Down Expand Up @@ -296,6 +340,18 @@ public bool rightButton
set { plugin.SetButtonPressed(1, value); }
}

public bool x1Button
{
get { return plugin.IsButtonDown(3); }
set { plugin.SetButtonPressed(3, value); }
}

public bool x2Button
{
get { return plugin.IsButtonDown(4); }
set { plugin.SetButtonPressed(4, value); }
}

public bool getButton(int button)
{
return plugin.IsButtonDown(button);
Expand Down