From 3ad9b0a4665ed5c330e98412b2a828791482147b Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Sat, 18 Jul 2009 05:04:36 +0000 Subject: [PATCH] GH3 controller is now available to choose as an extension joystick works from a pad, but doesnt work from the keyboard, maybe because of incorrect calibration values? git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3827 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Plugins/Plugin_Wiimote/Src/Config.cpp | 2 + Source/Plugins/Plugin_Wiimote/Src/Config.h | 5 +- .../Plugin_Wiimote/Src/ConfigBasicDlg.cpp | 2 +- .../Plugin_Wiimote/Src/ConfigPadDlg.cpp | 14 ++- .../Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h | 4 +- Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp | 18 +++- .../Plugins/Plugin_Wiimote/Src/FillReport.cpp | 95 ++++++------------- .../Plugins/Plugin_Wiimote/Src/wiimote_hid.h | 2 - 8 files changed, 59 insertions(+), 83 deletions(-) diff --git a/Source/Plugins/Plugin_Wiimote/Src/Config.cpp b/Source/Plugins/Plugin_Wiimote/Src/Config.cpp index dfc06b6566..4d80df4ca5 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/Config.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/Config.cpp @@ -257,6 +257,7 @@ void Config::Load(bool ChangePad) iniFile.Get(SectionName, "CcTriggers", &ClassicController.TType, ClassicController.KEYBOARD); for (int x = 0; x < 23; x++) iniFile.Get(SectionName, ccControlNames[x], &WiiMoteEmu::PadMapping[i].Cc.keyForControls[x], ccDefaultControls[x]); + iniFile.Get(SectionName, "GH3Analog", &GH3Controller.AType, GH3Controller.ANALOG1); for (int x = 0; x < 14; x++) iniFile.Get(SectionName, gh3ControlNames[x], &WiiMoteEmu::PadMapping[i].GH3c.keyForControls[x], GH3DefaultControls[x]); @@ -359,6 +360,7 @@ void Config::Save(int Slot) for (int x = 0; x < 23; x++) iniFile.Set(SectionName, ccControlNames[x], WiiMoteEmu::PadMapping[i].Cc.keyForControls[x]); // GH3 + iniFile.Set(SectionName, "GH3Analog", GH3Controller.AType); for (int x = 0; x < 14; x++) iniFile.Set(SectionName, gh3ControlNames[x], WiiMoteEmu::PadMapping[i].GH3c.keyForControls[x]); diff --git a/Source/Plugins/Plugin_Wiimote/Src/Config.h b/Source/Plugins/Plugin_Wiimote/Src/Config.h index aac6c63d72..a3dcbbc8ff 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/Config.h +++ b/Source/Plugins/Plugin_Wiimote/Src/Config.h @@ -89,12 +89,11 @@ struct Config { enum EGH3Stick { - KEYBOARD, + // KEYBOARD, ANALOG1, ANALOG2 }; - int LType; // Analog Stick - int RType; + int AType; // Analog Stick int TType; // Whammy bar }; diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigBasicDlg.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigBasicDlg.cpp index a15a5fcb49..2bc7a9cb6d 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigBasicDlg.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigBasicDlg.cpp @@ -178,7 +178,7 @@ void WiimoteBasicConfigDialog::CreateGUIControls() arrayStringFor_extension.Add(wxT("None")); arrayStringFor_extension.Add(wxT("Nunchuck")); arrayStringFor_extension.Add(wxT("Classic Controller")); - //arrayStringFor_extension.Add(wxT("Guitar Hero 3 Guitar")); + arrayStringFor_extension.Add(wxT("Guitar Hero 3 Guitar")); //arrayStringFor_extension.Add(wxT("Guitar Hero World Tour Drums Connected")); // Prolly needs to be a separate plugin //arrayStringFor_extension.Add(wxT("Balance Board")); diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp index e728c710a0..88b3fecf97 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.cpp @@ -82,7 +82,7 @@ BEGIN_EVENT_TABLE(WiimotePadConfigDialog,wxDialog) EVT_BUTTON(IDB_GH3_PLUS, WiimotePadConfigDialog::OnButtonClick) EVT_BUTTON(IDB_GH3_MINUS, WiimotePadConfigDialog::OnButtonClick) // EVT_COMBOBOX(IDB_GH3_WHAMMY, WiimotePadConfigDialog::GeneralSettingsChanged) - EVT_COMBOBOX(IDCB_GH3_ANALOG_STICK, WiimotePadConfigDialog::GeneralSettingsChanged) + EVT_COMBOBOX(IDCB_GH3_ANALOG, WiimotePadConfigDialog::GeneralSettingsChanged) EVT_BUTTON(IDB_GH3_ANALOG_LEFT, WiimotePadConfigDialog::OnButtonClick) EVT_BUTTON(IDB_GH3_ANALOG_RIGHT, WiimotePadConfigDialog::OnButtonClick) EVT_BUTTON(IDB_GH3_ANALOG_UP, WiimotePadConfigDialog::OnButtonClick) @@ -844,9 +844,15 @@ void WiimotePadConfigDialog::CreatePadGUIControls() } else if(g_Config.iExtensionConnected == EXT_GUITARHERO3_CONTROLLER) { + // TODO: fix keyboard input for joystick use the nunchuck array str + wxArrayString tempArraySTR; + tempArraySTR.Add(wxString::FromAscii("Analog 1")); + tempArraySTR.Add(wxString::FromAscii("Analog 2")); + // Stick controls m_tGH3_Analog[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Analog joystick")); - m_GH3ComboAnalog[i] = new wxComboBox(m_Controller[i], IDCB_GH3_ANALOG_STICK, StrNunchuck[0], wxDefaultPosition, wxSize(100, -1), StrNunchuck, wxCB_READONLY); + m_GH3ComboAnalog[i] = new wxComboBox(m_Controller[i], IDCB_GH3_ANALOG, tempArraySTR[0], wxDefaultPosition, wxSize(100, -1), tempArraySTR, wxCB_READONLY); + m_GH3ComboAnalog[i]->SetSelection(g_Config.GH3Controller.AType); static const wxChar* gh3Text[] = { @@ -875,7 +881,6 @@ void WiimotePadConfigDialog::CreatePadGUIControls() if (IDB_GH3_WHAMMY <= x && x <= IDB_GH3_ANALOG_DOWN) m_Button_GH3[x - IDB_GH3_GREEN][i]->Disable(); } - m_GH3ComboAnalog[i]->Disable(); // Sizers m_sGH3_Analog[i] = new wxBoxSizer(wxHORIZONTAL); @@ -1015,6 +1020,9 @@ void WiimotePadConfigDialog::GeneralSettingsChanged(wxCommandEvent& event) case IDCB_CC_TRIGGERS: g_Config.ClassicController.TType = m_CcComboTriggers[Page]->GetSelection(); break; + case IDCB_GH3_ANALOG: + g_Config.GH3Controller.AType = m_GH3ComboAnalog[Page]->GetSelection(); + break; // These are defined in PadMapping and we can run the same function to update all of them case IDCB_LEFT_DIAGONAL: diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h b/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h index 2f9e5fbc5d..64967003bf 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigPadDlg.h @@ -197,8 +197,6 @@ class WiimotePadConfigDialog : public wxDialog ID_ANALOG_RIGHT_X, ID_ANALOG_RIGHT_Y, ID_TRIGGER_L, ID_TRIGGER_R, - IDCB_GH3_ANALOG_STICK, - // Wiimote IDS_WIDTH, IDS_HEIGHT, IDS_LEFT, IDS_TOP, IDB_WM_A, IDB_WM_B, @@ -235,7 +233,7 @@ class WiimotePadConfigDialog : public wxDialog IDB_GH3_MINUS, IDB_GH3_WHAMMY, IDB_GH3_ANALOG_LEFT, - IDB_GH3_ANALOG_UP, + IDB_GH3_ANALOG_UP, IDB_GH3_ANALOG_RIGHT, IDB_GH3_ANALOG_DOWN, IDB_GH3_STRUM_UP, diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp index 101948a338..e88b45caa5 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp @@ -344,7 +344,16 @@ void UpdateEeprom() WiiMoteEmu::g_RegExt[0x2a], WiiMoteEmu::g_RegExt[0x2d], WiiMoteEmu::g_RegExt[0x20], WiiMoteEmu::g_RegExt[0x21], WiiMoteEmu::g_RegExt[0x26]); } - +else if(g_Config.iExtensionConnected == EXT_GUITARHERO3_CONTROLLER) + { + // TODO get the correct values here + g_GH3Calibration.Lx.max = g_RegExt[0x20]; + g_GH3Calibration.Lx.min = g_RegExt[0x21]; + g_GH3Calibration.Lx.center = g_RegExt[0x22]; + g_GH3Calibration.Ly.max = g_RegExt[0x23]; + g_GH3Calibration.Ly.min = g_RegExt[0x24]; + g_GH3Calibration.Ly.center = g_RegExt[0x25]; + } } @@ -405,8 +414,9 @@ void SetDefaultExtensionRegistry() } else if(g_Config.iExtensionConnected == EXT_GUITARHERO3_CONTROLLER) { - // memcpy(g_RegExt + 0x20, classic_calibration, sizeof(classic_calibration)); - // memcpy(g_RegExt + 0x30, classic_calibration, sizeof(classic_calibration)); + // TODO get the correct values here + memcpy(g_RegExt + 0x20, classic_calibration, sizeof(classic_calibration)); + memcpy(g_RegExt + 0x30, classic_calibration, sizeof(classic_calibration)); memcpy(g_RegExt + 0xfa, gh3glp_id, sizeof(gh3glp_id)); } @@ -718,4 +728,4 @@ void Update() } -} // end of namespace +} // end of namespace \ No newline at end of file diff --git a/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp b/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp index a5a3ecb941..3d517f51bd 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp @@ -1272,14 +1272,11 @@ void FillReportClassicExtension(wm_classic_extension& _ext) void FillReportGuitarHero3Extension(wm_GH3_extension& _ext) { - //_ext.SX : 6; - //_ext.SY : 6; // u8 TB : 5; // not used in GH3 // u8 WB : 5; u8 SX = g_GH3Calibration.Lx.center, SY = g_GH3Calibration.Ly.center; - _ext.pad1 = 3; _ext.pad2 = 3; _ext.pad3 = 0; @@ -1294,35 +1291,21 @@ void FillReportGuitarHero3Extension(wm_GH3_extension& _ext) _ext.Minus = 1; _ext.StrumDown = 1; _ext.StrumUp = 1; - _ext.Yellow = 0; - _ext.Green = 0; - _ext.Blue = 0; - _ext.Red = 0; - _ext.Orange = 0; + _ext.Yellow = 1; + _ext.Green = 1; + _ext.Blue = 1; + _ext.Red = 1; + _ext.Orange = 1; // Check that Dolphin is in focus if (IsFocus()) { - /* Left and right analog sticks and analog triggers - - u8 Lx : 6; // byte 0 - u8 Rx : 2; - u8 Ly : 6; // byte 1 - u8 Rx2 : 2; - u8 Ry : 5; // byte 2 - u8 lT : 2; - u8 Rx3 : 1; - u8 rT : 5; // byte 3 - u8 lT2 : 3; - - We use a 200 range (28 to 228) for the left analog stick and a 176 range - (40 to 216) for the right analog stick to match our calibration values - in classic_calibration - */ // Update the left analog stick - if (g_Config.GH3Controller.LType == g_Config.GH3Controller.KEYBOARD) + // TODO: Fix using the keyboard for the joystick + // only seems to work if there is a PanicAlert after setting the value +/* if (g_Config.GH3Controller.AType == g_Config.GH3Controller.KEYBOARD) { if(IsKey(g_GH3Ext.Al)) // Left analog left _ext.SX = g_GH3Calibration.Lx.min; @@ -1335,74 +1318,52 @@ void FillReportGuitarHero3Extension(wm_GH3_extension& _ext) } else - { +*/ { // Get adjusted pad state values - int _Sx, _Sy, - _Rx, _Ry, _Tl, _Tr; // Not Yet used - PadStateAdjustments(_Sx, _Sy, _Rx, _Ry, _Tl, _Tr); + int _Lx, _Ly, _Rx, _Ry, + _Tl, _Tr; // Not used + PadStateAdjustments(_Lx, _Ly, _Rx, _Ry, _Tl, _Tr); // The Y-axis is inverted - _Sy = 0xff - _Sy; - //_Ry = 0xff - _Ry; + _Ly = 0xff - _Ly; + _Ry = 0xff - _Ry; - /* This is if we are also using a real Classic Controller that we are sharing the calibration with. - It's not needed if we are using our default values. We adjust the values to the configured range. - - Status: Not added, we are not currently sharing the calibration with the real Classic Controller - */ - if (g_Config.GH3Controller.LType == g_Config.GH3Controller.ANALOG1) + if (g_Config.GH3Controller.AType == g_Config.GH3Controller.ANALOG1) { - SX = _Sx; - SY = _Sy; + SX = _Lx; + SY = _Ly; } else // ANALOG2 { - // Lx = _Rx; - // Ly = _Ry; + SX = _Rx; + SX = _Ry; } } - if(IsKey(g_GH3Ext.StrumUp)) _ext.StrumUp = 0x00; // Strum Up - if(IsKey(g_GH3Ext.StrumDown)) _ext.StrumDown= 0x00; // Strum Down + if(IsKey(g_GH3Ext.StrumUp)) _ext.StrumUp = 0; // Strum Up + if(IsKey(g_GH3Ext.StrumDown)) _ext.StrumDown= 0; // Strum Down if(IsKey(g_GH3Ext.Plus)) - _ext.Plus = 0x00; + _ext.Plus = 0; if(IsKey(g_GH3Ext.Minus)) - _ext.Minus = 0x00; + _ext.Minus = 0; if(IsKey(g_GH3Ext.Yellow)) - _ext.Yellow = 0x01; + _ext.Yellow = 0; if(IsKey(g_GH3Ext.Green)) - _ext.Green = 0x01; + _ext.Green = 0; if(IsKey(g_GH3Ext.Blue)) - _ext.Blue = 0x01; + _ext.Blue = 0; if(IsKey(g_GH3Ext.Red)) - _ext.Red = 0x01; + _ext.Red = 0; if(IsKey(g_GH3Ext.Orange)) - _ext.Orange = 0x01; + _ext.Orange = 0; } // Convert data for reporting _ext.SX = (SX >> 2); _ext.SY = (SY >> 2); - - -/* // 5 bit to 1 bit - _ext.Rx = (Rx >> 3) & 0x01; - // 5 bit to the next 2 bit - _ext.Rx2 = ((Rx >> 3) >> 1) & 0x03; - // 5 bit to the next 2 bit - _ext.Rx3 = ((Rx >> 3) >> 3) & 0x03; - _ext.Ry = (Ry >> 3); - - // 5 bit to 3 bit - _ext.lT = (lT >> 3) & 0x07; - // 5 bit to the highest two bits - _ext.lT2 = (lT >> 3) >> 3; - _ext.rT = (rT >> 3); -*/ - /* Here we encrypt the report */ // Create a temporary storage for the data diff --git a/Source/Plugins/Plugin_Wiimote/Src/wiimote_hid.h b/Source/Plugins/Plugin_Wiimote/Src/wiimote_hid.h index 243d951b02..0a7a0e37b4 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/wiimote_hid.h +++ b/Source/Plugins/Plugin_Wiimote/Src/wiimote_hid.h @@ -357,8 +357,6 @@ struct gh3_cal { nu_js Lx; nu_js Ly; - nu_js Rx; - nu_js Ry; }; #pragma pack(pop)