diff --git a/SConstruct b/SConstruct index a1d84fc5c3..d9e758d577 100644 --- a/SConstruct +++ b/SConstruct @@ -66,18 +66,17 @@ dirs = [ 'Source/Core/DebuggerUICommon/Src', 'Source/Core/DSPCore/Src', 'Source/DSPTool/Src', + 'Source/Plugins/InputPluginCommon/Src/', 'Source/Plugins/Plugin_VideoOGL/Src', 'Source/Plugins/Plugin_VideoSoftware/Src', 'Source/Plugins/Plugin_DSP_HLE/Src', 'Source/Plugins/Plugin_DSP_LLE/Src', - 'Source/Plugins/Plugin_GCPad/Src', 'Source/Plugins/Plugin_GCPadNew/Src', 'Source/Plugins/Plugin_Wiimote/Src', + 'Source/Plugins/Plugin_WiimoteNew/Src/', 'Source/Core/DolphinWX/Src', 'Source/Core/DebuggerWX/Src', 'Source/UnitTests/', - 'Source/Plugins/InputPluginCommon/Src/', - 'Source/Plugins/Plugin_WiimoteNew/Src/', ] builders = {} diff --git a/Source/Dolphin.sln b/Source/Dolphin.sln index 66bd93866b..e654ad6041 100644 --- a/Source/Dolphin.sln +++ b/Source/Dolphin.sln @@ -64,7 +64,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Dolphin", "Core\DolphinWX\D {4D3CD4C5-412B-4B49-9B1B-A68A2A129C77} = {4D3CD4C5-412B-4B49-9B1B-A68A2A129C77} {F0B874CB-4476-4199-9315-8343D05AE684} = {F0B874CB-4476-4199-9315-8343D05AE684} {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} - {9FF603F8-B3BB-4144-9688-B2B802FA0F16} = {9FF603F8-B3BB-4144-9688-B2B802FA0F16} {B7F1A9FB-BEA8-416E-9460-AE35A6A5165C} = {B7F1A9FB-BEA8-416E-9460-AE35A6A5165C} EndProjectSection EndProject @@ -184,16 +183,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_VideoSoftware", "Plu {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_GCPad", "Plugins\Plugin_GCPad\Plugin_GCPad.vcproj", "{9FF603F8-B3BB-4144-9688-B2B802FA0F16}" - 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}") = "Plugin_GCPadNew", "Plugins\Plugin_GCPadNew\Plugin_GCPadNew.vcproj", "{1C3A7A91-A97F-4C7C-B45D-26F2242904D7}" ProjectSection(ProjectDependencies) = postProject {C7E5D50A-2916-464B-86A7-E10B3CC88ADA} = {C7E5D50A-2916-464B-86A7-E10B3CC88ADA} @@ -574,18 +563,6 @@ Global {66A4E7BD-E2E8-4373-9B75-8750EB5AE683}.Release|Win32.Build.0 = Release|Win32 {66A4E7BD-E2E8-4373-9B75-8750EB5AE683}.Release|x64.ActiveCfg = Release|x64 {66A4E7BD-E2E8-4373-9B75-8750EB5AE683}.Release|x64.Build.0 = Release|x64 - {9FF603F8-B3BB-4144-9688-B2B802FA0F16}.Debug|Win32.ActiveCfg = Debug|Win32 - {9FF603F8-B3BB-4144-9688-B2B802FA0F16}.Debug|Win32.Build.0 = Debug|Win32 - {9FF603F8-B3BB-4144-9688-B2B802FA0F16}.Debug|x64.ActiveCfg = Debug|x64 - {9FF603F8-B3BB-4144-9688-B2B802FA0F16}.Debug|x64.Build.0 = Debug|x64 - {9FF603F8-B3BB-4144-9688-B2B802FA0F16}.DebugFast|Win32.ActiveCfg = DebugFast|Win32 - {9FF603F8-B3BB-4144-9688-B2B802FA0F16}.DebugFast|Win32.Build.0 = DebugFast|Win32 - {9FF603F8-B3BB-4144-9688-B2B802FA0F16}.DebugFast|x64.ActiveCfg = DebugFast|x64 - {9FF603F8-B3BB-4144-9688-B2B802FA0F16}.DebugFast|x64.Build.0 = DebugFast|x64 - {9FF603F8-B3BB-4144-9688-B2B802FA0F16}.Release|Win32.ActiveCfg = Release|Win32 - {9FF603F8-B3BB-4144-9688-B2B802FA0F16}.Release|Win32.Build.0 = Release|Win32 - {9FF603F8-B3BB-4144-9688-B2B802FA0F16}.Release|x64.ActiveCfg = Release|x64 - {9FF603F8-B3BB-4144-9688-B2B802FA0F16}.Release|x64.Build.0 = Release|x64 {1C3A7A91-A97F-4C7C-B45D-26F2242904D7}.Debug|Win32.ActiveCfg = Debug|Win32 {1C3A7A91-A97F-4C7C-B45D-26F2242904D7}.Debug|Win32.Build.0 = Debug|Win32 {1C3A7A91-A97F-4C7C-B45D-26F2242904D7}.Debug|x64.ActiveCfg = Debug|x64 diff --git a/Source/Plugins/Plugin_GCPad/Plugin_GCPad.vcproj b/Source/Plugins/Plugin_GCPad/Plugin_GCPad.vcproj deleted file mode 100644 index 23f647aafe..0000000000 --- a/Source/Plugins/Plugin_GCPad/Plugin_GCPad.vcproj +++ /dev/null @@ -1,559 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Source/Plugins/Plugin_GCPad/Src/Config.cpp b/Source/Plugins/Plugin_GCPad/Src/Config.cpp deleted file mode 100644 index dfeab270b4..0000000000 --- a/Source/Plugins/Plugin_GCPad/Src/Config.cpp +++ /dev/null @@ -1,261 +0,0 @@ -// Project description -// ------------------- -// Name: nJoy -// Description: A Dolphin Compatible Input Plugin -// -// Author: Falcon4ever (nJoy@falcon4ever.com) -// Site: www.multigesture.net -// Copyright (C) 2003 Dolphin Project. -// - - -// 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 "IniFile.h" -#include "Config.h" -#include "GCPad.h" -#include "FileUtil.h" -#include "WXInputBase.h" - -static const char* gcControlNames[] = -{ - "Button_A", - "Button_B", - "Button_X", - "Button_Y", - "Button_Z", - "Button_Start", - - "DPad_Up", - "DPad_Down", - "DPad_Left", - "DPad_Right", - - "Stick_Up", - "Stick_Down", - "Stick_Left", - "Stick_Right", - "Stick_Semi", - - "CStick_Up", - "CStick_Down", - "CStick_Left", - "CStick_Right", - "CStick_Semi", - - "Shoulder_L", - "Shoulder_R", - "Shoulder_Semi_L", - "Shoulder_Semi_R", -}; - -static const int gcDefaultControls[] = -#ifdef _WIN32 - { - 'X', - 'Z', - 'C', - 'S', - 'D', - VK_RETURN, - 'T', - 'G', - 'F', - 'H', - VK_UP, - VK_DOWN, - VK_LEFT, - VK_RIGHT, - VK_LSHIFT, - 'I', - 'K', - 'J', - 'L', - VK_LCONTROL, - 'Q', - 'W', - 0x00, - 0x00, - }; -#elif defined(HAVE_X11) && HAVE_X11 - { - XK_x, // A - XK_z, // B - XK_c, // X - XK_s, // Y - XK_d, // Z - XK_Return, // Start - XK_t, // D-pad up - XK_g, // D-pad down - XK_f, // D-pad left - XK_h, // D-pad right - 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 - 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 - XK_q, // L - XK_w, // R - 0x00, // L semi-press - 0x00, // R semi-press - }; -#elif defined(USE_WX) && USE_WX - { - 'X', // A - 'Z', // B - 'C', // X - 'S', // Y - 'D', // Z - WXK_RETURN, // Start - 'T', // D-pad up - 'G', // D-pad down - 'F', // D-pad left - 'H', // D-pad right - WXK_UP, // Main stick up - WXK_DOWN, // Main stick down - WXK_LEFT, // Main stick left - WXK_RIGHT, // Main stick right - WXK_SHIFT, // Main stick semi - 'I', // C-stick up - 'K', // C-stick down - 'J', // C-stick left - 'L', // C-stick right - WXK_CONTROL, // C-stick semi - 'Q', // L - 'W', // R - 0, // L semi-press - 0, // R semi-press - }; -#else - { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; -#endif - -Config g_Config; - -// Run when created -// ----------------- -Config::Config() -{ -} - -// Save settings to file -// --------------------- -void Config::Save() -{ - // Load ini file - IniFile file; - file.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "GCPad.ini").c_str()); - - // ================================================================== - // Global settings - file.Set("General", "NoTriggerFilter", g_Config.bNoTriggerFilter); -#ifdef RERECORDING - file.Set("General", "Recording", g_Config.bRecording); - file.Set("General", "Playback", g_Config.bPlayback); -#endif - - for (int i = 0; i < 4; i++) - { - // ================================================================== - // Slot specific settings only - std::string SectionName = StringFromFormat("GCPad%i", i+1); - file.Set(SectionName.c_str(), "DeviceID", GCMapping[i].ID); - file.Set(SectionName.c_str(), "Axis_Lx", GCMapping[i].AxisMapping.Lx); - file.Set(SectionName.c_str(), "Axis_Ly", GCMapping[i].AxisMapping.Ly); - file.Set(SectionName.c_str(), "Axis_Rx", GCMapping[i].AxisMapping.Rx); - file.Set(SectionName.c_str(), "Axis_Ry", GCMapping[i].AxisMapping.Ry); - file.Set(SectionName.c_str(), "Trigger_L", GCMapping[i].AxisMapping.Tl); - file.Set(SectionName.c_str(), "Trigger_R", GCMapping[i].AxisMapping.Tr); - file.Set(SectionName.c_str(), "DeadZoneL", GCMapping[i].DeadZoneL); - file.Set(SectionName.c_str(), "DeadZoneR", GCMapping[i].DeadZoneR); - file.Set(SectionName.c_str(), "Diagonal", GCMapping[i].Diagonal); - file.Set(SectionName.c_str(), "Square2Circle", GCMapping[i].bSquare2Circle); - file.Set(SectionName.c_str(), "Rumble", GCMapping[i].Rumble); - file.Set(SectionName.c_str(), "RumbleStrength", GCMapping[i].RumbleStrength); - file.Set(SectionName.c_str(), "TriggerType", GCMapping[i].TriggerType); - - file.Set(SectionName.c_str(), "Source_Stick", GCMapping[i].Stick.Main); - file.Set(SectionName.c_str(), "Source_CStick", GCMapping[i].Stick.Sub); - file.Set(SectionName.c_str(), "Source_Shoulder", GCMapping[i].Stick.Shoulder); - - file.Set(SectionName.c_str(), "Pressure_Stick", GCMapping[i].Pressure.Main); - file.Set(SectionName.c_str(), "Pressure_CStick", GCMapping[i].Pressure.Sub); - file.Set(SectionName.c_str(), "Pressure_Shoulder", GCMapping[i].Pressure.Shoulder); - - // ButtonMapping - for (int x = 0; x < LAST_CONSTANT; x++) - file.Set(SectionName.c_str(), gcControlNames[x], GCMapping[i].Button[x]); - } - - file.Save((std::string(File::GetUserPath(D_CONFIG_IDX)) + "GCPad.ini").c_str()); -} - -// Load settings from file -// ----------------------- -void Config::Load() -{ - // Load file - IniFile file; - file.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "GCPad.ini").c_str()); - - // ================================================================== - // Global settings - file.Get("General", "NoTriggerFilter", &g_Config.bNoTriggerFilter, false); - - for (int i = 0; i < 4; i++) - { - std::string SectionName = StringFromFormat("GCPad%i", i+1); - - file.Get(SectionName.c_str(), "DeviceID", &GCMapping[i].ID, 0); - file.Get(SectionName.c_str(), "Axis_Lx", &GCMapping[i].AxisMapping.Lx, 0); - file.Get(SectionName.c_str(), "Axis_Ly", &GCMapping[i].AxisMapping.Ly, 1); - file.Get(SectionName.c_str(), "Axis_Rx", &GCMapping[i].AxisMapping.Rx, 2); - file.Get(SectionName.c_str(), "Axis_Ry", &GCMapping[i].AxisMapping.Ry, 3); - file.Get(SectionName.c_str(), "Trigger_L", &GCMapping[i].AxisMapping.Tl, 1004); - file.Get(SectionName.c_str(), "Trigger_R", &GCMapping[i].AxisMapping.Tr, 1005); - file.Get(SectionName.c_str(), "DeadZoneL", &GCMapping[i].DeadZoneL, 0); - file.Get(SectionName.c_str(), "DeadZoneR", &GCMapping[i].DeadZoneR, 0); - file.Get(SectionName.c_str(), "Diagonal", &GCMapping[i].Diagonal, 100); - file.Get(SectionName.c_str(), "Square2Circle", &GCMapping[i].bSquare2Circle, false); - file.Get(SectionName.c_str(), "Rumble", &GCMapping[i].Rumble, false); - file.Get(SectionName.c_str(), "RumbleStrength", &GCMapping[i].RumbleStrength, 80); - file.Get(SectionName.c_str(), "TriggerType", &GCMapping[i].TriggerType, 0); - - file.Get(SectionName.c_str(), "Source_Stick", &GCMapping[i].Stick.Main, 0); - file.Get(SectionName.c_str(), "Source_CStick", &GCMapping[i].Stick.Sub, 0); - file.Get(SectionName.c_str(), "Source_Shoulder", &GCMapping[i].Stick.Shoulder, 0); - - file.Get(SectionName.c_str(), "Pressure_Stick", &GCMapping[i].Pressure.Main, DEF_STICK_HALF); - file.Get(SectionName.c_str(), "Pressure_CStick", &GCMapping[i].Pressure.Sub, DEF_STICK_HALF); - file.Get(SectionName.c_str(), "Pressure_Shoulder", &GCMapping[i].Pressure.Shoulder, DEF_TRIGGER_HALF); - - // ButtonMapping - for (int x = 0; x < LAST_CONSTANT; x++) - file.Get(SectionName.c_str(), gcControlNames[x], &GCMapping[i].Button[x], gcDefaultControls[x]); - } -} - diff --git a/Source/Plugins/Plugin_GCPad/Src/Config.h b/Source/Plugins/Plugin_GCPad/Src/Config.h deleted file mode 100644 index 9d99c4b4d7..0000000000 --- a/Source/Plugins/Plugin_GCPad/Src/Config.h +++ /dev/null @@ -1,49 +0,0 @@ -// Project description -// ------------------- -// Name: nJoy -// Description: A Dolphin Compatible Input Plugin -// -// Author: Falcon4ever (nJoy@falcon4ever.com) -// Site: www.multigesture.net -// Copyright (C) 2003 Dolphin Project. -// - - -// 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 _PLUGIN_GCPAD_CONFIG_H -#define _PLUGIN_GCPAD_CONFIG_H - -struct Config -{ - Config(); - void Load(); - void Save(); - - // General - bool bNoTriggerFilter; -#ifdef RERECORDING - bool bRecording; - bool bPlayback; -#endif -}; - -extern Config g_Config; - -#endif // _PLUGIN_GCPAD_CONFIG_H diff --git a/Source/Plugins/Plugin_GCPad/Src/ConfigBox.cpp b/Source/Plugins/Plugin_GCPad/Src/ConfigBox.cpp deleted file mode 100644 index 93e3ba752b..0000000000 --- a/Source/Plugins/Plugin_GCPad/Src/ConfigBox.cpp +++ /dev/null @@ -1,835 +0,0 @@ -// Project description -// ------------------- -// Name: nJoy -// Description: A Dolphin Compatible Input Plugin -// -// Author: Falcon4ever (nJoy@falcon4ever.com) -// Site: www.multigesture.net -// Copyright (C) 2003 Dolphin Project. -// - - -// 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 "math.h" // System -#include "WXInputBase.h" -#include "ConfigBox.h" -#include "Config.h" -#include "GCPad.h" -#if defined(HAVE_X11) && HAVE_X11 - #include - #include - #include - #include - #include "X11InputBase.h" -#endif - -// The wxWidgets class -BEGIN_EVENT_TABLE(GCPadConfigDialog,wxDialog) - EVT_CLOSE(GCPadConfigDialog::OnClose) - EVT_BUTTON(wxID_OK, GCPadConfigDialog::OnCloseClick) - EVT_BUTTON(wxID_CANCEL, GCPadConfigDialog::OnCloseClick) - EVT_NOTEBOOK_PAGE_CHANGED(ID_NOTEBOOK, GCPadConfigDialog::NotebookPageChanged) - - EVT_CHOICE(IDC_JOYNAME, GCPadConfigDialog::ChangeSettings) - EVT_CHECKBOX(IDC_RUMBLE, GCPadConfigDialog::ChangeSettings) - EVT_CHOICE(IDC_RUMBLE_STRENGTH, GCPadConfigDialog::ChangeSettings) - EVT_CHOICE(IDC_DEAD_ZONE_LEFT, GCPadConfigDialog::ChangeSettings) - EVT_CHOICE(IDC_DEAD_ZONE_RIGHT, GCPadConfigDialog::ChangeSettings) - EVT_CHOICE(IDC_STICK_DIAGONAL, GCPadConfigDialog::ChangeSettings) - EVT_CHECKBOX(IDC_STICK_S2C, GCPadConfigDialog::ChangeSettings) - EVT_CHOICE(IDC_TRIGGER_TYPE, GCPadConfigDialog::ChangeSettings) - EVT_CHOICE(IDC_STICK_SOURCE, GCPadConfigDialog::ChangeSettings) - EVT_CHOICE(IDC_CSTICK_SOURCE, GCPadConfigDialog::ChangeSettings) - EVT_CHOICE(IDC_TRIGGER_SOURCE, GCPadConfigDialog::ChangeSettings) - EVT_SLIDER(IDS_STICK_PRESS, GCPadConfigDialog::ChangeSettings) - EVT_SLIDER(IDS_CSTICK_PRESS, GCPadConfigDialog::ChangeSettings) - EVT_SLIDER(IDS_TRIGGER_PRESS, GCPadConfigDialog::ChangeSettings) - - EVT_BUTTON(IDB_ANALOG_LEFT_X, GCPadConfigDialog::OnAxisClick) - EVT_BUTTON(IDB_ANALOG_LEFT_Y, GCPadConfigDialog::OnAxisClick) - EVT_BUTTON(IDB_ANALOG_RIGHT_X, GCPadConfigDialog::OnAxisClick) - EVT_BUTTON(IDB_ANALOG_RIGHT_Y, GCPadConfigDialog::OnAxisClick) - EVT_BUTTON(IDB_TRIGGER_L, GCPadConfigDialog::OnAxisClick) - EVT_BUTTON(IDB_TRIGGER_R, GCPadConfigDialog::OnAxisClick) - - EVT_BUTTON(IDB_BTN_A, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_BTN_B, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_BTN_X, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_BTN_Y, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_BTN_Z, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_BTN_START, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_DPAD_UP, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_DPAD_DOWN, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_DPAD_LEFT, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_DPAD_RIGHT, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_MAIN_UP, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_MAIN_DOWN, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_MAIN_LEFT, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_MAIN_RIGHT, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_MAIN_SEMI, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_SUB_UP, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_SUB_DOWN, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_SUB_LEFT, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_SUB_RIGHT, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_SUB_SEMI, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_SHDR_L, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_SHDR_R, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_SHDR_SEMI_L, GCPadConfigDialog::OnButtonClick) - EVT_BUTTON(IDB_SHDR_SEMI_R, GCPadConfigDialog::OnButtonClick) - -#if wxUSE_TIMER - EVT_TIMER(IDTM_UPDATE_PAD, GCPadConfigDialog::UpdatePadInfo) - EVT_TIMER(IDTM_BUTTON, GCPadConfigDialog::OnButtonTimer) -#endif -END_EVENT_TABLE() - -GCPadConfigDialog::GCPadConfigDialog(wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint &position, const wxSize& size, long style) - : wxDialog(parent, id, title, position, size, style) -{ - // Define values - m_ControlsCreated = false; - m_Page = 0; - - // Create controls - CreateGUIControls(); - -#if wxUSE_TIMER - m_UpdatePadTimer = new wxTimer(this, IDTM_UPDATE_PAD); - m_ButtonMappingTimer = new wxTimer(this, IDTM_BUTTON); - - // Reset values - g_Pressed = 0; - ClickedButton = NULL; - GetButtonWaitingID = 0; - GetButtonWaitingTimer = 0; - - if (NumGoodPads) - { - // Start the constant timer - int TimesPerSecond = 10; - m_UpdatePadTimer->Start(1000 / TimesPerSecond); - } -#endif - - UpdateGUI(); -} - -GCPadConfigDialog::~GCPadConfigDialog() -{ - if (m_ButtonMappingTimer) - { - delete m_ButtonMappingTimer; - m_ButtonMappingTimer = NULL; - } - if (m_UpdatePadTimer) - { - delete m_UpdatePadTimer; - m_UpdatePadTimer = NULL; - } -} - -// Notebook page changed -void GCPadConfigDialog::NotebookPageChanged(wxNotebookEvent& event) -{ - // Update the global variable - m_Page = event.GetSelection(); - // Update GUI - UpdateGUI(); -} - -// Close window -void GCPadConfigDialog::OnClose(wxCloseEvent& event) -{ - // Allow wxWidgets to close the window - //event.Skip(); - - // Stop the timer - if (m_UpdatePadTimer) - m_UpdatePadTimer->Stop(); - if (m_ButtonMappingTimer) - m_ButtonMappingTimer->Stop(); - - EndModal(wxID_CLOSE); -} - -// Button Click -void GCPadConfigDialog::OnCloseClick(wxCommandEvent& event) -{ - switch (event.GetId()) - { - case wxID_OK: - g_Config.Save(); - Close(); // Call OnClose() - break; - case wxID_CANCEL: - g_Config.Load(); - Close(); // Call OnClose() - break; - } -} - -void GCPadConfigDialog::SaveButtonMapping(int Id, int Key) -{ - if (IDB_ANALOG_LEFT_X <= Id && Id <= IDB_TRIGGER_R) - { - GCMapping[m_Page].AxisMapping.Code[Id - IDB_ANALOG_LEFT_X] = Key; - } - else if (IDB_BTN_A <= Id && Id <= IDB_SHDR_SEMI_R) - { - GCMapping[m_Page].Button[Id - IDB_BTN_A] = Key; - } -} - -void GCPadConfigDialog::OnKeyDown(wxKeyEvent& event) -{ - //event.Skip(); - - if(ClickedButton != NULL) - { - // Save the key - g_Pressed = event.GetKeyCode(); - // Handle the keyboard key mapping - - // Allow the escape key to set a blank key - if (g_Pressed == WXK_ESCAPE) - { - SaveButtonMapping(ClickedButton->GetId(), -1); - SetButtonText(ClickedButton->GetId(), wxString()); - } - else - { - #ifdef _WIN32 - BYTE keyState[256]; - GetKeyboardState(keyState); - for (int i = 1; i < 256; ++i) - { - if ((keyState[i] & 0x80) != 0) - { - // Use the left and right specific keys instead of the common ones - if (i == VK_SHIFT || i == VK_CONTROL || i == VK_MENU) continue; - // Update the button label - SetButtonText(ClickedButton->GetId(), - wxString::FromAscii(InputCommon::VKToString(i).c_str())); - // Save the setting - SaveButtonMapping(ClickedButton->GetId(), i); - break; - } - } - #elif defined(HAVE_X11) && HAVE_X11 - char keyStr[128] = {0}; - int XKey = InputCommon::wxCharCodeWXToX(g_Pressed); - InputCommon::XKeyToString(XKey, keyStr); - SetButtonText(ClickedButton->GetId(), - wxString::FromAscii(keyStr)); - SaveButtonMapping(ClickedButton->GetId(), XKey); - #elif defined(USE_WX) && USE_WX - SetButtonText(ClickedButton->GetId(), - InputCommon::WXKeyToString(g_Pressed)); - SaveButtonMapping(ClickedButton->GetId(), g_Pressed); - #endif - } - EndGetButtons(); - } -} - -// Configure button mapping -void GCPadConfigDialog::OnButtonClick(wxCommandEvent& event) -{ - event.Skip(); - - // Don't allow space to start a new Press Key option, that will interfer with setting a key to space - if (g_Pressed == WXK_SPACE) { g_Pressed = 0; return; } - - if (m_ButtonMappingTimer->IsRunning()) return; - - wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard - wxKeyEventHandler(GCPadConfigDialog::OnKeyDown), - (wxObject*)0, this); - - // Create the button object - ClickedButton = (wxButton *)event.GetEventObject(); - // Save old label so we can revert back - OldLabel = ClickedButton->GetLabel(); - ClickedButton->SetWindowStyle(wxWANTS_CHARS); - ClickedButton->SetLabel(wxT("")); - DoGetButtons(ClickedButton->GetId()); -} - -// Configure axis mapping -void GCPadConfigDialog::OnAxisClick(wxCommandEvent& event) -{ - event.Skip(); - - if (m_ButtonMappingTimer->IsRunning()) return; - - ClickedButton = NULL; - wxButton* pButton = (wxButton *)event.GetEventObject(); - OldLabel = pButton->GetLabel(); - pButton->SetWindowStyle(wxWANTS_CHARS); - pButton->SetLabel(wxT("")); - DoGetButtons(pButton->GetId()); -} - -void GCPadConfigDialog::ChangeSettings(wxCommandEvent& event) -{ - int id = event.GetId(); - - switch (id) - { - case IDC_JOYNAME: - GCMapping[m_Page].ID = m_Joyname[m_Page]->GetSelection(); - GCMapping[m_Page].joy = joyinfo.at(GCMapping[m_Page].ID).joy; - break; - case IDC_DEAD_ZONE_LEFT: - GCMapping[m_Page].DeadZoneL = m_ComboDeadZoneLeft[m_Page]->GetSelection(); - break; - case IDC_DEAD_ZONE_RIGHT: - GCMapping[m_Page].DeadZoneR = m_ComboDeadZoneRight[m_Page]->GetSelection(); - break; - case IDC_STICK_DIAGONAL: - GCMapping[m_Page].Diagonal = 100 - m_ComboDiagonal[m_Page]->GetSelection() * 5; - break; - case IDC_STICK_S2C: - GCMapping[m_Page].bSquare2Circle = m_CheckS2C[m_Page]->IsChecked(); - break; - case IDC_RUMBLE: - GCMapping[m_Page].Rumble = m_CheckRumble[m_Page]->IsChecked(); - break; - case IDC_RUMBLE_STRENGTH: - GCMapping[m_Page].RumbleStrength = m_RumbleStrength[m_Page]->GetSelection() * 10; - break; - case IDC_TRIGGER_TYPE: - GCMapping[m_Page].TriggerType = m_TriggerType[m_Page]->GetSelection(); - break; - case IDC_STICK_SOURCE: - GCMapping[m_Page].Stick.Main = m_Combo_StickSrc[m_Page]->GetSelection(); - break; - case IDC_CSTICK_SOURCE: - GCMapping[m_Page].Stick.Sub = m_Combo_CStickSrc[m_Page]->GetSelection(); - break; - case IDC_TRIGGER_SOURCE: - GCMapping[m_Page].Stick.Shoulder = m_Combo_TriggerSrc[m_Page]->GetSelection(); - break; - case IDS_STICK_PRESS: - GCMapping[m_Page].Pressure.Main = m_Slider_Stick[m_Page]->GetValue(); - break; - case IDS_CSTICK_PRESS: - GCMapping[m_Page].Pressure.Sub = m_Slider_CStick[m_Page]->GetValue(); - break; - case IDS_TRIGGER_PRESS: - GCMapping[m_Page].Pressure.Shoulder = m_Slider_Trigger[m_Page]->GetValue(); - break; - } - - UpdateGUI(); -} - -void GCPadConfigDialog::UpdateGUI() -{ - if(!m_ControlsCreated) - return; - - // Disable all pad items if no pads are detected - bool PadEnabled = NumGoodPads != 0; - - m_Joyname[m_Page]->Enable(PadEnabled); - m_ComboDeadZoneLeft[m_Page]->Enable(PadEnabled); - m_ComboDeadZoneRight[m_Page]->Enable(PadEnabled); - m_CheckS2C[m_Page]->Enable(PadEnabled); - m_ComboDiagonal[m_Page]->Enable(PadEnabled); - m_CheckRumble[m_Page]->Enable(PadEnabled); - m_RumbleStrength[m_Page]->Enable(PadEnabled); - m_TriggerType[m_Page]->Enable(PadEnabled); - for(int i = 0; i <= IDB_TRIGGER_R - IDB_ANALOG_LEFT_X; i++) - m_Button_Analog[i][m_Page]->Enable(PadEnabled); - - wxString tmp; - - m_Joyname[m_Page]->SetSelection(GCMapping[m_Page].ID); - m_ComboDeadZoneLeft[m_Page]->SetSelection(GCMapping[m_Page].DeadZoneL); - m_ComboDeadZoneRight[m_Page]->SetSelection(GCMapping[m_Page].DeadZoneR); - m_ComboDiagonal[m_Page]->SetSelection((100 - GCMapping[m_Page].Diagonal) / 5); - m_CheckS2C[m_Page]->SetValue(GCMapping[m_Page].bSquare2Circle); - m_CheckRumble[m_Page]->SetValue(GCMapping[m_Page].Rumble); - m_RumbleStrength[m_Page]->SetSelection(GCMapping[m_Page].RumbleStrength / 10); - m_TriggerType[m_Page]->SetSelection(GCMapping[m_Page].TriggerType); - - m_Combo_StickSrc[m_Page]->SetSelection(GCMapping[m_Page].Stick.Main); - m_Combo_CStickSrc[m_Page]->SetSelection(GCMapping[m_Page].Stick.Sub); - m_Combo_TriggerSrc[m_Page]->SetSelection(GCMapping[m_Page].Stick.Shoulder); - m_Slider_Stick[m_Page]->SetValue(GCMapping[m_Page].Pressure.Main); - m_Slider_CStick[m_Page]->SetValue(GCMapping[m_Page].Pressure.Sub); - m_Slider_Trigger[m_Page]->SetValue(GCMapping[m_Page].Pressure.Shoulder); - - for (int i = 0; i <= IDB_TRIGGER_R - IDB_ANALOG_LEFT_X; i++) - { - tmp << GCMapping[m_Page].AxisMapping.Code[i]; - m_Button_Analog[i][m_Page]->SetLabel(tmp); - tmp.clear(); - } - -#ifdef _WIN32 - for (int x = 0; x <= IDB_SHDR_SEMI_R - IDB_BTN_A; x++) - { - m_Button_GC[x][m_Page]->SetLabel(wxString::FromAscii( - InputCommon::VKToString(GCMapping[m_Page].Button[x + EGC_A]).c_str())); - } -#elif defined(HAVE_X11) && HAVE_X11 - char keyStr[10] = {0}; - for (int x = 0; x <= IDB_SHDR_SEMI_R - IDB_BTN_A; x++) - { - InputCommon::XKeyToString(GCMapping[m_Page].Button[x + EGC_A], keyStr); - m_Button_GC[x][m_Page]->SetLabel(wxString::FromAscii(keyStr)); - } -#elif defined(USE_WX) && USE_WX - for (int x = 0; x <= IDB_SHDR_SEMI_R - IDB_BTN_A; x++) - { - m_Button_GC[x][m_Page]-> \ - SetLabel(InputCommon::WXKeyToString( - GCMapping[m_Page].Button[x + EGC_A])); - } -#endif - - DoChangeDeadZone(); -} - -void GCPadConfigDialog::CreateGUIControls() -{ - // Search for devices and add them to the device list - wxArrayString StrJoyname; // The string array - if (NumGoodPads > 0) - { - for (int i = 0; i < NumPads; i++) - StrJoyname.Add(wxString::FromAscii(joyinfo[i].Name.c_str())); - } - else - { - StrJoyname.Add(wxT("")); - } - - wxArrayString TextDeadZone; - for (int i = 0; i <= 50; i++) - TextDeadZone.Add(wxString::Format(wxT("%i%%"), i)); - - wxArrayString StrDiagonal; - for (int i = 0; i <= 10; i++) - StrDiagonal.Add(wxString::Format(wxT("%i%%"), 100 - i * 5)); - - wxArrayString StrRumble; - for (int i = 0; i <= 10; i++) - StrRumble.Add(wxString::Format(wxT("%i%%"), i * 10)); - - wxArrayString StrSource; - StrSource.Add(wxT("Keyboard")); - StrSource.Add(wxT("Analog 1")); - StrSource.Add(wxT("Analog 2")); - StrSource.Add(wxT("Triggers")); - - // The Trigger type list - wxArrayString StrTriggerType; - StrTriggerType.Add(wxT("SDL")); // -0x8000 to 0x7fff - StrTriggerType.Add(wxT("XInput")); // 0x00 to 0xff - - static const wxChar* anText[] = - { - wxT("Left X-Axis"), - wxT("Left Y-Axis"), - wxT("Right X-Axis"), - wxT("Right Y-Axis"), - wxT("Left Trigger"), - wxT("Right Trigger"), - }; - - static const wxChar* padText[] = - { - wxT("A"), - wxT("B"), - wxT("X"), - wxT("Y"), - wxT("Z"), - wxT("Start"), - - wxT("Up"), // D-Pad - wxT("Down"), - wxT("Left"), - wxT("Right"), - - wxT("Up"), // Main Stick - wxT("Down"), - wxT("Left"), - wxT("Right"), - wxT("Semi"), - - wxT("Up"), // C-Stick - wxT("Down"), - wxT("Left"), - wxT("Right"), - wxT("Semi"), - - wxT("L"), // Triggers - wxT("R"), - wxT("Semi-L"), - wxT("Semi-R"), - }; - - // Configuration controls sizes - static const int BtW = 70, BtH = 20; - // A small type font - wxFont m_SmallFont(7, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); - - m_Notebook = new wxNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize); - - for (int i = 0; i < 4; i++) - { - m_Controller[i] = new wxPanel(m_Notebook, ID_CONTROLLERPAGE1 + i, wxDefaultPosition, wxDefaultSize); - m_Notebook->AddPage(m_Controller[i], wxString::Format(wxT("Gamecube Pad %d"), i+1)); - - // Controller - m_Joyname[i] = new wxChoice(m_Controller[i], IDC_JOYNAME, wxDefaultPosition, wxSize(400, -1), StrJoyname, 0, wxDefaultValidator, StrJoyname[0]); - - // Dead zone - m_ComboDeadZoneLabel[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Dead Zone")); - m_ComboDeadZoneLeft[i] = new wxChoice(m_Controller[i], IDC_DEAD_ZONE_LEFT, wxDefaultPosition, wxSize(50, -1), TextDeadZone, 0, wxDefaultValidator, TextDeadZone[0]); - m_ComboDeadZoneRight[i] = new wxChoice(m_Controller[i], IDC_DEAD_ZONE_RIGHT, wxDefaultPosition, wxSize(50, -1), TextDeadZone, 0, wxDefaultValidator, TextDeadZone[0]); - - // Circle to square - m_CheckS2C[i] = new wxCheckBox(m_Controller[i], IDC_STICK_S2C, wxT("Square To Circle")); - m_CheckS2C[i]->SetToolTip(wxT("This will convert a square stick radius to a circle stick radius, which is\n") - wxT("similar to the octagonal area that the original GameCube pad produces.")); - - // The drop down menu for the circle to square adjustment - m_DiagonalLabel[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Diagonal")); - m_DiagonalLabel[i]->SetToolTip(wxT("To produce a perfect circle in the 'Out' window you have to manually set\n") - wxT("your diagonal values here from what is shown in the 'In' window.")); - m_ComboDiagonal[i] = new wxChoice(m_Controller[i], IDC_STICK_DIAGONAL, wxDefaultPosition, wxSize(50, -1), StrDiagonal, 0, wxDefaultValidator, StrDiagonal[0]); - - // Rumble - m_CheckRumble[i] = new wxCheckBox(m_Controller[i], IDC_RUMBLE, wxT("Rumble")); - m_RumbleStrengthLabel[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Strength")); - m_RumbleStrength[i] = new wxChoice(m_Controller[i], IDC_RUMBLE_STRENGTH, wxDefaultPosition, wxSize(50, -1), StrRumble, 0, wxDefaultValidator, StrRumble[0]); - // Sizers - m_sDeadZoneHoriz[i] = new wxBoxSizer(wxHORIZONTAL); - m_sDeadZoneHoriz[i]->Add(m_ComboDeadZoneLeft[i], 0, (wxUP), 0); - m_sDeadZoneHoriz[i]->Add(m_ComboDeadZoneRight[i], 0, (wxUP), 0); - - m_sDeadZone[i] = new wxBoxSizer(wxVERTICAL); - m_sDeadZone[i]->Add(m_ComboDeadZoneLabel[i], 0, wxALIGN_CENTER | (wxUP), 0); - m_sDeadZone[i]->Add(m_sDeadZoneHoriz[i], 0, wxALIGN_CENTER | (wxUP), 2); - - m_sDiagonal[i] = new wxBoxSizer(wxHORIZONTAL); - m_sDiagonal[i]->Add(m_DiagonalLabel[i], 0, (wxUP), 4); - m_sDiagonal[i]->Add(m_ComboDiagonal[i], 0, (wxLEFT), 2); - - m_sSquare2Circle[i] = new wxBoxSizer(wxVERTICAL); - m_sSquare2Circle[i]->Add(m_CheckS2C[i], 0, wxALIGN_CENTER | (wxUP), 0); - m_sSquare2Circle[i]->Add(m_sDiagonal[i], 0, wxALIGN_CENTER | (wxUP), 2); - - m_sRumbleStrength[i] = new wxBoxSizer(wxHORIZONTAL); - m_sRumbleStrength[i]->Add(m_RumbleStrengthLabel[i], 0, (wxUP), 4); - m_sRumbleStrength[i]->Add(m_RumbleStrength[i], 0, (wxLEFT), 2); - - m_sRumble[i] = new wxBoxSizer(wxVERTICAL); - m_sRumble[i]->Add(m_CheckRumble[i], 0, wxALIGN_CENTER | (wxUP), 0); - m_sRumble[i]->Add(m_sRumbleStrength[i], 0, wxALIGN_CENTER | (wxUP), 2); - - m_sS2CDeadZone[i] = new wxBoxSizer(wxHORIZONTAL); - m_sS2CDeadZone[i]->Add(m_sDeadZone[i], 0, (wxUP), 0); - m_sS2CDeadZone[i]->Add(m_sSquare2Circle[i], 0, (wxLEFT), 40); - m_sS2CDeadZone[i]->Add(m_sRumble[i], 0, (wxLEFT), 40); - - m_gJoyPad[i] = new wxStaticBoxSizer (wxVERTICAL, m_Controller[i], wxT("Gamepad")); - m_gJoyPad[i]->AddStretchSpacer(); - m_gJoyPad[i]->Add(m_Joyname[i], 0, wxEXPAND | (wxLEFT | wxRIGHT | wxDOWN), 5); - m_gJoyPad[i]->Add(m_sS2CDeadZone[i], 0, wxALIGN_CENTER | (wxUP | wxDOWN), 4); - m_gJoyPad[i]->AddStretchSpacer(); - - // Row 1 Sizers: Connected pads, tilt - m_sHorizJoypad[i] = new wxBoxSizer(wxHORIZONTAL); - m_sHorizJoypad[i]->Add(m_gJoyPad[i], 0, wxEXPAND | (wxLEFT), 5); - - - // Stick Status Panels - m_tStatusLeftIn[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Not connected")); - m_tStatusLeftOut[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Not connected")); - m_tStatusRightIn[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Not connected")); - m_tStatusRightOut[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Not connected")); - - 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); - m_bmpSquareLeftOut[i] = new wxStaticBitmap(m_pLeftOutStatus[i], wxID_ANY, CreateBitmap(), wxDefaultPosition, wxDefaultSize); - m_bmpDotLeftOut[i] = new wxStaticBitmap(m_pLeftOutStatus[i], wxID_ANY, CreateBitmapDot(), wxPoint(BoxW / 2, BoxH / 2), wxDefaultSize); - - m_pRightInStatus[i] = new wxPanel(m_Controller[i], wxID_ANY, wxDefaultPosition, wxDefaultSize); - m_bmpSquareRightIn[i] = new wxStaticBitmap(m_pRightInStatus[i], wxID_ANY, CreateBitmap(), wxDefaultPosition, wxDefaultSize); - m_bmpDeadZoneRightIn[i] = new wxStaticBitmap(m_pRightInStatus[i], wxID_ANY, CreateBitmapDeadZone(0), wxDefaultPosition, wxDefaultSize); - m_bmpDotRightIn[i] = new wxStaticBitmap(m_pRightInStatus[i], wxID_ANY, CreateBitmapDot(), wxPoint(BoxW / 2, BoxH / 2), wxDefaultSize); - - m_pRightOutStatus[i] = new wxPanel(m_Controller[i], wxID_ANY, wxDefaultPosition, wxDefaultSize); - m_bmpSquareRightOut[i] = new wxStaticBitmap(m_pRightOutStatus[i], wxID_ANY, CreateBitmap(), wxDefaultPosition, wxDefaultSize); - m_bmpDotRightOut[i] = new wxStaticBitmap(m_pRightOutStatus[i], wxID_ANY, CreateBitmapDot(), wxPoint(BoxW / 2, BoxH / 2), wxDefaultSize); - - // Sizers - m_sGridStickLeft[i] = new wxGridBagSizer(0, 0); - m_sGridStickLeft[i]->Add(m_pLeftInStatus[i], wxGBPosition(0, 0), wxGBSpan(1, 1), wxALL, 0); - m_sGridStickLeft[i]->Add(m_pLeftOutStatus[i], wxGBPosition(0, 1), wxGBSpan(1, 1), wxLEFT, 10); - m_sGridStickLeft[i]->Add(m_tStatusLeftIn[i], wxGBPosition(1, 0), wxGBSpan(1, 1), wxALL, 0); - m_sGridStickLeft[i]->Add(m_tStatusLeftOut[i], wxGBPosition(1, 1), wxGBSpan(1, 1), wxLEFT, 10); - - m_sGridStickRight[i] = new wxGridBagSizer(0, 0); - m_sGridStickRight[i]->Add(m_pRightInStatus[i], wxGBPosition(0, 0), wxGBSpan(1, 1), wxALL, 0); - m_sGridStickRight[i]->Add(m_pRightOutStatus[i], wxGBPosition(0, 1), wxGBSpan(1, 1), wxLEFT, 10); - m_sGridStickRight[i]->Add(m_tStatusRightIn[i], wxGBPosition(1, 0), wxGBSpan(1, 1), wxALL, 0); - m_sGridStickRight[i]->Add(m_tStatusRightOut[i], wxGBPosition(1, 1), wxGBSpan(1, 1), wxLEFT, 10); - - m_gStickLeft[i] = new wxStaticBoxSizer (wxHORIZONTAL, m_Controller[i], wxT("Analog 1 Status (In) (Out)")); - m_gStickLeft[i]->Add(m_sGridStickLeft[i], 0, (wxLEFT | wxRIGHT), 5); - - m_gStickRight[i] = new wxStaticBoxSizer (wxHORIZONTAL, m_Controller[i], wxT("Analog 2 Status (In) (Out)")); - m_gStickRight[i]->Add(m_sGridStickRight[i], 0, (wxLEFT | wxRIGHT), 5); - - // Trigger Status Panels - m_TriggerL[i]= new wxStaticText(m_Controller[i], wxID_ANY, wxT("Left: ")); - m_TriggerR[i]= new wxStaticText(m_Controller[i], wxID_ANY, wxT("Right: ")); - m_TriggerStatusL[i]= new wxStaticText(m_Controller[i], wxID_ANY, wxT("000"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); - m_TriggerStatusR[i]= new wxStaticText(m_Controller[i], wxID_ANY, wxT("000"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); - m_tTriggerSource[i]= new wxStaticText(m_Controller[i], wxID_ANY, wxT("Trigger Source")); - m_TriggerType[i] = new wxChoice(m_Controller[i], IDC_TRIGGER_TYPE, wxDefaultPosition, wxSize(70, -1), StrTriggerType, 0, wxDefaultValidator, StrTriggerType[0]); - - // Sizers - m_sGridTrigger[i] = new wxGridBagSizer(0, 0); - m_sGridTrigger[i]->Add(m_TriggerL[i], wxGBPosition(0, 0), wxGBSpan(1, 1), (wxTOP), 4); - m_sGridTrigger[i]->Add(m_TriggerStatusL[i], wxGBPosition(0, 1), wxGBSpan(1, 1), (wxLEFT | wxTOP), 4); - m_sGridTrigger[i]->Add(m_TriggerR[i], wxGBPosition(1, 0), wxGBSpan(1, 1), (wxTOP), 4); - m_sGridTrigger[i]->Add(m_TriggerStatusR[i], wxGBPosition(1, 1), wxGBSpan(1, 1), (wxLEFT | wxTOP), 4); - - m_gTriggers[i] = new wxStaticBoxSizer (wxVERTICAL, m_Controller[i], wxT("Triggers Status")); - m_gTriggers[i]->AddStretchSpacer(); - m_gTriggers[i]->Add(m_sGridTrigger[i], 0, wxEXPAND | (wxLEFT | wxRIGHT), 5); - m_gTriggers[i]->Add(m_tTriggerSource[i], 0, wxEXPAND | (wxUP | wxLEFT | wxRIGHT), 5); - m_gTriggers[i]->Add(m_TriggerType[i], 0, wxEXPAND | (wxUP | wxLEFT | wxRIGHT), 5); - m_gTriggers[i]->AddStretchSpacer(); - - // Row 2 Sizers: Analog status - m_sHorizStatus[i] = new wxBoxSizer(wxHORIZONTAL); - m_sHorizStatus[i]->Add(m_gStickLeft[i], 0, wxEXPAND | (wxLEFT), 5); - m_sHorizStatus[i]->Add(m_gStickRight[i], 0, wxEXPAND | (wxLEFT), 5); - m_sHorizStatus[i]->Add(m_gTriggers[i], 0, wxEXPAND | (wxLEFT), 5); - - - // Analog Axes and Triggers Mapping - m_sAnalogLeft[i] = new wxBoxSizer(wxVERTICAL); - m_sAnalogMiddle[i] = new wxBoxSizer(wxVERTICAL); - m_sAnalogRight[i] = new wxBoxSizer(wxVERTICAL); - - for (int x = 0; x < 6; x++) - { - m_Text_Analog[x][i] = new wxStaticText(m_Controller[i], wxID_ANY, anText[x]); - m_Button_Analog[x][i] = new wxButton(m_Controller[i], x + IDB_ANALOG_LEFT_X, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH)); - m_Button_Analog[x][i]->SetFont(m_SmallFont); - m_Sizer_Analog[x][i] = new wxBoxSizer(wxHORIZONTAL); - m_Sizer_Analog[x][i]->Add(m_Text_Analog[x][i], 0, (wxUP), 4); - m_Sizer_Analog[x][i]->Add(m_Button_Analog[x][i], 0, (wxLEFT), 2); - if (x < 2) // Make some balance - m_sAnalogLeft[i]->Add(m_Sizer_Analog[x][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1); - else if (x < 4) - m_sAnalogMiddle[i]->Add(m_Sizer_Analog[x][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1); - else - m_sAnalogRight[i]->Add(m_Sizer_Analog[x][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1); - } - - m_gAnalog[i] = new wxStaticBoxSizer (wxHORIZONTAL, m_Controller[i], wxT("Analog Axes and Triggers")); - m_gAnalog[i]->Add(m_sAnalogLeft[i], 0, wxALIGN_RIGHT | (wxALL), 0); - m_gAnalog[i]->Add(m_sAnalogMiddle[i], 0, wxALIGN_RIGHT | (wxLEFT), 5); - m_gAnalog[i]->Add(m_sAnalogRight[i], 0, wxALIGN_RIGHT | (wxLEFT), 5); - - // Row 3 Sizes: Analog Mapping - m_sHorizAnalog[i] = new wxBoxSizer(wxHORIZONTAL); - m_sHorizAnalog[i]->Add(m_gAnalog[i], 0, (wxLEFT), 5); - - - // Pad Mapping - m_gButton[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Buttons")); - m_gDPad[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("D-Pad")); - m_gStick[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Main Stick")); - m_Text_StickSrc[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Source")); - m_Combo_StickSrc[i] = new wxChoice(m_Controller[i], IDC_STICK_SOURCE, wxDefaultPosition, wxSize(70, -1), StrSource, 0, wxDefaultValidator, StrSource[0]); - m_sStickSrc[i] = new wxBoxSizer(wxHORIZONTAL); - m_sStickSrc[i]->Add(m_Text_StickSrc[i], 0, (wxUP), 4); - m_sStickSrc[i]->Add(m_Combo_StickSrc[i], 0, (wxLEFT), 2); - m_gStick[i]->Add(m_sStickSrc[i], 0, wxALIGN_RIGHT | (wxALL), 2); - m_gStick[i]->AddSpacer(2); - m_gCStick[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("C-Stick")); - m_Text_CStickSrc[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Source")); - m_Combo_CStickSrc[i] = new wxChoice(m_Controller[i], IDC_CSTICK_SOURCE, wxDefaultPosition, wxSize(70, -1), StrSource, 0, wxDefaultValidator, StrSource[0]); - m_sCStickSrc[i] = new wxBoxSizer(wxHORIZONTAL); - m_sCStickSrc[i]->Add(m_Text_CStickSrc[i], 0, (wxUP), 4); - m_sCStickSrc[i]->Add(m_Combo_CStickSrc[i], 0, (wxLEFT), 2); - m_gCStick[i]->Add(m_sCStickSrc[i], 0, wxALIGN_RIGHT | (wxALL), 2); - m_gCStick[i]->AddSpacer(2); - m_gTrigger[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Triggers")); - m_Text_TriggerSrc[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Source")); - m_Combo_TriggerSrc[i] = new wxChoice(m_Controller[i], IDC_TRIGGER_SOURCE, wxDefaultPosition, wxSize(70, -1), StrSource, 0, wxDefaultValidator, StrSource[0]); - m_sTriggerSrc[i] = new wxBoxSizer(wxHORIZONTAL); - m_sTriggerSrc[i]->Add(m_Text_TriggerSrc[i], 0, (wxUP), 4); - m_sTriggerSrc[i]->Add(m_Combo_TriggerSrc[i], 0, (wxLEFT), 2); - m_gTrigger[i]->Add(m_sTriggerSrc[i], 0, wxALIGN_RIGHT | (wxALL), 2); - m_gTrigger[i]->AddSpacer(2); - - for (int x = 0; x <= IDB_SHDR_SEMI_R - IDB_BTN_A; x++) - { - m_Text_Pad[x][i] = new wxStaticText(m_Controller[i], wxID_ANY, padText[x]); - m_Button_GC[x][i] = new wxButton(m_Controller[i], x + IDB_BTN_A, wxEmptyString, wxDefaultPosition, wxSize(BtW, BtH)); - m_Button_GC[x][i]->SetFont(m_SmallFont); - m_Sizer_Pad[x][i] = new wxBoxSizer(wxHORIZONTAL); - m_Sizer_Pad[x][i]->Add(m_Text_Pad[x][i], 0, (wxUP), 4); - m_Sizer_Pad[x][i]->Add(m_Button_GC[x][i], 0, (wxLEFT), 2); - if (x <= IDB_BTN_START) - m_gButton[i]->Add(m_Sizer_Pad[x - IDB_BTN_A][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1); - else if (x <= IDB_DPAD_RIGHT) - m_gDPad[i]->Add(m_Sizer_Pad[x - IDB_BTN_A][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1); - else if (x <= IDB_MAIN_SEMI) - m_gStick[i]->Add(m_Sizer_Pad[x - IDB_BTN_A][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1); - else if (x <= IDB_SUB_SEMI) - m_gCStick[i]->Add(m_Sizer_Pad[x - IDB_BTN_A][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1); - else - m_gTrigger[i]->Add(m_Sizer_Pad[x - IDB_BTN_A][i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1); - } - - m_Slider_Stick[i] = new wxSlider(m_Controller[i], IDS_STICK_PRESS, DEF_STICK_HALF, 0, DEF_STICK_FULL, wxDefaultPosition, wxSize(100,-1), wxSL_LABELS | wxSL_TOP); - m_gStick[i]->Add(m_Slider_Stick[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1); - m_Slider_CStick[i] = new wxSlider(m_Controller[i], IDS_CSTICK_PRESS, DEF_STICK_HALF, 0, DEF_STICK_FULL, wxDefaultPosition, wxSize(100,-1), wxSL_LABELS | wxSL_TOP); - m_gCStick[i]->Add(m_Slider_CStick[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1); - m_Slider_Trigger[i] = new wxSlider(m_Controller[i], IDS_TRIGGER_PRESS, DEF_TRIGGER_HALF, 0, DEF_TRIGGER_FULL, wxDefaultPosition, wxSize(100,-1), wxSL_LABELS | wxSL_TOP); - m_gTrigger[i]->Add(m_Slider_Trigger[i], 0, wxALIGN_RIGHT | (wxLEFT | wxRIGHT | wxDOWN), 1); - - // Row 4 Sizers: Button Mapping - m_sHorizMapping[i] = new wxBoxSizer(wxHORIZONTAL); - m_sHorizMapping[i]->Add(m_gButton[i], 0, (wxLEFT), 5); - m_sHorizMapping[i]->Add(m_gDPad[i], 0, (wxLEFT), 5); - m_sHorizMapping[i]->Add(m_gStick[i], 0, (wxLEFT), 5); - m_sHorizMapping[i]->Add(m_gCStick[i], 0, (wxLEFT), 5); - m_sHorizMapping[i]->Add(m_gTrigger[i], 0, (wxLEFT), 5); - - - // Set up sizers and layout - // The sizer m_sMain will be expanded inside m_Controller - m_sMain[i] = new wxBoxSizer(wxVERTICAL); - m_sMain[i]->Add(m_sHorizJoypad[i], 0, wxEXPAND | (wxLEFT | wxRIGHT | wxDOWN), 5); - m_sMain[i]->Add(m_sHorizStatus[i], 0, wxEXPAND | (wxLEFT | wxRIGHT | wxDOWN), 5); - m_sMain[i]->Add(m_sHorizAnalog[i], 0, wxEXPAND | (wxLEFT | wxRIGHT | wxDOWN), 5); - m_sMain[i]->Add(m_sHorizMapping[i], 0, wxEXPAND | (wxLEFT | wxRIGHT | wxDOWN), 5); - - // Set the main sizer - m_Controller[i]->SetSizer(m_sMain[i]); - } - - m_OK = new wxButton(this, wxID_OK, wxT("OK")); - m_OK->SetToolTip(wxT("Save changes and close")); - m_Cancel = new wxButton(this, wxID_CANCEL, wxT("Cancel")); - m_Cancel->SetToolTip(wxT("Discard changes and close")); - wxBoxSizer* m_DlgButton = new wxBoxSizer(wxHORIZONTAL); - m_DlgButton->AddStretchSpacer(); - m_DlgButton->Add(m_OK, 0, (wxLEFT), 5); - m_DlgButton->Add(m_Cancel, 0, (wxLEFT), 5); - - m_MainSizer = new wxBoxSizer(wxVERTICAL); - m_MainSizer->Add(m_Notebook, 1, wxEXPAND | wxALL, 5); - m_MainSizer->Add(m_DlgButton, 0, wxEXPAND | (wxLEFT | wxRIGHT | wxDOWN), 5); - - SetSizer(m_MainSizer); - Layout(); - Fit(); - // Center the window if there is room for it - #ifdef _WIN32 - if (GetSystemMetrics(SM_CYFULLSCREEN) > 600) - Center(); - #endif - - m_ControlsCreated = true; -} - -// Bitmap box and dot -wxBitmap GCPadConfigDialog::CreateBitmap() -{ - BoxW = 70, BoxH = 70; - wxBitmap bitmap(BoxW, BoxH); - wxMemoryDC dc; - dc.SelectObject(bitmap); - - // Set outline and fill colors - wxPen LightBluePen(_T("#7f9db9")); // Windows XP color - dc.SetPen(LightBluePen); - dc.SetBrush(*wxWHITE_BRUSH); - - dc.Clear(); - dc.DrawRectangle(0, 0, BoxW, BoxH); - dc.SelectObject(wxNullBitmap); - return bitmap; -} - -wxBitmap GCPadConfigDialog::CreateBitmapDot() -{ - int w = 2, h = 2; - wxBitmap bitmap(w, h); - wxMemoryDC dc; - dc.SelectObject(bitmap); - - // Set outline and fill colors - dc.SetPen(*wxRED_PEN); - dc.SetBrush(*wxRED_BRUSH); - - dc.Clear(); - dc.DrawRectangle(0, 0, w, h); - dc.SelectObject(wxNullBitmap); - return bitmap; -} - -wxBitmap GCPadConfigDialog::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 GCPadConfigDialog::CreateBitmapClear() -{ - wxBitmap bitmap(BoxW, BoxH); - wxMemoryDC dc; - dc.SelectObject(bitmap); - - dc.Clear(); - dc.SelectObject(wxNullBitmap); - return bitmap; -} diff --git a/Source/Plugins/Plugin_GCPad/Src/ConfigBox.h b/Source/Plugins/Plugin_GCPad/Src/ConfigBox.h deleted file mode 100644 index 8069be9f94..0000000000 --- a/Source/Plugins/Plugin_GCPad/Src/ConfigBox.h +++ /dev/null @@ -1,243 +0,0 @@ -// Project description -// ------------------- -// Name: nJoy -// Description: A Dolphin Compatible Input Plugin -// -// Author: Falcon4ever (nJoy@falcon4ever.com) -// Site: www.multigesture.net -// Copyright (C) 2003 Dolphin Project. -// - - -// 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 __GCPAD_CONFIGBOX_h__ -#define __GCPAD_CONFIGBOX_h__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "GCPad.h" - -class GCPadConfigDialog : public wxDialog -{ - public: - GCPadConfigDialog(wxWindow *parent, wxWindowID id = wxID_ANY, - const wxString &title = wxT("Gamecube Pad Plugin Configuration"), - const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_DIALOG_STYLE); - virtual ~GCPadConfigDialog(); - - private: - DECLARE_EVENT_TABLE(); - - enum - { - // it's important that they are kept in this order - IDB_BTN_A = 0, - IDB_BTN_B, - IDB_BTN_X, - IDB_BTN_Y, - IDB_BTN_Z, - IDB_BTN_START, - - IDB_DPAD_UP, - IDB_DPAD_DOWN, - IDB_DPAD_LEFT, - IDB_DPAD_RIGHT, - - IDB_MAIN_UP, - IDB_MAIN_DOWN, - IDB_MAIN_LEFT, - IDB_MAIN_RIGHT, - IDB_MAIN_SEMI, - - IDB_SUB_UP, - IDB_SUB_DOWN, - IDB_SUB_LEFT, - IDB_SUB_RIGHT, - IDB_SUB_SEMI, - - IDB_SHDR_L, - IDB_SHDR_R, - IDB_SHDR_SEMI_L, - IDB_SHDR_SEMI_R, - - // Joypad - IDB_ANALOG_LEFT_X, IDB_ANALOG_LEFT_Y, - IDB_ANALOG_RIGHT_X, IDB_ANALOG_RIGHT_Y, - IDB_TRIGGER_L, IDB_TRIGGER_R, - - // Dialog controls - ID_NOTEBOOK = 1000, - ID_CONTROLLERPAGE1, - ID_CONTROLLERPAGE2, - ID_CONTROLLERPAGE3, - ID_CONTROLLERPAGE4, - - // Timers - IDTM_BUTTON, IDTM_UPDATE_PAD, - - // Gamepad settings - IDC_JOYNAME, - IDC_DEAD_ZONE_LEFT, IDC_DEAD_ZONE_RIGHT, - IDC_STICK_DIAGONAL, IDC_STICK_S2C, - IDC_RUMBLE, IDC_RUMBLE_STRENGTH, - IDC_TRIGGER_TYPE, - IDC_STICK_SOURCE, IDC_CSTICK_SOURCE, IDC_TRIGGER_SOURCE, - IDS_STICK_PRESS, IDS_CSTICK_PRESS, IDS_TRIGGER_PRESS, - }; - - wxNotebook *m_Notebook; - - wxPanel *m_Controller[4], - *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]; - - wxSlider *m_Slider_Stick[4], - *m_Slider_CStick[4], - *m_Slider_Trigger[4]; - - wxCheckBox *m_CheckS2C[4], - *m_CheckRumble[4]; - - wxButton *m_OK, *m_Cancel, *ClickedButton, - *m_Button_Analog[IDB_TRIGGER_R - IDB_ANALOG_LEFT_X + 1][4], - *m_Button_GC[IDB_SHDR_SEMI_R - IDB_BTN_A + 1][4]; - - wxChoice *m_Joyname[4], - *m_ComboDeadZoneLeft[4], - *m_ComboDeadZoneRight[4], - *m_ComboDiagonal[4], - *m_RumbleStrength[4], - *m_TriggerType[4], - *m_Combo_StickSrc[4], - *m_Combo_CStickSrc[4], - *m_Combo_TriggerSrc[4]; - - wxGridBagSizer *m_sGridStickLeft[4], - *m_sGridStickRight[4], - *m_sGridTrigger[4]; - - wxBoxSizer *m_MainSizer, - *m_sMain[4], - *m_sDeadZoneHoriz[4], - *m_sDeadZone[4], - *m_sDiagonal[4], - *m_sSquare2Circle[4], - *m_sS2CDeadZone[4], - *m_sRumbleStrength[4], - *m_sRumble[4], - *m_sHorizJoypad[4], - *m_sHorizStatus[4], - *m_Sizer_Analog[IDB_TRIGGER_R - IDB_ANALOG_LEFT_X + 1][4], - *m_sAnalogLeft[4], - *m_sAnalogMiddle[4], - *m_sAnalogRight[4], - *m_sHorizAnalog[4], - *m_sStickSrc[4], - *m_sCStickSrc[4], - *m_sTriggerSrc[4], - *m_Sizer_Pad[IDB_SHDR_SEMI_R - IDB_BTN_A + 1][4], - *m_sHorizMapping[4]; - - wxStaticBoxSizer *m_gJoyPad[4], - *m_gStickLeft[4], - *m_gStickRight[4], - *m_gTriggers[4], - *m_gAnalog[4], - *m_gButton[4], - *m_gDPad[4], - *m_gStick[4], - *m_gCStick[4], - *m_gTrigger[4]; - - wxStaticText *m_ComboDeadZoneLabel[4], - *m_DiagonalLabel[4], - *m_RumbleStrengthLabel[4], - *m_tStatusLeftIn[4], *m_tStatusLeftOut[4], - *m_tStatusRightIn[4], *m_tStatusRightOut[4], - *m_TriggerL[4], *m_TriggerR[4], - *m_TriggerStatusL[4], *m_TriggerStatusR[4], - *m_tTriggerSource[4], - *m_Text_Analog[IDB_TRIGGER_R - IDB_ANALOG_LEFT_X + 1][4], - *m_Text_Pad[IDB_SHDR_SEMI_R - IDB_BTN_A + 1][4], - *m_Text_StickSrc[4], - *m_Text_CStickSrc[4], - *m_Text_TriggerSrc[4]; - - wxStaticBitmap *m_bmpDotLeftIn[4], - *m_bmpDotLeftOut[4], - *m_bmpDotRightIn[4], - *m_bmpDotRightOut[4], - *m_bmpDeadZoneLeftIn[4], - *m_bmpDeadZoneRightIn[4]; - - bool m_ControlsCreated; - int m_Page, BoxW, BoxH; - int GetButtonWaitingID, GetButtonWaitingTimer, g_Pressed; - wxString OldLabel; - - #if wxUSE_TIMER - wxTimer *m_UpdatePadTimer, *m_ButtonMappingTimer; - void UpdatePadInfo(wxTimerEvent& WXUNUSED(event)); - void OnButtonTimer(wxTimerEvent& WXUNUSED(event)) { DoGetButtons(GetButtonWaitingID); } - #endif - - wxBitmap CreateBitmap(); - wxBitmap CreateBitmapDot(); - wxBitmap CreateBitmapDeadZone(int Radius); - wxBitmap CreateBitmapClear(); - - void NotebookPageChanged(wxNotebookEvent& event); - void OnClose(wxCloseEvent& event); - void OnCloseClick(wxCommandEvent& event); - void OnKeyDown(wxKeyEvent& event); - void OnButtonClick(wxCommandEvent& event); - void OnAxisClick(wxCommandEvent& event); - void ChangeSettings(wxCommandEvent& event); - void SaveButtonMapping(int Id, int Key); - void UpdateGUI(); - void CreateGUIControls(); - - void Convert2Box(int &x); - void DoChangeDeadZone(); - void ToBlank(bool ToBlank, int Id); - - void DoGetButtons(int _GetId); - void EndGetButtons(); - void SetButtonText(int id, const wxString &str); - wxString GetButtonText(int id); -}; - -#endif // __GCPAD_CONFIGBOX_h__ diff --git a/Source/Plugins/Plugin_GCPad/Src/ConfigJoypad.cpp b/Source/Plugins/Plugin_GCPad/Src/ConfigJoypad.cpp deleted file mode 100644 index a73e45e994..0000000000 --- a/Source/Plugins/Plugin_GCPad/Src/ConfigJoypad.cpp +++ /dev/null @@ -1,329 +0,0 @@ -// Project description -// ------------------- -// Name: nJoy -// Description: A Dolphin Compatible Input Plugin -// -// Author: Falcon4ever (nJoy@falcon4ever.com) -// Site: www.multigesture.net -// Copyright (C) 2003 Dolphin Project. -// - - -// 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 "Config.h" -#include "ConfigBox.h" -#include "GCPad.h" - - -// Replace the harder to understand -1 with "" for the sake of user friendliness -void GCPadConfigDialog::ToBlank(bool toBlank, int Id) -{ - if (!m_ControlsCreated) - return; - - if(toBlank) - { - if (GetButtonText(Id) == wxString(wxT("-1"))) - SetButtonText(Id, wxString()); - } - else - { - if (GetButtonText(Id).IsEmpty()) - SetButtonText(Id, wxString(wxT("-1"))); - } -} - -void GCPadConfigDialog::DoChangeDeadZone() -{ - float Rad; - - Rad = (float)GCMapping[m_Page].DeadZoneL * ((float)BoxW / 100.0) * 0.5; - m_bmpDeadZoneLeftIn[m_Page]->SetBitmap(CreateBitmapClear()); - m_bmpDeadZoneLeftIn[m_Page]->SetSize(0, 0); - m_bmpDeadZoneLeftIn[m_Page]->SetBitmap(CreateBitmapDeadZone((int)Rad)); - m_bmpDeadZoneLeftIn[m_Page]->SetPosition(wxPoint(BoxW / 2 - (int)Rad, BoxH / 2 - (int)Rad)); - m_bmpDeadZoneLeftIn[m_Page]->Refresh(); - - Rad = (float)GCMapping[m_Page].DeadZoneR * ((float)BoxW / 100.0) * 0.5; - m_bmpDeadZoneRightIn[m_Page]->SetBitmap(CreateBitmapClear()); - m_bmpDeadZoneRightIn[m_Page]->SetSize(0, 0); - m_bmpDeadZoneRightIn[m_Page]->SetBitmap(CreateBitmapDeadZone((int)Rad)); - m_bmpDeadZoneRightIn[m_Page]->SetPosition(wxPoint(BoxW / 2 - (int)Rad, BoxH / 2 - (int)Rad)); - m_bmpDeadZoneRightIn[m_Page]->Refresh(); -} - -// Update the textbox for the buttons -void GCPadConfigDialog::SetButtonText(int id, const wxString &str) -{ - if (IDB_ANALOG_LEFT_X <= id && id <= IDB_TRIGGER_R) - m_Button_Analog[id - IDB_ANALOG_LEFT_X][m_Page]->SetLabel(str); - else if (IDB_BTN_A <= id && id <= IDB_SHDR_SEMI_R) - m_Button_GC[id - IDB_BTN_A][m_Page]->SetLabel(str); -} - -// Get the text in the textbox for the buttons -wxString GCPadConfigDialog::GetButtonText(int id) -{ - if (IDB_ANALOG_LEFT_X <= id && id <= IDB_TRIGGER_R) - return m_Button_Analog[id - IDB_ANALOG_LEFT_X][m_Page]->GetLabel(); - else if (IDB_BTN_A <= id && id <= IDB_SHDR_SEMI_R) - return m_Button_GC[id - IDB_BTN_A][m_Page]->GetLabel(); - - return wxString(); -} - -void GCPadConfigDialog::DoGetButtons(int _GetId) -{ - // Collect the starting values - // Get the current controller - int PadID = GCMapping[m_Page].ID; - - // Get the controller and trigger type - int TriggerType = GCMapping[m_Page].TriggerType; - - // Collect the accepted buttons for this slot - bool LeftRight = (_GetId == IDB_TRIGGER_L || _GetId == IDB_TRIGGER_R); - - bool Axis = (_GetId >= IDB_ANALOG_LEFT_X && _GetId <= IDB_TRIGGER_R) - // Don't allow SDL axis input for the shoulder buttons if XInput is selected - && !(TriggerType == InputCommon::CTL_TRIGGER_XINPUT && (_GetId == IDB_TRIGGER_L || _GetId == IDB_TRIGGER_R) ); - - bool XInput = (TriggerType == InputCommon::CTL_TRIGGER_XINPUT); - - bool Button = (_GetId >= IDB_BTN_A && _GetId <= IDB_SHDR_SEMI_R); - - bool Hat = (_GetId >= IDB_BTN_A && _GetId <= IDB_SHDR_SEMI_R); - - bool NoTriggerFilter = g_Config.bNoTriggerFilter; - - // Values used in this function - int Seconds = 4; // Seconds to wait for - int TimesPerSecond = 40; // How often to run the check - - // Values returned from InputCommon::GetButton() - int value; // Axis value or Hat value - int type; // Button type - - int KeyPressed = 0; - int pressed = 0; - bool Succeed = false; - bool Stop = false; // Stop the timer - - // If the Id has changed or the timer is not running we should start one - if( GetButtonWaitingID != _GetId || !m_ButtonMappingTimer->IsRunning() ) - { - if(m_ButtonMappingTimer->IsRunning()) - m_ButtonMappingTimer->Stop(); - - // Save the button Id - GetButtonWaitingID = _GetId; - GetButtonWaitingTimer = 0; - - // Start the timer - #if wxUSE_TIMER - m_ButtonMappingTimer->Start(1000 / TimesPerSecond); - #endif - DEBUG_LOG(PAD, "Timer Started: Pad:%i _GetId:%i " - "Allowed input is Axis:%i LeftRight:%i XInput:%i Button:%i Hat:%i", - GCMapping[m_Page].ID, _GetId, - Axis, LeftRight, XInput, Button, Hat); - } - - // Check for buttons - // If there is a timer we should not create a new one - else if (NumGoodPads > 0) - { - InputCommon::GetButton( - GCMapping[m_Page].joy, PadID, joyinfo[PadID].NumButtons, joyinfo[PadID].NumAxes, joyinfo[PadID].NumHats, - KeyPressed, value, type, pressed, Succeed, Stop, - LeftRight, Axis, XInput, Button, Hat, NoTriggerFilter); - } - - // Process results - // Count each time - GetButtonWaitingTimer++; - - // This is run every second - if (GetButtonWaitingTimer % TimesPerSecond == 0) - { - // Current time - int TmpTime = Seconds - (GetButtonWaitingTimer / TimesPerSecond); - // Update text - SetButtonText(_GetId, wxString::Format(wxT("[ %d ]"), TmpTime)); - } - - // Time's up - if (GetButtonWaitingTimer / TimesPerSecond >= Seconds) - { - Stop = true; - // Revert back to old label - SetButtonText(_GetId, OldLabel); - } - - // If we got a button - if(Succeed) - { - Stop = true; - // We need to assign hat special code - if (type == InputCommon::CTL_HAT) - { - // Index of pressed starts from 0 - if (value & SDL_HAT_UP) pressed = 0x0100 + 0x0010 * pressed + SDL_HAT_UP; - else if (value & SDL_HAT_DOWN) pressed = 0x0100 + 0x0010 * pressed + SDL_HAT_DOWN; - else if (value & SDL_HAT_LEFT) pressed = 0x0100 + 0x0010 * pressed + SDL_HAT_LEFT; - else if (value & SDL_HAT_RIGHT) pressed = 0x0100 + 0x0010 * pressed + SDL_HAT_RIGHT; - else pressed = -1; - } - if (IDB_BTN_A <= _GetId && _GetId <= IDB_SHDR_SEMI_R) - { - // Better make the pad button code far from virtual key code - SaveButtonMapping(_GetId, 0x1000 + pressed); - SetButtonText(_GetId, wxString::Format(wxT("PAD: %d"), pressed)); - } - else if (IDB_ANALOG_LEFT_X <= _GetId && _GetId <= IDB_TRIGGER_R) - { - SaveButtonMapping(_GetId, pressed); - SetButtonText(_GetId, wxString::Format(wxT("%d"), pressed)); - } - } - - // Stop the timer - if(Stop) - { - DEBUG_LOG(PAD, "Timer Stopped for Pad:%i _GetId:%i", GCMapping[m_Page].ID, _GetId); - - EndGetButtons(); - } - - // If we got a bad button - if(KeyPressed == -1) - { - // Update text - SetButtonText(_GetId, wxString(wxT("PAD: -1"))); - // Notify the user - wxMessageBox(wxString::Format( - wxT("You selected a key with a to low key code (%i), please") - wxT(" select another key with a higher key code."), pressed) - , wxT("Notice"), wxICON_INFORMATION); - } -} - -void GCPadConfigDialog::EndGetButtons(void) -{ - wxTheApp->Disconnect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard - wxKeyEventHandler(GCPadConfigDialog::OnKeyDown), - (wxObject*)0, this); - m_ButtonMappingTimer->Stop(); - GetButtonWaitingTimer = 0; - GetButtonWaitingID = 0; - ClickedButton = NULL; -} - -// Convert the 0x8000 range values to BoxW and BoxH for the plot -void GCPadConfigDialog::Convert2Box(int &x) -{ - // Border adjustment - int BoxW_ = BoxW - 2; - // Convert values - x = (BoxW_ / 2) + (x * BoxW_ / (32767 * 2)); -} - -// Update the input status boxes -void GCPadConfigDialog::UpdatePadInfo(wxTimerEvent& WXUNUSED(event)) -{ - if (GCMapping[m_Page].ID < 0 || GCMapping[m_Page].ID >= NumPads) - { - m_tStatusLeftIn[m_Page]->SetLabel(wxT("Not connected")); - m_tStatusLeftOut[m_Page]->SetLabel(wxT("Not connected")); - m_tStatusRightIn[m_Page]->SetLabel(wxT("Not connected")); - m_tStatusRightOut[m_Page]->SetLabel(wxT("Not connected")); - m_TriggerStatusL[m_Page]->SetLabel(wxT("000")); - m_TriggerStatusR[m_Page]->SetLabel(wxT("000")); - return; - } - - // Check that Dolphin is in focus, otherwise don't update the pad status - //if (IsFocus()) - GetAxisState(GCMapping[m_Page]); - - // Analog stick - // Get original values - int main_x = GCMapping[m_Page].AxisState.Lx; - int main_y = GCMapping[m_Page].AxisState.Ly; - int right_x = GCMapping[m_Page].AxisState.Rx; - int right_y = GCMapping[m_Page].AxisState.Ry; - - // Get adjusted values - int main_x_after = main_x, main_y_after = main_y; - int right_x_after = right_x, right_y_after = right_y; - - // Produce square - if(GCMapping[m_Page].bSquare2Circle) - InputCommon::Square2Circle(main_x_after, main_y_after, GCMapping[m_Page].Diagonal, false); - - // Check dead zone - float DeadZoneLeft = (float)GCMapping[m_Page].DeadZoneL / 100.0; - float DeadZoneRight = (float)GCMapping[m_Page].DeadZoneR / 100.0; - if (InputCommon::IsDeadZone(DeadZoneLeft, main_x_after, main_y_after)) - { - main_x_after = 0; - main_y_after = 0; - } - if (InputCommon::IsDeadZone(DeadZoneRight, right_x_after, right_y_after)) - { - right_x_after = 0; - right_y_after = 0; - } - - int Lx = InputCommon::Pad_Convert(main_x); int Ly = InputCommon::Pad_Convert(main_y); - int Rx = InputCommon::Pad_Convert(right_x); int Ry = InputCommon::Pad_Convert(right_y); - int Lx_after = InputCommon::Pad_Convert(main_x_after); int Ly_after = InputCommon::Pad_Convert(main_y_after); - int Rx_after = InputCommon::Pad_Convert(right_x_after); int Ry_after = InputCommon::Pad_Convert(right_y_after); - - m_tStatusLeftIn[m_Page]->SetLabel(wxString::Format(wxT("X:%03i Y:%03i"), Lx, Ly)); - m_tStatusLeftOut[m_Page]->SetLabel(wxString::Format(wxT("X:%03i Y:%03i"), Lx_after, Ly_after)); - m_tStatusRightIn[m_Page]->SetLabel(wxString::Format(wxT("X:%03i Y:%03i"), Rx, Ry)); - m_tStatusRightOut[m_Page]->SetLabel(wxString::Format(wxT("X:%03i Y:%03i"), Rx_after, Ry_after)); - - // Adjust the values for the plot - Convert2Box(main_x); Convert2Box(main_y); - Convert2Box(right_x); Convert2Box(right_y); - Convert2Box(main_x_after); Convert2Box(main_y_after); - Convert2Box(right_x_after); Convert2Box(right_y_after); - - // Adjust the dot - m_bmpDotLeftIn[m_Page]->SetPosition(wxPoint(main_x, main_y)); - m_bmpDotLeftOut[m_Page]->SetPosition(wxPoint(main_x_after, main_y_after)); - m_bmpDotRightIn[m_Page]->SetPosition(wxPoint(right_x, right_y)); - m_bmpDotRightOut[m_Page]->SetPosition(wxPoint(right_x_after, right_y_after)); - - // Get the trigger values - int TriggerLeft = GCMapping[m_Page].AxisState.Tl; - int TriggerRight = GCMapping[m_Page].AxisState.Tr; - - // Convert the triggers values - if (GCMapping[m_Page].TriggerType == InputCommon::CTL_TRIGGER_SDL) - { - TriggerLeft = InputCommon::Pad_Convert(TriggerLeft); - TriggerRight = InputCommon::Pad_Convert(TriggerRight); - } - - m_TriggerStatusL[m_Page]->SetLabel(wxString::Format(wxT("%03i"), TriggerLeft)); - m_TriggerStatusR[m_Page]->SetLabel(wxString::Format(wxT("%03i"), TriggerRight)); -} diff --git a/Source/Plugins/Plugin_GCPad/Src/GCPad.cpp b/Source/Plugins/Plugin_GCPad/Src/GCPad.cpp deleted file mode 100644 index 776638542d..0000000000 --- a/Source/Plugins/Plugin_GCPad/Src/GCPad.cpp +++ /dev/null @@ -1,670 +0,0 @@ -// Project description -// ------------------- -// Name: nJoy -// Description: A Dolphin Compatible Input Plugin -// -// Author: Falcon4ever (nJoy@falcon4ever.com) -// Site: www.multigesture.net -// Copyright (C) 2003 Dolphin Project. -// - - -// 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 "GCPad.h" -#include "Config.h" -#include "LogManager.h" -#if defined(HAVE_WX) && HAVE_WX - #include "ConfigBox.h" -#endif - -#ifdef _WIN32 -#include "XInput.h" -#endif - -// Declare config window so that we can write debugging info to it from functions in this file -#if defined(HAVE_WX) && HAVE_WX - GCPadConfigDialog* m_ConfigFrame = NULL; -#endif - - -// Variables -// --------- -bool g_SearchDeviceDone = false; -CONTROLLER_MAPPING_GC GCMapping[4]; -std::vector joyinfo; -int NumPads = 0, NumGoodPads = 0, g_ID = 0; -#ifdef _WIN32 - HWND m_hWnd = NULL; // Handle to window -#endif -#if defined(HAVE_X11) && HAVE_X11 - Display* GCdisplay; -#endif -SPADInitialize *g_PADInitialize = NULL; -PLUGIN_GLOBALS* globals = NULL; - - -// 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); - wxInitialize(); -#endif - } - break; - - case DLL_PROCESS_DETACH: -#if defined(HAVE_WX) && HAVE_WX - wxUninitialize(); -#endif - 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 Plugin Functions (from spec's) -// ------------------------------------ - -// Get properties of plugin -// ------------------------ -void GetDllInfo(PLUGIN_INFO* _PluginInfo) -{ - _PluginInfo->Version = 0x0100; - _PluginInfo->Type = PLUGIN_TYPE_PAD; - -#ifdef DEBUGFAST - sprintf(_PluginInfo->Name, "Dolphin GCPad Plugin (DebugFast)"); -#else -#ifdef _DEBUG - sprintf(_PluginInfo->Name, "Dolphin GCPad Plugin (Debug)"); -#else - sprintf(_PluginInfo->Name, "Dolphin GCPad Plugin"); -#endif -#endif -} - -void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) -{ - globals = _pPluginGlobals; - LogManager::SetInstance((LogManager *)globals->logManager); -} - - -// Call config dialog -// ------------------ -void DllConfig(HWND _hParent) -{ - if (!g_SearchDeviceDone) - { - g_Config.Load(); // load settings - // Init Joystick + Haptic (force feedback) subsystem on SDL 1.3 - // Populate joyinfo for all attached devices - Search_Devices(joyinfo, NumPads, NumGoodPads); - g_SearchDeviceDone = true; - } - -#if defined(HAVE_WX) && HAVE_WX - wxWindow *frame = GetParentedWxWindow(_hParent); - m_ConfigFrame = new GCPadConfigDialog(frame); - -#ifdef _WIN32 - frame->Disable(); - m_ConfigFrame->ShowModal(); - frame->Enable(); -#else - m_ConfigFrame->ShowModal(); -#endif - -#ifdef _WIN32 - frame->SetFocus(); - frame->SetHWND(NULL); -#endif - - m_ConfigFrame->Destroy(); - m_ConfigFrame = NULL; - frame->Destroy(); -#endif -} - -void DllDebugger(HWND _hParent, bool Show) -{ -} - - -// Init PAD (start emulation) -// -------------------------- -void Initialize(void *init) -{ - INFO_LOG(PAD, "Initialize: %i", SDL_WasInit(0)); - g_PADInitialize = (SPADInitialize*)init; - -#ifdef _WIN32 - m_hWnd = (HWND)g_PADInitialize->hWnd; -#endif -#if defined(HAVE_X11) && HAVE_X11 - GCdisplay = (Display*)g_PADInitialize->hWnd; -#endif - - if (!g_SearchDeviceDone) - { - g_Config.Load(); // load settings - // Populate joyinfo for all attached devices - Search_Devices(joyinfo, NumPads, NumGoodPads); - g_SearchDeviceDone = true; - } -} - -// Shutdown PAD (stop emulation) -// ----------------------------- -void Shutdown() -{ - INFO_LOG(PAD, "Shutdown: %i", SDL_WasInit(0)); - - Close_Devices(); - - // Finally close SDL - if (SDL_WasInit(0)) - { - SDL_Quit(); - } - - // Remove the pointer to the initialize data - g_PADInitialize = NULL; - g_SearchDeviceDone = false; -} - -// Save state -// -------------- -void DoState(unsigned char **ptr, int mode) -{ -#ifdef RERECORDING - Recording::DoState(ptr, mode); -#endif -} - -void EmuStateChange(PLUGIN_EMUSTATE newState) -{ -} - -#if defined(HAVE_WX) && HAVE_WX -// Hack to use wx key events -volatile bool wxkeystate[WXK_SPECIAL20]; -#endif - -// Set buttons status from keyboard input. Currently this is done from wxWidgets in the main application. -// -------------- -void PAD_Input(u16 _Key, u8 _UpDown) -{ -#if defined(__APPLE__) && defined(USE_WX) && USE_WX - if (_Key < WXK_SPECIAL20) - { - wxkeystate[_Key] = _UpDown; - } -#endif -} - -// Set PAD status -// -------------- -// Called from: SI_DeviceGCController.cpp -// Function: Gives the current pad status to the Core -void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus) -{ - // Check if all is okay - if (_pPADStatus == NULL) return; - - // Clear pad - memset(_pPADStatus, 0, sizeof(SPADStatus)); - const int base = 0x80; - _pPADStatus->stickX = base; - _pPADStatus->stickY = base; - _pPADStatus->substickX = base; - _pPADStatus->substickY = base; - _pPADStatus->button |= PAD_USE_ORIGIN; - _pPADStatus->err = PAD_ERR_NONE; - - // Check that Dolphin is in focus, otherwise don't update the pad status - if (!IsFocus()) return; - - g_ID = _numPAD; - - if (NumGoodPads && NumPads > GCMapping[_numPAD].ID) - UpdatePadState(GCMapping[_numPAD]); - - if (IsKey(EGC_A)) - { - _pPADStatus->button |= PAD_BUTTON_A; - _pPADStatus->analogA = DEF_BUTTON_FULL; - } - if (IsKey(EGC_B)) - { - _pPADStatus->button |= PAD_BUTTON_B; - _pPADStatus->analogB = DEF_BUTTON_FULL; - } - if (IsKey(EGC_X)) _pPADStatus->button |= PAD_BUTTON_X; - if (IsKey(EGC_Y)) _pPADStatus->button |= PAD_BUTTON_Y; - if (IsKey(EGC_Z)) _pPADStatus->button |= PAD_TRIGGER_Z; - if (IsKey(EGC_START)) _pPADStatus->button |= PAD_BUTTON_START; - if (IsKey(EGC_DPAD_UP)) _pPADStatus->button |= PAD_BUTTON_UP; - if (IsKey(EGC_DPAD_DOWN)) _pPADStatus->button |= PAD_BUTTON_DOWN; - if (IsKey(EGC_DPAD_LEFT)) _pPADStatus->button |= PAD_BUTTON_LEFT; - if (IsKey(EGC_DPAD_RIGHT)) _pPADStatus->button |= PAD_BUTTON_RIGHT; - - if (GCMapping[_numPAD].Stick.Main == FROM_KEYBOARD) - { - int iMagnitude = DEF_STICK_FULL; - bool bUp = false; - bool bDown = false; - bool bLeft = false; - bool bRight = false; - if (IsKey(EGC_STICK_SEMI)) iMagnitude = GCMapping[_numPAD].Pressure.Main; - if (IsKey(EGC_STICK_UP)) bUp = true; - else if (IsKey(EGC_STICK_DOWN)) bDown = true; - if (IsKey(EGC_STICK_LEFT)) bLeft = true; - else if (IsKey(EGC_STICK_RIGHT)) bRight = true; - EmulateAnalogStick(_pPADStatus->stickX, _pPADStatus->stickY, bUp, bDown, bLeft, bRight, iMagnitude); - } - else if (GCMapping[_numPAD].Stick.Main == FROM_ANALOG1) - { - _pPADStatus->stickX = GCMapping[_numPAD].AxisState.Lx; - // Y-axis is inverted - _pPADStatus->stickY = 0xFF - (u8)GCMapping[_numPAD].AxisState.Ly; - } - else if (GCMapping[_numPAD].Stick.Main == FROM_ANALOG2) - { - _pPADStatus->stickX = GCMapping[_numPAD].AxisState.Rx; - // Y-axis is inverted - _pPADStatus->stickY = 0xFF - (u8)GCMapping[_numPAD].AxisState.Ry; - } - else - { - _pPADStatus->stickX = GCMapping[_numPAD].AxisState.Tl; - _pPADStatus->stickY = GCMapping[_numPAD].AxisState.Tr; - } - - if (GCMapping[_numPAD].Stick.Sub == FROM_KEYBOARD) - { - int iMagnitude = DEF_STICK_FULL; - bool bUp = false; - bool bDown = false; - bool bLeft = false; - bool bRight = false; - if (IsKey(EGC_CSTICK_SEMI)) iMagnitude = GCMapping[_numPAD].Pressure.Sub; - if (IsKey(EGC_CSTICK_UP)) bUp = true; - else if (IsKey(EGC_CSTICK_DOWN)) bDown = true; - if (IsKey(EGC_CSTICK_LEFT)) bLeft = true; - else if (IsKey(EGC_CSTICK_RIGHT)) bRight = true; - EmulateAnalogStick(_pPADStatus->substickX, _pPADStatus->substickY, bUp, bDown, bLeft, bRight, iMagnitude); - } - else if (GCMapping[_numPAD].Stick.Sub == FROM_ANALOG1) - { - _pPADStatus->substickX = GCMapping[_numPAD].AxisState.Lx; - // Y-axis is inverted - _pPADStatus->substickY = 0xFF - (u8)GCMapping[_numPAD].AxisState.Ly; - } - else if (GCMapping[_numPAD].Stick.Sub == FROM_ANALOG2) - { - _pPADStatus->substickX = GCMapping[_numPAD].AxisState.Rx; - // Y-axis is inverted - _pPADStatus->substickY = 0xFF - (u8)GCMapping[_numPAD].AxisState.Ry; - } - else - { - _pPADStatus->substickX = GCMapping[_numPAD].AxisState.Tl; - _pPADStatus->substickY = GCMapping[_numPAD].AxisState.Tr; - } - - if (GCMapping[_numPAD].Stick.Shoulder == FROM_KEYBOARD) - { - if (IsKey(EGC_TGR_L)) - { - _pPADStatus->triggerLeft = DEF_TRIGGER_FULL; - _pPADStatus->button |= PAD_TRIGGER_L; - } - else if (IsKey(EGC_TGR_SEMI_L)) - { - _pPADStatus->triggerLeft = GCMapping[_numPAD].Pressure.Shoulder; - if (_pPADStatus->triggerLeft > DEF_TRIGGER_THRESHOLD) - _pPADStatus->button |= PAD_TRIGGER_L; - } - - if (IsKey(EGC_TGR_R)) - { - _pPADStatus->triggerRight = DEF_TRIGGER_FULL; - _pPADStatus->button |= PAD_TRIGGER_R; - } - else if (IsKey(EGC_TGR_SEMI_R)) - { - _pPADStatus->triggerRight = GCMapping[_numPAD].Pressure.Shoulder; - if (_pPADStatus->triggerRight > DEF_TRIGGER_THRESHOLD) - _pPADStatus->button |= PAD_TRIGGER_R; - } - } - else if (GCMapping[_numPAD].Stick.Shoulder == FROM_ANALOG1) - { - _pPADStatus->triggerLeft = GCMapping[_numPAD].AxisState.Lx; - _pPADStatus->triggerRight = GCMapping[_numPAD].AxisState.Ly; - EmulateAnalogTrigger(_pPADStatus->triggerLeft, _pPADStatus->triggerRight); - if (_pPADStatus->triggerLeft > DEF_TRIGGER_THRESHOLD) - _pPADStatus->button |= PAD_TRIGGER_L; - if (_pPADStatus->triggerRight > DEF_TRIGGER_THRESHOLD) - _pPADStatus->button |= PAD_TRIGGER_R; - } - else if (GCMapping[_numPAD].Stick.Shoulder == FROM_ANALOG2) - { - _pPADStatus->triggerLeft = GCMapping[_numPAD].AxisState.Rx; - _pPADStatus->triggerRight = GCMapping[_numPAD].AxisState.Ry; - EmulateAnalogTrigger(_pPADStatus->triggerLeft, _pPADStatus->triggerRight); - if (_pPADStatus->triggerLeft > DEF_TRIGGER_THRESHOLD) - _pPADStatus->button |= PAD_TRIGGER_L; - if (_pPADStatus->triggerRight > DEF_TRIGGER_THRESHOLD) - _pPADStatus->button |= PAD_TRIGGER_R; - } - else - { - _pPADStatus->triggerLeft = GCMapping[_numPAD].AxisState.Tl; - _pPADStatus->triggerRight = GCMapping[_numPAD].AxisState.Tr; - EmulateAnalogTrigger(_pPADStatus->triggerLeft, _pPADStatus->triggerRight); - if (_pPADStatus->triggerLeft > DEF_TRIGGER_THRESHOLD) - _pPADStatus->button |= PAD_TRIGGER_L; - if (_pPADStatus->triggerRight > DEF_TRIGGER_THRESHOLD) - _pPADStatus->button |= PAD_TRIGGER_R; - } - -} - - -//****************************************************************************** -// Supporting functions -//****************************************************************************** - -// 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 mainX = 0; - int mainY = 0; - if (buttonUp) - mainY = magnitude; - else if (buttonDown) - mainY = -magnitude; - if (buttonLeft) - mainX = -magnitude; - else if (buttonRight) - mainX = magnitude; - - if ((mainX == 0) || (mainY == 0)) - { - stickX += mainX; - stickY += mainY; - } - else - { - stickX += mainX * DIAGONAL_SCALE; - stickY += mainY * DIAGONAL_SCALE; - } -} - -void EmulateAnalogTrigger(unsigned char &trL, unsigned char &trR) -{ - if (GCMapping[g_ID].TriggerType == InputCommon::CTL_TRIGGER_SDL) - { - int triggerL = abs((int)trL - 0x80) * 2; - int triggerR = abs((int)trR - 0x80) * 2; - trL = (triggerL > 0xFF) ? 0xFF : triggerL; - trR = (triggerR > 0xFF) ? 0xFF : triggerR; - } -} - -void Close_Devices() -{ - PAD_RumbleClose(); - - if (SDL_WasInit(0)) - { - for (int i = 0; i < NumPads; i++) - { - if (joyinfo.at(i).joy) - { - if(SDL_JoystickOpened(i)) - { - INFO_LOG(WIIMOTE, "Shut down Joypad: %i", i); - SDL_JoystickClose(joyinfo.at(i).joy); - } - } - } - } - - for (int i = 0; i < 4; i++) - GCMapping[i].joy = NULL; - - // Clear the physical device info - joyinfo.clear(); - NumPads = 0; - NumGoodPads = 0; -} - -// Search for SDL devices -// ---------------- -bool Search_Devices(std::vector &_joyinfo, int &_NumPads, int &_NumGoodPads) -{ - // Close opened devices first - Close_Devices(); - - bool success = InputCommon::SearchDevices(_joyinfo, _NumPads, _NumGoodPads); - - if (_NumGoodPads == 0) - return false; - - for (int i = 0; i < 4; i++) - { - if (_NumPads > GCMapping[i].ID) - if(joyinfo.at(GCMapping[i].ID).Good) - { - GCMapping[i].joy = joyinfo.at(GCMapping[i].ID).joy; -#ifdef _WIN32 - XINPUT_STATE xstate; - DWORD xresult = XInputGetState(GCMapping[i].ID, &xstate); - if (xresult == ERROR_SUCCESS) - GCMapping[i].TriggerType = InputCommon::CTL_TRIGGER_XINPUT; -#endif - } - } - - return success; -} - -void GetAxisState(CONTROLLER_MAPPING_GC &_GCMapping) -{ - // Update the gamepad status - SDL_JoystickUpdate(); - - // Update axis states. It doesn't hurt much if we happen to ask for nonexisting axises here. - _GCMapping.AxisState.Lx = SDL_JoystickGetAxis(_GCMapping.joy, _GCMapping.AxisMapping.Lx); - _GCMapping.AxisState.Ly = SDL_JoystickGetAxis(_GCMapping.joy, _GCMapping.AxisMapping.Ly); - _GCMapping.AxisState.Rx = SDL_JoystickGetAxis(_GCMapping.joy, _GCMapping.AxisMapping.Rx); - _GCMapping.AxisState.Ry = SDL_JoystickGetAxis(_GCMapping.joy, _GCMapping.AxisMapping.Ry); - - // Update the analog trigger axis values -#ifdef _WIN32 - if (_GCMapping.TriggerType == InputCommon::CTL_TRIGGER_SDL) - { -#endif - // If we are using SDL analog triggers the buttons have to be mapped as 1000 or up, otherwise they are not used - // We must also check that we are not asking for a negative axis number because SDL_JoystickGetAxis() has - // no good way of handling that - if ((_GCMapping.AxisMapping.Tl - 1000) >= 0) - _GCMapping.AxisState.Tl = SDL_JoystickGetAxis(_GCMapping.joy, _GCMapping.AxisMapping.Tl - 1000); - if ((_GCMapping.AxisMapping.Tr - 1000) >= 0) - _GCMapping.AxisState.Tr = SDL_JoystickGetAxis(_GCMapping.joy, _GCMapping.AxisMapping.Tr - 1000); -#ifdef _WIN32 - } - else - { - _GCMapping.AxisState.Tl = XInput::GetXI(_GCMapping.ID, _GCMapping.AxisMapping.Tl - 1000); - _GCMapping.AxisState.Tr = XInput::GetXI(_GCMapping.ID, _GCMapping.AxisMapping.Tr - 1000); - } -#endif -} - -void UpdatePadState(CONTROLLER_MAPPING_GC &_GCiMapping) -{ - // Return if we have no pads - if (NumGoodPads == 0) return; - - GetAxisState(_GCiMapping); - - int &Lx = _GCiMapping.AxisState.Lx; - int &Ly = _GCiMapping.AxisState.Ly; - int &Rx = _GCiMapping.AxisState.Rx; - int &Ry = _GCiMapping.AxisState.Ry; - int &Tl = _GCiMapping.AxisState.Tl; - int &Tr = _GCiMapping.AxisState.Tr; - - // Check the circle to square option - if(_GCiMapping.bSquare2Circle) - { - InputCommon::Square2Circle(Lx, Ly, _GCiMapping.Diagonal, false); - InputCommon::Square2Circle(Rx, Ry, _GCiMapping.Diagonal, false); - } - - // Dead zone adjustment - float DeadZoneLeft = (float)_GCiMapping.DeadZoneL / 100.0f; - float DeadZoneRight = (float)_GCiMapping.DeadZoneR / 100.0f; - if (InputCommon::IsDeadZone(DeadZoneLeft, Lx, Ly)) - { - Lx = 0; - Ly = 0; - } - if (InputCommon::IsDeadZone(DeadZoneRight, Rx, Ry)) - { - Rx = 0; - Ry = 0; - } - - // Downsize the values from 0x8000 to 0x80 - Lx = InputCommon::Pad_Convert(Lx); - Ly = InputCommon::Pad_Convert(Ly); - Rx = InputCommon::Pad_Convert(Rx); - Ry = InputCommon::Pad_Convert(Ry); - // The XInput range is already 0 to 0x80 - if (_GCiMapping.TriggerType == InputCommon::CTL_TRIGGER_SDL) - { - Tl = InputCommon::Pad_Convert(Tl); - Tr = InputCommon::Pad_Convert(Tr); - } -} - -// Multi System Input Status Check -bool IsKey(int Key) -{ - int Ret = NULL; - int MapKey = GCMapping[g_ID].Button[Key]; - -#ifdef _WIN32 - if (MapKey < 256) - { - Ret = GetAsyncKeyState(MapKey); // Keyboard (Windows) - } - else if (MapKey < 0x1100) -#elif defined HAVE_X11 && HAVE_X11 - if (MapKey < 256 || MapKey > 0xf000) - { - char keys[32]; - KeyCode keyCode; - XQueryKeymap(GCdisplay, keys); - keyCode = XKeysymToKeycode(GCdisplay, MapKey); - Ret = (keys[keyCode/8] & (1 << (keyCode%8))); // Keyboard (Linux) - } - else if (MapKey < 0x1100) -#elif defined (USE_WX) && USE_WX - if (MapKey < WXK_SPECIAL20) { - Ret = wxkeystate[MapKey]; - } - else if (MapKey < 0x1100) -#else - if (MapKey < 0x1100) -#endif - { - Ret = SDL_JoystickGetButton(GCMapping[g_ID].joy, MapKey - 0x1000); // Pad button - } - else // Pad hat - { - u8 HatCode, HatKey; - HatCode = SDL_JoystickGetHat(GCMapping[g_ID].joy, (MapKey - 0x1100) / 0x0010); - HatKey = (MapKey - 0x1100) % 0x0010; - - if (HatCode & HatKey) - Ret = HatKey; - } - - return (Ret) ? true : false; -} - -// Check if Dolphin is in focus -// ---------------- -bool IsFocus() -{ -#if defined(__APPLE__) && defined(USE_WX) && USE_WX - return true; /* XXX */ -#endif - return g_PADInitialize->pRendererHasFocus(); -} diff --git a/Source/Plugins/Plugin_GCPad/Src/GCPad.h b/Source/Plugins/Plugin_GCPad/Src/GCPad.h deleted file mode 100644 index 52fe385785..0000000000 --- a/Source/Plugins/Plugin_GCPad/Src/GCPad.h +++ /dev/null @@ -1,165 +0,0 @@ -// Project description -// ------------------- -// Name: nJoy -// Description: A Dolphin Compatible Input Plugin -// -// Author: Falcon4ever (nJoy@falcon4ever.com) -// Site: www.multigesture.net -// Copyright (C) 2003 Dolphin Project. -// - - -// 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 _PLUGIN_GCPAD_H -#define _PLUGIN_GCPAD_H - - -#include // System -#include -#include "../../../Core/InputCommon/Src/InputCommon.h" // Core -#include "../../../Core/InputCommon/Src/SDL_Util.h" -#ifdef _WIN32 - #include "../../../Core/InputCommon/Src/XInput_Util.h" -#elif defined(HAVE_X11) && HAVE_X11 - #include - #include - #include - #include -#endif -#include "pluginspecs_pad.h" - - -#define DEF_BUTTON_FULL 255 -#define DEF_STICK_FULL 100 -#define DEF_STICK_HALF 50 -#define DEF_TRIGGER_FULL 255 -#define DEF_TRIGGER_HALF 128 -#define DEF_TRIGGER_THRESHOLD 230 - -// GC Pad Buttons -enum EGCPad -{ - EGC_A = 0, - EGC_B, - EGC_X, - EGC_Y, - EGC_Z, - EGC_START, - - EGC_DPAD_UP, - EGC_DPAD_DOWN, - EGC_DPAD_LEFT, - EGC_DPAD_RIGHT, - - EGC_STICK_UP, - EGC_STICK_DOWN, - EGC_STICK_LEFT, - EGC_STICK_RIGHT, - EGC_STICK_SEMI, - - EGC_CSTICK_UP, - EGC_CSTICK_DOWN, - EGC_CSTICK_LEFT, - EGC_CSTICK_RIGHT, - EGC_CSTICK_SEMI, - - EGC_TGR_L, - EGC_TGR_R, - EGC_TGR_SEMI_L, - EGC_TGR_SEMI_R, - - LAST_CONSTANT, -}; - -enum EInputType -{ - FROM_KEYBOARD, - FROM_ANALOG1, - FROM_ANALOG2, - FROM_TRIGGER, -}; - -union UAxis -{ - int Code[6]; - struct - { - int Lx; - int Ly; - int Rx; - int Ry; - int Tl; // Trigger - int Tr; // Trigger - }; -}; - -struct SStickMapping -{ - int Main; - int Sub; - int Shoulder; //Trigger -}; - -struct CONTROLLER_MAPPING_GC // PAD MAPPING GC -{ - int ID; // SDL joystick device ID - SDL_Joystick *joy; // SDL joystick device - UAxis AxisState; - UAxis AxisMapping; // 6 Axes (Main, Sub, Triggers) - int TriggerType; // SDL or XInput trigger - bool Rumble; - int RumbleStrength; - int DeadZoneL; // Analog 1 Deadzone - int DeadZoneR; // Analog 2 Deadzone - bool bSquare2Circle; - int Diagonal; - - SStickMapping Stick; - SStickMapping Pressure; - int Button[LAST_CONSTANT]; -}; - -extern CONTROLLER_MAPPING_GC GCMapping[4]; -extern int NumPads, NumGoodPads, g_ID; - -extern SPADInitialize *g_PADInitialize; -extern std::vector joyinfo; -#ifdef _WIN32 -extern HWND m_hWnd; // Handle to window -#endif -#if defined(HAVE_X11) && HAVE_X11 -extern Display* GCdisplay; -#endif - - -// Custom Functions -// ---------------- -void EmulateAnalogStick(unsigned char &stickX, unsigned char &stickY, bool buttonUp, bool buttonDown, bool buttonLeft, bool buttonRight, int magnitude); -void EmulateAnalogTrigger(unsigned char &trL, unsigned char &trR); -void Close_Devices(); -bool Search_Devices(std::vector &_joyinfo, int &_NumPads, int &_NumGoodPads); -void GetAxisState(CONTROLLER_MAPPING_GC &_GCMapping); -void UpdatePadState(CONTROLLER_MAPPING_GC &_GCMapping); -bool IsKey(int Key); -bool IsFocus(); -bool ReloadDLL(); -void PAD_RumbleClose(); - -#endif // _PLUGIN_GCPAD_H diff --git a/Source/Plugins/Plugin_GCPad/Src/ReRecording.cpp b/Source/Plugins/Plugin_GCPad/Src/ReRecording.cpp deleted file mode 100644 index 19f5044815..0000000000 --- a/Source/Plugins/Plugin_GCPad/Src/ReRecording.cpp +++ /dev/null @@ -1,181 +0,0 @@ -// Project description -// ------------------- -// Name: nJoy -// Description: A Dolphin Compatible Input Plugin -// -// Author: Falcon4ever (nJoy@falcon4ever.com) -// Site: www.multigesture.net -// Copyright (C) 2003 Dolphin Project. -// - - -// 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 "GCPad.h" -#include "FileUtil.h" -#include "ChunkFile.h" - -// TODO : -// This is pretty much useless now with the TAS features right ? - -#ifdef RERECORDING - - -namespace Recording -{ - - - -// Definitions -// ------------- -// Pre defined maxium storage limit -#define RECORD_SIZE (1024 * 128) -SPADStatus RecordBuffer[RECORD_SIZE]; -int count = 0; - - - - - -// Recording 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) Save(); -} - -const SPADStatus& Play() -{ - // 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 Load() -{ - 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 Save() -{ - // 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("NJoy: Could not save pad-record.bin"); - } - //PanicAlert("SaveRecord()"); - //Console::Print("SaveRecord()"); -} - - - - -void Initialize() -{ - // ------------------------------------------- - // Rerecording - // ---------------------- - #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 (g_Config.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 - g_Config.bRecording = false; - } - } - - // Load recorded input if we are to play it back, otherwise begin with a blank recording - if (g_Config.bPlayback) Recording::Load(); - #endif - // ---------------------- -} - - -void ShutDown() -{ - // Save recording - if (g_Config.bRecording) Recording::Save(); - // Reset the counter - count = 0; -} - -void DoState(unsigned char **ptr, int mode) -{ - // 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 - } -} - - -} // Recording - - -#endif // RERECORDING diff --git a/Source/Plugins/Plugin_GCPad/Src/Rumble.cpp b/Source/Plugins/Plugin_GCPad/Src/Rumble.cpp deleted file mode 100644 index de232afe8c..0000000000 --- a/Source/Plugins/Plugin_GCPad/Src/Rumble.cpp +++ /dev/null @@ -1,407 +0,0 @@ -// Project description -// ------------------- -// Name: nJoy -// Description: A Dolphin Compatible Input Plugin -// -// Author: Falcon4ever (nJoy@falcon4ever.com) -// Site: www.multigesture.net -// Copyright (C) 2003 Dolphin Project. -// - - -// 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 "GCPad.h" - -#ifdef _WIN32 -#include "XInput.h" -#endif - -// SDL Haptic fails on windows, it just doesn't work (even the sample doesn't work) -// So until i can make it work, this is all disabled >:( -#if SDL_VERSION_ATLEAST(1, 3, 0) && !defined(_WIN32) && !defined(__APPLE__) - #define SDL_RUMBLE -#else - #ifdef _WIN32 - #define RUMBLE_HACK - #define DIRECTINPUT_VERSION 0x0800 - #define WIN32_LEAN_AND_MEAN - - #pragma comment(lib, "dxguid.lib") - #pragma comment(lib, "dinput8.lib") - #pragma comment(lib, "winmm.lib") - #include - #endif -#endif - - -#ifdef RUMBLE_HACK - -struct RUMBLE // GC Pad rumble DIDevice -{ - LPDIRECTINPUTDEVICE8 g_pDevice; // 4 pads objects - LPDIRECTINPUTEFFECT g_pEffect; - DWORD g_dwNumForceFeedbackAxis; - DIEFFECT eff; -}; - -BOOL CALLBACK EnumFFDevicesCallback(const DIDEVICEINSTANCE* pInst, VOID* pContext); -BOOL CALLBACK EnumAxesCallback(const DIDEVICEOBJECTINSTANCE* pdidoi, VOID* pContext); -void SetDeviceForcesXY(int pad, int nXYForce); -HRESULT InitRumble(HWND hWnd); -void Rumble_DInput(int _ID, unsigned int _Strength); -void Rumble_XInput(int _ID, unsigned int _Strength); - - -LPDIRECTINPUT8 g_Rumble; // DInput Rumble object -RUMBLE pRumble[4]; // 4 GC Rumble Pads - - -void PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength) -{ - if (GCMapping[_numPAD].ID >= NumPads || !GCMapping[_numPAD].Rumble) - return; - - unsigned int Strength = 0; - if (_uType == 1 && _uStrength > 2) - { - Strength = GCMapping[_numPAD].RumbleStrength; - Strength = Strength > 100 ? 100 : Strength; - } - - if (GCMapping[_numPAD].TriggerType == InputCommon::CTL_TRIGGER_XINPUT) - Rumble_XInput(GCMapping[_numPAD].ID, Strength); - else - Rumble_DInput(GCMapping[_numPAD].ID, Strength); -} - -//////////////////////////////////////////////////// -// Set rumble with XInput. -void Rumble_XInput(int _ID, unsigned int _Strength) -{ -#ifdef _WIN32 - XINPUT_VIBRATION vib; - vib.wLeftMotorSpeed = 0xFFFF / 100 * _Strength; - vib.wRightMotorSpeed = 0xFFFF / 100 * _Strength; - XInputSetState(_ID, &vib); -#endif -} - -//////////////////////////////////////////////////// -// Set rumble with DInput.ŻŻŻŻŻŻŻŻŻŻŻŻ -void Rumble_DInput(int _ID, unsigned int _Strength) -{ - if (!g_Rumble) - { - // GetForegroundWindow() always sends the good HWND - if (FAILED(InitRumble(GetForegroundWindow()))) - PanicAlert("Could not initialize Rumble!"); - } - else - { - // Acquire gamepad - if (pRumble[_ID].g_pDevice != NULL) - pRumble[_ID].g_pDevice->Acquire(); - } - - SetDeviceForcesXY(_ID, _Strength * 100); -} - -HRESULT InitRumble(HWND hWnd) -{ - DIPROPDWORD dipdw; - HRESULT hr; - - // Register with the DirectInput subsystem and get a pointer to a IDirectInput interface we can use. - if (FAILED(hr = DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&g_Rumble, NULL))) - return hr; - - // Look for a device we can use - if (FAILED(hr = g_Rumble->EnumDevices( DI8DEVCLASS_GAMECTRL, EnumFFDevicesCallback, NULL, DIEDFL_ATTACHEDONLY | DIEDFL_FORCEFEEDBACK))) - return hr; - - for (int i=0; i<4; i++) - { - if (NULL == pRumble[i].g_pDevice) - GCMapping[i].Rumble = false; // Disable Rumble for this pad only. - else - { - pRumble[i].g_pDevice->SetDataFormat(&c_dfDIJoystick); - pRumble[i].g_pDevice->SetCooperativeLevel(hWnd, DISCL_EXCLUSIVE | DISCL_BACKGROUND); - // Request exclusive acces for both background and foreground. - - dipdw.diph.dwSize = sizeof(DIPROPDWORD); - dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); - dipdw.diph.dwObj = 0; - dipdw.diph.dwHow = DIPH_DEVICE; - dipdw.dwData = FALSE; - - // if Force Feedback doesn't seem to work... - if (FAILED(pRumble[i].g_pDevice->EnumObjects(EnumAxesCallback, - (void*)&pRumble[i].g_dwNumForceFeedbackAxis, DIDFT_AXIS)) - || FAILED(pRumble[i].g_pDevice->SetProperty(DIPROP_AUTOCENTER, &dipdw.diph))) - { - PanicAlert("Device %d doesn't seem to work ! \nRumble for device %d is now Disabled !", i+1); - - GCMapping[i].Rumble = false; // Disable Rumble for this pad - - continue; // Next pad - } - - if (pRumble[i].g_dwNumForceFeedbackAxis > 2) - pRumble[i].g_dwNumForceFeedbackAxis = 2; - - DWORD _rgdwAxes[2] = {DIJOFS_X, DIJOFS_Y}; - long rglDirection[2] = {0, 0}; - DICONSTANTFORCE cf = {0}; - - ZeroMemory(&pRumble[i].eff, sizeof(pRumble[i].eff)); - pRumble[i].eff.dwSize = sizeof(DIEFFECT); - pRumble[i].eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS; - pRumble[i].eff.dwDuration = INFINITE; // fixed time may be safer (X * DI_SECONDS) - pRumble[i].eff.dwSamplePeriod = 0; - pRumble[i].eff.dwGain = DI_FFNOMINALMAX; - pRumble[i].eff.dwTriggerButton = DIEB_NOTRIGGER; - pRumble[i].eff.dwTriggerRepeatInterval = 0; - pRumble[i].eff.cAxes = pRumble[i].g_dwNumForceFeedbackAxis; - pRumble[i].eff.rgdwAxes = _rgdwAxes; - pRumble[i].eff.rglDirection = rglDirection; - pRumble[i].eff.lpEnvelope = 0; - pRumble[i].eff.cbTypeSpecificParams = sizeof( DICONSTANTFORCE ); - pRumble[i].eff.lpvTypeSpecificParams = &cf; - pRumble[i].eff.dwStartDelay = 0; - - // Create the prepared effect - if (FAILED(hr = pRumble[i].g_pDevice->CreateEffect(GUID_ConstantForce, &pRumble[i].eff, &pRumble[i].g_pEffect, NULL))) - continue; - - if (pRumble[i].g_pEffect == NULL) - continue; - } - } - - return S_OK; -} - -void SetDeviceForcesXY(int npad, int nXYForce) -{ - // Security check - if (pRumble[npad].g_pDevice == NULL) - return; - - // If nXYForce is null, there's no point to create the effect - // Just stop the force feedback - if (nXYForce == 0) { - pRumble[npad].g_pEffect->Stop(); - return; - } - - long rglDirection[2] = {0}; - DICONSTANTFORCE cf; - - // If only one force feedback axis, then apply only one direction and keep the direction at zero - if (pRumble[npad].g_dwNumForceFeedbackAxis == 1) - { - rglDirection[0] = 0; - cf.lMagnitude = nXYForce; // max should be 10000 - } - // If two force feedback axis, then apply magnitude from both directions - else - { - rglDirection[0] = nXYForce; - rglDirection[1] = nXYForce; - cf.lMagnitude = (long)(1.4142f*nXYForce); - } - - ZeroMemory(&pRumble[npad].eff, sizeof(pRumble[npad].eff)); - pRumble[npad].eff.dwSize = sizeof(DIEFFECT); - pRumble[npad].eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS; - pRumble[npad].eff.cAxes = pRumble[npad].g_dwNumForceFeedbackAxis; - pRumble[npad].eff.rglDirection = rglDirection; - pRumble[npad].eff.lpEnvelope = 0; - pRumble[npad].eff.cbTypeSpecificParams = sizeof(DICONSTANTFORCE); - pRumble[npad].eff.lpvTypeSpecificParams = &cf; - pRumble[npad].eff.dwStartDelay = 0; - - // Now set the new parameters.. - pRumble[npad].g_pEffect->SetParameters(&pRumble[npad].eff, DIEP_DIRECTION | DIEP_TYPESPECIFICPARAMS | DIEP_START); - // ..And start the effect immediately. - if (pRumble[npad].g_pEffect != NULL) - pRumble[npad].g_pEffect->Start(1, 0); -} - -BOOL CALLBACK EnumFFDevicesCallback(const DIDEVICEINSTANCE* pInst, VOID* pContext) -{ - LPDIRECTINPUTDEVICE8 pDevice; - DIPROPDWORD dipdw; - HRESULT hr; - - int JoystickID; - - dipdw.diph.dwSize = sizeof(DIPROPDWORD); - dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); - dipdw.diph.dwObj = 0; - dipdw.diph.dwHow = DIPH_DEVICE; - - g_Rumble->CreateDevice(pInst->guidInstance, &pDevice, NULL); // Create a DInput pad device - - if (SUCCEEDED(hr = pDevice->GetProperty(DIPROP_JOYSTICKID, &dipdw.diph))) // Get DInput Device ID - JoystickID = dipdw.dwData; - else - return DIENUM_CONTINUE; - - //PanicAlert("DInput ID : %d \nSDL ID (1-4) : %d / %d / %d / %d\n", JoystickID, GCMapping[0].ID, GCMapping[1].ID, GCMapping[2].ID, GCMapping[3].ID); - - for (int i=0; i<4; i++) - { - if (GCMapping[i].ID == JoystickID) // if SDL ID = DInput ID -> we're dealing with the same device - { - // a DInput device is created even if rumble is disabled on startup - // this way, you can toggle the rumble setting while in game - pRumble[i].g_pDevice = pDevice; // everything looks good, save the DInput device - } - } - - return DIENUM_CONTINUE; -} - -BOOL CALLBACK EnumAxesCallback(const DIDEVICEOBJECTINSTANCE* pdidoi, VOID* pContext) -{ - DWORD* pdwNumForceFeedbackAxis = (DWORD*)pContext; // Enum Rumble Axis - if ((pdidoi->dwFlags & DIDOI_FFACTUATOR) != 0) - (*pdwNumForceFeedbackAxis)++; - - return DIENUM_CONTINUE; -} - -void PAD_RumbleClose() -{ - for (int i = 0; i < 4; i++) - { - if (GCMapping[i].ID < NumPads) - if (GCMapping[i].TriggerType == InputCommon::CTL_TRIGGER_XINPUT) - { -#ifdef _WIN32 - // Kill Xpad rumble - XINPUT_VIBRATION vib; - vib.wLeftMotorSpeed = 0; - vib.wRightMotorSpeed = 0; - XInputSetState(GCMapping[i].ID, &vib); -#endif - } - else - { - // It may look weird, but we don't free anything here, it was the cause of crashes - // on stop, and the DLL isn't unloaded anyway, so the pointers stay - // We just stop the rumble in case it's still playing an effect. - if (pRumble[GCMapping[i].ID].g_pDevice && pRumble[GCMapping[i].ID].g_pEffect) - pRumble[GCMapping[i].ID].g_pEffect->Stop(); - } - } -} - -#else // Multiplatform SDL Rumble code - -#ifdef SDL_RUMBLE - -struct RUMBLE // GC Pad rumble DIDevice -{ - SDL_Haptic* g_pDevice; - SDL_HapticEffect g_pEffect; - int effect_id; -}; - -RUMBLE pRumble[4] = {0}; // 4 GC Rumble Pads -#endif - - -// Use PAD rumble -// -------------- -bool PAD_Init_Rumble(u8 _numPAD, SDL_Joystick *SDL_Device) -{ -#ifdef SDL_RUMBLE - if (SDL_Device == NULL) - return false; - - pRumble[_numPAD].g_pDevice = SDL_HapticOpenFromJoystick(SDL_Device); - - if (pRumble[_numPAD].g_pDevice == NULL) - return false; // Most likely joystick isn't haptic - - if (!(SDL_HapticQuery(pRumble[_numPAD].g_pDevice) & SDL_HAPTIC_CONSTANT)) - { - SDL_HapticClose(pRumble[_numPAD].g_pDevice); // No effect - pRumble[_numPAD].g_pDevice = 0; - GCMapping[_numPAD].rumble = false; - return false; - } - - // Set the strength of the rumble effect - int Strenght = 3276 * (g_Config.RumbleStrength + 1); - Strenght = Strenght > 32767 ? 32767 : Strenght; - - // Create the effect - memset(&pRumble[_numPAD].g_pEffect, 0, sizeof(SDL_HapticEffect)); // 0 is safe default - pRumble[_numPAD].g_pEffect.type = SDL_HAPTIC_CONSTANT; - pRumble[_numPAD].g_pEffect.constant.direction.type = SDL_HAPTIC_POLAR; // Polar coordinates - pRumble[_numPAD].g_pEffect.constant.direction.dir[0] = 18000; // Force comes from south - pRumble[_numPAD].g_pEffect.constant.level = Strenght; - pRumble[_numPAD].g_pEffect.constant.length = 10000; // 10s long (should be INFINITE, but 10s is safer) - pRumble[_numPAD].g_pEffect.constant.attack_length = 0; // disable Fade in... - pRumble[_numPAD].g_pEffect.constant.fade_length = 0; // ...and out - - // Upload the effect - pRumble[_numPAD].effect_id = SDL_HapticNewEffect( pRumble[_numPAD].g_pDevice, &pRumble[_numPAD].g_pEffect ); -#endif - return true; -} - - -// Set PAD rumble. Explanation: Stop = 0, Rumble = 1 -// -------------- -void PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength) -{ -#ifdef SDL_RUMBLE - if (GCMapping[_numPAD].rumble) // rumble activated - { - if (!pRumble[_numPAD].g_pDevice) - return; - - if (_uType == 1 && _uStrength > 2) - SDL_HapticRunEffect( pRumble[_numPAD].g_pDevice, pRumble[_numPAD].effect_id, 1 ); - else - SDL_HapticStopAll(pRumble[_numPAD].g_pDevice); - } -#endif -} - -void PAD_RumbleClose() -{ -#ifdef SDL_RUMBLE - for (int i=0; i<4; i++) // Free all pads - { - if (pRumble[i].g_pDevice) { - SDL_HapticClose( pRumble[i].g_pDevice ); - pRumble[i].g_pDevice = NULL; - } - } -#endif -} - -#endif // RUMBLE_HACK diff --git a/Source/Plugins/Plugin_GCPad/Src/SConscript b/Source/Plugins/Plugin_GCPad/Src/SConscript deleted file mode 100644 index 1930af31be..0000000000 --- a/Source/Plugins/Plugin_GCPad/Src/SConscript +++ /dev/null @@ -1,25 +0,0 @@ -# -*- python -*- - -Import('env') -import sys - -name = "Plugin_GCPad" -padenv = env.Clone() - -files = [ - 'Config.cpp', - 'GCPad.cpp', - 'Rumble.cpp', - ] - -if padenv['HAVE_WX']: - files += [ - 'ConfigJoypad.cpp', - 'ConfigBox.cpp', - ] - -padenv.Append( - LIBS = [ 'inputcommon', 'common', ], - ) - -padenv.SharedLibrary(env['plugin_dir']+name, files)