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