diff --git a/BetterJoyForCemu/Joycon.cs b/BetterJoyForCemu/Joycon.cs index b80fc6f..4e3ce93 100644 --- a/BetterJoyForCemu/Joycon.cs +++ b/BetterJoyForCemu/Joycon.cs @@ -291,11 +291,6 @@ namespace BetterJoyForCemu { a[0] = 0x1; dump_calibration_data(); - - a = Enumerable.Repeat((byte)0xFF, 25).ToArray(); - a[0] = 0x18; - a[1] = 0x01; - Subcommand(0x38, a, 25, false); } else { Subcommand(0x03, new byte[] { 0x3f }, 1, false); @@ -328,7 +323,12 @@ namespace BetterJoyForCemu { dump_calibration_data(); } - a[0] = leds_; + a = Enumerable.Repeat((byte)0xFF, 25).ToArray(); // LED ring + a[0] = 0x18; + a[1] = 0x01; + Subcommand(0x38, a, 25, false); + + a[0] = leds_; Subcommand(0x30, a, 1); Subcommand(0x40, new byte[] { (imu_enabled ? (byte)0x1 : (byte)0x0) }, 1, true); Subcommand(0x3, new byte[] { 0x30 }, 1, true); @@ -377,7 +377,9 @@ namespace BetterJoyForCemu { byte[] raw_buf = new byte[report_len]; int ret = HIDapi.hid_read(handle, raw_buf, new UIntPtr(report_len)); if (ret > 0) { - SendRumble(rumble_obj.GetData()); // Needed for USB to not time out + if (!isPro) + SendRumble(rumble_obj.GetData()); // make rumble better when on bluetooth + // Process packets as soon as they come for (int n = 0; n < 3; n++) { ExtractIMUValues(raw_buf, n); @@ -411,6 +413,8 @@ namespace BetterJoyForCemu { private void Poll() { int attempts = 0; while (!stop_polling & state > state_.NO_JOYCONS) { + if (isPro) + SendRumble(rumble_obj.GetData()); // Needed for USB to not time out int a = ReceiveRaw(); if (a > 0) { @@ -593,7 +597,7 @@ namespace BetterJoyForCemu { } if (xin != null) { - if (other != null) { + if (other != null | isPro) { report.SetAxis(Xbox360Axes.LeftThumbX, (short)Math.Max(Int16.MinValue, Math.Min(Int16.MaxValue, stick[0] * (stick[0] > 0 ? Int16.MaxValue : -Int16.MinValue)))); report.SetAxis(Xbox360Axes.LeftThumbY, (short)Math.Max(Int16.MinValue, Math.Min(Int16.MaxValue, stick[1] * (stick[1] > 0 ? Int16.MaxValue : -Int16.MinValue)))); report.SetAxis(Xbox360Axes.RightThumbX, (short)Math.Max(Int16.MinValue, Math.Min(Int16.MaxValue, stick2[0] * (stick2[0] > 0 ? Int16.MaxValue : -Int16.MinValue)))); @@ -648,6 +652,7 @@ namespace BetterJoyForCemu { public void Begin() { if (PollThreadObj == null) { PollThreadObj = new Thread(new ThreadStart(Poll)); + PollThreadObj.IsBackground = true; PollThreadObj.Start(); form.console.Text += "Starting poll thread.\r\n"; diff --git a/BetterJoyForCemu/MainForm.cs b/BetterJoyForCemu/MainForm.cs index 4025b69..543b299 100644 --- a/BetterJoyForCemu/MainForm.cs +++ b/BetterJoyForCemu/MainForm.cs @@ -31,23 +31,21 @@ namespace BetterJoyForCemu { private void MainForm_Load(object sender, EventArgs e) { this.ShowInTaskbar = true; notifyIcon.Visible = false; - - Program.Start(); + this.Show(); + Program.Start(); } private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { try { Program.Stop(); - System.Threading.Thread.Sleep(1000); - Application.Exit(); + Close(); } catch { } } private void exitToolStripMenuItem_Click(object sender, EventArgs e) { try { Program.Stop(); - System.Threading.Thread.Sleep(1000); - Application.Exit(); + Close(); } catch { } } diff --git a/BetterJoyForCemu/Program.cs b/BetterJoyForCemu/Program.cs index 0ad5571..18f8d85 100644 --- a/BetterJoyForCemu/Program.cs +++ b/BetterJoyForCemu/Program.cs @@ -181,12 +181,12 @@ namespace BetterJoyForCemu { } public void OnApplicationQuit() { - for (int i = 0; i < j.Count; ++i) { - j[i].Detach(); + foreach (Joycon v in j) { + v.Detach(); - if (j[i].xin != null) { - j[i].xin.Disconnect(); - j[i].xin.Dispose(); + if (v.xin != null) { + v.xin.Disconnect(); + v.xin.Dispose(); } } } @@ -214,6 +214,7 @@ namespace BetterJoyForCemu { public void Start() { run = true; thread = new Thread(new ThreadStart(Run)); + thread.IsBackground = true; thread.Start(); }