diff --git a/Source/Core/InputCommon/Src/Configuration.cpp b/Source/Core/InputCommon/Src/Configuration.cpp index ded3168bba..cea2182a9e 100644 --- a/Source/Core/InputCommon/Src/Configuration.cpp +++ b/Source/Core/InputCommon/Src/Configuration.cpp @@ -56,11 +56,32 @@ float Rad2Deg(float Rad) ////////////////////////////////////////////////////////////////////////////////////////// -// Convert stick values +// Check if the pad is within the dead zone, we assume the range is 0x8000 // ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ +float CoordinatesToRadius(int x, int y) +{ + return sqrt(pow((float)x, 2) + pow((float)y, 2)); +} -/* Convert stick values. +bool IsDeadZone(float DeadZone, int x, int y) +{ + // Get the distance from the center + float Distance = CoordinatesToRadius(x, y) / 32767.0; + //Console::Print("%f\n", Distance); + + // Check if it's within the dead zone + if (Distance <= DeadZone) + return true; + else + return false; +} +///////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////////////////// +// Scale down stick values from 0x8000 to 0x80 +/* ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ The value returned by SDL_JoystickGetAxis is a signed integer s16 (-32768 to 32767). The value used for the gamecube controller is an unsigned char u8 (0 to 255) with neutral at 0x80 (128), so that it's equivalent to a signed @@ -84,46 +105,50 @@ int Pad_Convert(int _val) return _val; } +///////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////// -/* Convert the stick raidus from a circular to a square. I don't know what input values - the actual GC controller produce for the GC, it may be a square, a circle or something - in between. But one thing that is certain is that PC pads differ in their output (as - shown in the list below), so it may be beneficiary to convert whatever radius they +/* Convert the stick raidus from a square or rounded box to a circular radius. I don't know what + input values the actual GC controller produce for the GC, it may be a square, a circle or + something in between. But one thing that is certain is that PC pads differ in their output + (as shown in the list below), so it may be beneficiary to convert whatever radius they produce to the radius the GC games expect. This is the first implementation of this that convert a square radius to a circual radius. Use the advanced settings to enable and calibrate it. Observed diagonals: - Perfect circle: 71% = sin(45) - Logitech Dual Action: 100% - Dual Shock 2 (Original) with Super Dual Box Pro: 90% - XBox 360 Wireless: 85% - GameCube Controller (Third Party) with EMS TrioLinker Plus II: 60% + Perfect circle: 71% = sin(45) + Logitech Dual Action: 100% + PS2 Dual Shock 2 (Original) with Super Dual Box Pro: 90% + XBox 360 Wireless: 85% + GameCube Controller (Third Party) with EMS Trio Linker Plus II: 60% */ // ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ -/* Calculate the distance from the center of the current stick coordinates. The distance is defined - as at most sqrt(2) in the corners */ -float SquareDistance(float deg) +/* Calculate the distance from the outer edges of the box to the outer edges of the circle inside the box + at any angle from 0° to 360°. The returned value is 1 + Distance, for example at most sqrt(2) in the + corners and at least 1.0 at the horizontal and vertical angles. */ +float Square2CircleDistance(float deg) { // See if we have to adjust the angle deg = abs(deg); if( (deg > 45 && deg < 135) ) deg = deg - 90; + // Calculate distance from center float val = abs(cos(Deg2Rad(deg))); - float dist = 1 / val; // Calculate distance from center + float Distance = 1 / val; //m_frame->m_pStatusBar2->SetLabel(wxString::Format("Deg:%f Val:%f Dist:%f", deg, val, dist)); - return dist; + return Distance; } -// Produce the circle from the original +// Produce a perfect circle from an original square or rounded box std::vector Square2Circle(int _x, int _y, int _pad, std::string SDiagonal, bool Circle2Square) { - /* Do we need this? */ - if(_x > 32767) _x = 32767; if(_y > 32767) _y = 32767; // upper limit - if(_x < -32768) _x = -32768; if(_y > 32767) _y = 32767; // lower limit + // Do we need this? + if(_x > 32767) _x = 32767; if(_y > 32767) _y = 32767; // upper limit + if(_x < -32768) _x = -32768; if(_y < -32768) _y = -32768; // lower limit // ==================================== // Convert to circle @@ -136,9 +161,10 @@ std::vector Square2Circle(int _x, int _y, int _pad, std::string SDiagonal, float OrigDist = sqrt( pow((float)_y, 2) + pow((float)_x, 2) ); // Get current distance float deg = Rad2Deg(atan2((float)_y, (float)_x)); // Get current angle - // A diagonal of 85% means a maximum distance of 0.85 * sqrt(2) ~1.2 in the diagonals + /* Calculate the actual distance between the maxium diagonal values, and the outer edges of the + square. A diagonal of 85% means a maximum distance of 0.85 * sqrt(2) ~1.2 in the diagonals. */ float corner_circle_dist = ( Diagonal / sin(Deg2Rad(45)) ); - float SquareDist = SquareDistance(deg); + float SquareDist = Square2CircleDistance(deg); // The original-to-square distance adjustment float adj_ratio1; // The circle-to-square distance adjustment @@ -163,8 +189,8 @@ std::vector Square2Circle(int _x, int _y, int _pad, std::string SDiagonal, int int_x = (int)floor(x); int int_y = (int)floor(y); // Boundaries - if (int_x < -32767) int_x = -32767; if (int_x > 32767) int_x = 32767; - if (int_y < -32767) int_y = -32767; if (int_y > 32767) int_y = 32767; + if (int_x < -32768) int_x = -32768; if (int_x > 32767) int_x = 32767; + if (int_y < -32768) int_y = -32768; if (int_y > 32767) int_y = 32767; // Return it std::vector vec; vec.push_back(int_x); diff --git a/Source/Core/InputCommon/Src/SDL.cpp b/Source/Core/InputCommon/Src/SDL.cpp index 2c20379394..15b552a08d 100644 --- a/Source/Core/InputCommon/Src/SDL.cpp +++ b/Source/Core/InputCommon/Src/SDL.cpp @@ -65,7 +65,7 @@ bool SearchDevices(std::vector &_joyinfo, int &_NumPads, int &_ DEBUG_INIT(); #endif - /* SDL 1.3 use DirectInput instead of the old Microsoft Multimeda API, and with this we need + /* SDL 1.3 use DirectInput instead of the old Microsoft Multimedia API, and with this we need the SDL_INIT_VIDEO flag to */ if (!SDL_WasInit(0)) if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) diff --git a/Source/Core/InputCommon/Src/SDL.h b/Source/Core/InputCommon/Src/SDL.h index 99896fa964..9e85bc8779 100644 --- a/Source/Core/InputCommon/Src/SDL.h +++ b/Source/Core/InputCommon/Src/SDL.h @@ -207,6 +207,8 @@ void GetButton(SDL_Joystick*, int,int,int,int, int&,int&,int&,int&,bool&,bool&, float Deg2Rad(float Deg); float Rad2Deg(float Rad); int Pad_Convert(int _val); +float SquareDistance(float deg); +bool IsDeadZone(float DeadZone, int x, int y); std::vector Square2Circle(int _x, int _y, int _pad, std::string SDiagonal, bool Circle2Square = false); #ifndef _SDL_MAIN_ diff --git a/Source/Plugins/Plugin_Wiimote/Src/Config.cpp b/Source/Plugins/Plugin_Wiimote/Src/Config.cpp index 465b4e3898..387c1d86fb 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/Config.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/Config.cpp @@ -162,8 +162,8 @@ void Config::Save(int Slot) iniFile.Set(SectionName.c_str(), "l_trigger", WiiMoteEmu::PadMapping[i].Axis.Tl); iniFile.Set(SectionName.c_str(), "r_trigger", WiiMoteEmu::PadMapping[i].Axis.Tr); - //iniFile.Set(SectionName.c_str(), "deadzone", PadMapping[i].deadzone); - //iniFile.Set(SectionName.c_str(), "controllertype", PadMapping[i].controllertype); + iniFile.Set(SectionName.c_str(), "DeadZone", WiiMoteEmu::PadMapping[i].deadzone); + //iniFile.Set(SectionName.c_str(), "controllertype", WiiMoteEmu::PadMapping[i].controllertype); iniFile.Set(SectionName.c_str(), "TriggerType", WiiMoteEmu::PadMapping[i].triggertype); iniFile.Set(SectionName.c_str(), "Diagonal", WiiMoteEmu::PadMapping[i].SDiagonal); iniFile.Set(SectionName.c_str(), "Circle2Square", WiiMoteEmu::PadMapping[i].bCircle2Square); diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp index 79f4536960..cda2e2384c 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp @@ -100,11 +100,13 @@ BEGIN_EVENT_TABLE(ConfigDialog,wxDialog) EVT_BUTTON(IDB_RECORD + 15, ConfigDialog::RecordMovement) // Gamepad + EVT_COMBOBOX(IDC_JOYNAME, ConfigDialog::GeneralSettingsChanged) EVT_COMBOBOX(ID_TRIGGER_TYPE, ConfigDialog::GeneralSettingsChanged) EVT_COMBOBOX(ID_TILT_INPUT, ConfigDialog::GeneralSettingsChanged) EVT_COMBOBOX(ID_TILT_RANGE_ROLL, ConfigDialog::GeneralSettingsChanged) EVT_COMBOBOX(ID_TILT_RANGE_PITCH, ConfigDialog::GeneralSettingsChanged) EVT_COMBOBOX(IDCB_LEFT_DIAGONAL, ConfigDialog::GeneralSettingsChanged) + EVT_COMBOBOX(IDCB_DEAD_ZONE, ConfigDialog::GeneralSettingsChanged) EVT_CHECKBOX(IDC_LEFT_C2S, ConfigDialog::GeneralSettingsChanged) EVT_CHECKBOX(ID_TILT_INVERT_ROLL, ConfigDialog::GeneralSettingsChanged) EVT_CHECKBOX(ID_TILT_INVERT_PITCH, ConfigDialog::GeneralSettingsChanged) @@ -157,7 +159,10 @@ ConfigDialog::ConfigDialog(wxWindow *parent, wxWindowID id, const wxString &titl g_Config.Load(); CreateGUIControls(); LoadFile(); + // Set control values UpdateGUI(); + // Update dead zone + DoChangeDeadZone(); wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard wxKeyEventHandler(ConfigDialog::OnKeyDown), @@ -281,7 +286,7 @@ void ConfigDialog::DoSave(bool ChangePad, int Slot) { // Since we are selecting the pad to save to by the Id we can't update it when we change the pad for(int i = 0; i < 4; i++) SaveButtonMapping(i, true); - + // Save the settings for the current pad g_Config.Save(Slot); // Now we can update the ID WiiMoteEmu::PadMapping[Page].ID = m_Joyname[Page]->GetSelection(); @@ -295,6 +300,8 @@ void ConfigDialog::DoSave(bool ChangePad, int Slot) // Then change it back to "" ToBlank(); + + Console::Print("WiiMoteEmu::PadMapping[%i].ID = %i\n", Page, m_Joyname[Page]->GetSelection()); } ////////////////////////////////////// @@ -332,7 +339,6 @@ wxBitmap ConfigDialog::CreateBitmapDot() // Set outline and fill colors //wxBrush RedBrush(_T("#0383f0")); //wxPen RedPen(_T("#80c5fd")); - //wxPen LightGrayPen(_T("#909090")); dc.SetPen(*wxRED_PEN); dc.SetBrush(*wxRED_BRUSH); @@ -341,6 +347,36 @@ wxBitmap ConfigDialog::CreateBitmapDot() dc.SelectObject(wxNullBitmap); return bitmap; } +wxBitmap ConfigDialog::CreateBitmapDeadZone(int Radius) +{ + wxBitmap bitmap(Radius*2, Radius*2); + wxMemoryDC dc; + dc.SelectObject(bitmap); + + // Set outline and fill colors + dc.SetPen(*wxLIGHT_GREY_PEN); + dc.SetBrush(*wxLIGHT_GREY_BRUSH); + + //dc.SetBackground(*wxGREEN_BRUSH); + dc.Clear(); + dc.DrawCircle(Radius, Radius, Radius); + //dc.SelectObject(wxNullBitmap); + return bitmap; +} +wxBitmap ConfigDialog::CreateBitmapClear() +{ + wxBitmap bitmap(BoxW, BoxH); + wxMemoryDC dc; + dc.SelectObject(bitmap); + + // Set outline and fill colors + //dc.SetBrush(*wxTRANSPARENT_BRUSH); + + dc.Clear(); + //dc.DrawRectangle(0, 0, BoxW, BoxH); + //dc.SelectObject(wxNullBitmap); + return bitmap; +} ////////////////////////////////////// @@ -499,15 +535,13 @@ void ConfigDialog::CreateGUIControls() // ----------------------------- /**/ // Controller - m_Joyname[i] = new wxComboBox(m_Controller[i], IDC_JOYNAME, StrJoyname[0], wxDefaultPosition, wxSize(155, -1), StrJoyname, wxCB_READONLY); + m_Joyname[i] = new wxComboBox(m_Controller[i], IDC_JOYNAME, StrJoyname[0], wxDefaultPosition, wxSize(185, -1), StrJoyname, wxCB_READONLY); // Circle to square - m_CheckC2S[i] = new wxCheckBox(m_Controller[i], IDC_LEFT_C2S, wxT("Circle to square")); - - // The label - m_CheckC2SLabel[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Diagonal")); + m_CheckC2S[i] = new wxCheckBox(m_Controller[i], IDC_LEFT_C2S, wxT("Circle To Square")); // The drop down menu for the circle to square adjustment + m_CheckC2SLabel[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Diagonal")); wxArrayString asStatusInSet; asStatusInSet.Add(wxT("100%")); asStatusInSet.Add(wxT("95%")); @@ -516,6 +550,12 @@ void ConfigDialog::CreateGUIControls() asStatusInSet.Add(wxT("80%")); m_ComboDiagonal[i] = new wxComboBox(m_Controller[i], IDCB_LEFT_DIAGONAL, asStatusInSet[0], wxDefaultPosition, wxDefaultSize, asStatusInSet, wxCB_READONLY); + // Dead zone + m_ComboDeadZoneLabel[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Dead Zone")); + wxArrayString TextDeadZone; + for (int i = 0; i <= 50; i++) TextDeadZone.Add(wxString::Format(wxT("%i%%"), i)); + m_ComboDeadZone[i] = new wxComboBox(m_Controller[i], IDCB_DEAD_ZONE, TextDeadZone[0], wxDefaultPosition, wxDefaultSize, TextDeadZone, wxCB_READONLY); + // Tooltips m_Joyname[i]->SetToolTip(wxT("Save your settings and configure another joypad")); m_CheckC2S[i]->SetToolTip(wxT( @@ -528,14 +568,25 @@ void ConfigDialog::CreateGUIControls() )); // Sizers + m_gDeadZone[i] = new wxBoxSizer(wxVERTICAL); + m_gDeadZone[i]->Add(m_ComboDeadZoneLabel[i], 0, (wxUP), 0); + m_gDeadZone[i]->Add(m_ComboDeadZone[i], 0, (wxUP), 2); + m_gCircle2Square[i] = new wxBoxSizer(wxHORIZONTAL); m_gCircle2Square[i]->Add(m_CheckC2SLabel[i], 0, (wxUP), 4); m_gCircle2Square[i]->Add(m_ComboDiagonal[i], 0, (wxLEFT), 2); + m_gCircle2SquareVert[i] = new wxBoxSizer(wxVERTICAL); + m_gCircle2SquareVert[i]->Add(m_CheckC2S[i], 0, wxALIGN_CENTER | (wxUP), 0); + m_gCircle2SquareVert[i]->Add(m_gCircle2Square[i], 0, wxALIGN_CENTER | (wxUP), 2); + + m_gC2SDeadZone[i] = new wxBoxSizer(wxHORIZONTAL); + m_gC2SDeadZone[i]->Add(m_gDeadZone[i], 0, (wxUP), 0); + m_gC2SDeadZone[i]->Add(m_gCircle2SquareVert[i], 0, (wxLEFT), 8); + m_gJoyname[i] = new wxStaticBoxSizer (wxVERTICAL, m_Controller[i], wxT("Gamepad")); m_gJoyname[i]->Add(m_Joyname[i], 0, wxALIGN_CENTER | (wxLEFT | wxRIGHT | wxDOWN), 5); - m_gJoyname[i]->Add(m_CheckC2S[i], 0, wxALIGN_CENTER | (wxLEFT | wxRIGHT | wxDOWN), 5); - m_gJoyname[i]->Add(m_gCircle2Square[i], 0, wxALIGN_CENTER | (wxLEFT | wxRIGHT | wxDOWN), 5); + m_gJoyname[i]->Add(m_gC2SDeadZone[i], 0, wxALIGN_CENTER | (wxLEFT | wxRIGHT | wxDOWN), 5); // -------------------------------------------------------------------- @@ -546,20 +597,20 @@ void ConfigDialog::CreateGUIControls() m_TiltComboInput[i] = new wxComboBox(m_Controller[i], ID_TILT_INPUT, StrTilt[0], wxDefaultPosition, wxDefaultSize, StrTilt, wxCB_READONLY); m_TiltComboRangeRoll[i] = new wxComboBox(m_Controller[i], ID_TILT_RANGE_ROLL, StrTiltRangeRoll[0], wxDefaultPosition, wxDefaultSize, StrTiltRangeRoll, wxCB_READONLY); m_TiltComboRangePitch[i] = new wxComboBox(m_Controller[i], ID_TILT_RANGE_PITCH, StrTiltRangePitch[0], wxDefaultPosition, wxDefaultSize, StrTiltRangePitch, wxCB_READONLY); - m_TiltTextRoll[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Roll Range")); - m_TiltTextPitch[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Pitch Range")); + m_TiltTextRoll[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Roll")); + m_TiltTextPitch[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Pitch")); m_TiltInvertRoll[i] = new wxCheckBox(m_Controller[i], ID_TILT_INVERT_ROLL, wxT("Invert")); m_TiltInvertPitch[i] = new wxCheckBox(m_Controller[i], ID_TILT_INVERT_PITCH, wxT("Invert")); // Sizers m_TiltGrid[i] = new wxGridBagSizer(0, 0); m_TiltGrid[i]->Add(m_TiltTextRoll[i], wxGBPosition(0, 0), wxGBSpan(1, 1), (wxTOP), 4); - m_TiltGrid[i]->Add(m_TiltComboRangeRoll[i], wxGBPosition(0, 1), wxGBSpan(1, 1), (wxLEFT | wxRIGHT), 2); - m_TiltGrid[i]->Add(m_TiltInvertRoll[i], wxGBPosition(0, 2), wxGBSpan(1, 1), (wxTOP), 4); + m_TiltGrid[i]->Add(m_TiltComboRangeRoll[i], wxGBPosition(0, 1), wxGBSpan(1, 1), (wxLEFT), 2); + m_TiltGrid[i]->Add(m_TiltInvertRoll[i], wxGBPosition(0, 2), wxGBSpan(1, 1), (wxLEFT | wxTOP), 4); - m_TiltGrid[i]->Add(m_TiltTextPitch[i], wxGBPosition(1, 0), wxGBSpan(1, 1), (wxTOP), 4); - m_TiltGrid[i]->Add(m_TiltComboRangePitch[i], wxGBPosition(1, 1), wxGBSpan(1, 1), (wxLEFT | wxTOP | wxDOWN | wxRIGHT), 2); - m_TiltGrid[i]->Add(m_TiltInvertPitch[i], wxGBPosition(1, 2), wxGBSpan(1, 1), (wxTOP), 4); + m_TiltGrid[i]->Add(m_TiltTextPitch[i], wxGBPosition(1, 0), wxGBSpan(1, 1), (wxTOP), 6); + m_TiltGrid[i]->Add(m_TiltComboRangePitch[i], wxGBPosition(1, 1), wxGBSpan(1, 1), (wxLEFT | wxTOP | wxDOWN), 2); + m_TiltGrid[i]->Add(m_TiltInvertPitch[i], wxGBPosition(1, 2), wxGBSpan(1, 1), (wxLEFT | wxTOP), 4); // For additional padding options if needed //m_TiltHoriz[i] = new wxBoxSizer(wxHORIZONTAL); @@ -626,7 +677,7 @@ void ConfigDialog::CreateGUIControls() m_SizeAnalogTriggerHorizConfig[i]->Add(m_bAnalogTriggerR[i], wxGBPosition(1, 2), wxGBSpan(1, 1), (wxUP), 5); // The choice box and its name label - m_SizeAnalogTriggerHorizInput[i]->Add(m_tAnalogTriggerInput[i], 0, (wxUP), 2); + m_SizeAnalogTriggerHorizInput[i]->Add(m_tAnalogTriggerInput[i], 0, (wxUP), 3); m_SizeAnalogTriggerHorizInput[i]->Add(m_TriggerType[i], 0, (wxLEFT), 2); // The status text boxes @@ -641,7 +692,6 @@ void ConfigDialog::CreateGUIControls() m_gTrigger[i]->Add(m_SizeAnalogTriggerVertLeft[i], 0, wxEXPAND | (wxLEFT | wxRIGHT), 5); m_gTrigger[i]->Add(m_SizeAnalogTriggerVertRight[i], 0, wxEXPAND | (wxLEFT | wxRIGHT), 5); - // -------------------------------------------------------------------- // Row 2 Sizers: Connected pads, tilt, triggers // ----------------------------- @@ -667,6 +717,7 @@ void ConfigDialog::CreateGUIControls() m_pLeftInStatus[i] = new wxPanel(m_Controller[i], wxID_ANY, wxDefaultPosition, wxDefaultSize); m_bmpSquareLeftIn[i] = new wxStaticBitmap(m_pLeftInStatus[i], wxID_ANY, CreateBitmap(), wxDefaultPosition, wxDefaultSize); + m_bmpDeadZoneLeftIn[i] = new wxStaticBitmap(m_pLeftInStatus[i], wxID_ANY, CreateBitmapDeadZone(0), wxDefaultPosition, wxDefaultSize); m_bmpDotLeftIn[i] = new wxStaticBitmap(m_pLeftInStatus[i], wxID_ANY, CreateBitmapDot(), wxPoint(BoxW / 2, BoxH / 2), wxDefaultSize); m_pLeftOutStatus[i] = new wxPanel(m_Controller[i], wxID_ANY, wxDefaultPosition, wxDefaultSize); @@ -1121,13 +1172,18 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event) break; case IDC_JOYNAME: DoChangeJoystick(); - // The are defined in PadMapping and we can run the same function to update all of them + break; + // These are defined in PadMapping and we can run the same function to update all of them case IDCB_LEFT_DIAGONAL: case IDC_LEFT_C2S: case ID_TILT_INVERT_ROLL: case ID_TILT_INVERT_PITCH: SaveButtonMappingAll(Page); break; + case IDCB_DEAD_ZONE: + SaveButtonMappingAll(Page); + DoChangeDeadZone(); + break; ////////////////////////// // Recording @@ -1211,6 +1267,9 @@ void ConfigDialog::UpdateGUI(int Slot) #ifdef _WIN32 for(int i = IDB_ANALOG_LEFT_X; i <= IDB_TRIGGER_R; i++) m_Notebook->FindItem(i)->Enable(PadEnabled); m_Notebook->FindItem(IDC_JOYNAME)->Enable(PadEnabled); + m_Notebook->FindItem(IDC_LEFT_C2S)->Enable(PadEnabled); + m_Notebook->FindItem(IDCB_LEFT_DIAGONAL)->Enable(PadEnabled); + m_Notebook->FindItem(IDCB_DEAD_ZONE)->Enable(PadEnabled); m_Notebook->FindItem(ID_TRIGGER_TYPE)->Enable(PadEnabled); #endif } diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.h b/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.h index 07507198b5..fe15cff2e8 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.h +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.h @@ -56,7 +56,8 @@ class ConfigDialog : public wxDialog // Wiimote status wxGauge *m_GaugeBattery, *m_GaugeRoll[2], *m_GaugeGForce[3], *m_GaugeAccel[3]; - wxStaticBitmap *m_bmpDotLeftIn[4], *m_bmpDotLeftOut[4], *m_bmpDotRightIn[4], *m_bmpDotRightOut[4]; + wxStaticBitmap *m_bmpDotLeftIn[4], *m_bmpDotLeftOut[4], *m_bmpDotRightIn[4], *m_bmpDotRightOut[4], + *m_bmpDeadZoneLeftIn[4]; wxStaticText *m_TextIR, *m_TextAccNeutralCurrent; bool m_bWaitForRecording, m_bRecording, m_bAllowA; int m_iRecordTo; @@ -86,7 +87,7 @@ class ConfigDialog : public wxDialog // Emulated Wiimote key settings wxBoxSizer *m_SizeBasicPadding[4], *m_SizeEmuPadding[4], *m_SizeRealPadding[4], *m_SizeExtensionsPadding[4], *m_SizeBasicGeneral[4], *m_SizeBasicGeneralLeft[4], *m_SizeBasicGeneralRight[4], - *m_HorizControllers[4], *m_gCircle2Square[4], *m_HorizControllerTiltParent[4], *m_HorizControllerTilt[4], *m_TiltHoriz[4], + *m_HorizControllers[4], *m_gC2SDeadZone[4], *m_gCircle2Square[4], *m_gCircle2SquareVert[4], *m_gDeadZone[4], *m_HorizControllerTiltParent[4], *m_HorizControllerTilt[4], *m_TiltHoriz[4], *m_SizeAnalogLeft[4], *m_SizeAnalogLeftHorizX[4], *m_SizeAnalogLeftHorizY[4], *m_SizeAnalogRight[4], *m_SizeAnalogRightHorizX[4], *m_SizeAnalogRightHorizY[4], *m_SizeAnalogTriggerVertLeft[4], *m_SizeAnalogTriggerVertRight[4], *m_SizeAnalogTriggerHorizInput[4]; wxGridBagSizer *m_SizeAnalogTriggerHorizConfig[4], *m_SizeAnalogTriggerStatusBox[4], *m_TiltGrid[4], @@ -97,7 +98,7 @@ class ConfigDialog : public wxDialog wxButton *m_bAnalogLeftX[4], *m_bAnalogLeftY[4], *m_bAnalogRightX[4], *m_bAnalogRightY[4], *m_bAnalogTriggerL[4], *m_bAnalogTriggerR[4]; wxStaticText *m_tAnalogX[8], *m_tAnalogY[8], *m_TiltTextRoll[4], *m_TiltTextPitch[4], - *m_CheckC2SLabel[4], *m_TStatusLeftIn[4], *m_TStatusLeftOut[4], *m_TStatusRightIn[4], *m_TStatusRightOut[4], + *m_CheckC2SLabel[4], *m_ComboDeadZoneLabel[4], *m_TStatusLeftIn[4], *m_TStatusLeftOut[4], *m_TStatusRightIn[4], *m_TStatusRightOut[4], *m_TriggerStatusL[4], *m_TriggerStatusR[4], *m_TriggerStatusLx[4], *m_TriggerStatusRx[4], *m_tAnalogTriggerInput[4], *m_tAnalogTriggerL[4], *m_tAnalogTriggerR[4]; @@ -105,7 +106,7 @@ class ConfigDialog : public wxDialog wxCheckBox *m_SidewaysDPad[4], *m_WiimoteOnline[4], *m_WideScreen[4]; wxCheckBox *m_CheckC2S[4], *m_TiltInvertRoll[4], *m_TiltInvertPitch[4]; wxCheckBox *m_WiiMotionPlusConnected[4], *m_NunchuckConnected[4], *m_ClassicControllerConnected[4], *m_BalanceBoardConnected[4], *m_GuitarHeroGuitarConnected[4], *m_GuitarHeroWorldTourDrumsConnected[4]; - wxComboBox *m_TiltComboInput[4], *m_TiltComboRangeRoll[4], *m_TiltComboRangePitch[4], *m_Joyname[4], *m_ComboDiagonal[4], *m_TriggerType[4]; + wxComboBox *m_TiltComboInput[4], *m_TiltComboRangeRoll[4], *m_TiltComboRangePitch[4], *m_Joyname[4], *m_ComboDiagonal[4], *m_ComboDeadZone[4], *m_TriggerType[4]; // Real Wiimote settings wxCheckBox *m_ConnectRealWiimote[4], *m_UseRealWiimote[4], *m_UpdateMeters; @@ -114,7 +115,7 @@ class ConfigDialog : public wxDialog wxPanel *m_pLeftInStatus[4], *m_pLeftOutStatus[4], *m_pRightInStatus[4], *m_pRightOutStatus[4]; wxStaticBitmap *m_bmpSquareLeftIn[4], *m_bmpSquareLeftOut[4], *m_bmpSquareRightIn[4], *m_bmpSquareRightOut[4]; wxStaticBoxSizer *m_gAnalogLeft[4], *m_gAnalogRight[4], *m_gTrigger[4]; - wxBitmap CreateBitmapDot(), CreateBitmap(); + wxBitmap CreateBitmapDot(), CreateBitmap(), CreateBitmapDeadZone(int Radius), CreateBitmapClear(); wxButton * m_RecordButton[RECORDING_ROWS + 1]; wxChoice * m_RecordHotKey[RECORDING_ROWS + 1]; @@ -144,11 +145,12 @@ class ConfigDialog : public wxDialog IDTM_EXIT, IDTM_UPDATE, IDTM_SHUTDOWN, IDTM_UPDATE_ONCE, IDTM_BUTTON, IDTM_UPDATE_PAD, // Timer ID_NOTEBOOK, ID_CONTROLLERPAGE1, ID_CONTROLLERPAGE2, ID_CONTROLLERPAGE3, ID_CONTROLLERPAGE4, ID_PAGE_RECORDING, - - ID_SIDEWAYSDPAD, // Emulated + + // Emulated Wiimote + ID_SIDEWAYSDPAD, ID_WIDESCREEN, ID_NUNCHUCKCONNECTED, ID_CLASSICCONTROLLERCONNECTED, - IDC_WIMOTE_ON, IDC_JOYNAME, IDC_LEFT_C2S, IDCB_LEFT_DIAGONAL, + IDC_WIMOTE_ON, // Gamepad IDB_ANALOG_LEFT_X, IDB_ANALOG_LEFT_Y, @@ -160,6 +162,7 @@ class ConfigDialog : public wxDialog ID_TRIGGER_L, ID_TRIGGER_R, // Gamepad settings + IDC_JOYNAME, IDC_LEFT_C2S, IDCB_LEFT_DIAGONAL, IDCB_DEAD_ZONE, ID_TRIGGER_TYPE, ID_TILT_INPUT, ID_TILT_RANGE_ROLL, ID_TILT_RANGE_PITCH, ID_TILT_INVERT_ROLL, ID_TILT_INVERT_PITCH, // Real @@ -188,7 +191,7 @@ class ConfigDialog : public wxDialog void ToBlank(bool ToBlank = true); void PadGetStatus(); void DoSave(bool ChangePad = false, int Slot = -1); - void DoChangeJoystick(); void PadOpen(int Open); void PadClose(int Close); + void DoChangeJoystick(); void PadOpen(int Open); void PadClose(int Close); void DoChangeDeadZone(); // Configure buttons int GetButtonWaitingID, GetButtonWaitingTimer; diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp index 034959b94d..6759ce5e7e 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp @@ -74,6 +74,16 @@ void ConfigDialog::PadClose(int Close) // Close for slot 1, 2, 3 or 4 if (SDL_JoystickOpened(WiiMoteEmu::PadMapping[Close].ID)) SDL_JoystickClose(WiiMoteEmu::PadState[Close].joy); WiiMoteEmu::PadState[Close].joy = NULL; } + +void ConfigDialog::DoChangeDeadZone() +{ + float Rad = (float)WiiMoteEmu::PadMapping[Page].deadzone * ((float)BoxW / 100.0) * 0.5; + m_bmpDeadZoneLeftIn[Page]->SetBitmap(CreateBitmapClear()); + m_bmpDeadZoneLeftIn[Page]->SetSize(0, 0); + m_bmpDeadZoneLeftIn[Page]->SetBitmap(CreateBitmapDeadZone((int)Rad)); + m_bmpDeadZoneLeftIn[Page]->SetPosition(wxPoint(BoxW / 2 - (int)Rad, BoxH / 2 - (int)Rad)); + m_bmpDeadZoneLeftIn[Page]->Refresh(); +} ////////////////////////////////////// @@ -128,13 +138,13 @@ void ConfigDialog::UpdateGUIButtonMapping(int controller) // Update the deadzone and controller type controls m_TriggerType[controller]->SetSelection(WiiMoteEmu::PadMapping[controller].triggertype); - //m_Deadzone[controller]->SetSelection(PadMapping[controller].deadzone); + m_ComboDeadZone[controller]->SetSelection(WiiMoteEmu::PadMapping[controller].deadzone); m_ComboDiagonal[controller]->SetValue(wxString::FromAscii(WiiMoteEmu::PadMapping[controller].SDiagonal.c_str())); m_CheckC2S[controller]->SetValue(WiiMoteEmu::PadMapping[controller].bCircle2Square); m_TiltInvertRoll[controller]->SetValue(WiiMoteEmu::PadMapping[controller].bRollInvert); m_TiltInvertPitch[controller]->SetValue(WiiMoteEmu::PadMapping[controller].bPitchInvert); - //LogMsg("m_TriggerType[%i] = %i\n", controller, PadMapping[controller].triggertype); + //Console::Print("m_ComboDeadZone[%i] = %i\n", controller, WiiMoteEmu::PadMapping[controller].deadzone); } /* Populate the PadMapping array with the dialog items settings (for example @@ -152,12 +162,14 @@ void ConfigDialog::SaveButtonMapping(int controller, bool DontChangeId, int From // Replace "" with "-1" in the GUI controls ToBlank(false); - // Set enabled or disable status and other settings + // Set physical device Id if(!DontChangeId) WiiMoteEmu::PadMapping[controller].ID = m_Joyname[FromSlot]->GetSelection(); + // Set enabled or disable status if(FromSlot == controller) WiiMoteEmu::PadMapping[controller].enabled = true; //m_Joyattach[FromSlot]->GetValue(); // Only enable one + // Set other settings //WiiMoteEmu::PadMapping[controller].controllertype = m_ControlType[FromSlot]->GetSelection(); WiiMoteEmu::PadMapping[controller].triggertype = m_TriggerType[FromSlot]->GetSelection(); - //WiiMoteEmu::PadMapping[controller].deadzone = m_Deadzone[FromSlot]->GetSelection(); + WiiMoteEmu::PadMapping[controller].deadzone = m_ComboDeadZone[FromSlot]->GetSelection(); WiiMoteEmu::PadMapping[controller].SDiagonal = m_ComboDiagonal[FromSlot]->GetLabel().mb_str(); WiiMoteEmu::PadMapping[controller].bCircle2Square = m_CheckC2S[FromSlot]->IsChecked(); WiiMoteEmu::PadMapping[controller].bRollInvert = m_TiltInvertRoll[FromSlot]->IsChecked(); @@ -173,8 +185,8 @@ void ConfigDialog::SaveButtonMapping(int controller, bool DontChangeId, int From m_AnalogTriggerL[FromSlot]->GetValue().ToLong(&value); WiiMoteEmu::PadMapping[controller].Axis.Tl = value; m_AnalogTriggerR[FromSlot]->GetValue().ToLong(&value); WiiMoteEmu::PadMapping[controller].Axis.Tr = value; - //Console::Print("WiiMoteEmu::PadMapping[%i].bSquareToCircle = %i, m_CheckC2S[%i]->GetValue() = %i\n", - // controller, WiiMoteEmu::PadMapping[controller].bSquareToCircle, FromSlot, m_CheckC2S[FromSlot]->GetValue()); + //Console::Print("WiiMoteEmu::PadMapping[%i].deadzone = %i, m_ComboDeadZone[%i]->GetSelection() = %i\n", + // controller, WiiMoteEmu::PadMapping[controller].deadzone, FromSlot, m_ComboDeadZone[FromSlot]->GetSelection()); // Replace "-1" with "" ToBlank(); @@ -523,6 +535,13 @@ void ConfigDialog::PadGetStatus() //main_x = main_xy.at(0); //main_y = main_xy.at(1); } + // Check dead zone + float DeadZone = (float)WiiMoteEmu::PadMapping[Page].deadzone / 100.0; + if (InputCommon::IsDeadZone(DeadZone, main_x_after, main_y_after)) + { + main_x_after = 0; + main_y_after = 0; + } // ------------------------------------------- // Show the adjusted angles in the status box diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigRecording.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigRecording.cpp index 954a67151a..8dae8b6e3a 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigRecording.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigRecording.cpp @@ -374,7 +374,6 @@ void ConfigDialog::ConvertToString() int Time = (int)((m_vRecording.at(i).Time - m_vRecording.at(0).Time) * 1000); TmpTime += StringFromFormat("%05i", Time); if(i < (m_vRecording.size() - 1)) TmpTime += ","; - //Console::Print("Time: %f %i\n", m_vRecording.at(i).Time, Time); /* Break just short of the IniFile.cpp byte limit so that we don't crash file.Load() the next time. This limit should never be hit because of the recording limit below. I keep it here just in case. */ @@ -383,6 +382,9 @@ void ConfigDialog::ConvertToString() break; PanicAlert("Your recording was to long, the entire recording was not saved."); } + + // Debug + Console::Print("Saved: [%i / %i] %03i %03i %03i\n", i, m_vRecording.size(), m_vRecording.at(i).x, m_vRecording.at(i).y, m_vRecording.at(i).z); } // Recordings per second @@ -499,7 +501,7 @@ void ConfigDialog::DoRecordMovement(u8 _x, u8 _y, u8 _z, const u8 *_IR, int _IRB if (!m_bRecording) return; - //Console::Print("DoRecordMovement\n"); + //Console::Print("DoRecordMovement: %03i %03i %03i\n", _x, _y, _z); SRecording Tmp; Tmp.x = _x; diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuDynamics.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuDynamics.cpp index 3f5e2b4d37..e05dc5d6b3 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuDynamics.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuDynamics.cpp @@ -159,18 +159,21 @@ void PitchDegreeToAccelerometer(float _Roll, float _Pitch, u8 &_x, u8 &_y, u8 &_ ////////////////////////////////////////////////////////////////////////////////////////// // Accelerometer to roll and pitch angles // ŻŻŻŻŻŻŻŻŻŻŻŻŻ +float AccelerometerToG(float Current, float Neutral, float G) +{ + float _G = (Current - Neutral) / G; + return _G; +} + void PitchAccelerometerToDegree(u8 _x, u8 _y, u8 _z, int &_Roll, int &_Pitch, int &_RollAdj, int &_PitchAdj) { - /* find out how much it has to move to be 1g */ - float xg = (float)g_accel.cal_g.x; - float yg = (float)g_accel.cal_g.y; - float zg = (float)g_accel.cal_g.z; + // Definitions float Roll = 0, Pitch = 0; // Calculate how many g we are from the neutral - float x = ((float)_x - (float)g_accel.cal_zero.x) / xg; - float y = ((float)_y - (float)g_accel.cal_zero.y) / yg; - float z = ((float)_z - (float)g_accel.cal_zero.z) / zg; + float x = AccelerometerToG((float)_x, (float)g_accel.cal_zero.x, (float)g_accel.cal_g.x); + float y = AccelerometerToG((float)_y, (float)g_accel.cal_zero.y, (float)g_accel.cal_g.y); + float z = AccelerometerToG((float)_z, (float)g_accel.cal_zero.z, (float)g_accel.cal_g.z); // If it is over 1g then it is probably accelerating and may not reliable //if (abs(accel->x - ac->cal_zero.x) <= ac->cal_g.x) diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.h b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.h index b233118543..bd53fd307e 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.h +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.h @@ -54,6 +54,7 @@ bool Search_Devices(std::vector &_joyinfo, int &_N void GetJoyState(InputCommon::CONTROLLER_STATE_NEW &_PadState, InputCommon::CONTROLLER_MAPPING_NEW _PadMapping, int controller, int NumButtons); void PitchDegreeToAccelerometer(float _Roll, float _Pitch, u8 &_x, u8 &_y, u8 &_z); void PitchAccelerometerToDegree(u8 _x, u8 _y, u8 _z, int &_Roll, int &_Pitch, int&, int&); +float AccelerometerToG(float Current, float Neutral, float G); void TiltTest(u8 x, u8 y, u8 z); void Tilt(u8 &_x, u8 &_y, u8 &_z); void AdjustAngles(float &Roll, float &Pitch); diff --git a/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp b/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp index 4b5f9344b1..3658c0406d 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp @@ -116,6 +116,9 @@ bool RecordingPlayAccIR(u8 &_x, u8 &_y, u8 &_z, IRReportType &_IR, int Wm) if(g_RecordingCurrentTime[Wm] >= VRecording.at(g_RecordingPlaying[Wm]).Recording.at( VRecording.at(g_RecordingPlaying[Wm]).Recording.size() - 1).Time) + // Or if we are playing back all observations regardless of time + //g_RecordingPoint[Wm] = g_RecordingCounter[Wm]; + //if (g_RecordingPoint[Wm] >= VRecording.at(g_RecordingPlaying[Wm]).Recording.size()) { g_RecordingCounter[Wm] = 0; g_RecordingPlaying[Wm] = -1; @@ -125,24 +128,23 @@ bool RecordingPlayAccIR(u8 &_x, u8 &_y, u8 &_z, IRReportType &_IR, int Wm) return false; } - // Update values + // Update accelerometer values _x = VRecording.at(g_RecordingPlaying[Wm]).Recording.at(g_RecordingPoint[Wm]).x; _y = VRecording.at(g_RecordingPlaying[Wm]).Recording.at(g_RecordingPoint[Wm]).y; _z = VRecording.at(g_RecordingPlaying[Wm]).Recording.at(g_RecordingPoint[Wm]).z; + // Update IR values if(Wm == WM_RECORDING_IR) memcpy(&_IR, VRecording.at(g_RecordingPlaying[Wm]).Recording.at(g_RecordingPoint[Wm]).IR, IRBytes); - /**/ if (g_DebugAccelerometer) { - Console::ClearScreen(); - Console::Print("Current time: %f %f %i %i\n", - VRecording.at(g_RecordingPlaying[Wm]).Recording.at(g_RecordingPoint[Wm]).Time, g_RecordingCurrentTime[Wm], - VRecording.at(g_RecordingPlaying[Wm]).Recording.size(), g_RecordingPoint[Wm] + //Console::ClearScreen(); + Console::Print("Current time: [%i / %i] %f %f\n", + g_RecordingPoint[Wm], VRecording.at(g_RecordingPlaying[Wm]).Recording.size(), + VRecording.at(g_RecordingPlaying[Wm]).Recording.at(g_RecordingPoint[Wm]).Time, g_RecordingCurrentTime[Wm] ); Console::Print("Accel x, y, z: %03u %03u %03u\n", _x, _y, _z); } //Console::Print("Accel x, y, z: %03u %03u %03u\n", _x, _y, _z); - //Console::Print("Accel x, y, z: %02x %02x %02x\n", _x, _y, _z); g_RecordingCounter[Wm]++; @@ -324,8 +326,8 @@ void FillReportInfo(wm_core& _core) // For all functions u8 g_x, g_y, g_z, g_X, g_Y, g_Z; -// For the shake function -int shake = -1; +// For the shake function, 0 = Wiimote, 1 = Nunchuck +int Shake[] = {-1, -1}; // For the tilt function, the size of this list determines how fast Y returns to its neutral value std::vector yhist(15, 0); float KbDegree; @@ -334,32 +336,29 @@ std::vector yhist(15, 0); float KbDegree; // ------------------------------------------ // Single shake of Wiimote while holding it sideways (Wario Land pound ground) // --------------- -void SingleShake(u8 &_z, u8 &_y) +void SingleShake(u8 &_y, u8 &_z, int i) { #ifdef _WIN32 - if(GetAsyncKeyState('S')) + // Shake Wiimote with S, Nunchuck with D + if((i == 0 && GetAsyncKeyState('S')) || (i == 1 && GetAsyncKeyState('D'))) { _z = 0; _y = 0; - shake = 2; + Shake[i] = 2; } - else if(shake == 2) + else if(Shake[i] == 2) { - _z = 128; + // This works regardless of calibration, in Wario Land + _z = g_accel.cal_zero.z - 2; _y = 0; - shake = 1; + Shake[i] = 1; } - else if(shake == 1) + else if(Shake[i] == 1) { - _z = g_Z; - _y = g_Y; - shake = -1; - } - else // the default Z if nothing is pressed - { - _z = g_Z; + Shake[i] = -1; } #endif + //if (Shake[i] > -1) Console::Print("Shake: %i\n", Shake[i]); } @@ -385,6 +384,13 @@ void TiltWiimoteGamepad(float &Roll, float &Pitch) PadState[Page].Axis.Lx = main_xy.at(0); PadState[Page].Axis.Ly = main_xy.at(1); } + // Check dead zone + float DeadZone = (float)PadMapping[Page].deadzone / 100.0; + if (InputCommon::IsDeadZone(DeadZone, PadState[Page].Axis.Lx, PadState[Page].Axis.Ly)) + { + PadState[Page].Axis.Lx = 0; + PadState[Page].Axis.Ly = 0; + } // Convert the big values float Lx = (float)InputCommon::Pad_Convert(PadState[Page].Axis.Lx); @@ -464,10 +470,10 @@ void TiltWiimoteKeyboard(float &Roll, float &Pitch) // ----------------------------------- // Check for inactivity in the tilting, the Y value will be reset after ten inactive updates // ---------- + // Check for activity yhist[yhist.size() - 1] = ( GetAsyncKeyState('3') || GetAsyncKeyState('4') - || shake > 0 ); // Move all items back, and check if any of them are true @@ -496,6 +502,9 @@ void TiltWiimoteKeyboard(float &Roll, float &Pitch) // --------------- void Tilt(u8 &_x, u8 &_y, u8 &_z) { + // Ceck if it's on + if (g_Config.Trigger.Type == g_Config.TRIGGER_OFF) return; + // Set to zero float Roll = 0, Pitch = 0; @@ -517,7 +526,7 @@ void Tilt(u8 &_x, u8 &_y, u8 &_z) //Console::ClearScreen(); /*Console::Print("L:%2.1f R:%2.1f Lx:%2.1f Range:%2.1f Degree:%2.1f L:%i R:%i\n", Tl, Tr, Lx, Range, Degree, PadState[Page].Axis.Tl, PadState[Page].Axis.Tr);*/ - /**/Console::Print("Roll:%2.1f Pitch:%2.1f\n", Roll, Pitch); + /*Console::Print("Roll:%2.1f Pitch:%2.1f\n", Roll, Pitch);*/ } } @@ -564,10 +573,10 @@ void FillReportAcc(wm_accel& _acc) g_z = g_Z; // Shake the Wiimote - SingleShake(g_z, g_y); + SingleShake(g_y, g_z, 0); - // Tilt Wiimote - Tilt(g_x, g_y, g_z); + // Tilt Wiimote, allow the shake function to interrupt it + if (Shake[0] == -1) Tilt(g_x, g_y, g_z); // Write final values _acc.x = g_x; @@ -908,6 +917,9 @@ void FillReportExtension(wm_extension& _ext) } // --------------------- + // Shake the Wiimote + SingleShake(_ext.ay, _ext.az, 1); + // ------------------------------------ // The default joystick and button values unless we use them // -------------- diff --git a/Source/Plugins/Plugin_Wiimote/Src/ReadWiimote.cpp b/Source/Plugins/Plugin_Wiimote/Src/ReadWiimote.cpp index f4e39f71fd..c09d3ec2ed 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ReadWiimote.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ReadWiimote.cpp @@ -204,8 +204,8 @@ void handle_event(struct wiimote_t* wm) wxT("Current: %03u %03u %03u"), AccelX, AccelY, AccelZ)); if(frame->m_bRecording) - Console::Print("Wiiuse Recorded accel x, y, z: %03i %03i %03i\n", wm->accel.x, wm->accel.y, wm->accel.z); - //Console::Print("Wiiuse Recorded accel x, y, z: %02x %02x %02x\n", wm->accel.x, wm->accel.y, wm->accel.z); + Console::Print("Wiiuse Recorded accel x, y, z: %03i %03i %03i\n", AccelX, AccelY, AccelZ); + //Console::Print("Wiiuse Recorded accel x, y, z: %02x %02x %02x\n", AccelX, AccelY, AccelZ); } // Send the data to be saved diff --git a/Source/Plugins/Plugin_Wiimote/Src/main.cpp b/Source/Plugins/Plugin_Wiimote/Src/main.cpp index 758b69cccf..8c6394ba0b 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/main.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/main.cpp @@ -635,8 +635,8 @@ void ReadDebugging(bool Emu, const void* _pData, int Size) std::string RollPitch = StringFromFormat("%s %s %s %s", (Roll >= 0) ? StringFromFormat(" %03i", Roll).c_str() : StringFromFormat("%04i", Roll).c_str(), (Pitch >= 0) ? StringFromFormat(" %03i", Pitch).c_str() : StringFromFormat("%04i", Pitch).c_str(), - (RollAdj == Roll) ? "" : StringFromFormat("%i*", RollAdj).c_str(), - (PitchAdj == Pitch) ? "" : StringFromFormat("%i*", PitchAdj).c_str()); + (RollAdj == Roll) ? " " : StringFromFormat("%04i*", RollAdj).c_str(), + (PitchAdj == Pitch) ? " " : StringFromFormat("%04i*", PitchAdj).c_str()); // --------------------------------------------- // Test the angles to x, y, z values formula by calculating the values back and forth @@ -648,8 +648,17 @@ void ReadDebugging(bool Emu, const void* _pData, int Size) WiiMoteEmu::Tilt(x, y, z); WiiMoteEmu::TiltTest(x, y, z);*/ // ------------------------- + + // Show the number of g forces on the axes + float Gx = WiiMoteEmu::AccelerometerToG((float)data[4], (float)g_accel.cal_zero.x, (float)g_accel.cal_g.x); + float Gy = WiiMoteEmu::AccelerometerToG((float)data[5], (float)g_accel.cal_zero.y, (float)g_accel.cal_g.y); + float Gz = WiiMoteEmu::AccelerometerToG((float)data[6], (float)g_accel.cal_zero.z, (float)g_accel.cal_g.z); + std::string GForce = StringFromFormat("%s %s %s", + (Gx >= 0) ? StringFromFormat(" %i", (int)Gx).c_str() : StringFromFormat("%i", (int)Gx).c_str(), + (Gy >= 0) ? StringFromFormat(" %i", (int)Gy).c_str() : StringFromFormat("%i", (int)Gy).c_str(), + (Gz >= 0) ? StringFromFormat(" %i", (int)Gz).c_str() : StringFromFormat("%i", (int)Gz).c_str()); - Console::Print("Read[%s]: %s| %s\n", (Emu ? "Emu" : "Real"), TmpData.c_str(), RollPitch.c_str()); // No timestamp + Console::Print("Read[%s]: %s| %s | %s\n", (Emu ? "Emu" : "Real"), TmpData.c_str(), RollPitch.c_str(), GForce.c_str()); // No timestamp //Console::Print(" (%s): %s\n", Tm(true).c_str(), Temp.c_str()); // Timestamp }