- Fixed Subcommands not properly returning.
- all subcommand require a read back from the controller to confirm it has been acknowledged - Got rid of the last reminants of "BetterJoyForCemu" - Changed GUID to actual GUID of program
This commit is contained in:
parent
d894335017
commit
a291f0daf6
5 changed files with 122 additions and 135 deletions
|
@ -50,7 +50,7 @@
|
||||||
<!-- Default: true -->
|
<!-- Default: true -->
|
||||||
<add key="PurgeWhitelist" value="false" />
|
<add key="PurgeWhitelist" value="false" />
|
||||||
<!-- Determines whether or not to use HidGuardian (improves compatibility with other programs, like Steam, when set to "false") -->
|
<!-- Determines whether or not to use HidGuardian (improves compatibility with other programs, like Steam, when set to "false") -->
|
||||||
<!-- When "true", BetterJoyForCemu will hide the Pro/Joycons from other programs to prevent glitching out on exit and to prevent DI/XI clashes in certain programs -->
|
<!-- When "true", BetterJoy will hide the Pro/Joycons from other programs to prevent glitching out on exit and to prevent DI/XI clashes in certain programs -->
|
||||||
<!-- Default: false -->
|
<!-- Default: false -->
|
||||||
<add key="UseHIDG" value="true" />
|
<add key="UseHIDG" value="true" />
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@
|
||||||
<add key="DragToggle" value="false"/>
|
<add key="DragToggle" value="false"/>
|
||||||
|
|
||||||
<!-- Determines whether or not the program will expose detected controllers as Xbox 360 controllers -->
|
<!-- Determines whether or not the program will expose detected controllers as Xbox 360 controllers -->
|
||||||
<!-- When "false", BetterJoyForCemu is only usable with CEMU. -->
|
<!-- When "false", BetterJoy is only usable with CEMU. -->
|
||||||
<!-- Default: true -->
|
<!-- Default: true -->
|
||||||
<add key="ShowAsXInput" value="true" />
|
<add key="ShowAsXInput" value="true" />
|
||||||
<!-- Have ShowAsXInput as false if using this -->
|
<!-- Have ShowAsXInput as false if using this -->
|
||||||
|
|
|
@ -91,8 +91,6 @@ namespace BetterJoyForCemu {
|
||||||
private UInt16[] stick2_precal = { 0, 0 };
|
private UInt16[] stick2_precal = { 0, 0 };
|
||||||
|
|
||||||
private bool stop_polling = true;
|
private bool stop_polling = true;
|
||||||
private int timestamp;
|
|
||||||
private bool first_imu_packet = true;
|
|
||||||
private bool imu_enabled = false;
|
private bool imu_enabled = false;
|
||||||
private Int16[] acc_r = { 0, 0, 0 };
|
private Int16[] acc_r = { 0, 0, 0 };
|
||||||
private Int16[] acc_neutral = { 0, 0, 0 };
|
private Int16[] acc_neutral = { 0, 0, 0 };
|
||||||
|
@ -381,17 +379,16 @@ namespace BetterJoyForCemu {
|
||||||
//Subcommand(0x01, new byte[] { 0x03 }, 1, true);
|
//Subcommand(0x01, new byte[] { 0x03 }, 1, true);
|
||||||
|
|
||||||
BlinkHomeLight();
|
BlinkHomeLight();
|
||||||
|
|
||||||
Subcommand(0x40, new byte[] { (imu_enabled ? (byte)0x1 : (byte)0x0) }, 1, true);
|
|
||||||
Subcommand(0x48, new byte[] { 0x01 }, 1, true);
|
|
||||||
|
|
||||||
Subcommand(0x41, new byte[] { 0x03, 0x00, 0x00, 0x01 }, 4, false); // higher gyro performance rate
|
|
||||||
|
|
||||||
Subcommand(0x3, new byte[] { 0x30 }, 1, true);
|
|
||||||
DebugPrint("Done with init.", DebugType.COMMS);
|
|
||||||
|
|
||||||
SetPlayerLED(leds_);
|
SetPlayerLED(leds_);
|
||||||
|
|
||||||
|
Subcommand(0x40, new byte[] { (imu_enabled ? (byte)0x1 : (byte)0x0) }, 1);
|
||||||
|
Subcommand(0x48, new byte[] { 0x01 }, 1);
|
||||||
|
|
||||||
|
Subcommand(0x41, new byte[] { 0x03, 0x00, 0x00, 0x01 }, 4); // higher gyro performance rate
|
||||||
|
|
||||||
|
Subcommand(0x3, new byte[] { 0x30 }, 1);
|
||||||
|
DebugPrint("Done with init.", DebugType.COMMS);
|
||||||
|
|
||||||
HIDapi.hid_set_nonblocking(handle, 1);
|
HIDapi.hid_set_nonblocking(handle, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -970,10 +967,6 @@ namespace BetterJoyForCemu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Recenter() {
|
|
||||||
first_imu_packet = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Should really be called calculating stick data
|
// Should really be called calculating stick data
|
||||||
private float[] CenterSticks(UInt16[] vals, ushort[] cal, ushort dz) {
|
private float[] CenterSticks(UInt16[] vals, ushort[] cal, ushort dz) {
|
||||||
ushort[] t = cal;
|
ushort[] t = cal;
|
||||||
|
@ -1012,7 +1005,7 @@ namespace BetterJoyForCemu {
|
||||||
HIDapi.hid_write(handle, buf_, new UIntPtr(report_len));
|
HIDapi.hid_write(handle, buf_, new UIntPtr(report_len));
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] Subcommand(byte sc, byte[] buf, uint len, bool ignoreResponse = true, bool print = true) {
|
private byte[] Subcommand(byte sc, byte[] buf, uint len, bool print = true) {
|
||||||
byte[] buf_ = new byte[report_len];
|
byte[] buf_ = new byte[report_len];
|
||||||
byte[] response = new byte[report_len];
|
byte[] response = new byte[report_len];
|
||||||
Array.Copy(default_buf, 0, buf_, 2, 8);
|
Array.Copy(default_buf, 0, buf_, 2, 8);
|
||||||
|
@ -1024,12 +1017,6 @@ namespace BetterJoyForCemu {
|
||||||
else ++global_count;
|
else ++global_count;
|
||||||
if (print) { PrintArray(buf_, DebugType.COMMS, len, 11, "Subcommand 0x" + string.Format("{0:X2}", sc) + " sent. Data: 0x{0:S}"); };
|
if (print) { PrintArray(buf_, DebugType.COMMS, len, 11, "Subcommand 0x" + string.Format("{0:X2}", sc) + " sent. Data: 0x{0:S}"); };
|
||||||
HIDapi.hid_write(handle, buf_, new UIntPtr(len + 11));
|
HIDapi.hid_write(handle, buf_, new UIntPtr(len + 11));
|
||||||
if (ignoreResponse) {
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
if (stop_polling == false) {
|
|
||||||
throw new ArgumentException("Can't request response while poll is running as it could eat the response.");
|
|
||||||
}
|
|
||||||
int tries = 0;
|
int tries = 0;
|
||||||
do {
|
do {
|
||||||
|
|
||||||
|
@ -1037,17 +1024,40 @@ namespace BetterJoyForCemu {
|
||||||
if (res < 1) DebugPrint("No response.", DebugType.COMMS);
|
if (res < 1) DebugPrint("No response.", DebugType.COMMS);
|
||||||
else if (print) { PrintArray(response, DebugType.COMMS, report_len - 1, 1, "Response ID 0x" + string.Format("{0:X2}", response[0]) + ". Data: 0x{0:S}"); }
|
else if (print) { PrintArray(response, DebugType.COMMS, report_len - 1, 1, "Response ID 0x" + string.Format("{0:X2}", response[0]) + ". Data: 0x{0:S}"); }
|
||||||
tries++;
|
tries++;
|
||||||
|
} while (tries < 10 && response[0] != 0x21 && response[14] != sc);
|
||||||
if (tries > 20) throw new InvalidOperationException("we should be able to find our response, where could it be?");
|
|
||||||
} while (response[0] != 0x21 && response[14] != sc);
|
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dump_calibration_data() {
|
private void dump_calibration_data() {
|
||||||
if (!isSnes) {
|
if (isSnes)
|
||||||
byte[] buf_ = ReadSPI(0x80, (isLeft ? (byte)0x12 : (byte)0x1d), 9); // get user calibration data if possible
|
return;
|
||||||
bool found = false;
|
HIDapi.hid_set_nonblocking(handle, 0);
|
||||||
|
byte[] buf_ = ReadSPI(0x80, (isLeft ? (byte)0x12 : (byte)0x1d), 9); // get user calibration data if possible
|
||||||
|
bool found = false;
|
||||||
|
for (int i = 0; i < 9; ++i) {
|
||||||
|
if (buf_[i] != 0xff) {
|
||||||
|
form.AppendTextBox("Using user stick calibration data.\r\n");
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
form.AppendTextBox("Using factory stick calibration data.\r\n");
|
||||||
|
buf_ = ReadSPI(0x60, (isLeft ? (byte)0x3d : (byte)0x46), 9); // get user calibration data if possible
|
||||||
|
}
|
||||||
|
stick_cal[isLeft ? 0 : 2] = (UInt16)((buf_[1] << 8) & 0xF00 | buf_[0]); // X Axis Max above center
|
||||||
|
stick_cal[isLeft ? 1 : 3] = (UInt16)((buf_[2] << 4) | (buf_[1] >> 4)); // Y Axis Max above center
|
||||||
|
stick_cal[isLeft ? 2 : 4] = (UInt16)((buf_[4] << 8) & 0xF00 | buf_[3]); // X Axis Center
|
||||||
|
stick_cal[isLeft ? 3 : 5] = (UInt16)((buf_[5] << 4) | (buf_[4] >> 4)); // Y Axis Center
|
||||||
|
stick_cal[isLeft ? 4 : 0] = (UInt16)((buf_[7] << 8) & 0xF00 | buf_[6]); // X Axis Min below center
|
||||||
|
stick_cal[isLeft ? 5 : 1] = (UInt16)((buf_[8] << 4) | (buf_[7] >> 4)); // Y Axis Min below center
|
||||||
|
|
||||||
|
PrintArray(stick_cal, len: 6, start: 0, format: "Stick calibration data: {0:S}");
|
||||||
|
|
||||||
|
if (isPro) {
|
||||||
|
buf_ = ReadSPI(0x80, (!isLeft ? (byte)0x12 : (byte)0x1d), 9); // get user calibration data if possible
|
||||||
|
found = false;
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
if (buf_[i] != 0xff) {
|
if (buf_[i] != 0xff) {
|
||||||
form.AppendTextBox("Using user stick calibration data.\r\n");
|
form.AppendTextBox("Using user stick calibration data.\r\n");
|
||||||
|
@ -1057,94 +1067,71 @@ namespace BetterJoyForCemu {
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
form.AppendTextBox("Using factory stick calibration data.\r\n");
|
form.AppendTextBox("Using factory stick calibration data.\r\n");
|
||||||
buf_ = ReadSPI(0x60, (isLeft ? (byte)0x3d : (byte)0x46), 9); // get user calibration data if possible
|
buf_ = ReadSPI(0x60, (!isLeft ? (byte)0x3d : (byte)0x46), 9); // get user calibration data if possible
|
||||||
}
|
}
|
||||||
stick_cal[isLeft ? 0 : 2] = (UInt16)((buf_[1] << 8) & 0xF00 | buf_[0]); // X Axis Max above center
|
stick2_cal[!isLeft ? 0 : 2] = (UInt16)((buf_[1] << 8) & 0xF00 | buf_[0]); // X Axis Max above center
|
||||||
stick_cal[isLeft ? 1 : 3] = (UInt16)((buf_[2] << 4) | (buf_[1] >> 4)); // Y Axis Max above center
|
stick2_cal[!isLeft ? 1 : 3] = (UInt16)((buf_[2] << 4) | (buf_[1] >> 4)); // Y Axis Max above center
|
||||||
stick_cal[isLeft ? 2 : 4] = (UInt16)((buf_[4] << 8) & 0xF00 | buf_[3]); // X Axis Center
|
stick2_cal[!isLeft ? 2 : 4] = (UInt16)((buf_[4] << 8) & 0xF00 | buf_[3]); // X Axis Center
|
||||||
stick_cal[isLeft ? 3 : 5] = (UInt16)((buf_[5] << 4) | (buf_[4] >> 4)); // Y Axis Center
|
stick2_cal[!isLeft ? 3 : 5] = (UInt16)((buf_[5] << 4) | (buf_[4] >> 4)); // Y Axis Center
|
||||||
stick_cal[isLeft ? 4 : 0] = (UInt16)((buf_[7] << 8) & 0xF00 | buf_[6]); // X Axis Min below center
|
stick2_cal[!isLeft ? 4 : 0] = (UInt16)((buf_[7] << 8) & 0xF00 | buf_[6]); // X Axis Min below center
|
||||||
stick_cal[isLeft ? 5 : 1] = (UInt16)((buf_[8] << 4) | (buf_[7] >> 4)); // Y Axis Min below center
|
stick2_cal[!isLeft ? 5 : 1] = (UInt16)((buf_[8] << 4) | (buf_[7] >> 4)); // Y Axis Min below center
|
||||||
|
|
||||||
PrintArray(stick_cal, len: 6, start: 0, format: "Stick calibration data: {0:S}");
|
PrintArray(stick2_cal, len: 6, start: 0, format: "Stick calibration data: {0:S}");
|
||||||
|
|
||||||
if (isPro) {
|
buf_ = ReadSPI(0x60, (!isLeft ? (byte)0x86 : (byte)0x98), 16);
|
||||||
buf_ = ReadSPI(0x80, (!isLeft ? (byte)0x12 : (byte)0x1d), 9); // get user calibration data if possible
|
deadzone2 = (UInt16)((buf_[4] << 8) & 0xF00 | buf_[3]);
|
||||||
found = false;
|
}
|
||||||
for (int i = 0; i < 9; ++i) {
|
|
||||||
if (buf_[i] != 0xff) {
|
|
||||||
form.AppendTextBox("Using user stick calibration data.\r\n");
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
form.AppendTextBox("Using factory stick calibration data.\r\n");
|
|
||||||
buf_ = ReadSPI(0x60, (!isLeft ? (byte)0x3d : (byte)0x46), 9); // get user calibration data if possible
|
|
||||||
}
|
|
||||||
stick2_cal[!isLeft ? 0 : 2] = (UInt16)((buf_[1] << 8) & 0xF00 | buf_[0]); // X Axis Max above center
|
|
||||||
stick2_cal[!isLeft ? 1 : 3] = (UInt16)((buf_[2] << 4) | (buf_[1] >> 4)); // Y Axis Max above center
|
|
||||||
stick2_cal[!isLeft ? 2 : 4] = (UInt16)((buf_[4] << 8) & 0xF00 | buf_[3]); // X Axis Center
|
|
||||||
stick2_cal[!isLeft ? 3 : 5] = (UInt16)((buf_[5] << 4) | (buf_[4] >> 4)); // Y Axis Center
|
|
||||||
stick2_cal[!isLeft ? 4 : 0] = (UInt16)((buf_[7] << 8) & 0xF00 | buf_[6]); // X Axis Min below center
|
|
||||||
stick2_cal[!isLeft ? 5 : 1] = (UInt16)((buf_[8] << 4) | (buf_[7] >> 4)); // Y Axis Min below center
|
|
||||||
|
|
||||||
PrintArray(stick2_cal, len: 6, start: 0, format: "Stick calibration data: {0:S}");
|
buf_ = ReadSPI(0x60, (isLeft ? (byte)0x86 : (byte)0x98), 16);
|
||||||
|
deadzone = (UInt16)((buf_[4] << 8) & 0xF00 | buf_[3]);
|
||||||
|
|
||||||
buf_ = ReadSPI(0x60, (!isLeft ? (byte)0x86 : (byte)0x98), 16);
|
buf_ = ReadSPI(0x80, 0x28, 10);
|
||||||
deadzone2 = (UInt16)((buf_[4] << 8) & 0xF00 | buf_[3]);
|
acc_neutral[0] = (Int16)(buf_[0] | ((buf_[1] << 8) & 0xff00));
|
||||||
}
|
acc_neutral[1] = (Int16)(buf_[2] | ((buf_[3] << 8) & 0xff00));
|
||||||
|
acc_neutral[2] = (Int16)(buf_[4] | ((buf_[5] << 8) & 0xff00));
|
||||||
|
|
||||||
buf_ = ReadSPI(0x60, (isLeft ? (byte)0x86 : (byte)0x98), 16);
|
buf_ = ReadSPI(0x80, 0x2E, 10);
|
||||||
deadzone = (UInt16)((buf_[4] << 8) & 0xF00 | buf_[3]);
|
acc_sensiti[0] = (Int16)(buf_[0] | ((buf_[1] << 8) & 0xff00));
|
||||||
|
acc_sensiti[1] = (Int16)(buf_[2] | ((buf_[3] << 8) & 0xff00));
|
||||||
|
acc_sensiti[2] = (Int16)(buf_[4] | ((buf_[5] << 8) & 0xff00));
|
||||||
|
|
||||||
buf_ = ReadSPI(0x80, 0x28, 10);
|
buf_ = ReadSPI(0x80, 0x34, 10);
|
||||||
|
gyr_neutral[0] = (Int16)(buf_[0] | ((buf_[1] << 8) & 0xff00));
|
||||||
|
gyr_neutral[1] = (Int16)(buf_[2] | ((buf_[3] << 8) & 0xff00));
|
||||||
|
gyr_neutral[2] = (Int16)(buf_[4] | ((buf_[5] << 8) & 0xff00));
|
||||||
|
|
||||||
|
buf_ = ReadSPI(0x80, 0x3A, 10);
|
||||||
|
gyr_sensiti[0] = (Int16)(buf_[0] | ((buf_[1] << 8) & 0xff00));
|
||||||
|
gyr_sensiti[1] = (Int16)(buf_[2] | ((buf_[3] << 8) & 0xff00));
|
||||||
|
gyr_sensiti[2] = (Int16)(buf_[4] | ((buf_[5] << 8) & 0xff00));
|
||||||
|
|
||||||
|
PrintArray(gyr_neutral, len: 3, d: DebugType.IMU, format: "User gyro neutral position: {0:S}");
|
||||||
|
|
||||||
|
// This is an extremely messy way of checking to see whether there is user stick calibration data present, but I've seen conflicting user calibration data on blank Joy-Cons. Worth another look eventually.
|
||||||
|
if (gyr_neutral[0] + gyr_neutral[1] + gyr_neutral[2] == -3 || Math.Abs(gyr_neutral[0]) > 100 || Math.Abs(gyr_neutral[1]) > 100 || Math.Abs(gyr_neutral[2]) > 100) {
|
||||||
|
buf_ = ReadSPI(0x60, 0x20, 10);
|
||||||
acc_neutral[0] = (Int16)(buf_[0] | ((buf_[1] << 8) & 0xff00));
|
acc_neutral[0] = (Int16)(buf_[0] | ((buf_[1] << 8) & 0xff00));
|
||||||
acc_neutral[1] = (Int16)(buf_[2] | ((buf_[3] << 8) & 0xff00));
|
acc_neutral[1] = (Int16)(buf_[2] | ((buf_[3] << 8) & 0xff00));
|
||||||
acc_neutral[2] = (Int16)(buf_[4] | ((buf_[5] << 8) & 0xff00));
|
acc_neutral[2] = (Int16)(buf_[4] | ((buf_[5] << 8) & 0xff00));
|
||||||
|
|
||||||
buf_ = ReadSPI(0x80, 0x2E, 10);
|
buf_ = ReadSPI(0x60, 0x26, 10);
|
||||||
acc_sensiti[0] = (Int16)(buf_[0] | ((buf_[1] << 8) & 0xff00));
|
acc_sensiti[0] = (Int16)(buf_[0] | ((buf_[1] << 8) & 0xff00));
|
||||||
acc_sensiti[1] = (Int16)(buf_[2] | ((buf_[3] << 8) & 0xff00));
|
acc_sensiti[1] = (Int16)(buf_[2] | ((buf_[3] << 8) & 0xff00));
|
||||||
acc_sensiti[2] = (Int16)(buf_[4] | ((buf_[5] << 8) & 0xff00));
|
acc_sensiti[2] = (Int16)(buf_[4] | ((buf_[5] << 8) & 0xff00));
|
||||||
|
|
||||||
buf_ = ReadSPI(0x80, 0x34, 10);
|
buf_ = ReadSPI(0x60, 0x2C, 10);
|
||||||
gyr_neutral[0] = (Int16)(buf_[0] | ((buf_[1] << 8) & 0xff00));
|
gyr_neutral[0] = (Int16)(buf_[0] | ((buf_[1] << 8) & 0xff00));
|
||||||
gyr_neutral[1] = (Int16)(buf_[2] | ((buf_[3] << 8) & 0xff00));
|
gyr_neutral[1] = (Int16)(buf_[2] | ((buf_[3] << 8) & 0xff00));
|
||||||
gyr_neutral[2] = (Int16)(buf_[4] | ((buf_[5] << 8) & 0xff00));
|
gyr_neutral[2] = (Int16)(buf_[4] | ((buf_[5] << 8) & 0xff00));
|
||||||
|
|
||||||
buf_ = ReadSPI(0x80, 0x3A, 10);
|
buf_ = ReadSPI(0x60, 0x32, 10);
|
||||||
gyr_sensiti[0] = (Int16)(buf_[0] | ((buf_[1] << 8) & 0xff00));
|
gyr_sensiti[0] = (Int16)(buf_[0] | ((buf_[1] << 8) & 0xff00));
|
||||||
gyr_sensiti[1] = (Int16)(buf_[2] | ((buf_[3] << 8) & 0xff00));
|
gyr_sensiti[1] = (Int16)(buf_[2] | ((buf_[3] << 8) & 0xff00));
|
||||||
gyr_sensiti[2] = (Int16)(buf_[4] | ((buf_[5] << 8) & 0xff00));
|
gyr_sensiti[2] = (Int16)(buf_[4] | ((buf_[5] << 8) & 0xff00));
|
||||||
|
|
||||||
PrintArray(gyr_neutral, len: 3, d: DebugType.IMU, format: "User gyro neutral position: {0:S}");
|
PrintArray(gyr_neutral, len: 3, d: DebugType.IMU, format: "Factory gyro neutral position: {0:S}");
|
||||||
|
|
||||||
// This is an extremely messy way of checking to see whether there is user stick calibration data present, but I've seen conflicting user calibration data on blank Joy-Cons. Worth another look eventually.
|
|
||||||
if (gyr_neutral[0] + gyr_neutral[1] + gyr_neutral[2] == -3 || Math.Abs(gyr_neutral[0]) > 100 || Math.Abs(gyr_neutral[1]) > 100 || Math.Abs(gyr_neutral[2]) > 100) {
|
|
||||||
buf_ = ReadSPI(0x60, 0x20, 10);
|
|
||||||
acc_neutral[0] = (Int16)(buf_[0] | ((buf_[1] << 8) & 0xff00));
|
|
||||||
acc_neutral[1] = (Int16)(buf_[2] | ((buf_[3] << 8) & 0xff00));
|
|
||||||
acc_neutral[2] = (Int16)(buf_[4] | ((buf_[5] << 8) & 0xff00));
|
|
||||||
|
|
||||||
buf_ = ReadSPI(0x60, 0x26, 10);
|
|
||||||
acc_sensiti[0] = (Int16)(buf_[0] | ((buf_[1] << 8) & 0xff00));
|
|
||||||
acc_sensiti[1] = (Int16)(buf_[2] | ((buf_[3] << 8) & 0xff00));
|
|
||||||
acc_sensiti[2] = (Int16)(buf_[4] | ((buf_[5] << 8) & 0xff00));
|
|
||||||
|
|
||||||
buf_ = ReadSPI(0x60, 0x2C, 10);
|
|
||||||
gyr_neutral[0] = (Int16)(buf_[0] | ((buf_[1] << 8) & 0xff00));
|
|
||||||
gyr_neutral[1] = (Int16)(buf_[2] | ((buf_[3] << 8) & 0xff00));
|
|
||||||
gyr_neutral[2] = (Int16)(buf_[4] | ((buf_[5] << 8) & 0xff00));
|
|
||||||
|
|
||||||
buf_ = ReadSPI(0x60, 0x32, 10);
|
|
||||||
gyr_sensiti[0] = (Int16)(buf_[0] | ((buf_[1] << 8) & 0xff00));
|
|
||||||
gyr_sensiti[1] = (Int16)(buf_[2] | ((buf_[3] << 8) & 0xff00));
|
|
||||||
gyr_sensiti[2] = (Int16)(buf_[4] | ((buf_[5] << 8) & 0xff00));
|
|
||||||
|
|
||||||
PrintArray(gyr_neutral, len: 3, d: DebugType.IMU, format: "Factory gyro neutral position: {0:S}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
HIDapi.hid_set_nonblocking(handle, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] ReadSPI(byte addr1, byte addr2, uint len, bool print = false) {
|
private byte[] ReadSPI(byte addr1, byte addr2, uint len, bool print = false) {
|
||||||
|
@ -1153,7 +1140,7 @@ namespace BetterJoyForCemu {
|
||||||
byte[] buf_ = new byte[len + 20];
|
byte[] buf_ = new byte[len + 20];
|
||||||
|
|
||||||
for (int i = 0; i < 100; ++i) {
|
for (int i = 0; i < 100; ++i) {
|
||||||
buf_ = Subcommand(0x10, buf, 5, false, false);
|
buf_ = Subcommand(0x10, buf, 5, false);
|
||||||
if (buf_[15] == addr2 && buf_[16] == addr1) {
|
if (buf_[15] == addr2 && buf_[16] == addr1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
70
BetterJoyForCemu/MainForm.Designer.cs
generated
70
BetterJoyForCemu/MainForm.Designer.cs
generated
|
@ -1,28 +1,28 @@
|
||||||
namespace BetterJoyForCemu {
|
namespace BetterJoyForCemu {
|
||||||
partial class MainForm {
|
partial class MainForm {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private System.ComponentModel.IContainer components = null;
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clean up any resources being used.
|
/// Clean up any resources being used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
protected override void Dispose(bool disposing) {
|
protected override void Dispose(bool disposing) {
|
||||||
if (disposing && (components != null)) {
|
if (disposing && (components != null)) {
|
||||||
components.Dispose();
|
components.Dispose();
|
||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required method for Designer support - do not modify
|
/// Required method for Designer support - do not modify
|
||||||
/// the contents of this method with the code editor.
|
/// the contents of this method with the code editor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent() {
|
private void InitializeComponent() {
|
||||||
this.components = new System.ComponentModel.Container();
|
this.components = new System.ComponentModel.Container();
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||||
this.console = new System.Windows.Forms.TextBox();
|
this.console = new System.Windows.Forms.TextBox();
|
||||||
|
@ -81,10 +81,10 @@
|
||||||
// notifyIcon
|
// notifyIcon
|
||||||
//
|
//
|
||||||
this.notifyIcon.BalloonTipText = "Double click the tray icon to maximise";
|
this.notifyIcon.BalloonTipText = "Double click the tray icon to maximise";
|
||||||
this.notifyIcon.BalloonTipTitle = "BetterJoyForCemu";
|
this.notifyIcon.BalloonTipTitle = "BetterJoy";
|
||||||
this.notifyIcon.ContextMenuStrip = this.contextMenu;
|
this.notifyIcon.ContextMenuStrip = this.contextMenu;
|
||||||
this.notifyIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon.Icon")));
|
this.notifyIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon.Icon")));
|
||||||
this.notifyIcon.Text = "BetterJoyForCemu";
|
this.notifyIcon.Text = "BetterJoy";
|
||||||
this.notifyIcon.Visible = true;
|
this.notifyIcon.Visible = true;
|
||||||
this.notifyIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon_MouseDoubleClick);
|
this.notifyIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon_MouseDoubleClick);
|
||||||
//
|
//
|
||||||
|
@ -110,7 +110,7 @@
|
||||||
this.version_lbl.Name = "version_lbl";
|
this.version_lbl.Name = "version_lbl";
|
||||||
this.version_lbl.Size = new System.Drawing.Size(28, 13);
|
this.version_lbl.Size = new System.Drawing.Size(28, 13);
|
||||||
this.version_lbl.TabIndex = 2;
|
this.version_lbl.TabIndex = 2;
|
||||||
this.version_lbl.Text = "v6.3";
|
this.version_lbl.Text = "v6.4";
|
||||||
//
|
//
|
||||||
// passiveScanBox
|
// passiveScanBox
|
||||||
//
|
//
|
||||||
|
@ -379,16 +379,16 @@
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public System.Windows.Forms.TextBox console;
|
public System.Windows.Forms.TextBox console;
|
||||||
private System.Windows.Forms.Label console_lbl;
|
private System.Windows.Forms.Label console_lbl;
|
||||||
private System.Windows.Forms.NotifyIcon notifyIcon;
|
private System.Windows.Forms.NotifyIcon notifyIcon;
|
||||||
private System.Windows.Forms.Label version_lbl;
|
private System.Windows.Forms.Label version_lbl;
|
||||||
private System.Windows.Forms.ContextMenuStrip contextMenu;
|
private System.Windows.Forms.ContextMenuStrip contextMenu;
|
||||||
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
||||||
private System.Windows.Forms.CheckBox passiveScanBox;
|
private System.Windows.Forms.CheckBox passiveScanBox;
|
||||||
private System.Windows.Forms.LinkLabel donationLink;
|
private System.Windows.Forms.LinkLabel donationLink;
|
||||||
private System.Windows.Forms.GroupBox conCntrls;
|
private System.Windows.Forms.GroupBox conCntrls;
|
||||||
|
@ -409,6 +409,6 @@
|
||||||
private System.Windows.Forms.Button settingsApply;
|
private System.Windows.Forms.Button settingsApply;
|
||||||
private System.Windows.Forms.Label foldLbl;
|
private System.Windows.Forms.Label foldLbl;
|
||||||
private System.Windows.Forms.Button AutoCalibrate;
|
private System.Windows.Forms.Button AutoCalibrate;
|
||||||
private System.Windows.Forms.Button btn_reassign_open;
|
private System.Windows.Forms.Button btn_reassign_open;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,7 +229,7 @@ namespace BetterJoyForCemu {
|
||||||
v.other = temp;
|
v.other = temp;
|
||||||
|
|
||||||
//Set both Joycon LEDs to the one with the lowest ID
|
//Set both Joycon LEDs to the one with the lowest ID
|
||||||
byte led = temp.LED <= v.LED ? temp.LED : v.LED;
|
byte led = Math.Min(temp.LED, v.LED);
|
||||||
temp.LED = led;
|
temp.LED = led;
|
||||||
v.LED = led;
|
v.LED = led;
|
||||||
temp.SetPlayerLED(led);
|
temp.SetPlayerLED(led);
|
||||||
|
@ -476,7 +476,7 @@ namespace BetterJoyForCemu {
|
||||||
mgr.OnApplicationQuit();
|
mgr.OnApplicationQuit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string appGuid = "04450797-3520-462e-a563-107677a483d8"; // randomly-generated
|
private static string appGuid = "1bf709e9-c133-41df-933a-c9ff3f664c7b"; // randomly-generated
|
||||||
static void Main(string[] args) {
|
static void Main(string[] args) {
|
||||||
using (Mutex mutex = new Mutex(false, "Global\\" + appGuid)) {
|
using (Mutex mutex = new Mutex(false, "Global\\" + appGuid)) {
|
||||||
if (!mutex.WaitOne(0, false)) {
|
if (!mutex.WaitOne(0, false)) {
|
||||||
|
|
|
@ -5,12 +5,12 @@ using System.Runtime.InteropServices;
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
// associated with an assembly.
|
// associated with an assembly.
|
||||||
[assembly: AssemblyTitle("BetterJoyForCemu")]
|
[assembly: AssemblyTitle("BetterJoy")]
|
||||||
[assembly: AssemblyDescription("")]
|
[assembly: AssemblyDescription("")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("BetterJoyForCemu")]
|
[assembly: AssemblyProduct("BetterJoy")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue