Merge pull request #2290 from RachelBryk/cc-tasinput
Implement classic controller tas input.
This commit is contained in:
commit
9d8c347e8d
|
@ -26,6 +26,7 @@
|
||||||
#include "Core/Movie.h"
|
#include "Core/Movie.h"
|
||||||
#include "Core/HW/Wiimote.h"
|
#include "Core/HW/Wiimote.h"
|
||||||
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||||
|
#include "Core/HW/WiimoteEmu/Attachment/Classic.h"
|
||||||
#include "Core/HW/WiimoteEmu/Attachment/Nunchuk.h"
|
#include "Core/HW/WiimoteEmu/Attachment/Nunchuk.h"
|
||||||
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
||||||
#include "DolphinWX/TASInputDlg.h"
|
#include "DolphinWX/TASInputDlg.h"
|
||||||
|
@ -41,10 +42,12 @@ TASInputDlg::TASInputDlg(wxWindow* parent, wxWindowID id, const wxString& title,
|
||||||
|
|
||||||
void TASInputDlg::CreateBaseLayout()
|
void TASInputDlg::CreateBaseLayout()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < 10; ++i)
|
for (unsigned int i = 0; i < ArraySize(m_controls); ++i)
|
||||||
m_controls[i] = nullptr;
|
m_controls[i] = nullptr;
|
||||||
for (unsigned int i = 0; i < 14; ++i)
|
for (unsigned int i = 0; i < ArraySize(m_buttons); ++i)
|
||||||
m_buttons[i] = nullptr;
|
m_buttons[i] = nullptr;
|
||||||
|
for (unsigned int i = 0; i < ArraySize(m_cc_controls); ++i)
|
||||||
|
m_cc_controls[i] = nullptr;
|
||||||
|
|
||||||
m_buttons[0] = &m_dpad_down;
|
m_buttons[0] = &m_dpad_down;
|
||||||
m_buttons[1] = &m_dpad_up;
|
m_buttons[1] = &m_dpad_up;
|
||||||
|
@ -81,13 +84,25 @@ const int TASInputDlg::m_gc_pad_buttons_bitmask[12] = {
|
||||||
PAD_BUTTON_X, PAD_BUTTON_Y, PAD_TRIGGER_Z, PAD_TRIGGER_L, PAD_TRIGGER_R, PAD_BUTTON_START
|
PAD_BUTTON_X, PAD_BUTTON_Y, PAD_TRIGGER_Z, PAD_TRIGGER_L, PAD_TRIGGER_R, PAD_BUTTON_START
|
||||||
};
|
};
|
||||||
|
|
||||||
const int TASInputDlg::m_wii_buttons_bitmask[13] = {
|
const int TASInputDlg::m_wii_buttons_bitmask[11] = {
|
||||||
WiimoteEmu::Wiimote::PAD_DOWN, WiimoteEmu::Wiimote::PAD_UP, WiimoteEmu::Wiimote::PAD_LEFT,
|
WiimoteEmu::Wiimote::PAD_DOWN, WiimoteEmu::Wiimote::PAD_UP, WiimoteEmu::Wiimote::PAD_LEFT,
|
||||||
WiimoteEmu::Wiimote::PAD_RIGHT, WiimoteEmu::Wiimote::BUTTON_A, WiimoteEmu::Wiimote::BUTTON_B,
|
WiimoteEmu::Wiimote::PAD_RIGHT, WiimoteEmu::Wiimote::BUTTON_A, WiimoteEmu::Wiimote::BUTTON_B,
|
||||||
WiimoteEmu::Wiimote::BUTTON_ONE, WiimoteEmu::Wiimote::BUTTON_TWO, WiimoteEmu::Wiimote::BUTTON_PLUS,
|
WiimoteEmu::Wiimote::BUTTON_ONE, WiimoteEmu::Wiimote::BUTTON_TWO, WiimoteEmu::Wiimote::BUTTON_PLUS,
|
||||||
WiimoteEmu::Wiimote::BUTTON_MINUS, WiimoteEmu::Wiimote::BUTTON_HOME,
|
WiimoteEmu::Wiimote::BUTTON_MINUS, WiimoteEmu::Wiimote::BUTTON_HOME,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const int TASInputDlg::m_cc_buttons_bitmask[15] = {
|
||||||
|
WiimoteEmu::Classic::PAD_DOWN, WiimoteEmu::Classic::PAD_UP, WiimoteEmu::Classic::PAD_LEFT,
|
||||||
|
WiimoteEmu::Classic::PAD_RIGHT, WiimoteEmu::Classic::BUTTON_A, WiimoteEmu::Classic::BUTTON_B,
|
||||||
|
WiimoteEmu::Classic::BUTTON_X, WiimoteEmu::Classic::BUTTON_Y, WiimoteEmu::Classic::BUTTON_PLUS,
|
||||||
|
WiimoteEmu::Classic::BUTTON_MINUS, WiimoteEmu::Classic::TRIGGER_L, WiimoteEmu::Classic::TRIGGER_R,
|
||||||
|
WiimoteEmu::Classic::BUTTON_ZR, WiimoteEmu::Classic::BUTTON_ZL, WiimoteEmu::Classic::BUTTON_HOME,
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::string TASInputDlg::m_cc_button_names[] = {
|
||||||
|
"Down", "Up", "Left", "Right", "A", "B", "X", "Y", "+", "-", "L", "R", "ZR", "ZL", "Home"
|
||||||
|
};
|
||||||
|
|
||||||
void TASInputDlg::CreateWiiLayout(int num)
|
void TASInputDlg::CreateWiiLayout(int num)
|
||||||
{
|
{
|
||||||
if (m_has_layout)
|
if (m_has_layout)
|
||||||
|
@ -125,6 +140,7 @@ void TASInputDlg::CreateWiiLayout(int num)
|
||||||
m_main_szr = new wxBoxSizer(wxVERTICAL);
|
m_main_szr = new wxBoxSizer(wxVERTICAL);
|
||||||
m_wiimote_szr = new wxBoxSizer(wxHORIZONTAL);
|
m_wiimote_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||||
m_ext_szr = new wxBoxSizer(wxHORIZONTAL);
|
m_ext_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
m_cc_szr = CreateCCLayout();
|
||||||
|
|
||||||
if (Core::IsRunning())
|
if (Core::IsRunning())
|
||||||
{
|
{
|
||||||
|
@ -139,7 +155,7 @@ void TASInputDlg::CreateWiiLayout(int num)
|
||||||
|
|
||||||
if (extension == "Nunchuk")
|
if (extension == "Nunchuk")
|
||||||
m_ext = 1;
|
m_ext = 1;
|
||||||
if (extension == "Classic Controller")
|
if (extension == "Classic")
|
||||||
m_ext = 2;
|
m_ext = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +186,7 @@ void TASInputDlg::CreateWiiLayout(int num)
|
||||||
control->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this);
|
control->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 4; i < 14; ++i)
|
for (unsigned int i = 4; i < ArraySize(m_buttons); ++i)
|
||||||
if (m_buttons[i] != nullptr)
|
if (m_buttons[i] != nullptr)
|
||||||
m_buttons_grid->Add(m_buttons[i]->checkbox);
|
m_buttons_grid->Add(m_buttons[i]->checkbox);
|
||||||
m_buttons_grid->AddSpacer(5);
|
m_buttons_grid->AddSpacer(5);
|
||||||
|
@ -183,16 +199,100 @@ void TASInputDlg::CreateWiiLayout(int num)
|
||||||
m_wiimote_szr->Add(m_buttons_box, 0, wxTOP | wxRIGHT, 5);
|
m_wiimote_szr->Add(m_buttons_box, 0, wxTOP | wxRIGHT, 5);
|
||||||
m_main_szr->Add(m_wiimote_szr);
|
m_main_szr->Add(m_wiimote_szr);
|
||||||
m_main_szr->Add(m_ext_szr);
|
m_main_szr->Add(m_ext_szr);
|
||||||
if (m_ext == 1)
|
m_main_szr->Add(m_cc_szr);
|
||||||
m_main_szr->Show(m_ext_szr);
|
|
||||||
else
|
|
||||||
m_main_szr->Hide(m_ext_szr);
|
|
||||||
SetSizerAndFit(m_main_szr, true);
|
|
||||||
|
|
||||||
ResetValues();
|
HandleExtensionChange();
|
||||||
m_has_layout = true;
|
m_has_layout = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxBoxSizer* TASInputDlg::CreateCCLayout()
|
||||||
|
{
|
||||||
|
wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < ArraySize(m_cc_buttons); ++i)
|
||||||
|
m_cc_buttons[i] = CreateButton(m_cc_button_names[i]);
|
||||||
|
|
||||||
|
m_cc_l_stick = CreateStick(ID_CC_L_STICK, 63, 63, WiimoteEmu::Classic::LEFT_STICK_CENTER_X, WiimoteEmu::Classic::LEFT_STICK_CENTER_Y, false, true);
|
||||||
|
m_cc_r_stick = CreateStick(ID_CC_R_STICK, 31, 31, WiimoteEmu::Classic::RIGHT_STICK_CENTER_X, WiimoteEmu::Classic::RIGHT_STICK_CENTER_Y, false, true);
|
||||||
|
|
||||||
|
m_cc_controls[CC_L_STICK_X] = &m_cc_l_stick.x_cont;
|
||||||
|
m_cc_controls[CC_L_STICK_Y] = &m_cc_l_stick.y_cont;
|
||||||
|
m_cc_controls[CC_R_STICK_X] = &m_cc_r_stick.x_cont;
|
||||||
|
m_cc_controls[CC_R_STICK_Y] = &m_cc_r_stick.y_cont;
|
||||||
|
m_cc_controls[CC_L_TRIGGER] = &m_cc_l;
|
||||||
|
m_cc_controls[CC_R_TRIGGER] = &m_cc_r;
|
||||||
|
|
||||||
|
m_cc_l_stick_szr = CreateStickLayout(&m_cc_l_stick, _("Left stick"));
|
||||||
|
m_cc_r_stick_szr = CreateStickLayout(&m_cc_r_stick, _("Right stick"));
|
||||||
|
|
||||||
|
m_cc_l = CreateControl(wxSL_VERTICAL, -1, 100, false, 31, 0);;
|
||||||
|
m_cc_r = CreateControl(wxSL_VERTICAL, -1, 100, false, 31, 0);;
|
||||||
|
|
||||||
|
wxStaticBoxSizer* const shoulder_box = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Shoulder Buttons"));
|
||||||
|
shoulder_box->Add(m_cc_l.slider, 0, wxALIGN_CENTER_VERTICAL);
|
||||||
|
shoulder_box->Add(m_cc_l.text, 0, wxALIGN_CENTER_VERTICAL);
|
||||||
|
shoulder_box->Add(m_cc_r.slider, 0, wxALIGN_CENTER_VERTICAL);
|
||||||
|
shoulder_box->Add(m_cc_r.text, 0, wxALIGN_CENTER_VERTICAL);
|
||||||
|
|
||||||
|
wxStaticBoxSizer* const cc_buttons_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Buttons"));
|
||||||
|
wxGridSizer* const cc_buttons_grid = new wxGridSizer(4);
|
||||||
|
wxGridSizer* const cc_buttons_dpad = new wxGridSizer(3);
|
||||||
|
|
||||||
|
cc_buttons_dpad->AddSpacer(20);
|
||||||
|
cc_buttons_dpad->Add(m_cc_buttons[1].checkbox);
|
||||||
|
cc_buttons_dpad->AddSpacer(20);
|
||||||
|
cc_buttons_dpad->Add(m_cc_buttons[2].checkbox);
|
||||||
|
cc_buttons_dpad->AddSpacer(20);
|
||||||
|
cc_buttons_dpad->Add(m_cc_buttons[3].checkbox);
|
||||||
|
cc_buttons_dpad->AddSpacer(20);
|
||||||
|
cc_buttons_dpad->Add(m_cc_buttons[0].checkbox);
|
||||||
|
cc_buttons_dpad->AddSpacer(20);
|
||||||
|
|
||||||
|
|
||||||
|
for (auto button : m_cc_buttons)
|
||||||
|
cc_buttons_grid->Add(button.checkbox);
|
||||||
|
cc_buttons_grid->AddSpacer(5);
|
||||||
|
|
||||||
|
cc_buttons_box->Add(cc_buttons_grid);
|
||||||
|
cc_buttons_box->Add(cc_buttons_dpad);
|
||||||
|
|
||||||
|
szr->Add(m_cc_l_stick_szr, 0, wxALL, 5);
|
||||||
|
szr->Add(m_cc_r_stick_szr, 0, wxALL, 5);
|
||||||
|
szr->Add(shoulder_box, 0, wxLEFT | wxRIGHT, 5);
|
||||||
|
szr->Add(cc_buttons_box, 0, wxTOP | wxRIGHT, 5);
|
||||||
|
|
||||||
|
for (Control* const control : m_cc_controls)
|
||||||
|
{
|
||||||
|
if (control != nullptr)
|
||||||
|
control->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this);
|
||||||
|
}
|
||||||
|
return szr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TASInputDlg::HandleExtensionChange()
|
||||||
|
{
|
||||||
|
if (m_ext == 1)
|
||||||
|
{
|
||||||
|
m_main_szr->Hide(m_cc_szr);
|
||||||
|
m_main_szr->Show(m_wiimote_szr);
|
||||||
|
m_main_szr->Show(m_ext_szr);
|
||||||
|
}
|
||||||
|
else if (m_ext == 2)
|
||||||
|
{
|
||||||
|
m_main_szr->Hide(m_ext_szr);
|
||||||
|
m_main_szr->Hide(m_wiimote_szr);
|
||||||
|
m_main_szr->Show(m_cc_szr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_main_szr->Hide(m_ext_szr);
|
||||||
|
m_main_szr->Hide(m_cc_szr);
|
||||||
|
m_main_szr->Show(m_wiimote_szr);
|
||||||
|
}
|
||||||
|
SetSizerAndFit(m_main_szr, true);
|
||||||
|
ResetValues();
|
||||||
|
}
|
||||||
|
|
||||||
void TASInputDlg::CreateGCLayout()
|
void TASInputDlg::CreateGCLayout()
|
||||||
{
|
{
|
||||||
if (m_has_layout)
|
if (m_has_layout)
|
||||||
|
@ -244,7 +344,7 @@ void TASInputDlg::CreateGCLayout()
|
||||||
m_z = CreateButton("Z");
|
m_z = CreateButton("Z");
|
||||||
m_start = CreateButton("Start");
|
m_start = CreateButton("Start");
|
||||||
|
|
||||||
for (unsigned int i = 4; i < 14; ++i)
|
for (unsigned int i = 4; i < ArraySize(m_buttons); ++i)
|
||||||
if (m_buttons[i] != nullptr)
|
if (m_buttons[i] != nullptr)
|
||||||
m_buttons_grid->Add(m_buttons[i]->checkbox, false);
|
m_buttons_grid->Add(m_buttons[i]->checkbox, false);
|
||||||
m_buttons_grid->AddSpacer(5);
|
m_buttons_grid->AddSpacer(5);
|
||||||
|
@ -361,6 +461,18 @@ void TASInputDlg::ResetValues()
|
||||||
control->text->SetValue(std::to_string(control->default_value));
|
control->text->SetValue(std::to_string(control->default_value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (m_ext == 2)
|
||||||
|
{
|
||||||
|
for (Button const button : m_cc_buttons)
|
||||||
|
button.checkbox->SetValue(false);
|
||||||
|
|
||||||
|
for (Control* const control : m_cc_controls)
|
||||||
|
{
|
||||||
|
control->value = control->default_value;
|
||||||
|
control->slider->SetValue(control->default_value);
|
||||||
|
control->text->SetValue(std::to_string(control->default_value));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TASInputDlg::SetStickValue(bool* ActivatedByKeyboard, int* AmountPressed, wxTextCtrl* Textbox, int CurrentValue, int center)
|
void TASInputDlg::SetStickValue(bool* ActivatedByKeyboard, int* AmountPressed, wxTextCtrl* Textbox, int CurrentValue, int center)
|
||||||
|
@ -379,9 +491,9 @@ void TASInputDlg::SetStickValue(bool* ActivatedByKeyboard, int* AmountPressed, w
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TASInputDlg::SetSliderValue(Control* control, int CurrentValue, int default_value)
|
void TASInputDlg::SetSliderValue(Control* control, int CurrentValue)
|
||||||
{
|
{
|
||||||
if (CurrentValue != default_value)
|
if (CurrentValue != control->default_value)
|
||||||
{
|
{
|
||||||
control->value = CurrentValue;
|
control->value = CurrentValue;
|
||||||
control->set_by_keyboard = true;
|
control->set_by_keyboard = true;
|
||||||
|
@ -389,9 +501,9 @@ void TASInputDlg::SetSliderValue(Control* control, int CurrentValue, int default
|
||||||
}
|
}
|
||||||
else if (control->set_by_keyboard)
|
else if (control->set_by_keyboard)
|
||||||
{
|
{
|
||||||
control->value = default_value;
|
control->value = control->default_value;
|
||||||
control->set_by_keyboard = false;
|
control->set_by_keyboard = false;
|
||||||
control->text->SetValue(std::to_string(default_value));
|
control->text->SetValue(std::to_string(control->default_value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,10 +538,10 @@ void TASInputDlg::GetKeyBoardInput(GCPadStatus* PadStatus)
|
||||||
|
|
||||||
SetStickValue(&m_c_stick.x_cont.set_by_keyboard, &m_c_stick.x_cont.value, m_c_stick.x_cont.text, PadStatus->substickX);
|
SetStickValue(&m_c_stick.x_cont.set_by_keyboard, &m_c_stick.x_cont.value, m_c_stick.x_cont.text, PadStatus->substickX);
|
||||||
SetStickValue(&m_c_stick.y_cont.set_by_keyboard, &m_c_stick.y_cont.value, m_c_stick.y_cont.text, PadStatus->substickY);
|
SetStickValue(&m_c_stick.y_cont.set_by_keyboard, &m_c_stick.y_cont.value, m_c_stick.y_cont.text, PadStatus->substickY);
|
||||||
SetSliderValue(&m_l_cont, PadStatus->triggerLeft, 0);
|
SetSliderValue(&m_l_cont, PadStatus->triggerLeft);
|
||||||
SetSliderValue(&m_r_cont, PadStatus->triggerRight, 0);
|
SetSliderValue(&m_r_cont, PadStatus->triggerRight);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < 14; ++i)
|
for (unsigned int i = 0; i < ArraySize(m_buttons); ++i)
|
||||||
{
|
{
|
||||||
if (m_buttons[i] != nullptr)
|
if (m_buttons[i] != nullptr)
|
||||||
SetButtonValue(m_buttons[i], ((PadStatus->button & m_gc_pad_buttons_bitmask[i]) != 0));
|
SetButtonValue(m_buttons[i], ((PadStatus->button & m_gc_pad_buttons_bitmask[i]) != 0));
|
||||||
|
@ -457,9 +569,9 @@ void TASInputDlg::GetKeyBoardInput(u8* data, WiimoteEmu::ReportFeatures rptf, in
|
||||||
{
|
{
|
||||||
wm_accel* dt = (wm_accel*)accelData;
|
wm_accel* dt = (wm_accel*)accelData;
|
||||||
|
|
||||||
SetSliderValue(&m_x_cont, dt->x << 2 | ((wm_buttons*)coreData)->acc_x_lsb, m_x_cont.default_value);
|
SetSliderValue(&m_x_cont, dt->x << 2 | ((wm_buttons*)coreData)->acc_x_lsb);
|
||||||
SetSliderValue(&m_y_cont, dt->y << 2 | ((wm_buttons*)coreData)->acc_y_lsb << 1, m_y_cont.default_value);
|
SetSliderValue(&m_y_cont, dt->y << 2 | ((wm_buttons*)coreData)->acc_y_lsb << 1);
|
||||||
SetSliderValue(&m_z_cont, dt->z << 2 | ((wm_buttons*)coreData)->acc_z_lsb << 1, m_z_cont.default_value);
|
SetSliderValue(&m_z_cont, dt->z << 2 | ((wm_buttons*)coreData)->acc_z_lsb << 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// I don't think this can be made to work in a sane manner.
|
// I don't think this can be made to work in a sane manner.
|
||||||
|
@ -480,6 +592,28 @@ void TASInputDlg::GetKeyBoardInput(u8* data, WiimoteEmu::ReportFeatures rptf, in
|
||||||
SetButtonValue(m_buttons[11], nunchuk.bt.c != 0);
|
SetButtonValue(m_buttons[11], nunchuk.bt.c != 0);
|
||||||
SetButtonValue(m_buttons[12], nunchuk.bt.z != 0);
|
SetButtonValue(m_buttons[12], nunchuk.bt.z != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (extData && ext == 2)
|
||||||
|
{
|
||||||
|
wm_classic_extension& cc = *(wm_classic_extension*)extData;
|
||||||
|
WiimoteDecrypt(&key, (u8*)&cc, 0, sizeof(wm_classic_extension));
|
||||||
|
cc.bt.hex = cc.bt.hex ^ 0xFFFF;
|
||||||
|
for (unsigned int i = 0; i < 15; ++i)
|
||||||
|
{
|
||||||
|
SetButtonValue(&m_cc_buttons[i], ((cc.bt.hex & m_cc_buttons_bitmask[i]) != 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_cc_l.value == 31)
|
||||||
|
m_cc_buttons[10].checkbox->SetValue(true);
|
||||||
|
if (m_cc_r.value == 31)
|
||||||
|
m_cc_buttons[11].checkbox->SetValue(true);
|
||||||
|
|
||||||
|
SetSliderValue(&m_cc_l_stick.x_cont, cc.regular_data.lx);
|
||||||
|
SetSliderValue(&m_cc_l_stick.y_cont, cc.regular_data.ly);
|
||||||
|
|
||||||
|
SetSliderValue(&m_cc_r_stick.x_cont, cc.rx1 | (cc.rx2 << 1) | (cc.rx3 << 3));
|
||||||
|
SetSliderValue(&m_cc_r_stick.y_cont, cc.ry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TASInputDlg::GetValues(u8* data, WiimoteEmu::ReportFeatures rptf, int ext, const wiimote_key key)
|
void TASInputDlg::GetValues(u8* data, WiimoteEmu::ReportFeatures rptf, int ext, const wiimote_key key)
|
||||||
|
@ -493,7 +627,8 @@ void TASInputDlg::GetValues(u8* data, WiimoteEmu::ReportFeatures rptf, int ext,
|
||||||
u8* const accelData = rptf.accel ? (data + rptf.accel) : nullptr;
|
u8* const accelData = rptf.accel ? (data + rptf.accel) : nullptr;
|
||||||
u8* const irData = rptf.ir ? (data + rptf.ir) : nullptr;
|
u8* const irData = rptf.ir ? (data + rptf.ir) : nullptr;
|
||||||
u8* const extData = rptf.ext ? (data + rptf.ext) : nullptr;
|
u8* const extData = rptf.ext ? (data + rptf.ext) : nullptr;
|
||||||
|
if (ext != 2)
|
||||||
|
{
|
||||||
if (coreData)
|
if (coreData)
|
||||||
SetWiiButtons(&((wm_buttons*)coreData)->hex);
|
SetWiiButtons(&((wm_buttons*)coreData)->hex);
|
||||||
|
|
||||||
|
@ -569,18 +704,11 @@ void TASInputDlg::GetValues(u8* data, WiimoteEmu::ReportFeatures rptf, int ext,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (ext != m_ext)
|
if (ext != m_ext)
|
||||||
{
|
{
|
||||||
m_ext = ext;
|
m_ext = ext;
|
||||||
if (ext == 0)
|
HandleExtensionChange();
|
||||||
{
|
|
||||||
m_main_szr->Hide(m_ext_szr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_main_szr->Show(m_ext_szr);
|
|
||||||
}
|
|
||||||
SetSizerAndFit(m_main_szr);
|
|
||||||
}
|
}
|
||||||
else if (extData && ext == 1)
|
else if (extData && ext == 1)
|
||||||
{
|
{
|
||||||
|
@ -601,14 +729,33 @@ void TASInputDlg::GetValues(u8* data, WiimoteEmu::ReportFeatures rptf, int ext,
|
||||||
nunchuk.bt.hex = nunchuk.bt.hex ^ 0x3;
|
nunchuk.bt.hex = nunchuk.bt.hex ^ 0x3;
|
||||||
WiimoteEncrypt(&key, (u8*)&nunchuk, 0, sizeof(wm_nc));
|
WiimoteEncrypt(&key, (u8*)&nunchuk, 0, sizeof(wm_nc));
|
||||||
}
|
}
|
||||||
//else if (extData && ext == 2)
|
else if (extData && ext == 2)
|
||||||
//{
|
{
|
||||||
// TODO
|
wm_classic_extension& cc = *(wm_classic_extension*)extData;
|
||||||
//wm_classic_extension& cc = *(wm_classic_extension*)extData;
|
WiimoteDecrypt(&key, (u8*)&cc, 0, sizeof(wm_classic_extension));
|
||||||
//WiimoteDecrypt(&key, (u8*)&cc, 0, sizeof(wm_classic_extension));
|
cc.bt.hex = 0;
|
||||||
|
|
||||||
//WiimoteEncrypt(&key, (u8*)&cc, 0, sizeof(wm_classic_extension));
|
for (unsigned int i = 0; i < ArraySize(m_cc_buttons); ++i)
|
||||||
//}
|
{
|
||||||
|
cc.bt.hex |= (m_cc_buttons[i].checkbox->IsChecked()) ? m_cc_buttons_bitmask[i] : 0;
|
||||||
|
}
|
||||||
|
cc.bt.hex ^= 0xFFFF;
|
||||||
|
|
||||||
|
u16 rx = m_cc_r_stick.x_cont.value;
|
||||||
|
cc.rx1 = rx & 0x1;
|
||||||
|
cc.rx2 = (rx >> 1) & 0x3;
|
||||||
|
cc.rx3 = (rx >> 3) & 0x3;
|
||||||
|
cc.ry = m_cc_r_stick.y_cont.value;
|
||||||
|
|
||||||
|
cc.regular_data.lx = m_cc_l_stick.x_cont.value;
|
||||||
|
cc.regular_data.ly = m_cc_l_stick.y_cont.value;
|
||||||
|
|
||||||
|
cc.rt = m_cc_r.value;
|
||||||
|
cc.lt1 = m_cc_l.value & 0x7;
|
||||||
|
cc.lt2 = (m_cc_l.value >> 3) & 0x3;
|
||||||
|
|
||||||
|
WiimoteEncrypt(&key, (u8*)&cc, 0, sizeof(wm_classic_extension));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TASInputDlg::GetValues(GCPadStatus* PadStatus)
|
void TASInputDlg::GetValues(GCPadStatus* PadStatus)
|
||||||
|
@ -626,7 +773,7 @@ void TASInputDlg::GetValues(GCPadStatus* PadStatus)
|
||||||
PadStatus->triggerLeft = m_l.checkbox->GetValue() ? 255 : m_l_cont.slider->GetValue();
|
PadStatus->triggerLeft = m_l.checkbox->GetValue() ? 255 : m_l_cont.slider->GetValue();
|
||||||
PadStatus->triggerRight = m_r.checkbox->GetValue() ? 255 : m_r_cont.slider->GetValue();
|
PadStatus->triggerRight = m_r.checkbox->GetValue() ? 255 : m_r_cont.slider->GetValue();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < 14; ++i)
|
for (unsigned int i = 0; i < ArraySize(m_buttons); ++i)
|
||||||
{
|
{
|
||||||
if (m_buttons[i] != nullptr)
|
if (m_buttons[i] != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -660,6 +807,11 @@ void TASInputDlg::UpdateFromSliders(wxCommandEvent& event)
|
||||||
text = control->text;
|
text = control->text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Control* const control : m_cc_controls)
|
||||||
|
{
|
||||||
|
if (control != nullptr && event.GetId() == control->slider_id)
|
||||||
|
text = control->text;
|
||||||
|
}
|
||||||
int value = ((wxSlider*)event.GetEventObject())->GetValue();
|
int value = ((wxSlider*)event.GetEventObject())->GetValue();
|
||||||
if (text)
|
if (text)
|
||||||
text->SetValue(std::to_string(value));
|
text->SetValue(std::to_string(value));
|
||||||
|
@ -682,26 +834,35 @@ void TASInputDlg::UpdateFromText(wxCommandEvent& event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_controls[2] != nullptr)
|
for (Control* const control : m_cc_controls)
|
||||||
{
|
{
|
||||||
int x = m_c_stick.x_cont.value;
|
if (control != nullptr && event.GetId() == control->text_id)
|
||||||
int y = m_c_stick.y_cont.value;
|
{
|
||||||
|
int v = (value > control->range) ? control->range : value;
|
||||||
if (m_c_stick.x_cont.reverse)
|
control->slider->SetValue(v);
|
||||||
x = m_c_stick.x_cont.range - m_c_stick.x_cont.value + 1;
|
control->value = v;
|
||||||
if (m_c_stick.y_cont.reverse)
|
}
|
||||||
y = m_c_stick.y_cont.range - m_c_stick.y_cont.value + 1;
|
|
||||||
|
|
||||||
m_c_stick.bitmap->SetBitmap(CreateStickBitmap(x, y));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = (u8)(std::floor(((double)m_main_stick.x_cont.value / (double)m_main_stick.x_cont.range * 255.0) + .5));
|
if (m_controls[0] != nullptr)
|
||||||
int y = (u8)(std::floor(((double)m_main_stick.y_cont.value / (double)m_main_stick.y_cont.range * 255.0) + .5));
|
UpdateStickBitmap(m_main_stick);
|
||||||
if (m_main_stick.x_cont.reverse)
|
if (m_controls[2] != nullptr)
|
||||||
|
UpdateStickBitmap(m_c_stick);
|
||||||
|
if (m_cc_controls[CC_L_STICK_X] != nullptr)
|
||||||
|
UpdateStickBitmap(m_cc_l_stick);
|
||||||
|
if (m_cc_controls[CC_R_STICK_X] != nullptr)
|
||||||
|
UpdateStickBitmap(m_cc_r_stick);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TASInputDlg::UpdateStickBitmap(Stick stick)
|
||||||
|
{
|
||||||
|
int x = (u8)(std::floor(((double)stick.x_cont.value / (double)(stick.x_cont.range + 1) * 255.0) + .5));
|
||||||
|
int y = (u8)(std::floor(((double)stick.y_cont.value / (double)(stick.y_cont.range + 1) * 255.0) + .5));
|
||||||
|
if (stick.x_cont.reverse)
|
||||||
x = 256 - (u8)x;
|
x = 256 - (u8)x;
|
||||||
if (m_main_stick.y_cont.reverse)
|
if (stick.y_cont.reverse)
|
||||||
y = 256 - (u8)y;
|
y = 256 - (u8)y;
|
||||||
m_main_stick.bitmap->SetBitmap(CreateStickBitmap(x, y));
|
stick.bitmap->SetBitmap(CreateStickBitmap(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TASInputDlg::OnCloseWindow(wxCloseEvent& event)
|
void TASInputDlg::OnCloseWindow(wxCloseEvent& event)
|
||||||
|
@ -733,14 +894,22 @@ bool TASInputDlg::TASHasFocus()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TASInputDlg::Stick* TASInputDlg::FindStickByID(int id)
|
||||||
|
{
|
||||||
|
if (id == ID_MAIN_STICK)
|
||||||
|
return &m_main_stick;
|
||||||
|
else if (id == ID_C_STICK)
|
||||||
|
return &m_c_stick;
|
||||||
|
else if (id == ID_CC_L_STICK)
|
||||||
|
return &m_cc_l_stick;
|
||||||
|
else if (id == ID_CC_R_STICK)
|
||||||
|
return &m_cc_r_stick;
|
||||||
|
else
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
void TASInputDlg::OnMouseUpR(wxMouseEvent& event)
|
void TASInputDlg::OnMouseUpR(wxMouseEvent& event)
|
||||||
{
|
{
|
||||||
Stick* stick = nullptr;
|
Stick* stick = FindStickByID(event.GetId());
|
||||||
if (event.GetId() == ID_MAIN_STICK)
|
|
||||||
stick = &m_main_stick;
|
|
||||||
else if (event.GetId() == ID_C_STICK)
|
|
||||||
stick = &m_c_stick;
|
|
||||||
|
|
||||||
if (stick == nullptr)
|
if (stick == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -764,6 +933,17 @@ void TASInputDlg::OnRightClickSlider(wxMouseEvent& event)
|
||||||
control->value = control->default_value;
|
control->value = control->default_value;
|
||||||
control->slider->SetValue(control->default_value);
|
control->slider->SetValue(control->default_value);
|
||||||
control->text->SetValue(std::to_string(control->default_value));
|
control->text->SetValue(std::to_string(control->default_value));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Control* const control : m_cc_controls)
|
||||||
|
{
|
||||||
|
if (control != nullptr && event.GetId() == control->slider_id)
|
||||||
|
{
|
||||||
|
control->value = control->default_value;
|
||||||
|
control->slider->SetValue(control->default_value);
|
||||||
|
control->text->SetValue(std::to_string(control->default_value));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -773,12 +953,8 @@ void TASInputDlg::OnMouseDownL(wxMouseEvent& event)
|
||||||
if (!event.LeftIsDown())
|
if (!event.LeftIsDown())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Stick* stick;
|
Stick* stick = FindStickByID(event.GetId());
|
||||||
if (event.GetId() == ID_MAIN_STICK)
|
if (stick == nullptr)
|
||||||
stick = &m_main_stick;
|
|
||||||
else if (event.GetId() == ID_C_STICK)
|
|
||||||
stick = &m_c_stick;
|
|
||||||
else
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxPoint ptM(event.GetPosition());
|
wxPoint ptM(event.GetPosition());
|
||||||
|
@ -798,13 +974,10 @@ void TASInputDlg::OnMouseDownL(wxMouseEvent& event)
|
||||||
stick->x_cont.value = (unsigned int)stick->x_cont.value > stick->x_cont.range ? stick->x_cont.range : stick->x_cont.value;
|
stick->x_cont.value = (unsigned int)stick->x_cont.value > stick->x_cont.range ? stick->x_cont.range : stick->x_cont.value;
|
||||||
stick->y_cont.value = (unsigned int)stick->y_cont.value > stick->y_cont.range ? stick->y_cont.range : stick->y_cont.value;
|
stick->y_cont.value = (unsigned int)stick->y_cont.value > stick->y_cont.range ? stick->y_cont.range : stick->y_cont.value;
|
||||||
|
|
||||||
stick->bitmap->SetBitmap(CreateStickBitmap(ptM.x*2, ptM.y*2));
|
// This updates sliders and the bitmap too.
|
||||||
|
|
||||||
stick->x_cont.text->SetValue(std::to_string(stick->x_cont.value));
|
stick->x_cont.text->SetValue(std::to_string(stick->x_cont.value));
|
||||||
stick->y_cont.text->SetValue(std::to_string(stick->y_cont.value));
|
stick->y_cont.text->SetValue(std::to_string(stick->y_cont.value));
|
||||||
|
|
||||||
stick->x_cont.slider->SetValue(stick->x_cont.value);
|
|
||||||
stick->y_cont.slider->SetValue(stick->y_cont.value);
|
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -817,6 +990,14 @@ void TASInputDlg::SetTurbo(wxMouseEvent& event)
|
||||||
if (btn != nullptr && event.GetId() == btn->id)
|
if (btn != nullptr && event.GetId() == btn->id)
|
||||||
button = btn;
|
button = btn;
|
||||||
}
|
}
|
||||||
|
if (m_ext == 2)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < ArraySize(m_cc_buttons); ++i)
|
||||||
|
{
|
||||||
|
if (event.GetId() == m_cc_buttons[i].id)
|
||||||
|
button = &m_cc_buttons[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (event.LeftDown())
|
if (event.LeftDown())
|
||||||
{
|
{
|
||||||
|
@ -848,6 +1029,14 @@ void TASInputDlg::ButtonTurbo()
|
||||||
if (button != nullptr && button->turbo_on)
|
if (button != nullptr && button->turbo_on)
|
||||||
button->checkbox->SetValue(!button->checkbox->GetValue());
|
button->checkbox->SetValue(!button->checkbox->GetValue());
|
||||||
}
|
}
|
||||||
|
if (m_ext == 2)
|
||||||
|
{
|
||||||
|
for (Button const button : m_cc_buttons)
|
||||||
|
{
|
||||||
|
if (button.turbo_on)
|
||||||
|
button.checkbox->SetValue(!button.checkbox->GetValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,11 +58,14 @@ class TASInputDlg : public wxDialog
|
||||||
wxBitmap CreateStickBitmap(int x, int y);
|
wxBitmap CreateStickBitmap(int x, int y);
|
||||||
void SetWiiButtons(u16* butt);
|
void SetWiiButtons(u16* butt);
|
||||||
void GetIRData(u8* const data, u8 mode, bool use_accel);
|
void GetIRData(u8* const data, u8 mode, bool use_accel);
|
||||||
|
void HandleExtensionChange();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const int ID_C_STICK = 1001;
|
const int ID_C_STICK = 1001;
|
||||||
const int ID_MAIN_STICK = 1002;
|
const int ID_MAIN_STICK = 1002;
|
||||||
int m_eleID = 1003;
|
const int ID_CC_L_STICK = 1003;
|
||||||
|
const int ID_CC_R_STICK = 1004;
|
||||||
|
int m_eleID = 1005;
|
||||||
|
|
||||||
struct Control
|
struct Control
|
||||||
{
|
{
|
||||||
|
@ -92,32 +95,54 @@ class TASInputDlg : public wxDialog
|
||||||
Control y_cont;
|
Control y_cont;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxBoxSizer* CreateCCLayout();
|
||||||
void SetStickValue(bool* ActivatedByKeyboard, int* AmountPressed, wxTextCtrl* Textbox, int CurrentValue, int center = 128);
|
void SetStickValue(bool* ActivatedByKeyboard, int* AmountPressed, wxTextCtrl* Textbox, int CurrentValue, int center = 128);
|
||||||
void SetButtonValue(Button* button, bool CurrentState);
|
void SetButtonValue(Button* button, bool CurrentState);
|
||||||
void SetSliderValue(Control* control, int CurrentValue, int default_value = 128);
|
void SetSliderValue(Control* control, int CurrentValue);
|
||||||
void CreateBaseLayout();
|
void CreateBaseLayout();
|
||||||
|
void UpdateStickBitmap(Stick stick);
|
||||||
|
Stick* FindStickByID(int id);
|
||||||
Stick CreateStick(int id_stick, int xRange, int yRange, u32 defaultX, u32 defaultY, bool reverseX, bool reverseY);
|
Stick CreateStick(int id_stick, int xRange, int yRange, u32 defaultX, u32 defaultY, bool reverseX, bool reverseY);
|
||||||
wxStaticBoxSizer* CreateStickLayout(Stick* tempStick, const wxString& title);
|
wxStaticBoxSizer* CreateStickLayout(Stick* tempStick, const wxString& title);
|
||||||
wxStaticBoxSizer* CreateAccelLayout(Control* x, Control* y, Control* z, const wxString& title);
|
wxStaticBoxSizer* CreateAccelLayout(Control* x, Control* y, Control* z, const wxString& title);
|
||||||
Button CreateButton(const std::string& name);
|
Button CreateButton(const std::string& name);
|
||||||
Control CreateControl(long style, int width, int height, bool reverse = false, u32 range = 255, u32 default_value = 128);
|
Control CreateControl(long style, int width, int height, bool reverse = false, u32 range = 255, u32 default_value = 128);
|
||||||
|
|
||||||
Control m_l_cont, m_r_cont, m_x_cont, m_y_cont, m_z_cont, m_nx_cont, m_ny_cont, m_nz_cont;
|
enum
|
||||||
|
{
|
||||||
|
CC_L_STICK_X,
|
||||||
|
CC_L_STICK_Y,
|
||||||
|
CC_R_STICK_X,
|
||||||
|
CC_R_STICK_Y,
|
||||||
|
CC_L_TRIGGER,
|
||||||
|
CC_R_TRIGGER,
|
||||||
|
};
|
||||||
|
|
||||||
|
Control m_l_cont, m_r_cont, m_x_cont, m_y_cont, m_z_cont, m_nx_cont, m_ny_cont, m_nz_cont, m_cc_l, m_cc_r;
|
||||||
Button m_a, m_b, m_x, m_y, m_z, m_l, m_r, m_c;
|
Button m_a, m_b, m_x, m_y, m_z, m_l, m_r, m_c;
|
||||||
Button m_start, m_plus, m_minus, m_one, m_two, m_home;
|
Button m_start, m_plus, m_minus, m_one, m_two, m_home;
|
||||||
Button m_dpad_up, m_dpad_down, m_dpad_left, m_dpad_right;
|
Button m_dpad_up, m_dpad_down, m_dpad_left, m_dpad_right;
|
||||||
Stick m_main_stick, m_c_stick;
|
Stick m_main_stick, m_c_stick;
|
||||||
|
|
||||||
Button* m_buttons[14];
|
Stick m_cc_l_stick, m_cc_r_stick;
|
||||||
|
|
||||||
|
Button* m_buttons[13];
|
||||||
|
Button m_cc_buttons[15];
|
||||||
Control* m_controls[10];
|
Control* m_controls[10];
|
||||||
|
Control* m_cc_controls[6];
|
||||||
static const int m_gc_pad_buttons_bitmask[12];
|
static const int m_gc_pad_buttons_bitmask[12];
|
||||||
static const int m_wii_buttons_bitmask[13];
|
static const int m_wii_buttons_bitmask[11];
|
||||||
|
static const int m_cc_buttons_bitmask[15];
|
||||||
|
static const std::string m_cc_button_names[15];
|
||||||
u8 m_ext = 0;
|
u8 m_ext = 0;
|
||||||
wxBoxSizer* m_main_szr;
|
wxBoxSizer* m_main_szr;
|
||||||
wxBoxSizer* m_wiimote_szr;
|
wxBoxSizer* m_wiimote_szr;
|
||||||
wxBoxSizer* m_ext_szr;
|
wxBoxSizer* m_ext_szr;
|
||||||
|
wxBoxSizer* m_cc_szr;
|
||||||
wxStaticBoxSizer* m_main_stick_szr;
|
wxStaticBoxSizer* m_main_stick_szr;
|
||||||
wxStaticBoxSizer* m_c_stick_szr;
|
wxStaticBoxSizer* m_c_stick_szr;
|
||||||
|
wxStaticBoxSizer* m_cc_l_stick_szr;
|
||||||
|
wxStaticBoxSizer* m_cc_r_stick_szr;
|
||||||
|
|
||||||
bool m_has_layout = false;
|
bool m_has_layout = false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue