Allow for more than 1 pair of joycons to join up (could be buggy)
Change some colours
This commit is contained in:
parent
c8e0f93d54
commit
235aca5f75
3 changed files with 31 additions and 71 deletions
|
@ -228,7 +228,8 @@ namespace BetterJoyForCemu {
|
|||
isLeft = left;
|
||||
|
||||
PadId = id;
|
||||
this.isPro = isPro;
|
||||
LED = (byte)(0x1 << PadId);
|
||||
this.isPro = isPro;
|
||||
isUSB = usb;
|
||||
|
||||
this.path = path;
|
||||
|
|
|
@ -117,45 +117,28 @@ namespace BetterJoyForCemu {
|
|||
Joycon v = (Joycon)button.Tag;
|
||||
|
||||
if (v.other == null && !v.isPro) { // needs connecting to other joycon (so messy omg)
|
||||
bool succ = false;
|
||||
foreach (Joycon jc in Program.mgr.j) {
|
||||
if (!jc.isPro && jc.isLeft != v.isLeft && jc != v && jc.other == null) {
|
||||
v.other = jc;
|
||||
jc.other = v;
|
||||
|
||||
int found = 0;
|
||||
int minPadID = 10;
|
||||
foreach (Joycon jc in Program.mgr.j) { // current system is designed for a maximum of two joycons connected to the PC
|
||||
if (!jc.isPro) {
|
||||
found++;
|
||||
minPadID = Math.Min(jc.PadId, minPadID);
|
||||
v.xin.Dispose();
|
||||
v.xin = null;
|
||||
|
||||
foreach (Button b in con)
|
||||
if (b.Tag == jc)
|
||||
b.BackgroundImage = jc.isLeft ? Properties.Resources.jc_left : Properties.Resources.jc_right;
|
||||
|
||||
succ = true;
|
||||
break;
|
||||
}
|
||||
jc.LED = (byte)(0x1 << jc.PadId);
|
||||
}
|
||||
|
||||
if (found == 2) {
|
||||
AppendTextBox("Both joycons successfully found.\r\n");
|
||||
Joycon temp = null;
|
||||
foreach (Joycon jc in Program.mgr.j) {
|
||||
if (!jc.isPro) {
|
||||
jc.LED = (byte)(0x1 << minPadID);
|
||||
|
||||
if (temp == null)
|
||||
temp = jc;
|
||||
else {
|
||||
temp.other = jc;
|
||||
jc.other = temp;
|
||||
|
||||
temp.xin.Dispose();
|
||||
temp.xin = null;
|
||||
}
|
||||
|
||||
foreach (Button b in con) {
|
||||
if (b.Tag == jc) {
|
||||
if (jc.isLeft)
|
||||
b.BackgroundImage = Properties.Resources.jc_left;
|
||||
else
|
||||
b.BackgroundImage = Properties.Resources.jc_right;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // Join up the two joycons
|
||||
}
|
||||
if (succ)
|
||||
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
|
||||
if (v.xin == null) {
|
||||
ReenableXinput(v);
|
||||
|
@ -167,19 +150,11 @@ namespace BetterJoyForCemu {
|
|||
v.other.xin.Connect();
|
||||
}
|
||||
|
||||
if (v.isLeft)
|
||||
button.BackgroundImage = Properties.Resources.jc_left_s;
|
||||
else
|
||||
button.BackgroundImage = Properties.Resources.jc_right_s;
|
||||
button.BackgroundImage = v.isLeft ? Properties.Resources.jc_left_s : Properties.Resources.jc_right_s;
|
||||
|
||||
foreach (Button b in con) {
|
||||
if (b.Tag == v.other) {
|
||||
if (v.other.isLeft)
|
||||
b.BackgroundImage = Properties.Resources.jc_left_s;
|
||||
else
|
||||
b.BackgroundImage = 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;
|
||||
|
||||
v.other.other = null;
|
||||
v.other = null;
|
||||
|
|
|
@ -81,6 +81,7 @@ namespace BetterJoyForCemu {
|
|||
b.Invoke(new MethodInvoker(delegate {
|
||||
b.Enabled = false;
|
||||
b.BackgroundImage = Properties.Resources.cross;
|
||||
b.BackColor = System.Drawing.SystemColors.Control;
|
||||
}));
|
||||
break;
|
||||
}
|
||||
|
@ -210,23 +211,10 @@ namespace BetterJoyForCemu {
|
|||
ptr = enumerate.next;
|
||||
}
|
||||
|
||||
int found = 0;
|
||||
int minPadID = 10;
|
||||
foreach (Joycon v in j) { // current system is designed for a maximum of two joycons connected to the PC
|
||||
if (!v.isPro) {
|
||||
found++;
|
||||
minPadID = Math.Min(v.PadId, minPadID);
|
||||
}
|
||||
v.LED = (byte)(0x1 << v.PadId);
|
||||
}
|
||||
|
||||
if (found == 2 && foundNew) {
|
||||
form.AppendTextBox("Both joycons successfully found.\r\n");
|
||||
if (foundNew) { // attempt to auto join-up joycons on connection
|
||||
Joycon temp = null;
|
||||
foreach (Joycon v in j) {
|
||||
if (!v.isPro) {
|
||||
v.LED = (byte)(0x1 << minPadID);
|
||||
|
||||
if (temp == null)
|
||||
temp = v;
|
||||
else {
|
||||
|
@ -235,18 +223,14 @@ namespace BetterJoyForCemu {
|
|||
|
||||
temp.xin.Dispose();
|
||||
temp.xin = null;
|
||||
temp = null; // repeat
|
||||
}
|
||||
|
||||
foreach (Button b in form.con) {
|
||||
if (b.Tag == v) {
|
||||
if (v.isLeft)
|
||||
b.BackgroundImage = Properties.Resources.jc_left;
|
||||
else
|
||||
b.BackgroundImage = Properties.Resources.jc_right;
|
||||
}
|
||||
}
|
||||
foreach (Button b in form.con)
|
||||
if (b.Tag == v)
|
||||
b.BackgroundImage = v.isLeft ? Properties.Resources.jc_left : Properties.Resources.jc_right;
|
||||
}
|
||||
} // Join up the two joycons
|
||||
}
|
||||
}
|
||||
|
||||
HIDapi.hid_free_enumeration(top_ptr);
|
||||
|
|
Loading…
Add table
Reference in a new issue