Add wiimote tas input.

This commit is contained in:
Rachel Bryk 2014-09-14 23:42:32 -04:00
parent 0d768bd55e
commit c41b31d3ff
11 changed files with 691 additions and 998 deletions

View File

@ -110,7 +110,7 @@ bool CSIDevice_DanceMat::GetData(u32& _Hi, u32& _Low)
memset(&PadStatus, 0, sizeof(PadStatus)); memset(&PadStatus, 0, sizeof(PadStatus));
Pad::GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus); Pad::GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus);
Movie::CallInputManip(&PadStatus, ISIDevice::m_iDeviceNumber); Movie::CallGCInputManip(&PadStatus, ISIDevice::m_iDeviceNumber);
u32 netValues[2]; u32 netValues[2];
if (NetPlay_GetInput(ISIDevice::m_iDeviceNumber, PadStatus, netValues)) if (NetPlay_GetInput(ISIDevice::m_iDeviceNumber, PadStatus, netValues))

View File

@ -110,7 +110,7 @@ bool CSIDevice_GCController::GetData(u32& _Hi, u32& _Low)
memset(&PadStatus, 0, sizeof(PadStatus)); memset(&PadStatus, 0, sizeof(PadStatus));
Pad::GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus); Pad::GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus);
Movie::CallInputManip(&PadStatus, ISIDevice::m_iDeviceNumber); Movie::CallGCInputManip(&PadStatus, ISIDevice::m_iDeviceNumber);
u32 netValues[2]; u32 netValues[2];
if (NetPlay_GetInput(ISIDevice::m_iDeviceNumber, PadStatus, netValues)) if (NetPlay_GetInput(ISIDevice::m_iDeviceNumber, PadStatus, netValues))

View File

@ -101,7 +101,7 @@ bool CSIDevice_GCSteeringWheel::GetData(u32& _Hi, u32& _Low)
memset(&PadStatus, 0, sizeof(PadStatus)); memset(&PadStatus, 0, sizeof(PadStatus));
Pad::GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus); Pad::GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus);
Movie::CallInputManip(&PadStatus, ISIDevice::m_iDeviceNumber); Movie::CallGCInputManip(&PadStatus, ISIDevice::m_iDeviceNumber);
u32 netValues[2]; u32 netValues[2];
if (NetPlay_GetInput(ISIDevice::m_iDeviceNumber, PadStatus, netValues)) if (NetPlay_GetInput(ISIDevice::m_iDeviceNumber, PadStatus, netValues))

View File

@ -517,18 +517,18 @@ void Wiimote::GetIRData(u8* const data, bool use_accel)
{ {
if (x[i*2] < 1024 && y[i*2] < 768) if (x[i*2] < 1024 && y[i*2] < 768)
{ {
irdata[i].x1 = u8(x[i*2]); irdata[i].x1 = static_cast<u8>(x[i*2]);
irdata[i].x1hi = x[i*2] >> 8; irdata[i].x1hi = x[i*2] >> 8;
irdata[i].y1 = u8(y[i*2]); irdata[i].y1 = static_cast<u8>(y[i*2]);
irdata[i].y1hi = y[i*2] >> 8; irdata[i].y1hi = y[i*2] >> 8;
} }
if (x[i*2+1] < 1024 && y[i*2+1] < 768) if (x[i*2+1] < 1024 && y[i*2+1] < 768)
{ {
irdata[i].x2 = u8(x[i*2+1]); irdata[i].x2 = static_cast<u8>(x[i*2+1]);
irdata[i].x2hi = x[i*2+1] >> 8; irdata[i].x2hi = x[i*2+1] >> 8;
irdata[i].y2 = u8(y[i*2+1]); irdata[i].y2 = static_cast<u8>(y[i*2+1]);
irdata[i].y2hi = y[i*2+1] >> 8; irdata[i].y2hi = y[i*2+1] >> 8;
} }
} }
@ -542,10 +542,10 @@ void Wiimote::GetIRData(u8* const data, bool use_accel)
for (unsigned int i = 0; i < 4; ++i) for (unsigned int i = 0; i < 4; ++i)
if (x[i] < 1024 && y[i] < 768) if (x[i] < 1024 && y[i] < 768)
{ {
irdata[i].x = u8(x[i]); irdata[i].x = static_cast<u8>(x[i]);
irdata[i].xhi = x[i] >> 8; irdata[i].xhi = x[i] >> 8;
irdata[i].y = u8(y[i]); irdata[i].y = static_cast<u8>(y[i]);
irdata[i].yhi = y[i] >> 8; irdata[i].yhi = y[i] >> 8;
irdata[i].size = 10; irdata[i].size = 10;
@ -729,6 +729,8 @@ void Wiimote::Update()
} }
} }
} }
Movie::CallWiiInputManip(data, rptf, m_index);
} }
if (NetPlay::IsNetPlayRunning()) if (NetPlay::IsNetPlayRunning())
{ {

View File

@ -81,7 +81,8 @@ static std::string tmpStateFilename = File::GetUserPath(D_STATESAVES_IDX) + "dtm
static std::string s_InputDisplay[8]; static std::string s_InputDisplay[8];
static ManipFunction mfunc = nullptr; static GCManipFunction gcmfunc = nullptr;
static WiiManipFunction wiimfunc = nullptr;
static void EnsureTmpInputSize(size_t bound) static void EnsureTmpInputSize(size_t bound)
{ {
@ -631,8 +632,8 @@ static void SetWiiInputDisplayString(int remoteID, u8* const data, const Wiimote
if (irData) if (irData)
{ {
u16 x = irData[0] | ((irData[2] >> 4 & 0x3) << 8); u16 x = irData[0] | ((irData[2] >> 4 & 0x3) << 8);
u16 y = irData[1] | ((irData[2] >> 2 & 0x3) << 8); u16 y = irData[1] | ((irData[2] >> 6 & 0x3) << 8);
std::string ir = StringFromFormat(" IR:%d,%d", x, y); std::string ir = StringFromFormat(" IR:%d,%d", x,y);
s_InputDisplay[controllerID].append(ir); s_InputDisplay[controllerID].append(ir);
} }
@ -1245,15 +1246,24 @@ void SaveRecording(const std::string& filename)
Core::DisplayMessage(StringFromFormat("Failed to save %s", filename.c_str()), 2000); Core::DisplayMessage(StringFromFormat("Failed to save %s", filename.c_str()), 2000);
} }
void SetInputManip(ManipFunction func) void SetGCInputManip(GCManipFunction func)
{ {
mfunc = func; gcmfunc = func;
}
void SetWiiInputManip(WiiManipFunction func)
{
wiimfunc = func;
} }
void CallInputManip(GCPadStatus* PadStatus, int controllerID) void CallGCInputManip(GCPadStatus* PadStatus, int controllerID)
{ {
if (mfunc) if (gcmfunc)
(*mfunc)(PadStatus, controllerID); (*gcmfunc)(PadStatus, controllerID);
}
void CallWiiInputManip(u8* data, WiimoteEmu::ReportFeatures rptf, int controllerID)
{
if (wiimfunc)
(*wiimfunc)(data, rptf, controllerID);
} }
void SetGraphicsConfig() void SetGraphicsConfig()

View File

@ -176,8 +176,11 @@ void CheckWiimoteStatus(int wiimote, u8* data, const struct WiimoteEmu::ReportFe
std::string GetInputDisplay(); std::string GetInputDisplay();
// Done this way to avoid mixing of core and gui code // Done this way to avoid mixing of core and gui code
typedef void(*ManipFunction)(GCPadStatus*, int); typedef void(*GCManipFunction)(GCPadStatus*, int);
typedef void(*WiiManipFunction)(u8*, WiimoteEmu::ReportFeatures, int);
void SetInputManip(ManipFunction); void SetGCInputManip(GCManipFunction);
void CallInputManip(GCPadStatus* PadStatus, int controllerID); void SetWiiInputManip(WiiManipFunction);
void CallGCInputManip(GCPadStatus* PadStatus, int controllerID);
void CallWiiInputManip(u8* core, WiimoteEmu::ReportFeatures rptf, int controllerID);
} }

View File

@ -398,12 +398,11 @@ CFrame::CFrame(wxFrame* parent,
m_LogWindow->Hide(); m_LogWindow->Hide();
m_LogWindow->Disable(); m_LogWindow->Disable();
g_TASInputDlg[0] = new TASInputDlg(this); for (int i = 0; i < 8; ++i)
g_TASInputDlg[1] = new TASInputDlg(this); g_TASInputDlg[i] = new TASInputDlg(this);
g_TASInputDlg[2] = new TASInputDlg(this);
g_TASInputDlg[3] = new TASInputDlg(this);
Movie::SetInputManip(TASManipFunction); Movie::SetGCInputManip(GCTASManipFunction);
Movie::SetWiiInputManip(WiiTASManipFunction);
State::SetOnAfterLoadCallback(OnAfterLoadCallback); State::SetOnAfterLoadCallback(OnAfterLoadCallback);
Core::SetOnStoppedCallback(OnStoppedCallback); Core::SetOnStoppedCallback(OnStoppedCallback);
@ -974,15 +973,21 @@ void OnStoppedCallback()
} }
} }
void TASManipFunction(GCPadStatus* PadStatus, int controllerID) void GCTASManipFunction(GCPadStatus* PadStatus, int controllerID)
{ {
if (main_frame) if (main_frame)
main_frame->g_TASInputDlg[controllerID]->GetValues(PadStatus, controllerID); main_frame->g_TASInputDlg[controllerID]->GetValues(PadStatus);
}
void WiiTASManipFunction(u8* data, WiimoteEmu::ReportFeatures rptf, int controllerID)
{
if (main_frame)
main_frame->g_TASInputDlg[controllerID + 4]->GetValues(data, rptf);
} }
bool TASInputHasFocus() bool TASInputHasFocus()
{ {
for (int i = 0; i < 4; i++) for (int i = 0; i < 8; ++i)
{ {
if (main_frame->g_TASInputDlg[i]->TASHasFocus()) if (main_frame->g_TASInputDlg[i]->TASHasFocus())
return true; return true;

View File

@ -23,6 +23,7 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Event.h" #include "Common/Event.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
#include "DolphinWX/Globals.h" #include "DolphinWX/Globals.h"
#include "InputCommon/GCPadStatus.h" #include "InputCommon/GCPadStatus.h"
@ -98,7 +99,7 @@ public:
CCodeWindow* g_pCodeWindow; CCodeWindow* g_pCodeWindow;
NetPlaySetupDiag* g_NetPlaySetupDiag; NetPlaySetupDiag* g_NetPlaySetupDiag;
wxCheatsWindow* g_CheatsWindow; wxCheatsWindow* g_CheatsWindow;
TASInputDlg* g_TASInputDlg[4]; TASInputDlg* g_TASInputDlg[8];
void InitBitmaps(); void InitBitmaps();
void DoPause(); void DoPause();
@ -346,6 +347,7 @@ void OnAfterLoadCallback();
void OnStoppedCallback(); void OnStoppedCallback();
// For TASInputDlg // For TASInputDlg
void TASManipFunction(GCPadStatus* PadStatus, int controllerID); void GCTASManipFunction(GCPadStatus* PadStatus, int controllerID);
void WiiTASManipFunction(u8* data, WiimoteEmu::ReportFeatures rptf, int controllerID);
bool TASInputHasFocus(); bool TASInputHasFocus();
extern int g_saveSlot; extern int g_saveSlot;

View File

@ -699,11 +699,18 @@ void CFrame::OnTASInput(wxCommandEvent& event)
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
{ {
if (SConfig::GetInstance().m_SIDevice[i] == SIDEVICE_GC_CONTROLLER || SConfig::GetInstance().m_SIDevice[i] == SIDEVICE_GC_TARUKONGA) if (SConfig::GetInstance().m_SIDevice[i] != SIDEVICE_NONE && SConfig::GetInstance().m_SIDevice[i] != SIDEVICE_GC_GBA)
{ {
g_TASInputDlg[i]->CreateGCLayout();
g_TASInputDlg[i]->Show(true); g_TASInputDlg[i]->Show(true);
g_TASInputDlg[i]->SetTitle("TAS Input - Controller " + number[i]); g_TASInputDlg[i]->SetTitle("TAS Input - Controller " + number[i]);
} }
if (g_wiimote_sources[i] == WIIMOTE_SRC_EMU && !(Core::IsRunning() && !SConfig::GetInstance().m_LocalCoreStartupParameter.bWii))
{
g_TASInputDlg[i+4]->CreateWiiLayout();
g_TASInputDlg[i+4]->Show(true);
g_TASInputDlg[i+4]->SetTitle("TAS Input - Wiimote " + number[i]);
}
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -9,12 +9,14 @@
#include <wx/dialog.h> #include <wx/dialog.h>
#include <wx/event.h> #include <wx/event.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
#include <wx/sizer.h>
#include <wx/string.h> #include <wx/string.h>
#include <wx/toplevel.h> #include <wx/toplevel.h>
#include <wx/translation.h> #include <wx/translation.h>
#include <wx/windowid.h> #include <wx/windowid.h>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
#include "InputCommon/GCPadStatus.h" #include "InputCommon/GCPadStatus.h"
class wxCheckBox; class wxCheckBox;
@ -27,72 +29,89 @@ class TASInputDlg : public wxDialog
{ {
public: public:
TASInputDlg(wxWindow* parent, TASInputDlg(wxWindow* parent,
wxWindowID id = 1, wxWindowID id = 1,
const wxString& title = _("TAS Input"), const wxString& title = _("TAS Input"),
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP); long style = wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP);
void OnCloseWindow(wxCloseEvent& event); void OnCloseWindow(wxCloseEvent& event);
void UpdateFromSliders(wxCommandEvent& event); void UpdateFromSliders(wxCommandEvent& event);
void UpdateFromText(wxCommandEvent& event); void UpdateFromText(wxCommandEvent& event);
void OnMouseDownL(wxMouseEvent& event); void OnMouseDownL(wxMouseEvent& event);
void OnMouseUpR(wxMouseEvent& event); void OnMouseUpR(wxMouseEvent& event);
void OnRightClickSlider(wxMouseEvent& event);
void ResetValues(); void ResetValues();
void GetValues(GCPadStatus* PadStatus, int controllerID); void GetValues(GCPadStatus* PadStatus);
void GetValues(u8* data, WiimoteEmu::ReportFeatures rptf);
void SetTurbo(wxMouseEvent& event); void SetTurbo(wxMouseEvent& event);
void SetTurboFalse(wxMouseEvent& event); void SetTurboFalse(wxMouseEvent& event);
void SetTurboState(wxCheckBox* CheckBox, bool* TurboOn);
void ButtonTurbo(); void ButtonTurbo();
void GetKeyBoardInput(GCPadStatus* PadStatus); void GetKeyBoardInput(GCPadStatus* PadStatus);
void GetKeyBoardInput(u8* data, WiimoteEmu::ReportFeatures rptf);
bool TextBoxHasFocus(); bool TextBoxHasFocus();
void SetLandRTriggers(); void SetLandRTriggers();
bool TASHasFocus(); bool TASHasFocus();
void CreateGCLayout();
void CreateWiiLayout();
wxBitmap CreateStickBitmap(int x, int y); wxBitmap CreateStickBitmap(int x, int y);
void SetWiiButtons(wm_core* butt);
void GetIRData(u8* const data, u8 mode, bool use_accel);
private: private:
u8 mainX, mainY, cX, cY, lTrig, rTrig; const int ID_C_STICK = 1001;
const int ID_MAIN_STICK = 1002;
int eleID = 1003;
enum struct Control
{ {
ID_MAIN_X_SLIDER = 1000, wxTextCtrl* Text;
ID_MAIN_X_TEXT, wxSlider* Slider;
ID_MAIN_Y_SLIDER, int value = -1;
ID_MAIN_Y_TEXT, int Text_ID;
ID_C_X_SLIDER, int Slider_ID;
ID_C_X_TEXT, u32 range;
ID_C_Y_SLIDER, u32 defaultValue = 128;
ID_C_Y_TEXT, bool SetByKeyboard = false;
ID_L_SLIDER,
ID_L_TEXT,
ID_R_SLIDER,
ID_R_TEXT,
ID_CLOSE,
ID_UP,
ID_DOWN,
ID_LEFT,
ID_RIGHT,
ID_A,
ID_B,
ID_X,
ID_Y,
ID_Z,
ID_L,
ID_R,
ID_START,
ID_MAIN_STICK,
ID_C_STICK,
}; };
wxSlider *wx_mainX_s, *wx_mainY_s, *wx_cX_s, *wx_cY_s, *wx_l_s, *wx_r_s; struct Button
wxCheckBox *wx_up_button, *wx_down_button, *wx_left_button, *wx_right_button, *wx_a_button, *wx_b_button, *wx_x_button, *wx_y_button, *wx_l_button, *wx_r_button, *wx_z_button, *wx_start_button; {
wxTextCtrl *wx_mainX_t, *wx_mainY_t, *wx_cX_t, *wx_cY_t, *wx_l_t, *wx_r_t; wxCheckBox* Checkbox;
wxMemoryDC dc_main, dc_c; bool SetByKeyboard = false;
wxStaticBitmap *static_bitmap_main, *static_bitmap_c; bool TurboOn = false;
wxBitmap bitmap; int ID;
bool A_turbo,B_turbo, X_turbo, Y_turbo, Z_turbo, L_turbo, R_turbo, START_turbo,DL_turbo,DR_turbo,DD_turbo,DU_turbo; };
bool A_cont,B_cont, X_cont, Y_cont, Z_cont, L_cont, L_button_cont, R_cont, R_button_cont, START_cont,DL_cont,DR_cont,DD_cont,DU_cont,mstickx,msticky,cstickx,csticky;
int xaxis,yaxis,c_xaxis,c_yaxis,update,update_axis; struct Stick
{
wxStaticBitmap* bitmap;
Control xCont;
Control yCont;
};
void SetStickValue(bool* ActivatedByKeyboard, int* AmountPressed, wxTextCtrl* Textbox, int CurrentValue, int center = 128);
void SetButtonValue(Button* button, bool CurrentState);
void SetSliderValue(Control* control, int CurrentValue, int defaultValue = 128);
Stick CreateStick(int id_stick);
wxStaticBoxSizer* CreateStickLayout(Stick* tempStick, std::string title);
Button CreateButton(const std::string& name);
Control CreateControl(long style, int width, int height, u32 range = 255);
Control lCont, rCont, xCont, yCont, zCont;
Button A, B, X, Y, Z, L, R, C, START, PLUS, MINUS, ONE, TWO, HOME, dpad_up, dpad_down, dpad_left, dpad_right;
Stick MainStick, CStick;
Button* Buttons[14];
Control* Controls[10];
static const int GCPadButtonsBitmask[12];
static const int WiiButtonsBitmask[13];
bool hasLayout = false;
bool isWii = false;
wxGridSizer* const buttons_dpad = new wxGridSizer(3);
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
}; };