summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorayuanx <ayuanx@gmail.com>2009-12-17 14:15:56 +0000
committerayuanx <ayuanx@gmail.com>2009-12-17 14:15:56 +0000
commit7d1fdb85f3788a61fa8491a4b2e31a2ef3ea2096 (patch)
tree4615bd8e00e1caf04f73c44ff742c8d8f89e202e /Source
parentb0ef8117869aa1c96d8957c0235c6350fe912407 (diff)
Implemented Nunchuck Roll/Pitch
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4702 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/InputCommon/Src/SDL.h4
-rw-r--r--Source/Plugins/Plugin_Wiimote/Src/Config.cpp26
-rw-r--r--Source/Plugins/Plugin_Wiimote/Src/Config.h5
-rw-r--r--Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp3
-rw-r--r--Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp108
-rw-r--r--Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h11
-rw-r--r--Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.cpp7
-rw-r--r--Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.h29
-rw-r--r--Source/Plugins/Plugin_Wiimote/Src/EmuDynamics.cpp17
-rw-r--r--Source/Plugins/Plugin_Wiimote/Src/EmuMain.h5
-rw-r--r--Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp298
11 files changed, 346 insertions, 167 deletions
diff --git a/Source/Core/InputCommon/Src/SDL.h b/Source/Core/InputCommon/Src/SDL.h
index 619027dcda..048c736075 100644
--- a/Source/Core/InputCommon/Src/SDL.h
+++ b/Source/Core/InputCommon/Src/SDL.h
@@ -191,8 +191,8 @@ struct PadWiimote
};
struct PadNunchuck
{
- int keyForControls[7];
- // Order is Z, C, L, R, U, D, Shake
+ int keyForControls[11];
+ // Order is Z, C, L, R, U, D, RollL, RollR, PitchU, PitchD, Shake
};
struct PadClassicController
{
diff --git a/Source/Plugins/Plugin_Wiimote/Src/Config.cpp b/Source/Plugins/Plugin_Wiimote/Src/Config.cpp
index 4b09fa74b8..4d1c1ab06f 100644
--- a/Source/Plugins/Plugin_Wiimote/Src/Config.cpp
+++ b/Source/Plugins/Plugin_Wiimote/Src/Config.cpp
@@ -100,6 +100,10 @@ static const char* ncControlNames[] =
"NcR",
"NcU",
"NcD",
+ "NcRollL",
+ "NcRollR",
+ "NcPitchU",
+ "NcPitchD",
"NcShake",
};
static int nCDefaultControls[] =
@@ -111,7 +115,11 @@ static int nCDefaultControls[] =
VK_NUMPAD6,
VK_NUMPAD8,
VK_NUMPAD5,
- VK_ADD
+ VK_NUMPAD7,
+ VK_NUMPAD9,
+ VK_NUMPAD1,
+ VK_NUMPAD3,
+ VK_NUMPAD2
#elif defined(HAVE_X11) && HAVE_X11
XK_KP_0,
XK_KP_Decimal,
@@ -119,9 +127,13 @@ static int nCDefaultControls[] =
XK_KP_6,
XK_KP_8,
XK_KP_5,
- XK_KP_Add
+ XK_KP_7,
+ XK_KP_9,
+ XK_KP_1,
+ XK_KP_3,
+ XK_KP_2
#else
- 0,0,0,0,0,0,0
+ 0,0,0,0,0,0,0,0,0,0,0
#endif
};
@@ -288,7 +300,8 @@ void Config::Load(bool ChangePad)
sprintf(SectionName, "Wiimote%i", i + 1);
iniFile.Get(SectionName, "NoTriggerFilter", &bNoTriggerFilter, false);
- iniFile.Get(SectionName, "TiltType", &Tilt.Type, Tilt.KEYBOARD);
+ iniFile.Get(SectionName, "TiltTypeWM", &Tilt.TypeWM, Tilt.KEYBOARD);
+ iniFile.Get(SectionName, "TiltTypeNC", &Tilt.TypeNC, Tilt.KEYBOARD);
iniFile.Get(SectionName, "TiltRollSwing", &Tilt.Range.RollSwing, false);
iniFile.Get(SectionName, "TiltRollDegree", &Tilt.Range.RollDegree, 60);
Tilt.Range.Roll = (Tilt.Range.RollSwing) ? 0 : Tilt.Range.RollDegree;
@@ -375,7 +388,7 @@ void Config::Save(int Slot)
{
IniFile iniFile;
iniFile.Load(FULL_CONFIG_DIR "Wiimote.ini");
-// iniFile.Set("Settings", "InputActive", bInputActive);
+ iniFile.Set("Settings", "InputActive", bInputActive);
iniFile.Set("Settings", "Sideways", bSideways);
iniFile.Set("Settings", "Upright", bUpright);
iniFile.Set("Settings", "MotionPlusConnected", bMotionPlusConnected);
@@ -398,7 +411,8 @@ void Config::Save(int Slot)
sprintf(SectionName, "Wiimote%i", i + 1);
iniFile.Set(SectionName, "NoTriggerFilter", bNoTriggerFilter);
- iniFile.Set(SectionName, "TiltType", Tilt.Type);;
+ iniFile.Set(SectionName, "TiltTypeWM", Tilt.TypeWM);
+ iniFile.Set(SectionName, "TiltTypeNC", Tilt.TypeNC);
iniFile.Set(SectionName, "TiltRollDegree", Tilt.Range.RollDegree);
iniFile.Set(SectionName, "TiltRollSwing", Tilt.Range.RollSwing);
iniFile.Set(SectionName, "TiltRollInvert", Tilt.RollInvert);
diff --git a/Source/Plugins/Plugin_Wiimote/Src/Config.h b/Source/Plugins/Plugin_Wiimote/Src/Config.h
index 38ec9b15c1..8558533091 100644
--- a/Source/Plugins/Plugin_Wiimote/Src/Config.h
+++ b/Source/Plugins/Plugin_Wiimote/Src/Config.h
@@ -24,7 +24,7 @@
#define AN_CONTROLS 6
#define WM_CONTROLS 16
-#define NC_CONTROLS 7
+#define NC_CONTROLS 11
#define CC_CONTROLS 23
#define GH3_CONTROLS 14
@@ -61,7 +61,8 @@ struct Config
ANALOG2,
TRIGGER
};
- int Type;
+ int TypeWM;
+ int TypeNC;
bool RollInvert;
bool PitchInvert;
TiltRange Range;
diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp
index eb527b4983..0cbfec8767 100644
--- a/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp
+++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp
@@ -132,7 +132,8 @@ void WiimotePadConfigDialog::UpdateGUIButtonMapping(int controller)
m_RumbleStrength[controller]->SetSelection(WiiMoteEmu::PadMapping[controller].RumbleStrength);
m_TriggerType[controller]->SetSelection(WiiMoteEmu::PadMapping[controller].triggertype);
- m_TiltComboInput[controller]->SetSelection(g_Config.Tilt.Type);
+ m_TiltTypeWM[controller]->SetSelection(g_Config.Tilt.TypeWM);
+ m_TiltTypeNC[controller]->SetSelection(g_Config.Tilt.TypeNC);
m_TiltComboRangeRoll[controller]->SetSelection(g_Config.Tilt.Range.RollDegree / 5 - 1); // 5 to 180, step 5
m_TiltComboRangePitch[controller]->SetSelection(g_Config.Tilt.Range.PitchDegree / 5 - 1); // 5 to 180, step 5
m_TiltRollSwing[controller]->SetValue(g_Config.Tilt.Range.RollSwing);
diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp
index b4c1f349d1..79fcb7d2bb 100644
--- a/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp
+++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp
@@ -45,7 +45,8 @@ BEGIN_EVENT_TABLE(WiimotePadConfigDialog,wxDialog)
EVT_COMBOBOX(IDC_DEAD_ZONE_RIGHT, WiimotePadConfigDialog::GeneralSettingsChanged)
EVT_COMBOBOX(IDC_STICK_DIAGONAL, WiimotePadConfigDialog::GeneralSettingsChanged)
EVT_CHECKBOX(IDC_STICK_C2S, WiimotePadConfigDialog::GeneralSettingsChanged)
- EVT_COMBOBOX(IDC_TILT_INPUT, WiimotePadConfigDialog::GeneralSettingsChanged)
+ EVT_COMBOBOX(IDC_TILT_TYPE_WM, WiimotePadConfigDialog::GeneralSettingsChanged)
+ EVT_COMBOBOX(IDC_TILT_TYPE_NC, WiimotePadConfigDialog::GeneralSettingsChanged)
EVT_COMBOBOX(IDC_TILT_ROLL, WiimotePadConfigDialog::GeneralSettingsChanged)
EVT_CHECKBOX(IDC_TILT_ROLL_SWING, WiimotePadConfigDialog::GeneralSettingsChanged)
EVT_COMBOBOX(IDC_TILT_PITCH, WiimotePadConfigDialog::GeneralSettingsChanged)
@@ -79,6 +80,8 @@ BEGIN_EVENT_TABLE(WiimotePadConfigDialog,wxDialog)
EVT_BUTTON(IDB_NC_Z, WiimotePadConfigDialog::OnButtonClick) EVT_BUTTON(IDB_NC_C, WiimotePadConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_NC_L, WiimotePadConfigDialog::OnButtonClick) EVT_BUTTON(IDB_NC_R, WiimotePadConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_NC_U, WiimotePadConfigDialog::OnButtonClick) EVT_BUTTON(IDB_NC_D, WiimotePadConfigDialog::OnButtonClick)
+ EVT_BUTTON(IDB_NC_ROLL_L, WiimotePadConfigDialog::OnButtonClick) EVT_BUTTON(IDB_NC_ROLL_R, WiimotePadConfigDialog::OnButtonClick)
+ EVT_BUTTON(IDB_NC_PITCH_U, WiimotePadConfigDialog::OnButtonClick) EVT_BUTTON(IDB_NC_PITCH_D, WiimotePadConfigDialog::OnButtonClick)
EVT_BUTTON(IDB_NC_SHAKE, WiimotePadConfigDialog::OnButtonClick)
// Classic Controller
@@ -445,6 +448,10 @@ void WiimotePadConfigDialog::CreatePadGUIControls()
wxT("Right"),
wxT("Up"),
wxT("Down"),
+ wxT("Roll Left"),
+ wxT("Roll Right"),
+ wxT("Pitch Up"),
+ wxT("Pitch Down"),
wxT("Shake"),
};
@@ -567,42 +574,55 @@ void WiimotePadConfigDialog::CreatePadGUIControls()
m_gJoyPad[i]->AddStretchSpacer();
// Tilt Wiimote
- m_TiltComboInput[i] = new wxComboBox(m_Controller[i], IDC_TILT_INPUT, StrTilt[0], wxDefaultPosition, wxSize(80, -1), StrTilt, wxCB_READONLY);
- m_TiltComboInput[i]->SetSelection(g_Config.Tilt.Type);
- m_TiltComboInput[i]->SetToolTip(wxT("Control tilting by keyboard or analog stick or trigger"));
+ m_tTiltTypeWM[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Wiimote"));
+ m_tTiltTypeNC[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Nunchuck"));
+
+ m_TiltTypeWM[i] = new wxComboBox(m_Controller[i], IDC_TILT_TYPE_WM, StrTilt[0], wxDefaultPosition, wxSize(70, -1), StrTilt, wxCB_READONLY);
+ m_TiltTypeWM[i]->SetSelection(g_Config.Tilt.TypeWM);
+ m_TiltTypeWM[i]->SetToolTip(wxT("Control Wiimote tilting by keyboard or stick or trigger"));
+
+ m_TiltTypeNC[i] = new wxComboBox(m_Controller[i], IDC_TILT_TYPE_NC, StrTilt[0], wxDefaultPosition, wxSize(70, -1), StrTilt, wxCB_READONLY);
+ m_TiltTypeNC[i]->SetSelection(g_Config.Tilt.TypeNC);
+ m_TiltTypeNC[i]->SetToolTip(wxT("Control Nunchuck tilting by keyboard or stick or trigger"));
- m_TiltTextRoll[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Roll L/R"));
- m_TiltTextPitch[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Pitch U/D"));
+ m_TiltTextRoll[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Roll Left/Right"));
+ m_TiltTextPitch[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Pitch Up/Down"));
- m_TiltComboRangeRoll[i] = new wxComboBox(m_Controller[i], IDC_TILT_ROLL, StrTiltRangeRoll[0], wxDefaultPosition, wxSize(40, -1), StrTiltRangeRoll, wxCB_READONLY);
+ m_TiltComboRangeRoll[i] = new wxComboBox(m_Controller[i], IDC_TILT_ROLL, StrTiltRangeRoll[0], wxDefaultPosition, wxSize(50, -1), StrTiltRangeRoll, wxCB_READONLY);
m_TiltComboRangeRoll[i]->SetValue(wxString::Format(wxT("%i"), g_Config.Tilt.Range.Roll));
m_TiltComboRangeRoll[i]->SetToolTip(wxT("The maximum Left/Righ Roll in degrees"));
- m_TiltComboRangePitch[i] = new wxComboBox(m_Controller[i], IDC_TILT_PITCH, StrTiltRangePitch[0], wxDefaultPosition, wxSize(40, -1), StrTiltRangePitch, wxCB_READONLY);
+ m_TiltComboRangePitch[i] = new wxComboBox(m_Controller[i], IDC_TILT_PITCH, StrTiltRangePitch[0], wxDefaultPosition, wxSize(50, -1), StrTiltRangePitch, wxCB_READONLY);
m_TiltComboRangePitch[i]->SetValue(wxString::Format(wxT("%i"), g_Config.Tilt.Range.Pitch));
m_TiltComboRangePitch[i]->SetToolTip(wxT("The maximum Up/Down Pitch in degrees"));
m_TiltRollSwing[i] = new wxCheckBox(m_Controller[i], IDC_TILT_ROLL_SWING, wxT("Swing"));
- m_TiltRollSwing[i]->SetToolTip(wxT("Emulate Left/Right Swing instead of Left/Right Roll"));
+ m_TiltRollSwing[i]->SetToolTip(wxT("Emulate Swing Left/Right instead of Roll Left/Right"));
m_TiltPitchSwing[i] = new wxCheckBox(m_Controller[i], IDC_TILT_PITCH_SWING, wxT("Swing"));
- m_TiltPitchSwing[i]->SetToolTip(wxT("Emulate Up/Down Swing instead of Up/Down Pitch"));
+ m_TiltPitchSwing[i]->SetToolTip(wxT("Emulate Swing Up/Down instead of Pitch Up/Down"));
m_TiltRollInvert[i] = new wxCheckBox(m_Controller[i], IDC_TILT_ROLL_INVERT, wxT("Invert"));
- m_TiltRollInvert[i]->SetToolTip(wxT("Invert Left/Right direction"));
+ m_TiltRollInvert[i]->SetToolTip(wxT("Invert Left/Right direction (only effective for stick and trigger)"));
m_TiltPitchInvert[i] = new wxCheckBox(m_Controller[i], IDC_TILT_PITCH_INVERT, wxT("Invert"));
- m_TiltPitchInvert[i]->SetToolTip(wxT("Invert Up/Down direction"));
+ m_TiltPitchInvert[i]->SetToolTip(wxT("Invert Up/Down direction (only effective for stick and trigger)"));
// Sizers
+ m_sTiltType[i] = new wxBoxSizer(wxHORIZONTAL);
+ m_sTiltType[i]->Add(m_tTiltTypeWM[i], 0, wxEXPAND | (wxUP | wxDOWN | wxRIGHT), 4);
+ m_sTiltType[i]->Add(m_TiltTypeWM[i], 0, wxEXPAND | (wxDOWN | wxRIGHT), 4);
+ m_sTiltType[i]->Add(m_tTiltTypeNC[i], 0, wxEXPAND | (wxUP | wxDOWN | wxLEFT), 4);
+ m_sTiltType[i]->Add(m_TiltTypeNC[i], 0, wxEXPAND | (wxDOWN | wxLEFT), 4);
+
m_sGridTilt[i] = new wxGridBagSizer(0, 0);
- m_sGridTilt[i]->Add(m_TiltTextRoll[i], wxGBPosition(0, 0), wxGBSpan(1, 1), (wxTOP), 4);
- m_sGridTilt[i]->Add(m_TiltRollInvert[i], wxGBPosition(1, 0), wxGBSpan(1, 1), (wxTOP), 4);
+ m_sGridTilt[i]->Add(m_TiltTextRoll[i], wxGBPosition(0, 0), wxGBSpan(1, 1), (wxUP | wxRIGHT), 4);
m_sGridTilt[i]->Add(m_TiltComboRangeRoll[i], wxGBPosition(0, 1), wxGBSpan(1, 1), (wxLEFT | wxRIGHT), 4);
- m_sGridTilt[i]->Add(m_TiltRollSwing[i], wxGBPosition(1, 1), wxGBSpan(1, 1), (wxTOP | wxLEFT | wxRIGHT), 4);
- m_sGridTilt[i]->Add(m_TiltTextPitch[i], wxGBPosition(0, 2), wxGBSpan(1, 1), (wxLEFT | wxTOP), 4);
- m_sGridTilt[i]->Add(m_TiltPitchInvert[i], wxGBPosition(1, 2), wxGBSpan(1, 1), (wxLEFT | wxTOP), 4);
- m_sGridTilt[i]->Add(m_TiltComboRangePitch[i], wxGBPosition(0, 3), wxGBSpan(1, 1), (wxLEFT), 4);
- m_sGridTilt[i]->Add(m_TiltPitchSwing[i], wxGBPosition(1, 3), wxGBSpan(1, 1), (wxLEFT | wxTOP), 4);
+ m_sGridTilt[i]->Add(m_TiltRollSwing[i], wxGBPosition(0, 2), wxGBSpan(1, 1), (wxUP | wxLEFT | wxRIGHT), 4);
+ m_sGridTilt[i]->Add(m_TiltRollInvert[i], wxGBPosition(0, 3), wxGBSpan(1, 1), (wxUP | wxLEFT), 4);
+ m_sGridTilt[i]->Add(m_TiltTextPitch[i], wxGBPosition(1, 0), wxGBSpan(1, 1), (wxUP | wxRIGHT), 4);
+ m_sGridTilt[i]->Add(m_TiltComboRangePitch[i], wxGBPosition(1, 1), wxGBSpan(1, 1), (wxLEFT | wxRIGHT), 4);
+ m_sGridTilt[i]->Add(m_TiltPitchSwing[i], wxGBPosition(1, 2), wxGBSpan(1, 1), (wxUP | wxLEFT | wxRIGHT), 4);
+ m_sGridTilt[i]->Add(m_TiltPitchInvert[i], wxGBPosition(1, 3), wxGBSpan(1, 1), (wxUP | wxLEFT), 4);
m_gTilt[i] = new wxStaticBoxSizer (wxVERTICAL, m_Controller[i], wxT("Tilt and Swing"));
m_gTilt[i]->AddStretchSpacer();
- m_gTilt[i]->Add(m_TiltComboInput[i], 0, wxEXPAND | (wxLEFT | wxRIGHT | wxDOWN), 5);
+ m_gTilt[i]->Add(m_sTiltType[i], 0, wxEXPAND | (wxLEFT | wxDOWN), 5);
m_gTilt[i]->Add(m_sGridTilt[i], 0, wxEXPAND | (wxLEFT), 5);
m_gTilt[i]->AddStretchSpacer();
@@ -735,9 +755,8 @@ void WiimotePadConfigDialog::CreatePadGUIControls()
}
m_gWiimote[i] = new wxStaticBoxSizer (wxHORIZONTAL, m_Controller[i], wxT("Wiimote"));
- m_gWiimote[i]->Add(m_sWmVertLeft[i], 0, wxALIGN_RIGHT | (wxALL), 0);
- m_gWiimote[i]->Add(m_sWmVertRight[i], 0, wxALIGN_RIGHT | (wxLEFT), 5);
- m_gWiimote[i]->AddSpacer(1);
+ m_gWiimote[i]->Add(m_sWmVertLeft[i], 0, (wxLEFT | wxRIGHT | wxDOWN), 1);
+ m_gWiimote[i]->Add(m_sWmVertRight[i], 0, (wxLEFT | wxRIGHT | wxDOWN), 1);
// Extension Mapping
if(g_Config.iExtensionConnected == EXT_NUNCHUCK)
@@ -746,14 +765,6 @@ void WiimotePadConfigDialog::CreatePadGUIControls()
m_NunchuckTextStick[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Stick"));
m_NunchuckComboStick[i] = new wxComboBox(m_Controller[i], IDC_NUNCHUCK_STICK, StrNunchuck[0], wxDefaultPosition, wxSize(70, -1), StrNunchuck, wxCB_READONLY);
m_NunchuckComboStick[i]->SetSelection(g_Config.Nunchuck.Type);
-
- m_sNunchuckStick[i] = new wxBoxSizer(wxHORIZONTAL);
- m_sNunchuckStick[i]->Add(m_NunchuckTextStick[i], 0, (wxUP), 4);
- m_sNunchuckStick[i]->Add(m_NunchuckComboStick[i], 0, (wxLEFT), 2);
-
- m_gNunchuck[i] = new wxStaticBoxSizer (wxVERTICAL, m_Controller[i], wxT("Nunchuck"));
- m_gNunchuck[i]->Add(m_sNunchuckStick[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 2);
- m_gNunchuck[i]->AddSpacer(2);
for (int x = 0; x < NC_CONTROLS; x++)
{
@@ -761,10 +772,30 @@ void WiimotePadConfigDialog::CreatePadGUIControls()
m_Button_NunChuck[x][i] = new wxButton(m_Controller[i], x + IDB_NC_Z, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH));
m_Button_NunChuck[x][i]->SetFont(m_SmallFont);
m_Sizer_NunChuck[x][i] = new wxBoxSizer(wxHORIZONTAL);
- m_Sizer_NunChuck[x][i]->Add(m_statictext_NunChuck[x][i], 0, wxALIGN_RIGHT | (wxUP), 4);
- m_Sizer_NunChuck[x][i]->Add(m_Button_NunChuck[x][i], 0, wxALIGN_RIGHT | (wxLEFT), 2);
- m_gNunchuck[i]->Add(m_Sizer_NunChuck[x][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
+ m_Sizer_NunChuck[x][i]->Add(m_statictext_NunChuck[x][i], 0, (wxUP), 4);
+ m_Sizer_NunChuck[x][i]->Add(m_Button_NunChuck[x][i], 0, (wxLEFT), 2);
}
+
+ // Sizers
+ m_sNunchuckStick[i] = new wxBoxSizer(wxHORIZONTAL);
+ m_sNunchuckStick[i]->Add(m_NunchuckTextStick[i], 0, (wxUP), 4);
+ m_sNunchuckStick[i]->Add(m_NunchuckComboStick[i], 0, (wxLEFT), 2);
+
+ m_sNCVertLeft[i] = new wxBoxSizer(wxVERTICAL);
+ m_sNCVertRight[i] = new wxBoxSizer(wxVERTICAL);
+ m_sNCVertRight[i]->Add(m_sNunchuckStick[i], 0, wxALIGN_RIGHT | (wxALL), 2);
+ m_sNCVertRight[i]->AddSpacer(2);
+
+ for (int x = IDB_NC_Z; x <= IDB_NC_SHAKE; x++)
+ if (x < IDB_NC_ROLL_L) // Make some balance
+ m_sNCVertLeft[i]->Add(m_Sizer_NunChuck[x - IDB_NC_Z][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
+ else
+ m_sNCVertRight[i]->Add(m_Sizer_NunChuck[x - IDB_NC_Z][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
+
+ m_gNunchuck[i] = new wxStaticBoxSizer (wxHORIZONTAL, m_Controller[i], wxT("Nunchuck"));
+ m_gNunchuck[i]->Add(m_sNCVertLeft[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
+ m_gNunchuck[i]->Add(m_sNCVertRight[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1);
+
}
else if(g_Config.iExtensionConnected == EXT_CLASSIC_CONTROLLER)
{
@@ -834,7 +865,7 @@ void WiimotePadConfigDialog::CreatePadGUIControls()
else if(g_Config.iExtensionConnected == EXT_GUITARHERO3_CONTROLLER)
{
// Stick controls
- m_tGH3Analog[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Joystick"));
+ m_tGH3Analog[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Stick"));
m_GH3ComboAnalog[i] = new wxComboBox(m_Controller[i], IDC_GH3_ANALOG, StrAnalogArray[0], wxDefaultPosition, wxSize(70, -1), StrAnalogArray, wxCB_READONLY);
m_GH3ComboAnalog[i]->SetSelection(g_Config.GH3Controller.AType);
@@ -938,8 +969,11 @@ void WiimotePadConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
case IDC_JOYNAME:
DoChangeJoystick();
break;
- case IDC_TILT_INPUT:
- g_Config.Tilt.Type = m_TiltComboInput[Page]->GetSelection();
+ case IDC_TILT_TYPE_WM:
+ g_Config.Tilt.TypeWM = m_TiltTypeWM[Page]->GetSelection();
+ break;
+ case IDC_TILT_TYPE_NC:
+ g_Config.Tilt.TypeNC = m_TiltTypeNC[Page]->GetSelection();
break;
case IDC_TILT_ROLL:
case IDC_TILT_ROLL_SWING:
diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h b/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h
index 24c9d3dd7c..c84386ec63 100644
--- a/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h
+++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h
@@ -112,7 +112,8 @@ class WiimotePadConfigDialog : public wxDialog
*m_ComboDeadZoneRight[4],
*m_ComboDiagonal[4],
*m_RumbleStrength[4],
- *m_TiltComboInput[4],
+ *m_TiltTypeWM[4],
+ *m_TiltTypeNC[4],
*m_TiltComboRangeRoll[4],
*m_TiltComboRangePitch[4],
*m_TriggerType[4],
@@ -136,6 +137,7 @@ class WiimotePadConfigDialog : public wxDialog
*m_sC2SDeadZone[4],
*m_sJoyname[4],
*m_sRumble[4],
+ *m_sTiltType[4],
*m_sHorizController[4],
*m_sHorizStatus[4],
*m_Sizer_Analog[AN_CONTROLS][4],
@@ -148,6 +150,8 @@ class WiimotePadConfigDialog : public wxDialog
*m_sWmVertRight[4],
*m_Sizer_NunChuck[NC_CONTROLS][4],
*m_sNunchuckStick[4],
+ *m_sNCVertLeft[4],
+ *m_sNCVertRight[4],
*m_Sizer_Classic[CC_CONTROLS][4],
*m_sCcLeftStick[4],
*m_sCcRightStick[4],
@@ -175,6 +179,7 @@ class WiimotePadConfigDialog : public wxDialog
wxStaticText *m_ComboDeadZoneLabel[4],
*m_DiagonalLabel[4],
*m_RumbleStrengthLabel[4],
+ *m_tTiltTypeWM[4], *m_tTiltTypeNC[4],
*m_TiltTextRoll[4], *m_TiltTextPitch[4],
*m_tStatusLeftIn[4], *m_tStatusLeftOut[4], *m_tStatusRightIn[4], *m_tStatusRightOut[4],
*m_TriggerL[4], *m_TriggerR[4],
@@ -225,6 +230,8 @@ class WiimotePadConfigDialog : public wxDialog
IDB_NC_R,
IDB_NC_U,
IDB_NC_D,
+ IDB_NC_ROLL_L, IDB_NC_ROLL_R,
+ IDB_NC_PITCH_U, IDB_NC_PITCH_D,
IDB_NC_SHAKE,
// Classic Controller
@@ -257,7 +264,7 @@ class WiimotePadConfigDialog : public wxDialog
IDC_RUMBLE, IDC_RUMBLE_STRENGTH,
IDC_DEAD_ZONE_LEFT, IDC_DEAD_ZONE_RIGHT,
IDC_STICK_DIAGONAL, IDC_STICK_C2S,
- IDC_TILT_INPUT,
+ IDC_TILT_TYPE_WM, IDC_TILT_TYPE_NC,
IDC_TILT_ROLL, IDC_TILT_ROLL_SWING,
IDC_TILT_PITCH, IDC_TILT_PITCH_SWING,
IDC_TILT_ROLL_INVERT, IDC_TILT_PITCH_INVERT,
diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.cpp
index 5a7e1a9df5..3aa4e294fb 100644
--- a/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.cpp
+++ b/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.cpp
@@ -63,13 +63,6 @@ std::vector<InputCommon::CONTROLLER_INFO> joyinfo;
InputCommon::CONTROLLER_STATE_NEW PadState[4];
InputCommon::CONTROLLER_MAPPING_NEW PadMapping[4];
-// Shake emulation
-ShakeData::ShakeData() {
- Shake = 0;
- Roll = 0;
- Pitch = 0;
-}
-
// Keyboard input
KeyboardWiimote g_Wiimote_kbd;
KeyboardNunchuck g_NunchuckExt;
diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.h b/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.h
index 621fe962f5..ca5e864131 100644
--- a/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.h
+++ b/Source/Plugins/Plugin_Wiimote/Src/EmuDefinitions.h
@@ -171,12 +171,20 @@ struct SIR
int Distance;
};
-class ShakeData
+struct STiltData
{
- public:
- ShakeData();
+ // FakeNoise is used to prevent disconnection
+ // when there is no input for a long time
+ int FakeNoise;
int Shake;
int Roll, Pitch;
+ STiltData()
+ {
+ FakeNoise = 1;
+ Shake = 0;
+ Roll = 0;
+ Pitch = 0;
+ }
};
@@ -199,9 +207,10 @@ struct KeyboardWiimote
// Raw X and Y coordinate and processed X and Y coordinates
SIR IR;
- ShakeData shakeData;
+ STiltData TiltData;
};
- extern KeyboardWiimote g_Wiimote_kbd;
+extern KeyboardWiimote g_Wiimote_kbd;
+
struct KeyboardNunchuck
{
enum EKeyboardNunchuck
@@ -214,12 +223,16 @@ struct KeyboardNunchuck
#endif
C,
L, R, U, D,
+ ROLL_L, ROLL_R,
+ PITCH_U, PITCH_D,
SHAKE,
LAST_CONSTANT
};
- ShakeData shakeData;
+
+ STiltData TiltData;
};
extern KeyboardNunchuck g_NunchuckExt;
+
struct KeyboardClassicController
{
enum EKeyboardClassicController
@@ -228,7 +241,7 @@ struct KeyboardClassicController
#ifdef _WIN32
A = g_NunchuckExt.LAST_CONSTANT,
#else
- A = 25,
+ A = 29,
#endif
B, X, Y,
P, M, H,
@@ -249,7 +262,7 @@ struct KeyboardGH3GLP
#ifdef _WIN32
Green = g_ClassicContExt.LAST_CONSTANT,
#else
- Green = 48,
+ Green = 52,
#endif
Red, Yellow, Blue, Orange,
Plus, Minus, Whammy,
diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuDynamics.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuDynamics.cpp
index 5ba4192211..54b5b79a4b 100644
--- a/Source/Plugins/Plugin_Wiimote/Src/EmuDynamics.cpp
+++ b/Source/Plugins/Plugin_Wiimote/Src/EmuDynamics.cpp
@@ -89,13 +89,16 @@ void AdjustAngles(int &Roll, int &Pitch)
// Angles to accelerometer values
-void PitchDegreeToAccelerometer(int _Roll, int _Pitch, int &_x, int &_y, int &_z)
+void TiltToAccelerometer(int &_x, int &_y, int &_z, STiltData &_TiltData)
{
+ if (_TiltData.Roll == 0 && _TiltData.Pitch == 0)
+ return;
+
// We need radiands for the math functions
- float Roll = InputCommon::Deg2Rad((float)_Roll);
- float Pitch = InputCommon::Deg2Rad((float)_Pitch);
+ float Roll = InputCommon::Deg2Rad((float)_TiltData.Roll);
+ float Pitch = InputCommon::Deg2Rad((float)_TiltData.Pitch);
// We need float values
- float x = 0.0f, y = 0.0f, z = 0.0f;
+ float x = 0.0f, y = 0.0f, z = 1.0f; // Gravity
// In these cases we can use the simple and accurate formula
if(g_Config.Tilt.Range.Roll && g_Config.Tilt.Range.Pitch == 0)
@@ -155,14 +158,14 @@ void PitchDegreeToAccelerometer(int _Roll, int _Pitch, int &_x, int &_y, int &_z
// Direct mapping for swing, from analog stick to accelerometer
if (g_Config.Tilt.Range.Roll == 0)
{
- _x -= _Roll;
+ _x -= _TiltData.Roll;
}
if (g_Config.Tilt.Range.Pitch == 0)
{
if (!g_Config.bUpright)
- _z -= _Pitch;
+ _z -= _TiltData.Pitch;
else // Upright wiimote
- _y += _Pitch;
+ _y += _TiltData.Pitch;
}
}
diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.h b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.h
index a1ea9ddd04..7ad4055a2d 100644
--- a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.h
+++ b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.h
@@ -58,13 +58,14 @@ void GetJoyState(InputCommon::CONTROLLER_STATE_NEW &_PadState, InputCommon::CONT
void PadStateAdjustments(int &Lx, int &Ly, int &Rx, int &Ry, int &Tl, int &Tr);
// Accelerometer
-void PitchDegreeToAccelerometer(int _Roll, int _Pitch, int &_x, int &_y, int &_z);
void PitchAccelerometerToDegree(u8 _x, u8 _y, u8 _z, int &_Roll, int &_Pitch, int&, int&);
float AccelerometerToG(float Current, float Neutral, float G);
-void Tilt(int &_x, int &_y, int &_z);
+void ShakeToAccelerometer(int &_x, int &_y, int &_z, STiltData &_TiltData);
+void TiltToAccelerometer(int &_x, int &_y, int &_z, STiltData &_TiltData);
void AdjustAngles(int &Roll, int &Pitch);
// IR data
+void RotateIRDots(int &_x, int &_y, STiltData &_TiltData);
void IRData2Dots(u8 *Data);
void IRData2DotsBasic(u8 *Data);
void ReorderIRDots();
diff --git a/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp b/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp
index 22c91c53a7..e19c5baa0d 100644
--- a/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp
+++ b/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp
@@ -433,20 +433,14 @@ Y |. .|| Z
*/
-void StartShake(ShakeData &shakeData) {
- if (shakeData.Shake <= 0) shakeData.Shake = 1;
-}
-
// Single shake step of all three directions
-void SingleShake(int &_x, int &_y, int &_z, ShakeData &shakeData)
+void ShakeToAccelerometer(int &_x, int &_y, int &_z, STiltData &_TiltData)
{
-// if (shakeData.Shake == 0)
-// {
-// if((wm == 0 && IsKey(g_Wiimote_kbd.SHAKE)) || (wm == 1 && IsKey(g_NunchuckExt.SHAKE)))
-// Shake[wm] = 1;
-// }
- switch(shakeData.Shake)
+ switch(_TiltData.Shake)
{
+ case 0:
+ _TiltData.Shake = -1;
+ break;
case 1:
case 3:
_x = g_wm.cal_zero.x / 2;
@@ -475,18 +469,21 @@ void SingleShake(int &_x, int &_y, int &_z, ShakeData &shakeData)
_z = 0x80;
break;
default:
- shakeData.Shake = -1;
+ _TiltData.Shake = -1;
break;
}
- shakeData.Shake++;
- //if (Shake[wm] != 0) DEBUG_LOG(WIIMOTE, "Shake: %i - 0x%02x, 0x%02x, 0x%02x", Shake[wm], _x, _y, _z);
+ _TiltData.Shake++;
+
+ if (_TiltData.Shake != 0)
+ {
+ DEBUG_LOG(WIIMOTE, "Shake: %i - 0x%02x, 0x%02x, 0x%02x", _TiltData.Shake, _x, _y, _z);
+ }
}
-
-/* Tilting Wiimote with gamepad. We can guess that the game will calculate a
- Wiimote pitch and use it as a measure of the tilting of the Wiimote. We are
+/* Tilting by gamepad. We can guess that the game will calculate
+ roll and pitch and use them as measures of the tilting. We are
interested in this tilting range 90 to -90*/
-void TiltWiimoteGamepad(int &Roll, int &Pitch)
+void TiltByGamepad(STiltData &_TiltData, int Type)
{
// Return if we have no pads
if (NumGoodPads == 0) return;
@@ -508,7 +505,7 @@ void TiltWiimoteGamepad(int &Roll, int &Pitch)
int &PitchRange = g_Config.Tilt.Range.Pitch;
// The trigger currently only controls pitch, no roll, no free swing
- if (g_Config.Tilt.Type == g_Config.Tilt.TRIGGER)
+ if (Type == g_Config.Tilt.TRIGGER)
{
// Make the range the same dimension as the analog stick
Tl = Tl / 2;
@@ -516,13 +513,13 @@ void TiltWiimoteGamepad(int &Roll, int &Pitch)
// Invert
if (g_Config.Tilt.PitchInvert) { Tl = -Tl; Tr = -Tr; }
// The final value
- Pitch = (float)PitchRange * ((float)(Tl - Tr) / 128.0f);
+ _TiltData.Pitch = (float)PitchRange * ((float)(Tl - Tr) / 128.0f);
}
/* For the analog stick roll is by default set to the X-axis, pitch is by
default set to the Y-axis. By changing the axis mapping and the invert
options this can be altered in any way */
- else if (g_Config.Tilt.Type == g_Config.Tilt.ANALOG1)
+ else if (Type == g_Config.Tilt.ANALOG1)
{
// Adjust the trigger to go between negative and positive values
Lx = Lx - 0x80;
@@ -531,8 +528,8 @@ void TiltWiimoteGamepad(int &Roll, int &Pitch)
if (g_Config.Tilt.RollInvert) Lx = -Lx; // else Tr = -Tr;
if (g_Config.Tilt.PitchInvert) Ly = -Ly; // else Tr = -Tr;
// Produce the final value
- Roll = (RollRange) ? (float)RollRange * ((float)Lx / 128.0f) : Lx;
- Pitch = (PitchRange) ? (float)PitchRange * ((float)Ly / 128.0f) : Ly;
+ _TiltData.Roll = (RollRange) ? (float)RollRange * ((float)Lx / 128.0f) : Lx;
+ _TiltData.Pitch = (PitchRange) ? (float)PitchRange * ((float)Ly / 128.0f) : Ly;
}
// Otherwise we are using ANALOG2
else
@@ -544,105 +541,192 @@ void TiltWiimoteGamepad(int &Roll, int &Pitch)
if (g_Config.Tilt.RollInvert) Rx = -Rx; // else Tr = -Tr;
if (g_Config.Tilt.PitchInvert) Ry = -Ry; // else Tr = -Tr;
// Produce the final value
- Roll = (RollRange) ? (float)RollRange * ((float)Rx / 128.0f) : Rx;
- Pitch = (PitchRange) ? (float)PitchRange * ((float)Ry / 128.0f) : Ry;
+ _TiltData.Roll = (RollRange) ? (float)RollRange * ((float)Rx / 128.0f) : Rx;
+ _TiltData.Pitch = (PitchRange) ? (float)PitchRange * ((float)Ry / 128.0f) : Ry;
}
}
-
-// Tilting Wiimote with keyboard
-void TiltWiimoteKeyboard(int &Roll, int &Pitch)
+// Tilting Wiimote by keyboard
+void TiltByKeyboardWM(STiltData &_TiltData)
{
// Do roll/pitch or free swing
if (IsKey(g_Wiimote_kbd.ROLL_L))
{
if (g_Config.Tilt.Range.Roll)
{
- // Stop at the upper end of the range
- if (Roll < g_Config.Tilt.Range.Roll)
- Roll += 3; // aim left
+ // Stop at the lower end of the range
+ if (_TiltData.Roll > -g_Config.Tilt.Range.Roll)
+ _TiltData.Roll -= 3; // aim left
}
else // Free swing
{
- Roll = -0x80 / 2;
+ _TiltData.Roll = -0x80 / 2;
}
}
else if (IsKey(g_Wiimote_kbd.ROLL_R))
{
if (g_Config.Tilt.Range.Roll)
{
- // Stop at the lower end of the range
- if (Roll > -g_Config.Tilt.Range.Roll)
- Roll -= 3; // aim right
+ // Stop at the upper end of the range
+ if (_TiltData.Roll < g_Config.Tilt.Range.Roll)
+ _TiltData.Roll += 3; // aim right
}
else // Free swing
{
- Roll = 0x80 / 2;
+ _TiltData.Roll = 0x80 / 2;
}
}
else
{
- Roll = 0;
+ _TiltData.Roll = 0;
}
if (IsKey(g_Wiimote_kbd.PITCH_U))
{
if (g_Config.Tilt.Range.Pitch)
{
- // Stop at the upper end of the range
- if (Pitch < g_Config.Tilt.Range.Pitch)
- Pitch += 3; // aim up
+ // Stop at the lower end of the range
+ if (_TiltData.Pitch > -g_Config.Tilt.Range.Pitch)
+ _TiltData.Pitch -= 3; // aim down
}
else // Free swing
{
- Pitch = -0x80 / 2;
+ _TiltData.Pitch = -0x80 / 2;
}
}
else if (IsKey(g_Wiimote_kbd.PITCH_D))
{
if (g_Config.Tilt.Range.Pitch)
{
+ // Stop at the upper end of the range
+ if (_TiltData.Pitch < g_Config.Tilt.Range.Pitch)
+ _TiltData.Pitch += 3; // aim up
+ }
+ else // Free swing
+ {
+ _TiltData.Pitch = 0x80 / 2;
+ }
+ }
+ else
+ {
+ _TiltData.Pitch = 0;
+ }
+}
+
+// Tilting Nunchuck by keyboard
+void TiltByKeyboardNC(STiltData &_TiltData)
+{
+ // Do roll/pitch or free swing
+ if (IsKey(g_NunchuckExt.ROLL_L))
+ {
+ if (g_Config.Tilt.Range.Roll)
+ {
// Stop at the lower end of the range
- if (Pitch > -g_Config.Tilt.Range.Pitch)
- Pitch -= 3; // aim down
+ if (_TiltData.Roll > -g_Config.Tilt.Range.Roll)
+ _TiltData.Roll -= 3; // aim left
+ }
+ else // Free swing
+ {
+ _TiltData.Roll = -0x80 / 2;
+ }
+ }
+ else if (IsKey(g_NunchuckExt.ROLL_R))
+ {
+ if (g_Config.Tilt.Range.Roll)
+ {
+ // Stop at the upper end of the range
+ if (_TiltData.Roll < g_Config.Tilt.Range.Roll)
+ _TiltData.Roll += 3; // aim right
}
else // Free swing
{
- Pitch = 0x80 / 2;
+ _TiltData.Roll = 0x80 / 2;
}
}
else
{
- Pitch = 0;
+ _TiltData.Roll = 0;
+ }
+ if (IsKey(g_NunchuckExt.PITCH_U))
+ {
+ if (g_Config.Tilt.Range.Pitch)
+ {
+ // Stop at the lower end of the range
+ if (_TiltData.Pitch > -g_Config.Tilt.Range.Pitch)
+ _TiltData.Pitch -= 3; // aim up
+ }
+ else // Free swing
+ {
+ _TiltData.Pitch = -0x80 / 2;
+ }
+ }
+ else if (IsKey(g_NunchuckExt.PITCH_D))
+ {
+ if (g_Config.Tilt.Range.Pitch)
+ {
+ // Stop at the upper end of the range
+ if (_TiltData.Pitch < g_Config.Tilt.Range.Pitch)
+ _TiltData.Pitch += 3; // aim down
+ }
+ else // Free swing
+ {
+ _TiltData.Pitch = 0x80 / 2;
+ }
+ }
+ else
+ {
+ _TiltData.Pitch = 0;
}
}
// Tilting Wiimote (Wario Land aiming, Mario Kart steering and other things)
-void Tilt(int &_x, int &_y, int &_z)
+void TiltWiimote(int &_x, int &_y, int &_z)
{
// Check if it's on
- if (g_Config.Tilt.Type == g_Config.Tilt.OFF) return;
+ if (g_Config.Tilt.TypeWM == g_Config.Tilt.OFF)
+ return;
+ // Select input method and return the x, y, x values
+ else if (g_Config.Tilt.TypeWM == g_Config.Tilt.KEYBOARD)
+ TiltByKeyboardWM(g_Wiimote_kbd.TiltData);
+ else
+ TiltByGamepad(g_Wiimote_kbd.TiltData, g_Config.Tilt.TypeWM);
+
+ // Adjust angles, it's only needed if both roll and pitch is used together
+ if (g_Config.Tilt.Range.Roll != 0 && g_Config.Tilt.Range.Pitch != 0)
+ AdjustAngles(g_Wiimote_kbd.TiltData.Roll, g_Wiimote_kbd.TiltData.Pitch);
+ // Calculate the accelerometer value from this tilt angle
+ TiltToAccelerometer(_x, _y, _z, g_Wiimote_kbd.TiltData);
+
+ //DEBUG_LOG(WIIMOTE, "Roll:%i, Pitch:%i, _x:%u, _y:%u, _z:%u", g_Wiimote_kbd.TiltData.Roll, g_Wiimote_kbd.TiltData.Pitch, _x, _y, _z);
+}
+
+// Tilting Nunchuck (Mad World, Dead Space and other things)
+void TiltNunchuck(int &_x, int &_y, int &_z)
+{
+ // Check if it's on
+ if (g_Config.Tilt.TypeNC == g_Config.Tilt.OFF)
+ return;
// Select input method and return the x, y, x values
- if (g_Config.Tilt.Type == g_Config.Tilt.KEYBOARD)
- TiltWiimoteKeyboard(g_Wiimote_kbd.shakeData.Roll, g_Wiimote_kbd.shakeData.Pitch);
- else if (g_Config.Tilt.Type == g_Config.Tilt.TRIGGER || g_Config.Tilt.Type == g_Config.Tilt.ANALOG1 || g_Config.Tilt.Type == g_Config.Tilt.ANALOG2)
- TiltWiimoteGamepad(g_Wiimote_kbd.shakeData.Roll, g_Wiimote_kbd.shakeData.Pitch);
+ else if (g_Config.Tilt.TypeNC == g_Config.Tilt.KEYBOARD)
+ TiltByKeyboardNC(g_NunchuckExt.TiltData);
+ else
+ TiltByGamepad(g_NunchuckExt.TiltData, g_Config.Tilt.TypeNC);
// Adjust angles, it's only needed if both roll and pitch is used together
if (g_Config.Tilt.Range.Roll != 0 && g_Config.Tilt.Range.Pitch != 0)
- AdjustAngles(g_Wiimote_kbd.shakeData.Roll, g_Wiimote_kbd.shakeData.Pitch);
+ AdjustAngles(g_NunchuckExt.TiltData.Roll, g_NunchuckExt.TiltData.Pitch);
// Calculate the accelerometer value from this tilt angle
- PitchDegreeToAccelerometer(g_Wiimote_kbd.shakeData.Roll, g_Wiimote_kbd.shakeData.Pitch, _x, _y, _z);
+ TiltToAccelerometer(_x, _y, _z, g_NunchuckExt.TiltData);
- //DEBUG_LOG(WIIMOTE, "Roll:%i, Pitch:%i, _x:%u, _y:%u, _z:%u", Roll, Pitch, _x, _y, _z);
+ //DEBUG_LOG(WIIMOTE, "Roll:%i, Pitch:%i, _x:%u, _y:%u, _z:%u", g_NunchuckExt.TiltData.Roll, g_NunchuckExt.TiltData.Pitch, _x, _y, _z);
}
void FillReportAcc(wm_accel& _acc)
{
// Recorded movements
// Check for a playback command
- if(g_RecordingPlaying[0] < 0)
+ if (g_RecordingPlaying[0] < 0)
{
g_RecordingPlaying[0] = RecordingCheckKeys(0);
}
@@ -655,26 +739,34 @@ void FillReportAcc(wm_accel& _acc)
}
// Initial value
- int acc_x = g_wm.cal_zero.x;
- int acc_y = g_wm.cal_zero.y;
- int acc_z = g_wm.cal_zero.z;
+ _acc.x = g_wm.cal_zero.x;
+ _acc.y = g_wm.cal_zero.y;
+ _acc.z = g_wm.cal_zero.z;
+ // Adjust position, also add some noise to prevent disconnection
if (!g_Config.bUpright)
- acc_z += g_wm.cal_g.z;
+ _acc.z += g_wm.cal_g.z + g_Wiimote_kbd.TiltData.FakeNoise;
else // Upright wiimote
- acc_y -= g_wm.cal_g.y;
+ _acc.y -= g_wm.cal_g.y + g_Wiimote_kbd.TiltData.FakeNoise;
+
+ g_Wiimote_kbd.TiltData.FakeNoise = -g_Wiimote_kbd.TiltData.FakeNoise;
- // Check that Dolphin is in focus
if (IsFocus())
{
- // Check for shake button
- if(IsKey(g_Wiimote_kbd.SHAKE)) StartShake(g_Wiimote_kbd.shakeData);
+ int acc_x = _acc.x;
+ int acc_y = _acc.y;
+ int acc_z = _acc.z;
+
+ if (IsKey(g_Wiimote_kbd.SHAKE) && g_Wiimote_kbd.TiltData.Shake == 0)
+ g_Wiimote_kbd.TiltData.Shake = 1;
+
// Step the shake simulation one step
- SingleShake(acc_x, acc_y, acc_z, g_Wiimote_kbd.shakeData);
+ ShakeToAccelerometer(acc_x, acc_y, acc_z, g_Wiimote_kbd.TiltData);
// Tilt Wiimote, allow the shake function to interrupt it
- if (g_Wiimote_kbd.shakeData.Shake == 0) Tilt(acc_x, acc_y, acc_z);
-
+ if (g_Wiimote_kbd.TiltData.Shake == 0)
+ TiltWiimote(acc_x, acc_y, acc_z);
+
// Boundary check
if (acc_x > 0xFF) acc_x = 0xFF;
else if (acc_x < 0x00) acc_x = 0x00;
@@ -682,11 +774,11 @@ void FillReportAcc(wm_accel& _acc)
else if (acc_y < 0x00) acc_y = 0x00;
if (acc_z > 0xFF) acc_z = 0xFF;
else if (acc_z < 0x00) acc_z = 0x00;
- }
- _acc.x = acc_x;
- _acc.y = acc_y;
- _acc.z = acc_z;
+ _acc.x = acc_x;
+ _acc.y = acc_y;
+ _acc.z = acc_z;
+ }
// Debugging for translating Wiimote to Keyboard (or Gamepad)
/*
@@ -764,9 +856,9 @@ void FillReportAcc(wm_accel& _acc)
}
// Rotate IR dot when rolling Wiimote
-void RotateIRDot(int _Roll, int& _x, int& _y)
+void RotateIRDot(int &_x, int &_y, STiltData &_TiltData)
{
- if (g_Config.Tilt.Range.Roll == 0 || _Roll == 0)
+ if (g_Config.Tilt.Range.Roll == 0 || _TiltData.Roll == 0)
return;
// The IR camera resolution is 1023x767
@@ -776,8 +868,8 @@ void RotateIRDot(int _Roll, int& _x, int& _y)
float radius = sqrt(pow(dot_x, 2) + pow(dot_y, 2));
float radian = atan2(dot_y, dot_x);
- _x = radius * cos(radian + InputCommon::Deg2Rad((float)_Roll)) + 1023.0f / 2;
- _y = radius * sin(radian + InputCommon::Deg2Rad((float)_Roll)) + 767.0f / 2;
+ _x = radius * cos(radian + InputCommon::Deg2Rad((float)_TiltData.Roll)) + 1023.0f / 2;
+ _y = radius * sin(radian + InputCommon::Deg2Rad((float)_TiltData.Roll)) + 767.0f / 2;
// Out of sight check
if (_x < 0 || _x > 1023) _x = 0xFFFF;
@@ -824,8 +916,8 @@ void FillReportIR(wm_ir_extended& _ir0, wm_ir_extended& _ir1)
int x0 = 1023 - g_Config.iIRLeft - g_Config.iIRWidth * MouseX - SENSOR_BAR_WIDTH / 2;
int x1 = x0 + SENSOR_BAR_WIDTH;
- RotateIRDot(g_Wiimote_kbd.shakeData.Roll, x0, y0);
- RotateIRDot(g_Wiimote_kbd.shakeData.Roll, x1, y1);
+ RotateIRDot(x0, y0, g_Wiimote_kbd.TiltData);
+ RotateIRDot(x1, y1, g_Wiimote_kbd.TiltData);
// Converted to IR data
_ir0.x = x0 & 0xff; _ir0.xHi = x0 >> 8;
@@ -901,8 +993,8 @@ void FillReportIRBasic(wm_ir_basic& _ir0, wm_ir_basic& _ir1)
int x1 = 1023 - g_Config.iIRLeft - g_Config.iIRWidth * MouseX - SENSOR_BAR_WIDTH / 2;
int x2 = x1 + SENSOR_BAR_WIDTH;
- RotateIRDot(g_Wiimote_kbd.shakeData.Roll, x1, y1);
- RotateIRDot(g_Wiimote_kbd.shakeData.Roll, x2, y2);
+ RotateIRDot(x1, y1, g_Wiimote_kbd.TiltData);
+ RotateIRDot(x2, y2, g_Wiimote_kbd.TiltData);
/* As with the extented report we settle with emulating two out of four
possible objects the only difference is that we don't report any size of
@@ -974,24 +1066,44 @@ void FillReportExtension(wm_extension& _ext)
return;
}
- // Use the neutral values
- int ext_ax = g_nu.cal_zero.x;
- int ext_ay = g_nu.cal_zero.y;
- int ext_az = g_nu.cal_zero.z + g_nu.cal_g.z;
-
- if(IsKey(g_NunchuckExt.SHAKE)) StartShake(g_NunchuckExt.shakeData);
- // Shake the Nunchuk one frame
- SingleShake(ext_ax, ext_ay, ext_az, g_NunchuckExt.shakeData);
-
- _ext.ax = ext_ax;
- _ext.ay = ext_ay;
- _ext.az = ext_az;
-
// The default joystick and button values unless we use them
_ext.jx = g_nu.jx.center;
_ext.jy = g_nu.jy.center;
_ext.bt = 0x03; // 0x03 means no button pressed, the button is zero active
+ // Use the neutral values
+ _ext.ax = g_nu.cal_zero.x;
+ _ext.ay = g_nu.cal_zero.y;
+ _ext.az = g_nu.cal_zero.z + g_nu.cal_g.z;
+
+if (IsFocus())
+{
+ int acc_x = _ext.ax;
+ int acc_y = _ext.ay;
+ int acc_z = _ext.az;
+
+ if (IsKey(g_NunchuckExt.SHAKE) && g_NunchuckExt.TiltData.Shake == 0)
+ g_NunchuckExt.TiltData.Shake = 1;
+
+ // Step the shake simulation one step
+ ShakeToAccelerometer(acc_x, acc_y, acc_z, g_NunchuckExt.TiltData);
+
+ // Tilt Nunchuck, allow the shake function to interrupt it
+ if (g_NunchuckExt.TiltData.Shake == 0)
+ TiltNunchuck(acc_x, acc_y, acc_z);
+
+ // Boundary check
+ if (acc_x > 0xFF) acc_x = 0xFF;
+ else if (acc_x < 0x00) acc_x = 0x00;
+ if (acc_y > 0xFF) acc_y = 0xFF;
+ else if (acc_y < 0x00) acc_y = 0x00;
+ if (acc_z > 0xFF) acc_z = 0xFF;
+ else if (acc_z < 0x00) acc_z = 0x00;
+
+ _ext.ax = acc_x;
+ _ext.ay = acc_y;
+ _ext.az = acc_z;
+
// Update the analog stick
if (g_Config.Nunchuck.Type == g_Config.Nunchuck.KEYBOARD)
{
@@ -1077,6 +1189,8 @@ void FillReportExtension(wm_extension& _ext)
if(IsKey(g_NunchuckExt.C) && IsKey(g_NunchuckExt.Z))
_ext.bt = 0x00;
+}
+
/* Here we encrypt the report */
// Create a temporary storage for the data
@@ -1337,7 +1451,6 @@ void FillReportClassicExtension(wm_classic_extension& _ext)
// { _ext.b2.bA = 0x01; _ext.b2.bB = 0x01; }
}
-
// Convert data for reporting
_ext.Lx = (Lx >> 2);
_ext.Ly = (Ly >> 2);
@@ -1355,7 +1468,6 @@ void FillReportClassicExtension(wm_classic_extension& _ext)
_ext.lT2 = (lT >> 3) >> 3;
_ext.rT = (rT >> 3);
-
/* Here we encrypt the report */
// Create a temporary storage for the data