- 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,15 +1024,15 @@ 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)
|
||||||
|
return;
|
||||||
|
HIDapi.hid_set_nonblocking(handle, 0);
|
||||||
byte[] buf_ = ReadSPI(0x80, (isLeft ? (byte)0x12 : (byte)0x1d), 9); // get user calibration data if possible
|
byte[] buf_ = ReadSPI(0x80, (isLeft ? (byte)0x12 : (byte)0x1d), 9); // get user calibration data if possible
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
|
@ -1144,7 +1131,7 @@ namespace BetterJoyForCemu {
|
||||||
|
|
||||||
PrintArray(gyr_neutral, len: 3, d: DebugType.IMU, format: "Factory gyro neutral position: {0:S}");
|
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;
|
||||||
}
|
}
|
||||||
|
|
6
BetterJoyForCemu/MainForm.Designer.cs
generated
6
BetterJoyForCemu/MainForm.Designer.cs
generated
|
@ -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
|
||||||
//
|
//
|
||||||
|
|
|
@ -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