- Implemented active-gyro button
This commit is contained in:
parent
d8352d9b34
commit
e4c0690306
2 changed files with 42 additions and 4 deletions
|
@ -42,6 +42,7 @@ namespace BetterJoyForCemu {
|
||||||
public bool isSnes = false;
|
public bool isSnes = false;
|
||||||
bool isUSB = false;
|
bool isUSB = false;
|
||||||
public Joycon other;
|
public Joycon other;
|
||||||
|
public bool active_gyro = false;
|
||||||
|
|
||||||
public bool send = true;
|
public bool send = true;
|
||||||
|
|
||||||
|
@ -569,16 +570,25 @@ namespace BetterJoyForCemu {
|
||||||
if (extraGyroFeature == "joy") {
|
if (extraGyroFeature == "joy") {
|
||||||
// TODO
|
// TODO
|
||||||
} else if (extraGyroFeature == "mouse" && (isPro || (other == null) || (other != null && (Boolean.Parse(ConfigurationManager.AppSettings["GyroMouseLeftHanded"]) ? isLeft : !isLeft)))) {
|
} else if (extraGyroFeature == "mouse" && (isPro || (other == null) || (other != null && (Boolean.Parse(ConfigurationManager.AppSettings["GyroMouseLeftHanded"]) ? isLeft : !isLeft)))) {
|
||||||
|
string res_val = Config.Value("active_gyro");
|
||||||
|
if (res_val.StartsWith("joy_"))
|
||||||
|
if (buttons_down[Int32.Parse(res_val.Substring(4))])
|
||||||
|
active_gyro = true;
|
||||||
|
else if (buttons_up[Int32.Parse(res_val.Substring(4))])
|
||||||
|
active_gyro = false;
|
||||||
|
|
||||||
float dt = 0.015f; // 15ms
|
float dt = 0.015f; // 15ms
|
||||||
|
|
||||||
// gyro data is in degrees/s
|
// gyro data is in degrees/s
|
||||||
int dx = (int)(GyroMouseSensitivity * (gyr_g.Z * dt) * (Math.Abs(gyr_g.Z) < 1 ? 0 : 1));
|
if (Config.Value("active_gyro") == "0" || active_gyro) {
|
||||||
int dy = (int)-(GyroMouseSensitivity * (gyr_g.Y * dt) * (Math.Abs(gyr_g.Y) < 1 ? 0 : 1));
|
int dx = (int)(GyroMouseSensitivity * (gyr_g.Z * dt) * (Math.Abs(gyr_g.Z) < 1 ? 0 : 1));
|
||||||
|
int dy = (int)-(GyroMouseSensitivity * (gyr_g.Y * dt) * (Math.Abs(gyr_g.Y) < 1 ? 0 : 1));
|
||||||
|
|
||||||
WindowsInput.Simulate.Events().MoveBy(dx, dy).Invoke();
|
WindowsInput.Simulate.Events().MoveBy(dx, dy).Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
// reset mouse position to centre of primary monitor
|
// reset mouse position to centre of primary monitor
|
||||||
string res_val = Config.Value("reset_mouse");
|
res_val = Config.Value("reset_mouse");
|
||||||
if (res_val.StartsWith("joy_"))
|
if (res_val.StartsWith("joy_"))
|
||||||
if (buttons_down[Int32.Parse(res_val.Substring(4))])
|
if (buttons_down[Int32.Parse(res_val.Substring(4))])
|
||||||
WindowsInput.Simulate.Events().MoveTo(Screen.PrimaryScreen.Bounds.Width / 2, Screen.PrimaryScreen.Bounds.Height / 2).Invoke();
|
WindowsInput.Simulate.Events().MoveTo(Screen.PrimaryScreen.Bounds.Width / 2, Screen.PrimaryScreen.Bounds.Height / 2).Invoke();
|
||||||
|
|
|
@ -442,6 +442,20 @@ namespace BetterJoyForCemu {
|
||||||
if (res_val.StartsWith("mse_"))
|
if (res_val.StartsWith("mse_"))
|
||||||
if ((int)e.Data.ButtonDown.Button == Int32.Parse(res_val.Substring(4)))
|
if ((int)e.Data.ButtonDown.Button == Int32.Parse(res_val.Substring(4)))
|
||||||
WindowsInput.Simulate.Events().MoveTo(Screen.PrimaryScreen.Bounds.Width / 2, Screen.PrimaryScreen.Bounds.Height / 2).Invoke();
|
WindowsInput.Simulate.Events().MoveTo(Screen.PrimaryScreen.Bounds.Width / 2, Screen.PrimaryScreen.Bounds.Height / 2).Invoke();
|
||||||
|
|
||||||
|
res_val = Config.Value("active_gyro");
|
||||||
|
if (res_val.StartsWith("mse_"))
|
||||||
|
if ((int)e.Data.ButtonDown.Button == Int32.Parse(res_val.Substring(4)))
|
||||||
|
foreach (var i in mgr.j)
|
||||||
|
i.active_gyro = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.Data.ButtonUp != null) {
|
||||||
|
string res_val = Config.Value("active_gyro");
|
||||||
|
if (res_val.StartsWith("mse_"))
|
||||||
|
if ((int)e.Data.ButtonUp.Button == Int32.Parse(res_val.Substring(4)))
|
||||||
|
foreach (var i in mgr.j)
|
||||||
|
i.active_gyro = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,6 +465,20 @@ namespace BetterJoyForCemu {
|
||||||
if (res_val.StartsWith("key_"))
|
if (res_val.StartsWith("key_"))
|
||||||
if ((int)e.Data.KeyDown.Key == Int32.Parse(res_val.Substring(4)))
|
if ((int)e.Data.KeyDown.Key == Int32.Parse(res_val.Substring(4)))
|
||||||
WindowsInput.Simulate.Events().MoveTo(Screen.PrimaryScreen.Bounds.Width / 2, Screen.PrimaryScreen.Bounds.Height / 2).Invoke();
|
WindowsInput.Simulate.Events().MoveTo(Screen.PrimaryScreen.Bounds.Width / 2, Screen.PrimaryScreen.Bounds.Height / 2).Invoke();
|
||||||
|
|
||||||
|
res_val = Config.Value("active_gyro");
|
||||||
|
if (res_val.StartsWith("key_"))
|
||||||
|
if ((int)e.Data.KeyDown.Key == Int32.Parse(res_val.Substring(4)))
|
||||||
|
foreach (var i in mgr.j)
|
||||||
|
i.active_gyro = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.Data.KeyUp != null) {
|
||||||
|
string res_val = Config.Value("active_gyro");
|
||||||
|
if (res_val.StartsWith("key_"))
|
||||||
|
if ((int)e.Data.KeyUp.Key == Int32.Parse(res_val.Substring(4)))
|
||||||
|
foreach (var i in mgr.j)
|
||||||
|
i.active_gyro = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue