mirror of
https://github.com/CTCaer/jc_toolkit
synced 2026-11-26 09:08:07 +08:00
Add support for Loop .bnvib + many bugfixes
This commit is contained in:
1 parent
b3f26cc460
commit
d979dbf2eb
4 files changed
+193
-64
No files matched your search
+123
-46
@@ -99,7 +99,12 @@ namespace CppWinFormJoy {
|
||||
this->textBox_chg_sn->Validating += gcnew CancelEventHandler(this, &FormJoy::textBox_chg_sn_Validating);
|
||||
this->textBox_chg_sn->Validated += gcnew EventHandler(this, &FormJoy::textBox_chg_sn_Validated);
|
||||
|
||||
this->toolTip1->SetToolTip(this->label_sn, "Click here to change your S/N");
|
||||
this->textBox_vib_loop_times->Validating += gcnew CancelEventHandler(this, &FormJoy::textBox_loop_Validating);
|
||||
this->textBox_vib_loop_times->Validated += gcnew EventHandler(this, &FormJoy::textBox_loop_Validated);
|
||||
|
||||
this->toolTip1->SetToolTip(this->label_sn, L"Click here to change your S/N");
|
||||
this->toolTip1->SetToolTip(this->textBox_vib_loop_times, L"Set how many additional times the loop will be played.\n\nChoose a number from 0 to 999");
|
||||
this->toolTip1->SetToolTip(this->label_loop_times, L"Set how many additional times the loop will be played.\n\nChoose a number from 0 to 999");
|
||||
|
||||
//Initialise locations on start for easy designing
|
||||
this->menuStrip1->Size = System::Drawing::Size(485, 24);
|
||||
@@ -233,9 +238,10 @@ namespace CppWinFormJoy {
|
||||
private: System::Windows::Forms::GroupBox^ groupBox_vib_eq;
|
||||
private: System::Windows::Forms::Label^ label_batt_percent;
|
||||
private: System::Windows::Forms::Button^ btn_enable_expert_mode;
|
||||
private: System::Windows::Forms::Label^ label_play_time;
|
||||
private: System::Windows::Forms::Label^ label_loop_times;
|
||||
private: System::Windows::Forms::Button^ btnRestore_SN;
|
||||
private: System::Windows::Forms::GroupBox^ groupBox_vib_info;
|
||||
private: System::Windows::Forms::TextBox^ textBox_vib_loop_times;
|
||||
private: System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(images::typeid));
|
||||
|
||||
|
||||
@@ -326,8 +332,9 @@ namespace CppWinFormJoy {
|
||||
this->toolTip1 = (gcnew System::Windows::Forms::ToolTip(this->components));
|
||||
this->groupBoxVib = (gcnew System::Windows::Forms::GroupBox());
|
||||
this->groupBox_vib_info = (gcnew System::Windows::Forms::GroupBox());
|
||||
this->textBox_vib_loop_times = (gcnew System::Windows::Forms::TextBox());
|
||||
this->label_hdrumble_filename = (gcnew System::Windows::Forms::Label());
|
||||
this->label_play_time = (gcnew System::Windows::Forms::Label());
|
||||
this->label_loop_times = (gcnew System::Windows::Forms::Label());
|
||||
this->label_vib_loaded = (gcnew System::Windows::Forms::Label());
|
||||
this->label_samplerate = (gcnew System::Windows::Forms::Label());
|
||||
this->label_samples = (gcnew System::Windows::Forms::Label());
|
||||
@@ -1383,8 +1390,9 @@ namespace CppWinFormJoy {
|
||||
//
|
||||
// groupBox_vib_info
|
||||
//
|
||||
this->groupBox_vib_info->Controls->Add(this->textBox_vib_loop_times);
|
||||
this->groupBox_vib_info->Controls->Add(this->label_hdrumble_filename);
|
||||
this->groupBox_vib_info->Controls->Add(this->label_play_time);
|
||||
this->groupBox_vib_info->Controls->Add(this->label_loop_times);
|
||||
this->groupBox_vib_info->Controls->Add(this->label_vib_loaded);
|
||||
this->groupBox_vib_info->Controls->Add(this->label_samplerate);
|
||||
this->groupBox_vib_info->Controls->Add(this->label_samples);
|
||||
@@ -1397,6 +1405,24 @@ namespace CppWinFormJoy {
|
||||
this->groupBox_vib_info->TabStop = false;
|
||||
this->groupBox_vib_info->Text = L"Info";
|
||||
//
|
||||
// textBox_vib_loop_times
|
||||
//
|
||||
this->textBox_vib_loop_times->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(85)),
|
||||
static_cast<System::Int32>(static_cast<System::Byte>(85)), static_cast<System::Int32>(static_cast<System::Byte>(85)));
|
||||
this->textBox_vib_loop_times->BorderStyle = System::Windows::Forms::BorderStyle::None;
|
||||
this->textBox_vib_loop_times->Font = (gcnew System::Drawing::Font(L"Segoe UI", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
|
||||
static_cast<System::Byte>(161)));
|
||||
this->textBox_vib_loop_times->ForeColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(251)),
|
||||
static_cast<System::Int32>(static_cast<System::Byte>(251)), static_cast<System::Int32>(static_cast<System::Byte>(251)));
|
||||
this->textBox_vib_loop_times->Location = System::Drawing::Point(82, 106);
|
||||
this->textBox_vib_loop_times->MaxLength = 3;
|
||||
this->textBox_vib_loop_times->Name = L"textBox_vib_loop_times";
|
||||
this->textBox_vib_loop_times->Size = System::Drawing::Size(30, 16);
|
||||
this->textBox_vib_loop_times->TabIndex = 14;
|
||||
this->textBox_vib_loop_times->Text = L"0";
|
||||
this->textBox_vib_loop_times->TextAlign = System::Windows::Forms::HorizontalAlignment::Center;
|
||||
this->textBox_vib_loop_times->Visible = false;
|
||||
//
|
||||
// label_hdrumble_filename
|
||||
//
|
||||
this->label_hdrumble_filename->AutoSize = true;
|
||||
@@ -1408,16 +1434,17 @@ namespace CppWinFormJoy {
|
||||
this->label_hdrumble_filename->TabIndex = 5;
|
||||
this->label_hdrumble_filename->Text = L"No file loaded";
|
||||
//
|
||||
// label_play_time
|
||||
// label_loop_times
|
||||
//
|
||||
this->label_play_time->AutoSize = true;
|
||||
this->label_play_time->ForeColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(251)), static_cast<System::Int32>(static_cast<System::Byte>(251)),
|
||||
static_cast<System::Int32>(static_cast<System::Byte>(251)));
|
||||
this->label_play_time->Location = System::Drawing::Point(6, 62);
|
||||
this->label_play_time->Name = L"label_play_time";
|
||||
this->label_play_time->Size = System::Drawing::Size(96, 17);
|
||||
this->label_play_time->TabIndex = 13;
|
||||
this->label_play_time->Text = L"Total play time:";
|
||||
this->label_loop_times->AutoSize = true;
|
||||
this->label_loop_times->ForeColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(251)),
|
||||
static_cast<System::Int32>(static_cast<System::Byte>(251)), static_cast<System::Int32>(static_cast<System::Byte>(251)));
|
||||
this->label_loop_times->Location = System::Drawing::Point(6, 104);
|
||||
this->label_loop_times->Name = L"label_loop_times";
|
||||
this->label_loop_times->Size = System::Drawing::Size(77, 17);
|
||||
this->label_loop_times->TabIndex = 13;
|
||||
this->label_loop_times->Text = L"Extra loops:";
|
||||
this->label_loop_times->Visible = false;
|
||||
//
|
||||
// label_vib_loaded
|
||||
//
|
||||
@@ -1435,7 +1462,7 @@ namespace CppWinFormJoy {
|
||||
this->label_samplerate->AutoSize = true;
|
||||
this->label_samplerate->ForeColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(251)),
|
||||
static_cast<System::Int32>(static_cast<System::Byte>(251)), static_cast<System::Int32>(static_cast<System::Byte>(251)));
|
||||
this->label_samplerate->Location = System::Drawing::Point(6, 104);
|
||||
this->label_samplerate->Location = System::Drawing::Point(6, 62);
|
||||
this->label_samplerate->Name = L"label_samplerate";
|
||||
this->label_samplerate->Size = System::Drawing::Size(81, 17);
|
||||
this->label_samplerate->TabIndex = 3;
|
||||
@@ -2644,6 +2671,30 @@ namespace CppWinFormJoy {
|
||||
this->errorProvider2->SetError(test, String::Empty);
|
||||
}
|
||||
|
||||
private: System::Void textBox_loop_Validating(System::Object^ sender, CancelEventArgs^ e)
|
||||
{
|
||||
TextBox^ test = (TextBox^)sender;
|
||||
bool cancel = false;
|
||||
int number = -1;
|
||||
if (Int32::TryParse(test->Text, NumberStyles::Number, CultureInfo::InvariantCulture, number))
|
||||
{
|
||||
cancel = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//This control has failed validation: text box is not a number
|
||||
cancel = true;
|
||||
this->errorProvider2->SetError(test, "The input must be a number from 0-999!");
|
||||
}
|
||||
e->Cancel = cancel;
|
||||
}
|
||||
|
||||
private: System::Void textBox_loop_Validated(System::Object^ sender, System::EventArgs^ e)
|
||||
{
|
||||
TextBox^ test = (TextBox^)sender;
|
||||
this->errorProvider2->SetError(test, String::Empty);
|
||||
}
|
||||
|
||||
private: System::Void textBoxDbg_SubcmdArg_Validating(System::Object^ sender, CancelEventArgs^ e)
|
||||
{
|
||||
TextBox^ test = (TextBox^)sender;
|
||||
@@ -2839,8 +2890,10 @@ namespace CppWinFormJoy {
|
||||
this->label_hdrumble_filename->Text = openFileDialog1->SafeFileName;
|
||||
this->label_vib_loaded->Text = L"";
|
||||
this->label_samplerate->Text = L"";
|
||||
this->label_play_time->Text = L"";
|
||||
this->label_samples->Text = L"";
|
||||
this->textBox_vib_loop_times->Text = L"0";
|
||||
this->textBox_vib_loop_times->Visible = false;
|
||||
this->label_loop_times->Visible = false;
|
||||
System::IO::MemoryStream^ ms = gcnew System::IO::MemoryStream(fileStream->Length);;
|
||||
fileStream->CopyTo(ms);
|
||||
this->vib_loaded_file = ms->ToArray();
|
||||
@@ -2868,8 +2921,7 @@ namespace CppWinFormJoy {
|
||||
vib_sample_rate = (this->vib_loaded_file[0x4] << 8) + this->vib_loaded_file[0x5];
|
||||
vib_samples = (this->vib_loaded_file[0x6] << 24) + (this->vib_loaded_file[0x7] << 16) + (this->vib_loaded_file[0x8] << 8) + this->vib_loaded_file[0x9];
|
||||
this->label_samplerate->Text = L"Sample rate: " + vib_sample_rate + L"ms";
|
||||
this->label_play_time->Text = L"Total play time: " + (vib_sample_rate * vib_samples) / 1000.0f + L"s";
|
||||
this->label_samples->Text = L"Samples: " + vib_samples;
|
||||
this->label_samples->Text = L"Samples: " + vib_samples + L" (" + (vib_sample_rate * vib_samples) / 1000.0f + L"s)";
|
||||
}
|
||||
else {
|
||||
this->label_vib_loaded->Text = L"Type: Unknown format";
|
||||
@@ -2886,25 +2938,40 @@ namespace CppWinFormJoy {
|
||||
vib_sample_rate = 1000 / (this->vib_loaded_file[0x6] + (this->vib_loaded_file[0x7] << 8));
|
||||
vib_samples = vib_size / 4;
|
||||
this->label_samplerate->Text = L"Sample rate: " + vib_sample_rate + L"ms";
|
||||
this->label_play_time->Text = L"Total play time: " + (vib_sample_rate * vib_samples) / 1000.0f + L"s";
|
||||
this->label_samples->Text = L"Samples: " + vib_samples;
|
||||
|
||||
this->btnVibPlay->Enabled = true;
|
||||
this->label_samples->Text = L"Samples: " + vib_samples + L" (" + (vib_sample_rate * vib_samples) / 1000.0f + L"s)";
|
||||
}
|
||||
else if (this->vib_file_converted[0] == file_magic[5]) {
|
||||
vib_file_type = 3;
|
||||
this->label_vib_loaded->Text = L"Type: Loop Binary HD Rumble";
|
||||
this->btnVibPlay->Enabled = false;
|
||||
this->groupBox_vib_eq->Visible = true;
|
||||
this->groupBox_vib_eq->Enabled = false;
|
||||
this->groupBox_vib_eq->Enabled = true;
|
||||
u32 vib_size = this->vib_loaded_file[0x10] + (this->vib_loaded_file[0x11] << 8) + (this->vib_loaded_file[0x12] << 16) + (this->vib_loaded_file[0x13] << 24);
|
||||
vib_sample_rate = 1000 / (this->vib_loaded_file[0x6] + (this->vib_loaded_file[0x7] << 8));
|
||||
vib_samples = vib_size / 4;
|
||||
vib_loop_start = this->vib_loaded_file[0x8] + (this->vib_loaded_file[0x9] << 8) + (this->vib_loaded_file[0xA] << 16) + (this->vib_loaded_file[0xB] << 24);
|
||||
vib_loop_end = this->vib_loaded_file[0xC] + (this->vib_loaded_file[0xD] << 8) + (this->vib_loaded_file[0xE] << 16) + (this->vib_loaded_file[0xF] << 24);
|
||||
this->label_samplerate->Text = L"Sample rate: " + vib_sample_rate + L"ms";
|
||||
this->label_samples->Text = L"Samples: " + vib_samples + L" (" + (vib_sample_rate * vib_samples) / 1000.0f + L"s)";
|
||||
this->label_loop_times->Visible = true;
|
||||
this->textBox_vib_loop_times->Visible = true;
|
||||
}
|
||||
else if (this->vib_file_converted[0] == file_magic[7]) {
|
||||
vib_file_type = 4;
|
||||
this->label_vib_loaded->Text = L"Type: Loop and Wait Binary";
|
||||
this->btnVibPlay->Enabled = false;
|
||||
this->groupBox_vib_eq->Visible = true;
|
||||
this->groupBox_vib_eq->Enabled = false;
|
||||
this->groupBox_vib_eq->Enabled = true;
|
||||
u32 vib_size = this->vib_loaded_file[0x14] + (this->vib_loaded_file[0x15] << 8) + (this->vib_loaded_file[0x16] << 16) + (this->vib_loaded_file[0x17] << 24);
|
||||
vib_sample_rate = 1000 / (this->vib_loaded_file[0x6] + (this->vib_loaded_file[0x7] << 8));
|
||||
vib_samples = vib_size / 4;
|
||||
vib_loop_start = this->vib_loaded_file[0x8] + (this->vib_loaded_file[0x9] << 8) + (this->vib_loaded_file[0xA] << 16) + (this->vib_loaded_file[0xB] << 24);
|
||||
vib_loop_end = this->vib_loaded_file[0xC] + (this->vib_loaded_file[0xD] << 8) + (this->vib_loaded_file[0xE] << 16) + (this->vib_loaded_file[0xF] << 24);
|
||||
vib_loop_wait = this->vib_loaded_file[0x10] + (this->vib_loaded_file[0x11] << 8) + (this->vib_loaded_file[0x12] << 16) + (this->vib_loaded_file[0x13] << 24);
|
||||
this->label_samplerate->Text = L"Sample rate: " + vib_sample_rate + L"ms";
|
||||
this->label_samples->Text = L"Samples: " + vib_samples + L" (" + (vib_sample_rate * vib_samples) / 1000.0f + L"s)";
|
||||
this->label_loop_times->Visible = true;
|
||||
this->textBox_vib_loop_times->Visible = true;
|
||||
}
|
||||
this->btnVibPlay->Enabled = true;
|
||||
}
|
||||
else {
|
||||
vib_file_type = 0;
|
||||
@@ -2924,28 +2991,33 @@ namespace CppWinFormJoy {
|
||||
MessageBox::Show(L"The device was disconnected!\n\nPress a button on the controller to connect\nand try to replay the HD Rumble file!", L"CTCaer's Joy-Con Toolkit - Connection Error!", MessageBoxButtons::OK, MessageBoxIcon::Stop);
|
||||
return;
|
||||
}
|
||||
|
||||
if (vib_file_type == 2 && !vib_converted) {
|
||||
int vib_loop_times = 0;
|
||||
if ((vib_file_type == 2 || vib_file_type == 3 || vib_file_type == 4) && !vib_converted) {
|
||||
u8 vib_off = 0;
|
||||
if (vib_file_type == 3)
|
||||
vib_off = 8;
|
||||
if (vib_file_type == 4)
|
||||
vib_off = 12;
|
||||
//Convert to RAW vibration, apply EQ and clamp inside safe values
|
||||
this->btnVibPlay->Text = L"Loading...";
|
||||
u32 vib_size = this->vib_loaded_file[0x8] + (this->vib_loaded_file[0x9] << 8) + (this->vib_loaded_file[0xA] << 16) + (this->vib_loaded_file[0xB] << 24);
|
||||
//vib_size = this->vib_loaded_file[0x8] + (this->vib_loaded_file[0x9] << 8) + (this->vib_loaded_file[0xA] << 16) + (this->vib_loaded_file[0xB] << 24);
|
||||
|
||||
//Convert to raw
|
||||
for (int i = 0; i < (int)vib_size; i = i + 4)
|
||||
for (int i = 0; i < vib_samples * 4; i = i + 4)
|
||||
{
|
||||
//Apply amp eq
|
||||
u8 tempLA = (this->trackBar_lf_amp->Value == 10 ? this->vib_loaded_file[0xC + i] : (u8)CLAMP((float)this->vib_loaded_file[0xC + i] * lf_gain, 0.0f, 255.0f));
|
||||
u8 tempHA = (this->trackBar_hf_amp->Value == 10 ? this->vib_loaded_file[0xE + i] : (u8)CLAMP((float)this->vib_loaded_file[0xE + i] * hf_gain, 0.0f, 255.0f));
|
||||
u8 tempLA = (this->trackBar_lf_amp->Value == 10 ? this->vib_loaded_file[0xC + vib_off + i] : (u8)CLAMP((float)this->vib_loaded_file[0xC + vib_off + i] * lf_gain, 0.0f, 255.0f));
|
||||
u8 tempHA = (this->trackBar_hf_amp->Value == 10 ? this->vib_loaded_file[0xE + vib_off + i] : (u8)CLAMP((float)this->vib_loaded_file[0xE + vib_off + i] * hf_gain, 0.0f, 255.0f));
|
||||
|
||||
//Apply safe limit. The sum of LF and HF amplitudes should be lower than 1.0
|
||||
float apply_safe_limit = (float)this->vib_file_converted[0xC + i] / 255.0f + (float)this->vib_file_converted[0xE + i] / 255.0f;
|
||||
float apply_safe_limit = (float)tempLA / 255.0f + tempHA / 255.0f;
|
||||
//u8 tempLA = (apply_safe_limit > 1.0f ? (u8)((float)this->vib_file_converted[0xC + i] * (0.55559999f / apply_safe_limit)) : (u8)((float)this->vib_file_converted[0xC + i] * 0.55559999f));
|
||||
tempLA = (apply_safe_limit > 1.0f ? (u8)((float)this->vib_file_converted[0xC + i] * (1.0f / apply_safe_limit)) : this->vib_file_converted[0xC + i]);
|
||||
tempHA = (apply_safe_limit > 1.0f ? (u8)((float)this->vib_file_converted[0xE + i] * (1.0f / apply_safe_limit)) : this->vib_file_converted[0xE + i]);
|
||||
tempLA = (apply_safe_limit > 1.0f ? (u8)((float)tempLA * (1.0f / apply_safe_limit)) : tempLA);
|
||||
tempHA = (apply_safe_limit > 1.0f ? (u8)((float)tempHA * (1.0f / apply_safe_limit)) : tempHA);
|
||||
|
||||
//Apply eq and convert frequencies to raw range
|
||||
u8 tempLF = (this->trackBar_lf_freq->Value == 10 ? this->vib_loaded_file[0xD + i] : (u8)CLAMP((float)this->vib_loaded_file[0xD + i] * lf_pitch, 0.0f, 191.0f)) - 0x40;
|
||||
u16 tempHF = ((this->trackBar_hf_freq->Value == 10 ? this->vib_loaded_file[0xF + i] : (u8)CLAMP((float)this->vib_loaded_file[0xF + i] * hf_gain, 0.0f, 223.0f)) - 0x60) * 4;
|
||||
u8 tempLF = (this->trackBar_lf_freq->Value == 10 ? this->vib_loaded_file[0xD + vib_off + i] : (u8)CLAMP((float)this->vib_loaded_file[0xD + vib_off + i] * lf_pitch, 0.0f, 191.0f)) - 0x40;
|
||||
u16 tempHF = ((this->trackBar_hf_freq->Value == 10 ? this->vib_loaded_file[0xF + vib_off + i] : (u8)CLAMP((float)this->vib_loaded_file[0xF + vib_off + i] * hf_pitch, 0.0f, 223.0f)) - 0x60) * 4;
|
||||
|
||||
//Encode amplitudes with the look up table and direct encode frequencies
|
||||
int j;
|
||||
@@ -2956,8 +3028,8 @@ namespace CppWinFormJoy {
|
||||
break;
|
||||
}
|
||||
}
|
||||
this->vib_file_converted[0xE + i] = ((lut_joy_amp.la[j] >> 8) & 0xFF) + tempLF;
|
||||
this->vib_file_converted[0xF + i] = lut_joy_amp.la[j] & 0xFF;
|
||||
this->vib_file_converted[0xE + vib_off + i] = ((lut_joy_amp.la[j] >> 8) & 0xFF) + tempLF;
|
||||
this->vib_file_converted[0xF + vib_off + i] = lut_joy_amp.la[j] & 0xFF;
|
||||
|
||||
temp = tempHA / 255.0f;
|
||||
for (j = 1; j < 101; j++) {
|
||||
@@ -2966,13 +3038,17 @@ namespace CppWinFormJoy {
|
||||
break;
|
||||
}
|
||||
}
|
||||
this->vib_file_converted[0xC + i] = tempHF & 0xFF;
|
||||
this->vib_file_converted[0xD + i] = ((tempHF >> 8) & 0xFF) + lut_joy_amp.ha[j];
|
||||
this->vib_file_converted[0xC + vib_off + i] = tempHF & 0xFF;
|
||||
this->vib_file_converted[0xD + vib_off + i] = ((tempHF >> 8) & 0xFF) + lut_joy_amp.ha[j];
|
||||
|
||||
}
|
||||
vib_converted = 1;
|
||||
}
|
||||
|
||||
msclr::interop::marshal_context context;
|
||||
std::stringstream ss_loops;
|
||||
ss_loops << std::dec << context.marshal_as<std::string>(this->textBox_vib_loop_times->Text);
|
||||
ss_loops >> vib_loop_times;
|
||||
|
||||
this->btnVibPlay->Enabled = false;
|
||||
this->btnLoadVib->Enabled = false;
|
||||
@@ -2980,11 +3056,12 @@ namespace CppWinFormJoy {
|
||||
this->btnVibPlay->Text = L"Playing...";
|
||||
|
||||
|
||||
play_hd_rumble_file(vib_file_type, vib_sample_rate, vib_samples, vib_loop_start, vib_loop_end, vib_loop_wait);
|
||||
play_hd_rumble_file(vib_file_type, vib_sample_rate, vib_samples, vib_loop_start, vib_loop_end, vib_loop_wait, vib_loop_times);
|
||||
|
||||
this->btnVibPlay->Text = L"Play";
|
||||
this->btnVibPlay->Enabled = true;
|
||||
this->btnLoadVib->Enabled = true;
|
||||
if (vib_file_type == 2) {
|
||||
if (vib_file_type == 2 || vib_file_type == 3 || vib_file_type == 4) {
|
||||
this->groupBox_vib_eq->Enabled = true;
|
||||
}
|
||||
update_battery();
|
||||
@@ -3001,10 +3078,10 @@ namespace CppWinFormJoy {
|
||||
|
||||
private: System::Void TrackBar_ValueChanged(System::Object^ sender, System::EventArgs^ e)
|
||||
{
|
||||
lf_gain = 1.0f - ((10.0f - this->trackBar_lf_amp->Value) / 10.0f);
|
||||
lf_pitch = 1.0f - (10.0f - (this->trackBar_lf_freq->Value) / 10.0f);
|
||||
hf_gain = 1.0f - ((10.0f - this->trackBar_hf_amp->Value) / 10.0f);
|
||||
hf_pitch = 1.0f - ((10.0f - this->trackBar_hf_freq->Value) / 10.0f);
|
||||
lf_gain = this->trackBar_lf_amp->Value / 10.0f;
|
||||
lf_pitch = this->trackBar_lf_freq->Value / 10.0f;
|
||||
hf_gain = this->trackBar_hf_amp->Value / 10.0f;
|
||||
hf_pitch = this->trackBar_hf_freq->Value / 10.0f;
|
||||
this->toolTip1->SetToolTip(this->trackBar_lf_amp, String::Format("{0:d}%", (int)(lf_gain * 100.01f)));
|
||||
this->toolTip1->SetToolTip(this->trackBar_lf_freq, String::Format("{0:d}%", (int)(lf_pitch * 100.01f)));
|
||||
this->toolTip1->SetToolTip(this->trackBar_hf_amp, String::Format("{0:d}%", (int)(hf_gain * 100.01f)));
|
||||
|
||||
+68
-16
@@ -515,7 +515,7 @@ int send_custom_command(u8* arg) {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (res >= 0 && res <= 12) {
|
||||
else if (res > 0 && res <= 12) {
|
||||
for (int i = 0; i < res; i++)
|
||||
input_report_sys += String::Format(L"{0:X2} ", buf_reply[i]);
|
||||
}
|
||||
@@ -603,7 +603,7 @@ int play_tune() {
|
||||
|
||||
}
|
||||
|
||||
int play_hd_rumble_file(int file_type, u16 sample_rate, int samples, int loop_start, int loop_end, int loop_wait) {
|
||||
int play_hd_rumble_file(int file_type, u16 sample_rate, int samples, int loop_start, int loop_end, int loop_wait, int loop_times) {
|
||||
int res;
|
||||
u8 buf[0x100];
|
||||
u8 buf2[0x100];
|
||||
@@ -652,7 +652,13 @@ int play_hd_rumble_file(int file_type, u16 sample_rate, int samples, int loop_st
|
||||
}
|
||||
}
|
||||
else if (file_type == 3 || file_type == 4) {
|
||||
for (int i = 0; i < samples * 4; i = i + 4) {
|
||||
u8 vib_off = 0;
|
||||
if (file_type == 3)
|
||||
vib_off = 8;
|
||||
else if (file_type == 4)
|
||||
vib_off = 12;
|
||||
|
||||
for (int i = 0; i < loop_start * 4; i = i + 4) {
|
||||
Sleep(sample_rate);
|
||||
memset(buf, 0, sizeof(buf));
|
||||
hdr = (brcm_hdr *)buf;
|
||||
@@ -662,20 +668,66 @@ int play_hd_rumble_file(int file_type, u16 sample_rate, int samples, int loop_st
|
||||
timming_byte++;
|
||||
if (timming_byte > 0xF)
|
||||
timming_byte = 0x0;
|
||||
//file_type is loop bnvib
|
||||
if (file_type == 3) {
|
||||
hdr->rumble[1] = hdr->rumble[5] = FormJoy::myform1->vib_loaded_file[0x0A + i];
|
||||
hdr->rumble[2] = hdr->rumble[6] = FormJoy::myform1->vib_loaded_file[0x0B + i];
|
||||
hdr->rumble[3] = hdr->rumble[7] = FormJoy::myform1->vib_loaded_file[0x0C + i];
|
||||
hdr->rumble[4] = hdr->rumble[8] = FormJoy::myform1->vib_loaded_file[0x0D + i];
|
||||
}
|
||||
//file_type is loop+ bnvib
|
||||
else {
|
||||
hdr->rumble[1] = hdr->rumble[5] = FormJoy::myform1->vib_file_converted[0x0C + i];
|
||||
hdr->rumble[2] = hdr->rumble[6] = FormJoy::myform1->vib_file_converted[0x0D + i];
|
||||
hdr->rumble[3] = hdr->rumble[7] = FormJoy::myform1->vib_file_converted[0x0E + i];
|
||||
hdr->rumble[4] = hdr->rumble[8] = FormJoy::myform1->vib_file_converted[0x0F + i];
|
||||
|
||||
hdr->rumble[1] = hdr->rumble[5] = FormJoy::myform1->vib_loaded_file[0x0C + vib_off + i];
|
||||
hdr->rumble[2] = hdr->rumble[6] = FormJoy::myform1->vib_loaded_file[0x0D + vib_off + i];
|
||||
hdr->rumble[3] = hdr->rumble[7] = FormJoy::myform1->vib_loaded_file[0x0E + vib_off + i];
|
||||
hdr->rumble[4] = hdr->rumble[8] = FormJoy::myform1->vib_loaded_file[0x0F + vib_off + i];
|
||||
|
||||
res = hid_write(handle, buf, sizeof(*hdr));
|
||||
Application::DoEvents();
|
||||
}
|
||||
for (int j = 0; j < 1 + loop_times; j++) {
|
||||
for (int i = loop_start * 4; i < loop_end * 4; i = i + 4) {
|
||||
Sleep(sample_rate);
|
||||
memset(buf, 0, sizeof(buf));
|
||||
hdr = (brcm_hdr *)buf;
|
||||
pkt = (brcm_cmd_01 *)(hdr + 1);
|
||||
hdr->cmd = 0x10;
|
||||
hdr->rumble[0] = timming_byte;
|
||||
timming_byte++;
|
||||
if (timming_byte > 0xF)
|
||||
timming_byte = 0x0;
|
||||
|
||||
hdr->rumble[1] = hdr->rumble[5] = FormJoy::myform1->vib_loaded_file[0x0C + vib_off + i];
|
||||
hdr->rumble[2] = hdr->rumble[6] = FormJoy::myform1->vib_loaded_file[0x0D + vib_off + i];
|
||||
hdr->rumble[3] = hdr->rumble[7] = FormJoy::myform1->vib_loaded_file[0x0E + vib_off + i];
|
||||
hdr->rumble[4] = hdr->rumble[8] = FormJoy::myform1->vib_loaded_file[0x0F + vib_off + i];
|
||||
|
||||
res = hid_write(handle, buf, sizeof(*hdr));
|
||||
Application::DoEvents();
|
||||
}
|
||||
Sleep(sample_rate);
|
||||
//Disable vibration
|
||||
memset(buf, 0, sizeof(buf));
|
||||
hdr = (brcm_hdr *)buf;
|
||||
pkt = (brcm_cmd_01 *)(hdr + 1);
|
||||
hdr->cmd = 0x10;
|
||||
hdr->rumble[0] = timming_byte;
|
||||
timming_byte++;
|
||||
if (timming_byte > 0xF)
|
||||
timming_byte = 0x0;
|
||||
hdr->rumble[1] = 0x00; hdr->rumble[2] = 0x01; hdr->rumble[3] = 0x40; hdr->rumble[4] = 0x40;
|
||||
hdr->rumble[5] = 0x00; hdr->rumble[6] = 0x01; hdr->rumble[7] = 0x40; hdr->rumble[8] = 0x40;
|
||||
res = hid_write(handle, buf, sizeof(*hdr) + sizeof(*pkt));
|
||||
Sleep(loop_wait * sample_rate);
|
||||
}
|
||||
for (int i = loop_end * 4; i < samples * 4; i = i + 4) {
|
||||
Sleep(sample_rate);
|
||||
memset(buf, 0, sizeof(buf));
|
||||
hdr = (brcm_hdr *)buf;
|
||||
pkt = (brcm_cmd_01 *)(hdr + 1);
|
||||
hdr->cmd = 0x10;
|
||||
hdr->rumble[0] = timming_byte;
|
||||
timming_byte++;
|
||||
if (timming_byte > 0xF)
|
||||
timming_byte = 0x0;
|
||||
|
||||
hdr->rumble[1] = hdr->rumble[5] = FormJoy::myform1->vib_loaded_file[0x0C + vib_off + i];
|
||||
hdr->rumble[2] = hdr->rumble[6] = FormJoy::myform1->vib_loaded_file[0x0D + vib_off + i];
|
||||
hdr->rumble[3] = hdr->rumble[7] = FormJoy::myform1->vib_loaded_file[0x0E + vib_off + i];
|
||||
hdr->rumble[4] = hdr->rumble[8] = FormJoy::myform1->vib_loaded_file[0x0F + vib_off + i];
|
||||
|
||||
res = hid_write(handle, buf, sizeof(*hdr));
|
||||
Application::DoEvents();
|
||||
}
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ extern int get_battery(u8* test_buf);
|
||||
extern int dump_spi(const char *dev_name);
|
||||
extern int send_rumble();
|
||||
extern int play_tune();
|
||||
extern int play_hd_rumble_file(int file_type, u16 sample_rate, int samples);
|
||||
extern int play_hd_rumble_file(int file_type, u16 sample_rate, int samples, int loop_start, int loop_end, int loop_wait, int loop_times);
|
||||
extern int send_custom_command(u8* arg);
|
||||
extern int device_connection();
|
||||
extern int set_led_busy();
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ struct lut_amp {
|
||||
};
|
||||
|
||||
lut_amp lut_joy_amp{
|
||||
{ 0.0f, 0.009942f, 0.011823f, 0.014061f, 0.01672f, 0.019885f, 0.023648f, 0.028123f, 0.033442f, 0.039771f, 0.047296f, 0.056246f, 0.066886f, 0.079542f, 0.094592f, 0.112491f, 0.117471f, 0.122671f, 0.128102f, 0.133774f, 0.139697f, 0.145882f, 0.152341f, 0.159085f, 0.166129f, 0.173484f, 0.181166f, 0.189185f, 0.197561f, 0.206308f, 0.215442f, 0.224982f, 0.229908f, 0.234943f, 0.240087f, 0.245345f, 0.250715f, 0.256206f, 0.261816f, 0.267549f, 0.273407f, 0.279394f, 0.285514f, 0.291765f, 0.298154f, 0.304681f, 0.311353f, 0.318171f, 0.325138f, 0.332258f, 0.339534f, 0.346969f, 0.354566f, 0.362331f, 0.370265f, 0.378372f, 0.386657f, 0.395124f, 0.403777f, 0.412619f, 0.421652f, 0.430885f, 0.440321f, 0.449964f, 0.459817f, 0.469885f, 0.480174f, 0.490689f, 0.501433f, 0.512413f, 0.523633f, 0.5351f, 0.546816f, 0.55879f, 0.571027f, 0.58353f, 0.596307f, 0.609365f, 0.622708f, 0.636344f, 0.650279f, 0.664518f, 0.679069f, 0.693939f, 0.709133f, 0.724662f, 0.740529f, 0.756745f, 0.773316f, 0.790249f, 0.807554f, 0.825237f, 0.843307f, 0.861772f, 0.880643f, 0.899928f, 0.919633f, 0.939771f, 0.960348f, 0.981378f, 1.002867f },
|
||||
{ 0.0f, 0.007843f, 0.011823f, 0.014061f, 0.01672f, 0.019885f, 0.023648f, 0.028123f, 0.033442f, 0.039771f, 0.047296f, 0.056246f, 0.066886f, 0.079542f, 0.094592f, 0.112491f, 0.117471f, 0.122671f, 0.128102f, 0.133774f, 0.139697f, 0.145882f, 0.152341f, 0.159085f, 0.166129f, 0.173484f, 0.181166f, 0.189185f, 0.197561f, 0.206308f, 0.215442f, 0.224982f, 0.229908f, 0.234943f, 0.240087f, 0.245345f, 0.250715f, 0.256206f, 0.261816f, 0.267549f, 0.273407f, 0.279394f, 0.285514f, 0.291765f, 0.298154f, 0.304681f, 0.311353f, 0.318171f, 0.325138f, 0.332258f, 0.339534f, 0.346969f, 0.354566f, 0.362331f, 0.370265f, 0.378372f, 0.386657f, 0.395124f, 0.403777f, 0.412619f, 0.421652f, 0.430885f, 0.440321f, 0.449964f, 0.459817f, 0.469885f, 0.480174f, 0.490689f, 0.501433f, 0.512413f, 0.523633f, 0.5351f, 0.546816f, 0.55879f, 0.571027f, 0.58353f, 0.596307f, 0.609365f, 0.622708f, 0.636344f, 0.650279f, 0.664518f, 0.679069f, 0.693939f, 0.709133f, 0.724662f, 0.740529f, 0.756745f, 0.773316f, 0.790249f, 0.807554f, 0.825237f, 0.843307f, 0.861772f, 0.880643f, 0.899928f, 0.919633f, 0.939771f, 0.960348f, 0.981378f, 1.002867f },
|
||||
{ 0x0, 0x2, 0x4, 0x6, 0x8, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e, 0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e, 0x40, 0x42, 0x44, 0x46, 0x48, 0x4a, 0x4c, 0x4e, 0x50, 0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e, 0x60, 0x62, 0x64, 0x66, 0x68, 0x6a, 0x6c, 0x6e, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7a, 0x7c, 0x7e, 0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e, 0x90, 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e, 0xa0, 0xa2, 0xa4, 0xa6, 0xa8, 0xaa, 0xac, 0xae, 0xb0, 0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe, 0xc0, 0xc2, 0xc4, 0xc6, 0xc8 },
|
||||
{ 0x0040, 0x8040, 0x0041, 0x8041, 0x0042, 0x8042, 0x0043, 0x8043, 0x0044, 0x8044, 0x0045, 0x8045, 0x0046, 0x8046, 0x0047, 0x8047, 0x0048, 0x8048, 0x0049, 0x8049, 0x004a, 0x804a, 0x004b, 0x804b, 0x004c, 0x804c, 0x004d, 0x804d, 0x004e, 0x804e, 0x004f, 0x804f, 0x0050, 0x8050, 0x0051, 0x8051, 0x0052, 0x8052, 0x0053, 0x8053, 0x0054, 0x8054, 0x0055, 0x8055, 0x0056, 0x8056, 0x0057, 0x8057, 0x0058, 0x8058, 0x0059, 0x8059, 0x005a, 0x805a, 0x005b, 0x805b, 0x005c, 0x805c, 0x005d, 0x805d, 0x005e, 0x805e, 0x005f, 0x805f, 0x0060, 0x8060, 0x0061, 0x8061, 0x0062, 0x8062, 0x0063, 0x8063, 0x0064, 0x8064, 0x0065, 0x8065, 0x0066, 0x8066, 0x0067, 0x8067, 0x0068, 0x8068, 0x0069, 0x8069, 0x006a, 0x806a, 0x006b, 0x806b, 0x006c, 0x806c, 0x006d, 0x806d, 0x006e, 0x806e, 0x006f, 0x806f, 0x0070, 0x8070, 0x0071, 0x8071, 0x0072 }
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user