From 802504dd188e037186f6c2b68d3b44a7784bda4a Mon Sep 17 00:00:00 2001 From: ayuanx Date: Thu, 28 Jan 2010 03:29:49 +0000 Subject: [PATCH] PadSimple is out of phase. Thanks to glennricster for testing GCPad on Linux. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4976 8ced0084-cf51-0410-be5f-012b33b47a6e --- SConstruct | 1 - Source/Dolphin.sln | 23 - .../Plugin_PadSimple/Plugin_PadSimple.vcproj | 776 -------------- .../Plugin_PadSimple/Src/GUI/ConfigDlg.cpp | 555 ---------- .../Plugin_PadSimple/Src/GUI/ConfigDlg.h | 149 --- .../Plugin_PadSimple/Src/PadSimple.cpp | 993 ------------------ .../Plugins/Plugin_PadSimple/Src/PadSimple.h | 117 --- .../Plugins/Plugin_PadSimple/Src/SConscript | 39 - .../Plugins/Plugin_PadSimple/Src/stdafx.cpp | 18 - Source/Plugins/Plugin_PadSimple/Src/stdafx.h | 34 - 10 files changed, 2705 deletions(-) delete mode 100644 Source/Plugins/Plugin_PadSimple/Plugin_PadSimple.vcproj delete mode 100644 Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.cpp delete mode 100644 Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.h delete mode 100644 Source/Plugins/Plugin_PadSimple/Src/PadSimple.cpp delete mode 100644 Source/Plugins/Plugin_PadSimple/Src/PadSimple.h delete mode 100644 Source/Plugins/Plugin_PadSimple/Src/SConscript delete mode 100644 Source/Plugins/Plugin_PadSimple/Src/stdafx.cpp delete mode 100644 Source/Plugins/Plugin_PadSimple/Src/stdafx.h diff --git a/SConstruct b/SConstruct index 927cb14c29..bc7686a48d 100644 --- a/SConstruct +++ b/SConstruct @@ -80,7 +80,6 @@ dirs = [ 'Source/Plugins/Plugin_VideoSoftware/Src', 'Source/Plugins/Plugin_DSP_HLE/Src', 'Source/Plugins/Plugin_DSP_LLE/Src', - 'Source/Plugins/Plugin_PadSimple/Src', 'Source/Plugins/Plugin_GCPad/Src', 'Source/Plugins/Plugin_Wiimote/Src', 'Source/Core/DolphinWX/Src', diff --git a/Source/Dolphin.sln b/Source/Dolphin.sln index ef8a0f49b2..d272306500 100644 --- a/Source/Dolphin.sln +++ b/Source/Dolphin.sln @@ -20,16 +20,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_VideoDX9", "Plugins\ {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_PadSimple", "Plugins\Plugin_PadSimple\Plugin_PadSimple.vcproj", "{9A183B48-ECC2-4121-876A-9B3793686073}" - ProjectSection(ProjectDependencies) = postProject - {C7E5D50A-2916-464B-86A7-E10B3CC88ADA} = {C7E5D50A-2916-464B-86A7-E10B3CC88ADA} - {05C75041-D67D-4903-A362-8395A7B35C75} = {05C75041-D67D-4903-A362-8395A7B35C75} - {11F55366-12EC-4C44-A8CB-1D4E315D61ED} = {11F55366-12EC-4C44-A8CB-1D4E315D61ED} - {0E231FB1-F3C9-4724-ACCB-DE8BCB3C089E} = {0E231FB1-F3C9-4724-ACCB-DE8BCB3C089E} - {1C8436C9-DBAF-42BE-83BC-CF3EC9175ABE} = {1C8436C9-DBAF-42BE-83BC-CF3EC9175ABE} - {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Bochs_disasm", "..\Externals\Bochs_disasm\Bochs_disasm.vcproj", "{29C2ABC1-ADA5-42CD-A5FC-96022D52A510}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\Externals\zlib\zlib.vcproj", "{3E03C179-8251-46E4-81F4-466F114BAC63}" @@ -61,7 +51,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Dolphin", "Core\DolphinWX\D {D6E56527-BBB9-4EAD-A6EC-49D4BF6AFCD8} = {D6E56527-BBB9-4EAD-A6EC-49D4BF6AFCD8} {8D612734-FAA5-4B8A-804F-4DEA2367D495} = {8D612734-FAA5-4B8A-804F-4DEA2367D495} {05C75041-D67D-4903-A362-8395A7B35C75} = {05C75041-D67D-4903-A362-8395A7B35C75} - {9A183B48-ECC2-4121-876A-9B3793686073} = {9A183B48-ECC2-4121-876A-9B3793686073} {636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18} = {636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18} {33546D62-7F34-4EA6-A88E-D538B36E16BF} = {33546D62-7F34-4EA6-A88E-D538B36E16BF} {11F55366-12EC-4C44-A8CB-1D4E315D61ED} = {11F55366-12EC-4C44-A8CB-1D4E315D61ED} @@ -237,18 +226,6 @@ Global {636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18}.Release|Win32.Build.0 = Release|Win32 {636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18}.Release|x64.ActiveCfg = Release|x64 {636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18}.Release|x64.Build.0 = Release|x64 - {9A183B48-ECC2-4121-876A-9B3793686073}.Debug|Win32.ActiveCfg = Debug|Win32 - {9A183B48-ECC2-4121-876A-9B3793686073}.Debug|Win32.Build.0 = Debug|Win32 - {9A183B48-ECC2-4121-876A-9B3793686073}.Debug|x64.ActiveCfg = Debug|x64 - {9A183B48-ECC2-4121-876A-9B3793686073}.Debug|x64.Build.0 = Debug|x64 - {9A183B48-ECC2-4121-876A-9B3793686073}.DebugFast|Win32.ActiveCfg = DebugFast|Win32 - {9A183B48-ECC2-4121-876A-9B3793686073}.DebugFast|Win32.Build.0 = DebugFast|Win32 - {9A183B48-ECC2-4121-876A-9B3793686073}.DebugFast|x64.ActiveCfg = DebugFast|x64 - {9A183B48-ECC2-4121-876A-9B3793686073}.DebugFast|x64.Build.0 = DebugFast|x64 - {9A183B48-ECC2-4121-876A-9B3793686073}.Release|Win32.ActiveCfg = Release|Win32 - {9A183B48-ECC2-4121-876A-9B3793686073}.Release|Win32.Build.0 = Release|Win32 - {9A183B48-ECC2-4121-876A-9B3793686073}.Release|x64.ActiveCfg = Release|x64 - {9A183B48-ECC2-4121-876A-9B3793686073}.Release|x64.Build.0 = Release|x64 {29C2ABC1-ADA5-42CD-A5FC-96022D52A510}.Debug|Win32.ActiveCfg = Debug|Win32 {29C2ABC1-ADA5-42CD-A5FC-96022D52A510}.Debug|Win32.Build.0 = Debug|Win32 {29C2ABC1-ADA5-42CD-A5FC-96022D52A510}.Debug|x64.ActiveCfg = Debug|x64 diff --git a/Source/Plugins/Plugin_PadSimple/Plugin_PadSimple.vcproj b/Source/Plugins/Plugin_PadSimple/Plugin_PadSimple.vcproj deleted file mode 100644 index 274b84c586..0000000000 --- a/Source/Plugins/Plugin_PadSimple/Plugin_PadSimple.vcproj +++ /dev/null @@ -1,776 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.cpp b/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.cpp deleted file mode 100644 index 7f37e04039..0000000000 --- a/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.cpp +++ /dev/null @@ -1,555 +0,0 @@ -// Copyright (C) 2003 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - -#include - -#include "Common.h" -#include "ConfigDlg.h" -#include "../PadSimple.h" - -#ifdef _WIN32 -#include "XInput.h" -#include "../../../../Core/InputCommon/Src/DirectInputBase.h" // Core - -DInput m_dinput; -#endif - -BEGIN_EVENT_TABLE(PADConfigDialogSimple,wxDialog) - EVT_SHOW(PADConfigDialogSimple::OnShow) - EVT_CLOSE(PADConfigDialogSimple::OnClose) - EVT_BUTTON(ID_CLOSE,PADConfigDialogSimple::OnCloseClick) - EVT_BUTTON(ID_PAD_ABOUT,PADConfigDialogSimple::DllAbout) - - EVT_CHECKBOX(ID_X360PAD,PADConfigDialogSimple::ControllerSettingsChanged) - EVT_CHOICE(ID_X360PAD_CHOICE,PADConfigDialogSimple::ControllerSettingsChanged) - EVT_CHECKBOX(ID_RUMBLE,PADConfigDialogSimple::ControllerSettingsChanged) - EVT_CHECKBOX(ID_DISABLE,PADConfigDialogSimple::ControllerSettingsChanged) - - // Input recording -#ifdef RERECORDING - EVT_CHECKBOX(ID_RECORDING,PADConfigDialogSimple::ControllerSettingsChanged) - EVT_CHECKBOX(ID_PLAYBACK,PADConfigDialogSimple::ControllerSettingsChanged) - EVT_BUTTON(ID_SAVE_RECORDING,PADConfigDialogSimple::ControllerSettingsChanged) -#endif - - EVT_BUTTON(CTL_A, PADConfigDialogSimple::OnButtonClick) - EVT_BUTTON(CTL_B, PADConfigDialogSimple::OnButtonClick) - EVT_BUTTON(CTL_X, PADConfigDialogSimple::OnButtonClick) - EVT_BUTTON(CTL_Y, PADConfigDialogSimple::OnButtonClick) - EVT_BUTTON(CTL_Z, PADConfigDialogSimple::OnButtonClick) - EVT_BUTTON(CTL_START, PADConfigDialogSimple::OnButtonClick) - EVT_BUTTON(CTL_L, PADConfigDialogSimple::OnButtonClick) - EVT_BUTTON(CTL_R, PADConfigDialogSimple::OnButtonClick) - EVT_BUTTON(CTL_L_SEMI, PADConfigDialogSimple::OnButtonClick) - EVT_BUTTON(CTL_R_SEMI, PADConfigDialogSimple::OnButtonClick) - EVT_SLIDER(ID_TRIGGER_SEMIVALUE, PADConfigDialogSimple::ControllerSettingsChanged) - EVT_BUTTON(CTL_MAINUP, PADConfigDialogSimple::OnButtonClick) - EVT_BUTTON(CTL_MAINDOWN, PADConfigDialogSimple::OnButtonClick) - EVT_BUTTON(CTL_MAINLEFT, PADConfigDialogSimple::OnButtonClick) - EVT_BUTTON(CTL_MAINRIGHT, PADConfigDialogSimple::OnButtonClick) - EVT_BUTTON(CTL_MAIN_SEMI, PADConfigDialogSimple::OnButtonClick) - EVT_SLIDER(ID_MAIN_SEMIVALUE, PADConfigDialogSimple::ControllerSettingsChanged) - EVT_BUTTON(CTL_SUBUP, PADConfigDialogSimple::OnButtonClick) - EVT_BUTTON(CTL_SUBDOWN, PADConfigDialogSimple::OnButtonClick) - EVT_BUTTON(CTL_SUBLEFT, PADConfigDialogSimple::OnButtonClick) - EVT_SLIDER(ID_SUB_SEMIVALUE, PADConfigDialogSimple::ControllerSettingsChanged) - EVT_BUTTON(CTL_SUBRIGHT, PADConfigDialogSimple::OnButtonClick) - EVT_BUTTON(CTL_SUB_SEMI, PADConfigDialogSimple::OnButtonClick) - EVT_BUTTON(CTL_DPADUP, PADConfigDialogSimple::OnButtonClick) - EVT_BUTTON(CTL_DPADDOWN, PADConfigDialogSimple::OnButtonClick) - EVT_BUTTON(CTL_DPADLEFT, PADConfigDialogSimple::OnButtonClick) - EVT_BUTTON(CTL_DPADRIGHT, PADConfigDialogSimple::OnButtonClick) -END_EVENT_TABLE() - -PADConfigDialogSimple::PADConfigDialogSimple(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style) -: wxDialog(parent, id, title, position, size, style) -{ - ClickedButton = NULL; - CreateGUIControls(); - Fit(); - - // Connect keydown to the window - wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN, - wxKeyEventHandler(PADConfigDialogSimple::OnKeyDown), - (wxObject*)NULL, this); -} - -PADConfigDialogSimple::~PADConfigDialogSimple() -{ -} - -// Create input button controls -// ------------------- -inline void AddControl(wxPanel *pan, wxButton **button, - wxStaticBoxSizer *sizer, const char *name, int ctl, int controller) -{ - wxBoxSizer *hButton = new wxBoxSizer(wxHORIZONTAL); - char keyStr[10] = {0}; - - // Add the label - hButton->Add(new wxStaticText(pan, 0, wxString::FromAscii(name), - wxDefaultPosition, wxDefaultSize), 0, - wxALIGN_CENTER_VERTICAL|wxALL); - - // Give it the mapped key name -#ifdef _WIN32 - DInput::DIKToString(pad[controller].keyForControl[ctl], keyStr); -#elif defined(HAVE_X11) && HAVE_X11 - InputCommon::XKeyToString(pad[controller].keyForControl[ctl], keyStr); -#endif - - // Add the button to its sizer - *button = new wxButton(pan, ctl, wxString::FromAscii(keyStr), - wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS); - hButton->Add(*button, 0, wxALIGN_RIGHT|wxALL); - sizer->Add(hButton, 0, wxALIGN_RIGHT|wxALL); -} - -// Create input slider controls -// ------------------- -inline void PADConfigDialogSimple::AddSlider(wxPanel *pan, wxSlider **slider, - wxStaticBoxSizer *sizer, const char *name, int ctl, int controller) -{ - wxBoxSizer *hSlider = new wxBoxSizer(wxHORIZONTAL); - int semivalue, maxvalue; - std::stringstream ss; - - // Add the label - hSlider->Add(new wxStaticText(pan, 0, wxString::FromAscii(name), - wxDefaultPosition, wxDefaultSize), 0, - wxALIGN_CENTER_VERTICAL|wxALL); - - // Do everything else - switch (ctl) - { - case ID_TRIGGER_SEMIVALUE: - semivalue = pad[controller].Trigger_semivalue; - maxvalue = TRIGGER_FULL; - // Add the slider to its sizer - *slider = new wxSlider(pan, ctl, semivalue, 0, maxvalue, wxDefaultPosition, wxSize(100,-1)); - (**slider).SetPageSize(32); - hSlider->Add(*slider, 0, wxALIGN_RIGHT|wxALL); - sizer->Add(hSlider, 0, wxALIGN_RIGHT|wxALL); - // Add numeric value label to sizer - ss << pad[controller].Trigger_semivalue; - m_Trigger_SemiValue_Label[controller] = new wxStaticText(pan, 0, - wxString::FromAscii( ss.str().c_str() ), wxDefaultPosition, wxSize(25, -1)); - hSlider->Add(m_Trigger_SemiValue_Label[controller], - 0, wxALIGN_CENTER_VERTICAL|wxALL); - break; - case ID_MAIN_SEMIVALUE: - semivalue = pad[controller].Main_stick_semivalue; - maxvalue = STICK_FULL; - // Add the slider to its sizer - *slider = new wxSlider(pan, ctl, semivalue, 0, maxvalue, wxDefaultPosition, wxSize(100, -1)); - (**slider).SetPageSize(10); - hSlider->Add(*slider, 0, wxALIGN_RIGHT|wxALL); - sizer->Add(hSlider, 0, wxALIGN_RIGHT|wxALL); - // Add numeric value label to sizer - ss << pad[controller].Main_stick_semivalue; - m_Stick_SemiValue_Label[controller] = new wxStaticText(pan, 0, - wxString::FromAscii( ss.str().c_str() ), wxDefaultPosition, wxSize(25, -1)); - hSlider->Add(m_Stick_SemiValue_Label[controller], - 0, wxALIGN_CENTER_VERTICAL|wxALL); - break; - case ID_SUB_SEMIVALUE: - semivalue = pad[controller].Sub_stick_semivalue; - maxvalue = STICK_FULL; - // Add the slider to its sizer - *slider = new wxSlider(pan, ctl, semivalue, 0, maxvalue, wxDefaultPosition, wxSize(100,-1)); - (**slider).SetPageSize(10); - hSlider->Add(*slider, 0, wxALIGN_RIGHT|wxALL); - sizer->Add(hSlider, 0, wxALIGN_RIGHT|wxALL); - // Add numeric value label to sizer - ss << pad[controller].Sub_stick_semivalue; - m_CStick_SemiValue_Label[controller] = new wxStaticText(pan, 0, - wxString::FromAscii( ss.str().c_str() ), wxDefaultPosition, wxSize(25, -1)); - hSlider->Add(m_CStick_SemiValue_Label[controller], - 0, wxALIGN_CENTER_VERTICAL|wxALL); - break; - } -} - -void PADConfigDialogSimple::CreateGUIControls() -{ - // Notebook - m_Notebook = new wxNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize); - - // Controller pages - m_Controller[0] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE1, wxDefaultPosition, wxDefaultSize); - m_Notebook->AddPage(m_Controller[0], wxT("Controller 1")); - m_Controller[1] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE2, wxDefaultPosition, wxDefaultSize); - m_Notebook->AddPage(m_Controller[1], wxT("Controller 2")); - m_Controller[2] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE3, wxDefaultPosition, wxDefaultSize); - m_Notebook->AddPage(m_Controller[2], wxT("Controller 3")); - m_Controller[3] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE4, wxDefaultPosition, wxDefaultSize); - m_Notebook->AddPage(m_Controller[3], wxT("Controller 4")); - - // Standard buttons - m_Close = new wxButton(this, ID_CLOSE, wxT("Close"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - m_About = new wxButton(this, ID_PAD_ABOUT, wxT("About"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - - // Put notebook and standard buttons in sizers - wxBoxSizer* sSButtons; - sSButtons = new wxBoxSizer(wxHORIZONTAL); - sSButtons->Add(m_About,0,wxALL, 5); - sSButtons->Add(0, 0, 1, wxEXPAND, 5); - sSButtons->Add(m_Close, 0, wxALL, 5); - - wxBoxSizer* sMain; - sMain = new wxBoxSizer(wxVERTICAL); - sMain->Add(m_Notebook, 1, wxEXPAND|wxALL, 5); - sMain->Add(sSButtons, 0, wxEXPAND, 5); - - this->SetSizer(sMain); - this->Layout(); - -#ifdef _WIN32 - // Add connected XPads - for (int x = 0; x < 4; x++) - { - XINPUT_STATE xstate; - DWORD xresult = XInputGetState(x, &xstate); - - if (xresult == ERROR_SUCCESS) - { - arrayStringFor_X360Pad.Add(wxString::Format(wxT("%i"), x+1)); - } - } -#endif - - for(int i = 0; i < 4; i++) - { - // -------------------------------------------------------------------- - // Settings - // ----------------------------- - // Main horizontal container - sDevice[i] = new wxBoxSizer(wxHORIZONTAL); - - sbDevice[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Controller Settings")); - m_Disable[i] = new wxCheckBox(m_Controller[i], ID_DISABLE, wxT("Disable when Dolphin is not in focus"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - sbDevice[i]->Add(m_Disable[i], 0, wxEXPAND|wxALL, 1); - -#ifdef _WIN32 - m_SizeXInput[i] = new wxStaticBoxSizer(wxHORIZONTAL, m_Controller[i], wxT("XInput Pad")); - m_X360Pad[i] = new wxCheckBox(m_Controller[i], ID_X360PAD, wxT("Enable X360Pad"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - m_X360PadC[i] = new wxChoice(m_Controller[i], ID_X360PAD_CHOICE, wxDefaultPosition, wxDefaultSize, arrayStringFor_X360Pad, 0, wxDefaultValidator); - m_Rumble[i] = new wxCheckBox(m_Controller[i], ID_RUMBLE, wxT("Enable rumble"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - - m_SizeXInput[i]->Add(m_X360Pad[i], 0, wxEXPAND | wxALL, 1); - m_SizeXInput[i]->Add(m_X360PadC[i], 0, wxEXPAND | wxALL, 1); - m_SizeXInput[i]->Add(m_Rumble[i], 0, wxEXPAND | wxALL, 1); -#endif - // Set values - m_Disable[i]->SetValue(pad[i].bDisable); - -#ifdef _WIN32 - // Check if any XInput pad was found - if (arrayStringFor_X360Pad.IsEmpty()) - { - m_X360Pad[i]->SetLabel(wxT("Enable X360Pad - No pad connected")); - m_X360Pad[i]->SetValue(false); - m_X360Pad[i]->Enable(false); - pad[i].bEnableXPad = false; - m_X360PadC[i]->Hide(); - m_Rumble[i]->Hide(); - } - else - { - m_X360Pad[i]->SetValue(pad[i].bEnableXPad); - m_X360PadC[i]->SetSelection(pad[i].XPadPlayer); - m_X360PadC[i]->Enable(m_X360Pad[i]->IsChecked()); - m_Rumble[i]->SetValue(pad[i].bRumble); - m_Rumble[i]->Enable(m_X360Pad[i]->IsChecked()); - } -#endif - - // Sizers - sDevice[i]->Add(sbDevice[i], 0, wxEXPAND | wxALL, 1); - //sDevice[i]->AddStretchSpacer(); -#ifdef _WIN32 - sDevice[i]->Add(m_SizeXInput[i], 0, wxEXPAND | wxALL, 1); -#endif - // ----------------------------------- - - - - // Rerecording - // --------- -#ifdef RERECORDING - // Create controls - m_SizeRecording[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Input Recording")); - m_CheckRecording[i] = new wxCheckBox(m_Controller[i], ID_RECORDING, wxT("Record input")); - m_CheckPlayback[i] = new wxCheckBox(m_Controller[i], ID_PLAYBACK, wxT("Play back input")); - m_BtnSaveRecording[i] = new wxButton(m_Controller[i], ID_SAVE_RECORDING, wxT("Save recording"), wxDefaultPosition, wxDefaultSize); - - // Tool tips - m_CheckRecording[i]->SetToolTip(wxT("Your recording will be saved to pad-record.bin in the Dolphin dir when you stop the game")); - m_CheckPlayback[i]->SetToolTip(wxT("Play back the pad-record.bin file from the Dolphin dir")); - m_BtnSaveRecording[i]->SetToolTip(wxT( - "This will save the current recording to pad-record.bin. Your recording will\n" - "also be automatically saved every 60 * 10 frames. And when you shut down the\n" - "game.")); - - // Sizers - m_SizeRecording[i]->Add(m_CheckRecording[i], 0, wxEXPAND | wxALL, 1); - m_SizeRecording[i]->Add(m_CheckPlayback[i], 0, wxEXPAND | wxALL, 1); - m_SizeRecording[i]->Add(m_BtnSaveRecording[i], 0, wxEXPAND | wxALL, 1); - - // Only enable these options for pad 0 - m_CheckRecording[i]->Enable(false); m_CheckRecording[0]->Enable(true); - m_CheckPlayback[i]->Enable(false); m_CheckPlayback[0]->Enable(true); - m_BtnSaveRecording[i]->Enable(false); m_BtnSaveRecording[0]->Enable(true); - // Don't allow saving when we are not recording - m_BtnSaveRecording[i]->Enable(g_EmulatorRunning && pad[0].bRecording); - sDevice[i]->Add(m_SizeRecording[i], 0, wxEXPAND | wxALL, 1); - - // Set values - m_CheckRecording[0]->SetValue(pad[0].bRecording); - m_CheckPlayback[0]->SetValue(pad[0].bPlayback); - - //DEBUG_LOG(CONSOLE, "m_CheckRecording: %i\n", pad[0].bRecording, pad[0].bPlayback); -#endif - - - - // -------------------------------------------------------------------- - // Buttons - // ----------------------------- - sButtons[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Buttons")); - - AddControl(m_Controller[i], &(m_ButtonA[i]), sButtons[i], "A: ", CTL_A, i); - AddControl(m_Controller[i], &(m_ButtonB[i]), sButtons[i], "B: ", CTL_B, i); - AddControl(m_Controller[i], &(m_ButtonX[i]), sButtons[i], "X: ", CTL_X, i); - AddControl(m_Controller[i], &(m_ButtonY[i]), sButtons[i], "Y: ", CTL_Y, i); - AddControl(m_Controller[i], &(m_ButtonZ[i]), sButtons[i], "Z: ", CTL_Z, i); - AddControl(m_Controller[i], &(m_ButtonStart[i]), sButtons[i], "Start: ", CTL_START, i); - - sTriggers[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Triggers")); - - AddControl(m_Controller[i], &(m_ButtonL[i]), sTriggers[i], "L: ", CTL_L, i); - AddControl(m_Controller[i], &(m_ButtonR[i]), sTriggers[i], "R: ", CTL_R, i); - AddControl(m_Controller[i], &(m_ButtonL_Semi[i]), sTriggers[i], "Semi-L: ", CTL_L_SEMI, i); - AddControl(m_Controller[i], &(m_ButtonR_Semi[i]), sTriggers[i], "Semi-R: ", CTL_R_SEMI, i); - AddSlider(m_Controller[i], &(m_Trigger_SemiValue[i]), sTriggers[i], "Semi: ", ID_TRIGGER_SEMIVALUE, i); - - sStick[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Main Stick")); - - AddControl(m_Controller[i], &(m_StickUp[i]), sStick[i], "Up: ", CTL_MAINUP, i); - AddControl(m_Controller[i], &(m_StickDown[i]), sStick[i], "Down: ", CTL_MAINDOWN, i); - AddControl(m_Controller[i], &(m_StickLeft[i]), sStick[i], "Left: ", CTL_MAINLEFT, i); - AddControl(m_Controller[i], &(m_StickRight[i]), sStick[i], "Right: ", CTL_MAINRIGHT, i); - AddControl(m_Controller[i], &(m_Stick_Semi[i]), sStick[i], "Semi-press: ", CTL_MAIN_SEMI, i); - AddSlider(m_Controller[i], &(m_Stick_SemiValue[i]), sStick[i], "Semi: ", ID_MAIN_SEMIVALUE, i); - - sDPad[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("D-Pad")); - - AddControl(m_Controller[i], &(m_DPadUp[i]), sDPad[i], "Up: ", CTL_DPADUP, i); - AddControl(m_Controller[i], &(m_DPadDown[i]), sDPad[i], "Down: ", CTL_DPADDOWN, i); - AddControl(m_Controller[i], &(m_DPadLeft[i]), sDPad[i], "Left: ", CTL_DPADLEFT, i); - AddControl(m_Controller[i], &(m_DPadRight[i]), sDPad[i], "Right: ", CTL_DPADRIGHT, i); - - sCStick[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("C-Stick")); - - AddControl(m_Controller[i], &(m_CStickUp[i]), sCStick[i], "Up: ", CTL_SUBUP, i); - AddControl(m_Controller[i], &(m_CStickDown[i]), sCStick[i], "Down: ", CTL_SUBDOWN, i); - AddControl(m_Controller[i], &(m_CStickLeft[i]), sCStick[i], "Left: ", CTL_SUBLEFT, i); - AddControl(m_Controller[i], &(m_CStickRight[i]), sCStick[i], "Right: ", CTL_SUBRIGHT, i); - AddControl(m_Controller[i], &(m_CStick_Semi[i]), sCStick[i], "Semi-press: ", CTL_SUB_SEMI, i); - AddSlider(m_Controller[i], &(m_CStick_SemiValue[i]), sCStick[i], "Semi: ", ID_SUB_SEMIVALUE, i); - - // -------------------------------------------------------------------- - // Sizers - // ----------------------------- - sPage[i] = new wxGridBagSizer(0, 0); - sPage[i]->SetFlexibleDirection(wxBOTH); - sPage[i]->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED); - sPage[i]->Add(sDevice[i], wxGBPosition(0, 0), wxGBSpan(1, 5), wxEXPAND|wxALL, 1); - sPage[i]->Add(sButtons[i], wxGBPosition(1, 0), wxGBSpan(2, 1), wxALL, 1); - sPage[i]->Add(sTriggers[i], wxGBPosition(1, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 1); - sPage[i]->Add(sStick[i], wxGBPosition(1, 2), wxGBSpan(2, 1), wxALL, 1); - sPage[i]->Add(sDPad[i], wxGBPosition(1, 3), wxGBSpan(2, 1), wxALL, 1); - sPage[i]->Add(sCStick[i], wxGBPosition(1, 4), wxGBSpan(2, 1), wxALL, 1); - m_Controller[i]->SetSizer(sPage[i]); - sPage[i]->Layout(); - } -} - -void PADConfigDialogSimple::OnClose(wxCloseEvent& event) -{ -#ifdef _WIN32 - m_dinput.Free(); -#endif - EndModal(0); -} - -void PADConfigDialogSimple::OnCloseClick(wxCommandEvent& event) -{ - Close(); -} - -void PADConfigDialogSimple::OnShow(wxShowEvent& event) -{ -#ifdef _WIN32 - m_dinput.Init((HWND)this->GetParent()); -#endif -} - -void PADConfigDialogSimple::OnKeyDown(wxKeyEvent& event) -{ - char keyStr[10] = {0}; - if(ClickedButton) - { - // Get the selected notebook page - int page = m_Notebook->GetSelection(); - -#ifdef _WIN32 - m_dinput.Read(); - if (m_dinput.diks[DIK_ESCAPE]) - { - pad[page].keyForControl[ClickedButton->GetId()] = 0x00; - ClickedButton->SetLabel(wxString::FromAscii("")); - } - else - { - for(int i = 0; i < 255; i++) - { - if(m_dinput.diks[i]) - { - // Save the mapped key - pad[page].keyForControl[ClickedButton->GetId()] = i; - // Get the key name - DInput::DIKToString(i, keyStr); - ClickedButton->SetLabel(wxString::FromAscii(keyStr)); - break; - } - } - } - -#elif defined(HAVE_X11) && HAVE_X11 - if (event.GetKeyCode() == (XK_Escape & 0xFF)) - { - pad[page].keyForControl[ClickedButton->GetId()] = InputCommon::wxCharCodeWXToX(0x00); - ClickedButton->SetLabel(wxString::FromAscii("")); - } - else - { - pad[page].keyForControl[ClickedButton->GetId()] = InputCommon::wxCharCodeWXToX(event.GetKeyCode()); - InputCommon::XKeyToString(pad[page].keyForControl[ClickedButton->GetId()], keyStr); - ClickedButton->SetLabel(wxString::FromAscii(keyStr)); - } -#endif - ClickedButton->Disconnect(); - } - // Reset - ClickedButton = NULL; - //event.Skip(); -} - -// We have clicked a button -void PADConfigDialogSimple::OnButtonClick(wxCommandEvent& event) -{ - // Check if the Space key was set, to solve the problem that the Space key calls this function -#ifdef _WIN32 - if (m_dinput.diks[DIK_SPACE]) { m_dinput.diks[DIK_SPACE] = 0; return; } -#endif - - // If we come here again before any key was set - if(ClickedButton) ClickedButton->SetLabel(oldLabel); - - // Save the old button label so we can reapply it if necessary - ClickedButton = (wxButton *)event.GetEventObject(); - oldLabel = ClickedButton->GetLabel(); - ClickedButton->SetLabel(_("Press Key/Esc")); - - ClickedButton->SetWindowStyle(wxWANTS_CHARS); -} - -void PADConfigDialogSimple::ControllerSettingsChanged(wxCommandEvent& event) -{ - int page = m_Notebook->GetSelection(); - std::stringstream ss; - - switch (event.GetId()) - { - // General settings - case ID_DISABLE: - pad[page].bDisable = m_Disable[page]->GetValue(); - break; - - // XInput - case ID_X360PAD: - pad[page].bEnableXPad = event.IsChecked(); - m_Rumble[page]->Enable(event.IsChecked()); - m_X360PadC[page]->Enable(event.IsChecked()); - break; - case ID_X360PAD_CHOICE: - pad[page].XPadPlayer = event.GetSelection(); - break; - case ID_RUMBLE: - pad[page].bRumble = m_Rumble[page]->GetValue(); - break; - - // Semi-press adjustment - case ID_TRIGGER_SEMIVALUE: - pad[page].Trigger_semivalue = m_Trigger_SemiValue[page]->GetValue(); - ss << pad[page].Trigger_semivalue; - (*m_Trigger_SemiValue_Label[page]).SetLabel(wxString::FromAscii( ss.str().c_str() )); - break; - case ID_MAIN_SEMIVALUE: - pad[page].Main_stick_semivalue = m_Stick_SemiValue[page]->GetValue(); - ss << pad[page].Main_stick_semivalue; - (*m_Stick_SemiValue_Label[page]).SetLabel(wxString::FromAscii( ss.str().c_str() )); - break; - case ID_SUB_SEMIVALUE: - pad[page].Sub_stick_semivalue = m_CStick_SemiValue[page]->GetValue(); - ss << pad[page].Sub_stick_semivalue; - (*m_CStick_SemiValue_Label[page]).SetLabel(wxString::FromAscii( ss.str().c_str() )); - break; - - // Input recording -#ifdef RERECORDING - case ID_RECORDING: - pad[page].bRecording = m_CheckRecording[page]->GetValue(); - // Turn off the other option - pad[page].bPlayback = false; m_CheckPlayback[page]->SetValue(false); - break; - case ID_PLAYBACK: - pad[page].bPlayback = m_CheckPlayback[page]->GetValue(); - // Turn off the other option - pad[page].bRecording = false; m_CheckRecording[page]->SetValue(false); - break; - case ID_SAVE_RECORDING: - // Double check again that we are still running a game - if (g_EmulatorRunning) SaveRecord(); - break; -#endif - } -} - -void PADConfigDialogSimple::DllAbout(wxCommandEvent& event) -{ - wxString message; -#ifdef _WIN32 - message = _("A simple keyboard and XInput plugin for dolphin."); -#else - message = _("A simple keyboard plugin for dolphin."); -#endif - - wxMessageBox(_T("Dolphin PadSimple Plugin\nBy ector and F|RES\n\n" + message), - _T("Dolphin PadSimple"), wxOK, this); -} diff --git a/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.h b/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.h deleted file mode 100644 index c01897ff92..0000000000 --- a/Source/Plugins/Plugin_PadSimple/Src/GUI/ConfigDlg.h +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright (C) 2003 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - -#ifndef __CONFIGDLG_H__ -#define __CONFIGDLG_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(HAVE_X11) && HAVE_X11 -#include "X11InputBase.h" -#endif - -class PADConfigDialogSimple : public wxDialog -{ - - - public: - PADConfigDialogSimple(wxWindow *parent, wxWindowID id = 1, const wxString &title = wxT("Pad Configuration"), - const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE); - - virtual ~PADConfigDialogSimple(); - - private: - DECLARE_EVENT_TABLE(); - wxNotebook *m_Notebook; - wxPanel *m_Controller[4]; - wxButton *m_About; - wxButton *m_Close; - - wxStaticBoxSizer *sbDevice[4], *m_SizeXInput[4], *m_SizeRecording[4]; - wxBoxSizer *sDevice[4]; - wxGridBagSizer *sPage[4]; - wxStaticBoxSizer *sButtons[4]; - wxStaticBoxSizer *sTriggers[4]; - wxStaticBoxSizer *sStick[4]; - wxStaticBoxSizer *sCStick[4]; - wxStaticBoxSizer *sDPad[4]; - - wxArrayString arrayStringFor_X360Pad; - wxCheckBox *m_X360Pad[4]; - wxChoice *m_X360PadC[4]; - wxCheckBox *m_Disable[4]; - wxCheckBox *m_Rumble[4]; - - // Recording - wxCheckBox *m_CheckRecording[4]; - wxCheckBox *m_CheckPlayback[4]; - wxButton *m_BtnSaveRecording[4]; - - wxButton *m_ButtonA[4]; - wxButton *m_ButtonB[4]; - wxButton *m_ButtonX[4]; - wxButton *m_ButtonY[4]; - wxButton *m_ButtonZ[4]; - wxButton *m_ButtonStart[4]; - wxButton *m_ButtonL[4]; - wxButton *m_ButtonR[4]; - wxButton *m_ButtonL_Semi[4]; - wxButton *m_ButtonR_Semi[4]; - wxSlider *m_Trigger_SemiValue[4]; - wxStaticText *m_Trigger_SemiValue_Label[4]; - wxButton *m_StickUp[4]; - wxButton *m_StickDown[4]; - wxButton *m_StickLeft[4]; - wxButton *m_StickRight[4]; - wxButton *m_Stick_Semi[4]; - wxSlider *m_Stick_SemiValue[4]; - wxStaticText *m_Stick_SemiValue_Label[4]; - wxButton *m_CStickUp[4]; - wxButton *m_CStickDown[4]; - wxButton *m_CStickLeft[4]; - wxButton *m_CStickRight[4]; - wxButton *m_CStick_Semi[4]; - wxSlider *m_CStick_SemiValue[4]; - wxStaticText *m_CStick_SemiValue_Label[4]; - wxButton *m_DPadUp[4]; - wxButton *m_DPadDown[4]; - wxButton *m_DPadLeft[4]; - wxButton *m_DPadRight[4]; - - enum - { - ////GUI Enum Control ID Start - ID_CLOSE = 1000, - ID_NOTEBOOK, - ID_CONTROLLERPAGE1, - ID_CONTROLLERPAGE2, - ID_CONTROLLERPAGE3, - ID_CONTROLLERPAGE4, - - // XInput pad - ID_X360PAD_CHOICE, - ID_X360PAD, - ID_RUMBLE, - - // Semi-press values - ID_TRIGGER_SEMIVALUE, - ID_MAIN_SEMIVALUE, - ID_SUB_SEMIVALUE, - - // Input recording - ID_RECORDING, - ID_PLAYBACK, - ID_SAVE_RECORDING, - - // General settings - ID_DISABLE, - ID_PAD_ABOUT, - }; - - void OnClose(wxCloseEvent& event); - void CreateGUIControls(); - void OnCloseClick(wxCommandEvent& event); - void OnKeyDown(wxKeyEvent& event); - void ControllerSettingsChanged(wxCommandEvent& event); - void OnButtonClick(wxCommandEvent& event); - void DllAbout(wxCommandEvent& event); - void OnShow(wxShowEvent& event); - void AddSlider(wxPanel *pan, wxSlider **slider, - wxStaticBoxSizer *sizer, const char *name, int ctl, int controller); - - wxButton *ClickedButton; - wxString oldLabel; -}; - -#endif diff --git a/Source/Plugins/Plugin_PadSimple/Src/PadSimple.cpp b/Source/Plugins/Plugin_PadSimple/Src/PadSimple.cpp deleted file mode 100644 index 07742198f9..0000000000 --- a/Source/Plugins/Plugin_PadSimple/Src/PadSimple.cpp +++ /dev/null @@ -1,993 +0,0 @@ -// Copyright (C) 2003 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - - - -// Include -#include -#include - -#include "Common.h" -#include "LogManager.h" -#include "pluginspecs_pad.h" -#include "PadSimple.h" -#include "IniFile.h" -#include "StringUtil.h" -#include "FileUtil.h" -#include "ChunkFile.h" - -#if defined(HAVE_WX) && HAVE_WX - #include "GUI/ConfigDlg.h" - PADConfigDialogSimple* m_ConfigFrame = NULL; -#endif - -#ifdef _WIN32 - #include "XInput.h" - #include "../../../Core/InputCommon/Src/DirectInputBase.h" // Core - - DInput dinput; - //#elif defined(USE_SDL) && USE_SDL - //#include - -#elif defined(HAVE_X11) && HAVE_X11 - - #include - #include - #include - #include - - Display* GXdsp; - bool KeyStatus[NUMCONTROLS]; -#elif defined(HAVE_COCOA) && HAVE_COCOA - #include - bool KeyStatus[NUMCONTROLS]; -#endif - - - -// Declarations -SPads pad[4]; -SPADInitialize g_PADInitialize; - - -// Standard crap to make wxWidgets happy -#ifdef _WIN32 -HINSTANCE g_hInstance; - -#if defined(HAVE_WX) && HAVE_WX -class wxDLLApp : public wxApp -{ - bool OnInit() - { - return true; - } -}; -IMPLEMENT_APP_NO_MAIN(wxDLLApp) -WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); -#endif - -BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle - DWORD dwReason, // reason called - LPVOID lpvReserved) // reserved -{ - switch (dwReason) - { - case DLL_PROCESS_ATTACH: - { -#if defined(HAVE_WX) && HAVE_WX - wxSetInstance((HINSTANCE)hinstDLL); - int argc = 0; - char **argv = NULL; - wxEntryStart(argc, argv); - if (!wxTheApp || !wxTheApp->CallOnInit()) - return FALSE; -#endif - } - break; - - case DLL_PROCESS_DETACH: -#if defined(HAVE_WX) && HAVE_WX - wxEntryCleanup(); -#endif - break; - default: - break; - } - - g_hInstance = hinstDLL; - return TRUE; -} -#endif - -#if defined(HAVE_WX) && HAVE_WX -wxWindow* GetParentedWxWindow(HWND Parent) -{ -#ifdef _WIN32 - wxSetInstance((HINSTANCE)g_hInstance); -#endif - wxWindow *win = new wxWindow(); -#ifdef _WIN32 - win->SetHWND((WXHWND)Parent); - win->AdoptAttributesFromHWND(); -#endif - return win; -} -#endif - - - -// Input Recording - -// Enable these to record or play back -//#define RECORD_REPLAY -//#define RECORD_STORE - -// Pre defined maxium storage limit -#define RECORD_SIZE (1024 * 128) -PLUGIN_GLOBALS* globals = NULL; -SPADStatus recordBuffer[RECORD_SIZE]; -int count = 0; -bool g_EmulatorRunning = false; - -//****************************************************************************** -// Supporting functions -//****************************************************************************** - -void RecordInput(const SPADStatus& _rPADStatus) -{ - if (count >= RECORD_SIZE) return; - recordBuffer[count++] = _rPADStatus; - - // Logging - //u8 TmpData[sizeof(SPADStatus)]; - //memcpy(TmpData, &recordBuffer[count - 1], sizeof(SPADStatus)); - //Console::Print("RecordInput(%i): %s\n", count, ArrayToString(TmpData, sizeof(SPADStatus), 0, 30).c_str()); - - // Auto save every ten seconds - if (count % (60 * 10) == 0) SaveRecord(); -} - -const SPADStatus& PlayRecord() -{ - // Logging - //Console::Print("PlayRecord(%i)\n", count); - - if (count >= RECORD_SIZE) - { - // Todo: Make the recording size unlimited? - //PanicAlert("The recording reached its end"); - return(recordBuffer[0]); - } - return(recordBuffer[count++]); -} - -void LoadRecord() -{ - FILE* pStream = fopen("pad-record.bin", "rb"); - - if (pStream != NULL) - { - fread(recordBuffer, 1, RECORD_SIZE * sizeof(SPADStatus), pStream); - fclose(pStream); - } - else - { - PanicAlert("SimplePad: Could not open pad-record.bin"); - } - - //Console::Print("LoadRecord()"); -} - -void SaveRecord() -{ - // Open the file in a way that clears all old data - FILE* pStream = fopen("pad-record.bin", "wb"); - - if (pStream != NULL) - { - fwrite(recordBuffer, 1, RECORD_SIZE * sizeof(SPADStatus), pStream); - fclose(pStream); - } - else - { - PanicAlert("SimplePad: Could not save pad-record.bin"); - } - //PanicAlert("SaveRecord()"); - //Console::Print("SaveRecord()"); -} - - -// Check if Dolphin is in focus -bool IsFocus() -{ -#ifdef _WIN32 - HWND Parent = GetParent(g_PADInitialize.hWnd); - HWND TopLevel = GetParent(Parent); - // Support both rendering to main window and not - if (GetForegroundWindow() == TopLevel || GetForegroundWindow() == g_PADInitialize.hWnd) - return true; - else - return false; -#else - return true; -#endif -} - -// Implement circular deadzone -const float kDeadZone = 0.1f; -void ScaleStickValues(unsigned char* outx, - unsigned char* outy, - short inx, short iny) -{ - float x = ((float)inx + 0.5f) / 32767.5f; - float y = ((float)iny + 0.5f) / 32767.5f; - - if ((x == 0.0f) && (y == 0.0f)) // to be safe - { - *outx = 0; - *outy = 0; - return; - } - - float magnitude = sqrtf(x * x + y * y); - float nx = x / magnitude; - float ny = y / magnitude; - - if (magnitude < kDeadZone){magnitude = kDeadZone;} - - magnitude = (magnitude - kDeadZone) / (1.0f - kDeadZone); - magnitude *= magnitude; // another power may be more appropriate - nx *= magnitude; - ny *= magnitude; - int ix = (int)(nx * 100); - int iy = (int)(ny * 100); - *outx = 0x80 + ix; - *outy = 0x80 + iy; -} - -// for same displacement should be sqrt(2)/2 (in theory) -// 3/4 = 0.75 is a little faster than sqrt(2)/2 = 0.7071... -// In SMS, 17/20 = 0.85 is perfect; in WW, 7/10 = 0.70 is closer. -#define DIAGONAL_SCALE 0.70710678 -void EmulateAnalogStick(unsigned char *stickX, unsigned char *stickY, bool buttonUp, bool buttonDown, bool buttonLeft, bool buttonRight, int magnitude) { - int mainY = 0; - int mainX = 0; - if (buttonUp) - mainY = magnitude; - else if (buttonDown) - mainY = -magnitude; - if (buttonLeft) - mainX = -magnitude; - else if (buttonRight) - mainX = magnitude; - // only update if there is some action - // this allows analog stick to still work - // disable for now, enable later if any platform supports both methods of input - //if ((mainX != 0) && (mainY != 0)) { - if (true) { - if ((mainX == 0) || (mainY == 0)) - { - *stickX += mainX; - *stickY += mainY; - } - else - { - *stickX += mainX*DIAGONAL_SCALE; - *stickY += mainY*DIAGONAL_SCALE; - } - } -} - -//****************************************************************************** -// Input -//****************************************************************************** - - -#ifdef _WIN32 -void DInput_Read(int _numPAD, SPADStatus* _pPADStatus) -{ - dinput.Read(); - - // Analog stick values based on semi-press keys - int mainstickvalue = (dinput.diks[pad[_numPAD].keyForControl[CTL_MAIN_SEMI]] & 0xFF) ? pad[_numPAD].Main_stick_semivalue : STICK_FULL; - int substickvalue = (dinput.diks[pad[_numPAD].keyForControl[CTL_SUB_SEMI]] & 0xFF) ? pad[_numPAD].Sub_stick_semivalue : STICK_FULL; - // Buttons (A/B/X/Y/Z/Start) - if (dinput.diks[pad[_numPAD].keyForControl[CTL_A]] & 0xFF) - { - _pPADStatus->button |= PAD_BUTTON_A; - _pPADStatus->analogA = BUTTON_FULL; - } - if (dinput.diks[pad[_numPAD].keyForControl[CTL_B]] & 0xFF) - { - _pPADStatus->button |= PAD_BUTTON_B; - _pPADStatus->analogB = BUTTON_FULL; - } - if (dinput.diks[pad[_numPAD].keyForControl[CTL_X]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_X;} - if (dinput.diks[pad[_numPAD].keyForControl[CTL_Y]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_Y;} - if (dinput.diks[pad[_numPAD].keyForControl[CTL_Z]] & 0xFF){_pPADStatus->button |= PAD_TRIGGER_Z;} - if (dinput.diks[pad[_numPAD].keyForControl[CTL_START]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_START;} - // Triggers (L/R) - if (dinput.diks[pad[_numPAD].keyForControl[CTL_L]] & 0xFF) - { - _pPADStatus->button |= PAD_TRIGGER_L; - _pPADStatus->triggerLeft = TRIGGER_FULL; - } - if (dinput.diks[pad[_numPAD].keyForControl[CTL_R]] & 0xFF) - { - _pPADStatus->button |= PAD_TRIGGER_R; - _pPADStatus->triggerRight = TRIGGER_FULL; - } - if (dinput.diks[pad[_numPAD].keyForControl[CTL_L_SEMI]] & 0xFF) - { - _pPADStatus->triggerLeft = pad[_numPAD].Trigger_semivalue; - if (pad[_numPAD].Trigger_semivalue > TRIGGER_THRESHOLD) - _pPADStatus->button |= PAD_TRIGGER_L; - } - if (dinput.diks[pad[_numPAD].keyForControl[CTL_R_SEMI]] & 0xFF) - { - _pPADStatus->triggerRight = pad[_numPAD].Trigger_semivalue; - if (pad[_numPAD].Trigger_semivalue > TRIGGER_THRESHOLD) - _pPADStatus->button |= PAD_TRIGGER_R; - } - // Main stick - EmulateAnalogStick( - &_pPADStatus->stickX, - &_pPADStatus->stickY, - !!dinput.diks[pad[_numPAD].keyForControl[CTL_MAINUP]], - !!dinput.diks[pad[_numPAD].keyForControl[CTL_MAINDOWN]], - !!dinput.diks[pad[_numPAD].keyForControl[CTL_MAINLEFT]], - !!dinput.diks[pad[_numPAD].keyForControl[CTL_MAINRIGHT]], - mainstickvalue ); - - // Sub-stick (C-stick) - EmulateAnalogStick( - &_pPADStatus->substickX, - &_pPADStatus->substickY, - !!dinput.diks[pad[_numPAD].keyForControl[CTL_SUBUP]], - !!dinput.diks[pad[_numPAD].keyForControl[CTL_SUBDOWN]], - !!dinput.diks[pad[_numPAD].keyForControl[CTL_SUBLEFT]], - !!dinput.diks[pad[_numPAD].keyForControl[CTL_SUBRIGHT]], - substickvalue ); - // D-pad - if (dinput.diks[pad[_numPAD].keyForControl[CTL_DPADUP]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_UP;} - if (dinput.diks[pad[_numPAD].keyForControl[CTL_DPADDOWN]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_DOWN;} - if (dinput.diks[pad[_numPAD].keyForControl[CTL_DPADLEFT]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_LEFT;} - if (dinput.diks[pad[_numPAD].keyForControl[CTL_DPADRIGHT]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_RIGHT;} - // Mic key - _pPADStatus->MicButton = (dinput.diks[pad[_numPAD].keyForControl[CTL_MIC]] & 0xFF) ? true : false; -} - -bool XInput_Read(int XPadPlayer, SPADStatus* _pPADStatus) -{ - const int base = 0x80; - XINPUT_STATE xstate; - DWORD xresult = XInputGetState(XPadPlayer, &xstate); - - // Let's .. yes, let's use XINPUT! - if (xresult == ERROR_SUCCESS) - { - const XINPUT_GAMEPAD& xpad = xstate.Gamepad; - - if ((_pPADStatus->stickX == base) && (_pPADStatus->stickY == base)) - { - ScaleStickValues( - &_pPADStatus->stickX, - &_pPADStatus->stickY, - xpad.sThumbLX, - xpad.sThumbLY); - } - - if ((_pPADStatus->substickX == base) && (_pPADStatus->substickY == base)) - { - ScaleStickValues( - &_pPADStatus->substickX, - &_pPADStatus->substickY, - xpad.sThumbRX, - xpad.sThumbRY); - } - - if (xpad.wButtons & XINPUT_GAMEPAD_DPAD_UP) {_pPADStatus->button |= PAD_BUTTON_UP;} - if (xpad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN) {_pPADStatus->button |= PAD_BUTTON_DOWN;} - if (xpad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT) {_pPADStatus->button |= PAD_BUTTON_LEFT;} - if (xpad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) {_pPADStatus->button |= PAD_BUTTON_RIGHT;} - - _pPADStatus->triggerLeft = xpad.bLeftTrigger; - _pPADStatus->triggerRight = xpad.bRightTrigger; - if (xpad.bLeftTrigger > TRIGGER_THRESHOLD) {_pPADStatus->button |= PAD_TRIGGER_L;} - if (xpad.bRightTrigger > TRIGGER_THRESHOLD) {_pPADStatus->button |= PAD_TRIGGER_R;} - if (xpad.wButtons & XINPUT_GAMEPAD_START) {_pPADStatus->button |= PAD_BUTTON_START;} - if (xpad.wButtons & XINPUT_GAMEPAD_A) {_pPADStatus->button |= PAD_BUTTON_A;} - if (xpad.wButtons & XINPUT_GAMEPAD_B) {_pPADStatus->button |= PAD_BUTTON_X;} - if (xpad.wButtons & XINPUT_GAMEPAD_X) {_pPADStatus->button |= PAD_BUTTON_B;} - if (xpad.wButtons & XINPUT_GAMEPAD_Y) {_pPADStatus->button |= PAD_BUTTON_Y;} - if (xpad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER){_pPADStatus->button |= PAD_TRIGGER_Z;} - - //_pPADStatus->MicButton = (xpad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER) ? true : false; - - return true; - } - else - { - return false; - } -} -#endif - -#if (defined(HAVE_X11) && HAVE_X11) || (defined(HAVE_COCOA) && HAVE_COCOA) -#if defined(HAVE_X11) && HAVE_X11 -// The graphics plugin in the PCSX2 design leaves a lot of the window processing to the pad plugin, weirdly enough. -void X11_Read(int _numPAD, SPADStatus* _pPADStatus) -{ - // Do all the stuff we need to do once per frame here - if (_numPAD != 0) - return; - // This code is from Zerofrog's pcsx2 pad plugin - XEvent E; - //int keyPress=0, keyRelease=0; - KeySym key; - - // keyboard input - int num_events; - for (num_events = XPending(GXdsp);num_events > 0;num_events--) - { - XNextEvent(GXdsp, &E); - switch (E.type) - { - case KeyPress: - //_KeyPress(pad, XLookupKeysym((XKeyEvent *)&E, 0)); - //break; - key = XLookupKeysym((XKeyEvent*)&E, 0); - - if((key >= XK_F1 && key <= XK_F9) || - key == XK_Shift_L || key == XK_Shift_R || - key == XK_Control_L || key == XK_Control_R) - { - XPutBackEvent(GXdsp, &E); - break; - } - int i; - for (i = 0; i < NUMCONTROLS; i++) { - if (key == pad[_numPAD].keyForControl[i]) { - KeyStatus[i] = true; - break; - } - } - break; - case KeyRelease: - key = XLookupKeysym((XKeyEvent*)&E, 0); - if((key >= XK_F1 && key <= XK_F9) || - key == XK_Shift_L || key == XK_Shift_R || - key == XK_Control_L || key == XK_Control_R) - { - XPutBackEvent(GXdsp, &E); - break; - } - //_KeyRelease(pad, XLookupKeysym((XKeyEvent *)&E, 0)); - for (i = 0; i < NUMCONTROLS; i++) - { - if (key == pad[_numPAD].keyForControl[i]) - { - KeyStatus[i] = false; - break; - } - } - break; - case ConfigureNotify: - case ClientMessage: - XPutBackEvent(GXdsp, &E); - break; - default: - break; - - } - } -#elif defined(HAVE_COCOA) && HAVE_COCOA -void cocoa_Read(int _numPAD, SPADStatus* _pPADStatus) -{ - // Do all the stuff we need to do once per frame here - if (_numPAD != 0) - return; - //get event from main thread - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSConnection *conn; - NSDistantObject *proxy; - - conn = [NSConnection connectionWithRegisteredName:@"DolphinCocoaEvent" host:nil]; - //if (!conn) { - //printf("error creating cnx event client\n"); - //} - proxy = [conn rootProxy]; - //if (!proxy) { - // printf("error prox client\n"); - //} - - long cocoaKey = (long)[proxy keyCode]; - - int i; - if ((long)[proxy type] == 10) - { - for (i = 0; i < NUMCONTROLS; i++) - { - if (cocoaKey == pad[_numPAD].keyForControl[i]) - { - KeyStatus[i] = true; - break; - } - } - } - else - { - for (i = 0; i < NUMCONTROLS; i++) - { - if (cocoaKey == pad[_numPAD].keyForControl[i]) - { - KeyStatus[i] = false; - break; - } - } - } -#endif - // Analog stick values based on semi-press keys - int mainstickvalue = (KeyStatus[CTL_MAIN_SEMI]) ? pad[_numPAD].Main_stick_semivalue : STICK_FULL; - int substickvalue = (KeyStatus[CTL_SUB_SEMI]) ? pad[_numPAD].Sub_stick_semivalue : STICK_FULL; - // Buttons (A/B/X/Y/Z/Start) - if (KeyStatus[CTL_A]) - { - _pPADStatus->button |= PAD_BUTTON_A; - _pPADStatus->analogA = BUTTON_FULL; - } - if (KeyStatus[CTL_B]) - { - _pPADStatus->button |= PAD_BUTTON_B; - _pPADStatus->analogB = BUTTON_FULL; - } - if (KeyStatus[CTL_X]){_pPADStatus->button |= PAD_BUTTON_X;} - if (KeyStatus[CTL_Y]){_pPADStatus->button |= PAD_BUTTON_Y;} - if (KeyStatus[CTL_Z]){_pPADStatus->button |= PAD_TRIGGER_Z;} - if (KeyStatus[CTL_START]){_pPADStatus->button |= PAD_BUTTON_START;} - // Triggers (L/R) - if (KeyStatus[CTL_L]){_pPADStatus->triggerLeft = TRIGGER_FULL;} - if (KeyStatus[CTL_R]){_pPADStatus->triggerRight = TRIGGER_FULL;} - if (KeyStatus[CTL_L_SEMI]){_pPADStatus->triggerLeft = pad[_numPAD].Trigger_semivalue;} - if (KeyStatus[CTL_R_SEMI]){_pPADStatus->triggerRight = pad[_numPAD].Trigger_semivalue;} - // Main stick - EmulateAnalogStick( - &_pPADStatus->stickX, - &_pPADStatus->stickY, - KeyStatus[CTL_MAINUP], - KeyStatus[CTL_MAINDOWN], - KeyStatus[CTL_MAINLEFT], - KeyStatus[CTL_MAINRIGHT], - mainstickvalue ); - EmulateAnalogStick( - &_pPADStatus->substickX, - &_pPADStatus->substickY, - KeyStatus[CTL_SUBUP], - KeyStatus[CTL_SUBDOWN], - KeyStatus[CTL_SUBLEFT], - KeyStatus[CTL_SUBRIGHT], - substickvalue ); - // D-pad - if (KeyStatus[CTL_DPADUP]) {_pPADStatus->button |= PAD_BUTTON_UP;} - if (KeyStatus[CTL_DPADDOWN]) {_pPADStatus->button |= PAD_BUTTON_DOWN;} - if (KeyStatus[CTL_DPADLEFT]) {_pPADStatus->button |= PAD_BUTTON_LEFT;} - if (KeyStatus[CTL_DPADRIGHT]){_pPADStatus->button |= PAD_BUTTON_RIGHT;} - // Mic key - _pPADStatus->MicButton = KeyStatus[CTL_MIC]; -#if defined(HAVE_X11) && HAVE_X11 -} -#elif defined(HAVE_COCOA) && HAVE_COCOA - [pool release]; -} -#endif -#endif - -//****************************************************************************** -// Plugin specification functions -//****************************************************************************** - -void GetDllInfo(PLUGIN_INFO* _PluginInfo) -{ - _PluginInfo->Version = 0x0100; - _PluginInfo->Type = PLUGIN_TYPE_PAD; - -#ifdef DEBUGFAST - sprintf(_PluginInfo->Name, "Dolphin KB/X360pad (DebugFast)"); -#else -#ifndef _DEBUG - sprintf(_PluginInfo->Name, "Dolphin KB/X360pad"); -#else - sprintf(_PluginInfo->Name, "Dolphin KB/X360pad (Debug)"); -#endif -#endif - -} - -void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) -{ - globals = _pPluginGlobals; - LogManager::SetInstance((LogManager *)globals->logManager); -} - -void DllConfig(HWND _hParent) -{ - // Load configuration - LoadConfig(); - - // Show wxDialog -#if defined(HAVE_WX) && HAVE_WX - if (!m_ConfigFrame) - { - m_ConfigFrame = new PADConfigDialogSimple(GetParentedWxWindow(_hParent)); - m_ConfigFrame->ShowModal(); - m_ConfigFrame->Destroy(); - m_ConfigFrame = NULL; - } -#endif - - // Save configuration - SaveConfig(); -} - -void DllDebugger(HWND _hParent, bool Show) {} - -void Initialize(void *init) -{ - // We are now running a game - g_EmulatorRunning = true; - - // Load configuration - LoadConfig(); - -#ifdef RERECORDING - /* Check if we are starting the pad to record the input, and an old file exists. In that case ask - if we really want to start the recording and eventually overwrite the file */ - if (pad[0].bRecording && File::Exists("pad-record.bin")) - { - if (!AskYesNo("An old version of '%s' aleady exists in your Dolphin directory. You can" - " now make a copy of it before you start a new recording and overwrite the file." - " Select Yes to continue and overwrite the file. Select No to turn off the input" - " recording and continue without recording anything.", - "pad-record.bin")) - { - // Turn off recording and continue - pad[0].bRecording = false; - } - } - - // Load recorded input if we are to play it back, otherwise begin with a blank recording - if (pad[0].bPlayback) LoadRecord(); -#endif - - g_PADInitialize = *(SPADInitialize*)init; - - #ifdef _WIN32 - dinput.Init((HWND)g_PADInitialize.hWnd); - #elif defined(HAVE_X11) && HAVE_X11 - GXdsp = (Display*)g_PADInitialize.hWnd; - #elif defined(HAVE_COCOA) && HAVE_COCOA - - #endif -} - -void DoState(unsigned char **ptr, int mode) -{ -#ifdef RERECORDING - // Load or save the counter - PointerWrap p(ptr, mode); - p.Do(count); - - //Console::Print("count: %i\n", count); - - // Update the frame counter for the sake of the status bar - if (mode == PointerWrap::MODE_READ) - { - #ifdef _WIN32 - // This only works when rendering to the main window, I think - PostMessage(GetParent(g_PADInitialize.hWnd), WM_USER, INPUT_FRAME_COUNTER, count); - #endif - } -#endif -} - -void EmuStateChange(PLUGIN_EMUSTATE newState) -{ -} - -void Shutdown() -{ - // Save the recording and reset the counter -#ifdef RERECORDING - // Save recording - if (pad[0].bRecording) SaveRecord(); - // Reset the counter - count = 0; -#endif - - // We have stopped the game - g_EmulatorRunning = false; - -#ifdef _WIN32 - // Kill xpad rumble - XINPUT_VIBRATION vib; - vib.wLeftMotorSpeed = 0; - vib.wRightMotorSpeed = 0; - for (int i = 0; i < 4; i++) - if (pad[i].bRumble) - XInputSetState(pad[i].XPadPlayer, &vib); - dinput.Free(); -#endif - SaveConfig(); -} - - -// Set buttons status from wxWidgets in the main application -void PAD_Input(u16 _Key, u8 _UpDown) {} - - -void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus) -{ - // Check if all is okay - if (_pPADStatus == NULL) return; - - // Play back input instead of accepting any user input -#ifdef RERECORDING - if (pad[0].bPlayback) - { - *_pPADStatus = PlayRecord(); - return; - } -#endif - - const int base = 0x80; - // Clear pad - memset(_pPADStatus, 0, sizeof(SPADStatus)); - - _pPADStatus->stickY = base; - _pPADStatus->stickX = base; - _pPADStatus->substickX = base; - _pPADStatus->substickY = base; - _pPADStatus->button |= PAD_USE_ORIGIN; -#ifdef _WIN32 - // Only update pad on focus, don't do this when recording - if (pad[_numPAD].bDisable && !pad[0].bRecording && !IsFocus()) return; - - // Dolphin doesn't really care about the pad error codes anyways... - _pPADStatus->err = PAD_ERR_NONE; - - // Read XInput - if (pad[_numPAD].bEnableXPad) - XInput_Read(pad[_numPAD].XPadPlayer, _pPADStatus); - - // Read Direct Input - DInput_Read(_numPAD, _pPADStatus); - -#elif defined(HAVE_X11) && HAVE_X11 - _pPADStatus->err = PAD_ERR_NONE; - X11_Read(_numPAD, _pPADStatus); -#elif defined(HAVE_COCOA) && HAVE_COCOA - _pPADStatus->err = PAD_ERR_NONE; - cocoa_Read(_numPAD, _pPADStatus); -#endif - -#ifdef RERECORDING - // Record input - if (pad[0].bRecording) RecordInput(*_pPADStatus); -#endif -} - - -// Rough approximation of GC behaviour - needs improvement. -void PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength) -{ -#ifdef _WIN32 - if (pad[_numPAD].bEnableXPad) - { - static int a = 0; - - if ((_uType == 0) || (_uType == 2)) - { - a = 0; - } - else if (_uType == 1) - { - a = _uStrength > 2 ? pad[_numPAD].RumbleStrength : 0; - } - - a = int ((float)a * 0.96f); - - if (!pad[_numPAD].bRumble) - { - a = 0; - } - - XINPUT_VIBRATION vib; - vib.wLeftMotorSpeed = a; //_uStrength*100; - vib.wRightMotorSpeed = a; //_uStrength*100; - XInputSetState(pad[_numPAD].XPadPlayer, &vib); - } -#endif -} - -//****************************************************************************** -// Load and save the configuration -//****************************************************************************** - -void LoadConfig() -{ - // Initialize first pad to standard controls -#ifdef _WIN32 - const int defaultKeyForControl[NUMCONTROLS] = - { - DIK_X, // A - DIK_Z, // B - DIK_C, // X - DIK_S, // Y - DIK_D, // Z - DIK_RETURN, // Start - DIK_Q, // L - DIK_W, // R - 0x00, // L semi-press - 0x00, // R semi-press - DIK_UP, // Main stick up - DIK_DOWN, // Main stick down - DIK_LEFT, // Main stick left - DIK_RIGHT, // Main stick right - DIK_LSHIFT, // Main stick semi-press - DIK_I, // C-stick up - DIK_K, // C-stick down - DIK_J, // C-stick left - DIK_L, // C-stick right - DIK_LCONTROL, // C-stick semi-press - DIK_T, // D-pad up - DIK_G, // D-pad down - DIK_F, // D-pad left - DIK_H, // D-pad right - DIK_M, // Mic - }; -#elif defined(HAVE_X11) && HAVE_X11 - const int defaultKeyForControl[NUMCONTROLS] = - { - XK_x, // A - XK_z, // B - XK_c, // X - XK_s, // Y - XK_d, // Z - XK_Return, // Start - XK_q, // L - XK_w, // R - 0x00, // L semi-press - 0x00, // R semi-press - XK_Up, // Main stick up - XK_Down, // Main stick down - XK_Left, // Main stick left - XK_Right, // Main stick right - XK_Shift_L, // Main stick semi-press - XK_i, // C-stick up - XK_k, // C-stick down - XK_j, // C-stick left - XK_l, // C-stick right - XK_Control_L, // C-stick semi-press - XK_t, // D-pad up - XK_g, // D-pad down - XK_f, // D-pad left - XK_h, // D-pad right - XK_m, // Mic - }; -#elif defined(HAVE_COCOA) && HAVE_COCOA - // Reference for Cocoa key codes: - // http://boredzo.org/blog/archives/2007-05-22/virtual-key-codes - const int defaultKeyForControl[NUMCONTROLS] = - { - 7, // A (x) - 6, // B (z) - 8, // X (c) - 1, // Y (s) - 2, // Z (d) - 36, // Start (return) - 12, // L (q) - 13, // R (w) - -1, // L semi-press (none) - -1, // R semi-press (none) - 126, // Main stick up (up) - 125, // Main stick down (down) - 123, // Main stick left (left) - 124, // Main stick right (right) - 56, // Main stick semi-press (left shift) - 34, // C-stick up (i) - 40, // C-stick down (k) - 38, // C-stick left (j) - 37, // C-stick right (l) - 59, // C-stick semi-press (left control) - 17, // D-pad up (t) - 5, // D-pad down (g) - 3, // D-pad left (f) - 4, // D-pad right (h) - 46, // Mic (m) - }; -#endif - - IniFile file; - file.Load(FULL_CONFIG_DIR "pad.ini"); - - for(int i = 0; i < 4; i++) - { - char SectionName[32]; - sprintf(SectionName, "PAD%i", i+1); - - file.Get(SectionName, "UseXPad", &pad[i].bEnableXPad, i==0); - file.Get(SectionName, "DisableOnBackground", &pad[i].bDisable, false); - file.Get(SectionName, "Rumble", &pad[i].bRumble, true); - file.Get(SectionName, "RumbleStrength", &pad[i].RumbleStrength, 8000); - file.Get(SectionName, "XPad#", &pad[i].XPadPlayer); - - file.Get(SectionName, "Trigger_semivalue", &pad[i].Trigger_semivalue, TRIGGER_HALF_DEFAULT); - file.Get(SectionName, "Main_stick_semivalue", &pad[i].Main_stick_semivalue, STICK_HALF_DEFAULT); - file.Get(SectionName, "Sub_stick_semivalue", &pad[i].Sub_stick_semivalue, STICK_HALF_DEFAULT); - - #ifdef RERECORDING - file.Get(SectionName, "Recording", &pad[0].bRecording, false); - file.Get(SectionName, "Playback", &pad[0].bPlayback, false); - #endif - - for (int x = 0; x < NUMCONTROLS; x++) - { - file.Get(SectionName, controlNames[x], - &pad[i].keyForControl[x], - (i==0) ? defaultKeyForControl[x] : 0); -#if defined(HAVE_X11) && HAVE_X11 - // In linux we have a problem assigning the upper case of the - // keys because they're not being recognized - pad[i].keyForControl[x] = tolower(pad[i].keyForControl[x]); -#endif - } - } -} - - -void SaveConfig() -{ - IniFile file; - file.Load(FULL_CONFIG_DIR "pad.ini"); - - for(int i = 0; i < 4; i++) - { - char SectionName[32]; - sprintf(SectionName, "PAD%i", i+1); - - file.Set(SectionName, "UseXPad", pad[i].bEnableXPad); - file.Set(SectionName, "DisableOnBackground", pad[i].bDisable); - file.Set(SectionName, "Rumble", pad[i].bRumble); - file.Set(SectionName, "RumbleStrength", pad[i].RumbleStrength); - file.Set(SectionName, "XPad#", pad[i].XPadPlayer); - - file.Set(SectionName, "Trigger_semivalue", pad[i].Trigger_semivalue); - file.Set(SectionName, "Main_stick_semivalue", pad[i].Main_stick_semivalue); - file.Set(SectionName, "Sub_stick_semivalue", pad[i].Sub_stick_semivalue); - - #ifdef RERECORDING - file.Set(SectionName, "Recording", pad[0].bRecording); - file.Set(SectionName, "Playback", pad[0].bPlayback); - #endif - - for (int x = 0; x < NUMCONTROLS; x++) - { - file.Set(SectionName, controlNames[x], pad[i].keyForControl[x]); - } - } - file.Save(FULL_CONFIG_DIR "pad.ini"); -} diff --git a/Source/Plugins/Plugin_PadSimple/Src/PadSimple.h b/Source/Plugins/Plugin_PadSimple/Src/PadSimple.h deleted file mode 100644 index c162f8a434..0000000000 --- a/Source/Plugins/Plugin_PadSimple/Src/PadSimple.h +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (C) 2003 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - -#ifndef __PADSIMPLE_H__ -#define __PADSIMPLE_H__ - -#include "Setup.h" // Common - -// Constants for full-press sticks and triggers -const int BUTTON_FULL = 255; -const int STICK_FULL = 100; -const int STICK_HALF_DEFAULT = 50; -const int TRIGGER_FULL = 255; -const int TRIGGER_HALF_DEFAULT = 128; -const int TRIGGER_THRESHOLD = 230; - -// Controls -enum -{ - CTL_A = 0, - CTL_B, - CTL_X, - CTL_Y, - CTL_Z, - CTL_START, - CTL_L, - CTL_R, - CTL_L_SEMI, - CTL_R_SEMI, - CTL_MAINUP, - CTL_MAINDOWN, - CTL_MAINLEFT, - CTL_MAINRIGHT, - CTL_MAIN_SEMI, - CTL_SUBUP, - CTL_SUBDOWN, - CTL_SUBLEFT, - CTL_SUBRIGHT, - CTL_SUB_SEMI, - CTL_DPADUP, - CTL_DPADDOWN, - CTL_DPADLEFT, - CTL_DPADRIGHT, - CTL_MIC, - NUMCONTROLS, -}; - -// Control names -static const char* controlNames[] = -{ - "A_button", - "B_button", - "X_button", - "Y_button", - "Z_trigger", - "Start", - "L_button", - "R_button", - "L_button_semi", - "R_button_semi", - "Main_stick_up", - "Main_stick_down", - "Main_stick_left", - "Main_stick_right", - "Main_stick_semi", - "Sub_stick_up", - "Sub_stick_down", - "Sub_stick_left", - "Sub_stick_right", - "Sub_stick_semi", - "D-Pad_up", - "D-Pad_down", - "D-Pad_left", - "D-Pad_right", - "Mic-button", -}; - -struct SPads -{ - bool bEnableXPad; // Use an XPad in addition to the keyboard? - bool bDisable; // Disabled when dolphin isn't in focus - bool bRumble; // Rumble for xpad - u32 RumbleStrength; // Rumble strength - bool bRecording; // Record input? - bool bPlayback; // Playback input? - s32 XPadPlayer; // Player# of the xpad - u32 keyForControl[NUMCONTROLS]; // Keyboard mapping - u32 Trigger_semivalue; // Semi-press value for triggers - u32 Main_stick_semivalue; // Semi-press value for main stick - u32 Sub_stick_semivalue; // Semi-press value for sub-stick -}; - -extern SPads pad[]; -extern bool g_EmulatorRunning; - -void LoadConfig(); -void SaveConfig(); -bool IsFocus(); - -// Input Recording -void SaveRecord(); - -#endif diff --git a/Source/Plugins/Plugin_PadSimple/Src/SConscript b/Source/Plugins/Plugin_PadSimple/Src/SConscript deleted file mode 100644 index 1cc11d5250..0000000000 --- a/Source/Plugins/Plugin_PadSimple/Src/SConscript +++ /dev/null @@ -1,39 +0,0 @@ -# -*- python -*- - -Import('env') -import sys - -name = "Plugin_PadSimple" - -if not env['HAVE_X11']: - if not env['HAVE_COCOA']: - print name + " must have X11 to be built" - Return() - - -files = [ - "PadSimple.cpp", - ] -padenv = env.Clone() - - -if padenv['HAVE_COCOA']: - compileFlags = [ - '-x', - 'objective-c++', - ] - -if padenv['HAVE_WX']: - files += [ - "GUI/ConfigDlg.cpp", - ] - -if padenv['HAVE_COCOA']: - padenv.Append( CXXFLAGS = compileFlags, - LIBS = [ 'common' ]) - padenv['FRAMEWORKS'] = ['Cocoa', 'System'] - -else: - padenv.Append(LIBS = [ 'common', 'inputcommon' ]) - -padenv.SharedLibrary(env['plugin_dir']+name, files) diff --git a/Source/Plugins/Plugin_PadSimple/Src/stdafx.cpp b/Source/Plugins/Plugin_PadSimple/Src/stdafx.cpp deleted file mode 100644 index 31f734b17a..0000000000 --- a/Source/Plugins/Plugin_PadSimple/Src/stdafx.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2003 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - -#include "stdafx.h" diff --git a/Source/Plugins/Plugin_PadSimple/Src/stdafx.h b/Source/Plugins/Plugin_PadSimple/Src/stdafx.h deleted file mode 100644 index 0dcfd6a503..0000000000 --- a/Source/Plugins/Plugin_PadSimple/Src/stdafx.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2003 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - -#pragma once - -// Insert your headers here -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#define _CRT_SECURE_NO_DEPRECATE 1 - -#include -#include -#include -#include -#include - -// DInput -#define DIRECTINPUT_VERSION 0x0800 -#include - -