Add support for multiple keys

If the key setting contains “,”, then press multiple keys at the same time.
This commit is contained in:
Xzonn 2022-08-28 01:08:55 +08:00 committed by GitHub
parent 461f5f8f5c
commit 35e38cc5a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -636,14 +636,27 @@ namespace BetterJoyForCemu {
Dictionary<int, bool> mouse_toggle_btn = new Dictionary<int, bool>();
private void Simulate(string s, bool click = true, bool up = false) {
if (s.StartsWith("key_")) {
WindowsInput.Events.KeyCode key = (WindowsInput.Events.KeyCode)Int32.Parse(s.Substring(4));
if (click) {
WindowsInput.Simulate.Events().Click(key).Invoke();
} else {
if (up) {
WindowsInput.Simulate.Events().Release(key).Invoke();
if (s.Contains(",")) {
List<WindowsInput.Events.KeyCode> keys = s.Substring(4).Split(',').Select(x => (WindowsInput.Events.KeyCode)Int32.Parse(x)).ToList();
if (click) {
WindowsInput.Simulate.Events().ClickChord(keys).Invoke();
} else {
WindowsInput.Simulate.Events().Hold(key).Invoke();
if (up) {
WindowsInput.Simulate.Events().Release(keys).Invoke();
} else {
WindowsInput.Simulate.Events().Hold(keys).Invoke();
}
}
} else {
WindowsInput.Events.KeyCode key = (WindowsInput.Events.KeyCode)Int32.Parse(s.Substring(4));
if (click) {
WindowsInput.Simulate.Events().Click(key).Invoke();
} else {
if (up) {
WindowsInput.Simulate.Events().Release(key).Invoke();
} else {
WindowsInput.Simulate.Events().Hold(key).Invoke();
}
}
}
} else if (s.StartsWith("mse_")) {