Dual Joycon Support

Added support for using both joycons for rumble and gyroscope
This commit is contained in:
MYCRAFTisbest 2020-10-11 15:14:03 -04:00
parent 53ad5cfc61
commit 7c5b1ffae2
3 changed files with 44 additions and 28 deletions

View file

@ -12,6 +12,7 @@ using BetterJoyForCemu.Controller;
using Nefarius.ViGEm.Client.Targets.DualShock4;
using Nefarius.ViGEm.Client.Targets.Xbox360;
using SharpDX.XInput;
using JetBrains.Annotations;
//WARNING: Code is a mess and pretty hacked together changes were made for Win Max stuff -MYCRAFT
namespace BetterJoyForCemu {
@ -1042,6 +1043,7 @@ namespace BetterJoyForCemu {
bool swapAB = Boolean.Parse(ConfigurationManager.AppSettings["SwapAB"]);
bool swapXY = Boolean.Parse(ConfigurationManager.AppSettings["SwapXY"]);
bool proOverride = Boolean.Parse(ConfigurationManager.AppSettings["ProControllerOverride"]);
private int ProcessButtonsAndStick(byte[] report_buf) {
//Console.WriteLine("Well hello!");//*********
//XInputTest(controller, xState);
@ -1085,15 +1087,19 @@ namespace BetterJoyForCemu {
//Console.WriteLine((float)xState.Gamepad.LeftThumbX);
//Console.WriteLine(xState.Gamepad.LeftThumbX);
// Read other Joycon's sticks
if (isLeft && other != null && other != this) {
stick2 = otherStick;
other.otherStick = stick;
}
if (!isLeft && other != null && other != this) {
Array.Copy(stick, stick2, 2);
stick = otherStick;
other.otherStick = stick2;
//Check to fix joining dual joycons for rumble
if (!proOverride) {
if (isLeft && other != null && other != this) {
stick2 = otherStick;
other.otherStick = stick;
}
if (!isLeft && other != null && other != this) {
Array.Copy(stick, stick2, 2);
stick = otherStick;
other.otherStick = stick2;
}
}
}
//
@ -1146,24 +1152,27 @@ namespace BetterJoyForCemu {
//Console.WriteLine(((int)xState.Gamepad.LeftTrigger % 254));
}
if (other != null && other != this) {
buttons[(int)(Button.B)] = other.buttons[(int)Button.DPAD_DOWN];
buttons[(int)(Button.A)] = other.buttons[(int)Button.DPAD_RIGHT];
buttons[(int)(Button.X)] = other.buttons[(int)Button.DPAD_UP];
buttons[(int)(Button.Y)] = other.buttons[(int)Button.DPAD_LEFT];
//dual joycons check
if (!proOverride) {
if (other != null && other != this) {
buttons[(int)(Button.B)] = other.buttons[(int)Button.DPAD_DOWN];
buttons[(int)(Button.A)] = other.buttons[(int)Button.DPAD_RIGHT];
buttons[(int)(Button.X)] = other.buttons[(int)Button.DPAD_UP];
buttons[(int)(Button.Y)] = other.buttons[(int)Button.DPAD_LEFT];
buttons[(int)Button.STICK2] = other.buttons[(int)Button.STICK];
buttons[(int)Button.SHOULDER2_1] = other.buttons[(int)Button.SHOULDER_1];
buttons[(int)Button.SHOULDER2_2] = other.buttons[(int)Button.SHOULDER_2];
}
buttons[(int)Button.STICK2] = other.buttons[(int)Button.STICK];
buttons[(int)Button.SHOULDER2_1] = other.buttons[(int)Button.SHOULDER_1];
buttons[(int)Button.SHOULDER2_2] = other.buttons[(int)Button.SHOULDER_2];
}
if (isLeft && other != null && other != this) {
buttons[(int)Button.HOME] = other.buttons[(int)Button.HOME];
buttons[(int)Button.PLUS] = other.buttons[(int)Button.PLUS];
}
if (isLeft && other != null && other != this) {
buttons[(int)Button.HOME] = other.buttons[(int)Button.HOME];
buttons[(int)Button.PLUS] = other.buttons[(int)Button.PLUS];
}
if (!isLeft && other != null && other != this) {
buttons[(int)Button.MINUS] = other.buttons[(int)Button.MINUS];
if (!isLeft && other != null && other != this) {
buttons[(int)Button.MINUS] = other.buttons[(int)Button.MINUS];
}
}
//reconnect Xinput if SR is pressed and setting is not disabled
@ -1553,7 +1562,7 @@ namespace BetterJoyForCemu {
private static OutputControllerXbox360InputState MapToXbox360Input(Joycon input) {
var output = new OutputControllerXbox360InputState();
var swapAB = input.swapAB;
var swapXY = input.swapXY;

View file

@ -101,7 +101,7 @@
this.version_lbl.Name = "version_lbl";
this.version_lbl.Size = new System.Drawing.Size(78, 13);
this.version_lbl.TabIndex = 2;
this.version_lbl.Text = "v1.1WM (v6.4)";
this.version_lbl.Text = "v1.2WM (v6.4)";
this.version_lbl.Click += new System.EventHandler(this.version_lbl_Click);
//
// passiveScanBox
@ -219,6 +219,7 @@
this.con1.TabStop = false;
this.btnTip.SetToolTip(this.con1, "Click on Joycons to join/split them");
this.con1.UseVisualStyleBackColor = true;
this.con1.Click += new System.EventHandler(this.con1_Click);
//
// foldLbl
//

View file

@ -154,7 +154,7 @@ namespace BetterJoyForCemu {
if (button.Tag.GetType() == typeof(Joycon)) {
Joycon v = (Joycon)button.Tag;
if (v.other == null && !v.isPro) { // needs connecting to other joycon (so messy omg)
if (v.other == null && (!v.isPro || proOverride)) { // needs connecting to other joycon (so messy omg)
bool succ = false;
if (Program.mgr.j.Count == 1) { // when want to have a single joycon in vertical mode
@ -162,7 +162,7 @@ namespace BetterJoyForCemu {
succ = true;
} else {
foreach (Joycon jc in Program.mgr.j) {
if (!jc.isPro && jc.isLeft != v.isLeft && jc != v && jc.other == null) {
if ( jc.isLeft != v.isLeft && jc != v && jc.other == null) { //!jc.isPro && removed from start of if stetement **
v.other = jc;
jc.other = v;
@ -198,15 +198,17 @@ namespace BetterJoyForCemu {
foreach (Button b in con)
if (b.Tag == v)
b.BackgroundImage = v.isLeft ? Properties.Resources.jc_left : Properties.Resources.jc_right;
} else if (v.other != null && !v.isPro) { // needs disconnecting from other joycon
} else if (v.other != null && (!v.isPro || proOverride)) { //needs disconnecting from other joycon
ReenableViGEm(v);
ReenableViGEm(v.other);
button.BackgroundImage = v.isLeft ? Properties.Resources.jc_left_s : Properties.Resources.jc_right_s;
foreach (Button b in con)
if (b.Tag == v.other)
b.BackgroundImage = v.other.isLeft ? Properties.Resources.jc_left_s : Properties.Resources.jc_right_s;
//Set original Joycon LEDs
v.other.LED = (byte)(0x1 << v.other.PadId);
@ -358,6 +360,10 @@ namespace BetterJoyForCemu {
System.Diagnostics.Process.Start("https://discord.gg/XNUFgft");
}
private void con1_Click(object sender, EventArgs e) {
}
private void CountDown(object sender, EventArgs e) {
if (this.count == 0) {
this.console.Text = "Calibrating...";