From 9231d263bad1a964df8f856445f720df698abe04 Mon Sep 17 00:00:00 2001 From: Kostas Missos Date: Fri, 15 Sep 2017 05:11:41 +0300 Subject: [PATCH] Add Pro controllers colors change Unfortunatelly, no hw no test. So I took users testing for granted.. Had to change my Joy-Con to be recognisable as a Pro Controller to test that the buttons color work on Pro controller on Switch and that the default white is actually to distinguish them from the black body. Note: Now Pro buttons WHITE color will be previewed as Grey. --- jctool/FormJoy.h | 25 +++++++++++++++++-------- jctool/FormJoy.resx | 22 +++++++++++----------- jctool/jctool.cpp | 8 ++++---- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/jctool/FormJoy.h b/jctool/FormJoy.h index 352d2ee..0460034 100644 --- a/jctool/FormJoy.h +++ b/jctool/FormJoy.h @@ -37,7 +37,6 @@ namespace CppWinFormJoy { else { this->textBoxSN->Text = L"No S/N"; this->textBox_chg_sn->Text = this->textBoxSN->Text; - this->btnClrDlg2->Visible = false; } unsigned char device_info[10]; memset(device_info, 0, sizeof(device_info)); @@ -2010,7 +2009,7 @@ namespace CppWinFormJoy { return; } set_led_busy(); - if (MessageBox::Show(L"Don't forget to make a backup first!\nYou can also find retail colors at the bottom of the colors dialog for each type.\n\nNote: Pro controller buttons cannot be changed.\n\nAre you sure you want to continue?", L"Warning!", MessageBoxButtons::YesNo, MessageBoxIcon::Warning) == System::Windows::Forms::DialogResult::Yes) + if (MessageBox::Show(L"Don't forget to make a backup first!\nYou can also find retail colors at the bottom of the colors dialog for each type.\n\nAre you sure you want to continue?", L"Warning!", MessageBoxButtons::YesNo, MessageBoxIcon::Warning) == System::Windows::Forms::DialogResult::Yes) { this->btnWriteBody->Enabled = false; @@ -2028,8 +2027,7 @@ namespace CppWinFormJoy { button_color[2] = (u8)colorDialog2->Color.B; write_spi_data(0x6050, 0x3, body_color); - if (handle_ok != 3) - write_spi_data(0x6053, 0x3, button_color); + write_spi_data(0x6053, 0x3, button_color); send_rumble(); MessageBox::Show(L"The colors were writen to the device!", L"Done!", MessageBoxButtons::OK, MessageBoxIcon::Asterisk); @@ -2042,7 +2040,7 @@ namespace CppWinFormJoy { } private: System::Void btnClrDlg1_Click(System::Object^ sender, System::EventArgs^ e) { - if(handle_ok !=3 ) + if(handle_ok != 3 ) this->colorDialog1->CustomColors = getCustomColorFromConfig("bodycolors"); else this->colorDialog1->CustomColors = getCustomColorFromConfig("bodycolors_pro"); @@ -2158,13 +2156,25 @@ namespace CppWinFormJoy { if (gotColor.R <= 255 && gotColor.R > 100){ gotColor = Color::FromArgb(gotColor.A, CLAMP(r*color_coeff, 0.0f, 255.0f), CLAMP(g*color_coeff, 0.0f, 255.0f), CLAMP(b*color_coeff, 0.0f, 255.0f)); } - else if (gotColor.R <= 100 && gotColor.R != 78 && gotColor.R > 30 && handle_ok !=3) { + else if (handle_ok != 3 && gotColor.R <= 100 && gotColor.R != 78 && gotColor.R > 30) { if (gotColor.R == 100) gotColor = Color::FromArgb(gotColor.A, rb, gb, bb); else { gotColor = Color::FromArgb(gotColor.A, CLAMP(rb*color_coeff, 0.0f, 255.0f), CLAMP(gb*color_coeff, 0.0f, 255.0f), CLAMP(bb*color_coeff, 0.0f, 255.0f)); } } + else if (handle_ok == 3 && gotColor.R <= 100 && gotColor.R != 78 && gotColor.R > 30) { + if (rb == 255 && gb == 255 && bb == 255) { + //Do nothing + } + else { + if (gotColor.R == 100) + gotColor = Color::FromArgb(gotColor.A, rb, gb, bb); + else { + gotColor = Color::FromArgb(gotColor.A, CLAMP(rb*color_coeff, 0.0f, 255.0f), CLAMP(gb*color_coeff, 0.0f, 255.0f), CLAMP(bb*color_coeff, 0.0f, 255.0f)); + } + } + } MyImage->SetPixel(x, y, gotColor); } @@ -2191,8 +2201,7 @@ namespace CppWinFormJoy { memset(button_color, 0, 0x3); get_spi_data(0x6050, 0x3, body_color); - if (handle_ok != 3) - get_spi_data(0x6053, 0x3, button_color); + get_spi_data(0x6053, 0x3, button_color); update_joycon_color((u8)body_color[0], (u8)body_color[1], (u8)body_color[2], (u8)button_color[0], (u8)button_color[1], (u8)button_color[2]); diff --git a/jctool/FormJoy.resx b/jctool/FormJoy.resx index 0cacdfc..05ef8ab 100644 --- a/jctool/FormJoy.resx +++ b/jctool/FormJoy.resx @@ -132,6 +132,17 @@ 37 + + Make a backup first! +If you lose your serial number, bad things will happen! + +If you currently have the stock S/N, this will also create a backup of it inside the SPI. + +Restore it either here from the SPI backed up S/N or through Restore option from your SPI backup. + + +Maximum 15 ASCII characters. + @@ -212,17 +223,6 @@ 504, 17 - - Make a backup first! -If you lose your serial number, bad things will happen! - -If you currently have the stock S/N, this will also create a backup of it inside the SPI. - -Restore it either here from the SPI backed up S/N or through Restore option from your SPI backup. - - -Maximum 15 ASCII characters. - 634, 17 diff --git a/jctool/jctool.cpp b/jctool/jctool.cpp index 8457a1e..cfe0aea 100644 --- a/jctool/jctool.cpp +++ b/jctool/jctool.cpp @@ -66,8 +66,8 @@ int set_led_busy() { //Set breathing HOME Led if (handle_ok != 1) { memset(buf, 0, sizeof(buf)); - auto hdr = (brcm_hdr *)buf; - auto pkt = (brcm_cmd_01 *)(hdr + 1); + hdr = (brcm_hdr *)buf; + pkt = (brcm_cmd_01 *)(hdr + 1); hdr->cmd = 0x01; hdr->rumble[0] = timming_byte; timming_byte++; @@ -408,8 +408,8 @@ int send_rumble() { //Heartbeat HOME Led if (handle_ok != 1) { memset(buf, 0, sizeof(buf)); - auto hdr = (brcm_hdr *)buf; - auto pkt = (brcm_cmd_01 *)(hdr + 1); + hdr = (brcm_hdr *)buf; + pkt = (brcm_cmd_01 *)(hdr + 1); hdr->cmd = 0x01; hdr->rumble[0] = timming_byte; timming_byte++;