From 6daae62df3a2c62e3e0ec8832064c2c07be5ae19 Mon Sep 17 00:00:00 2001 From: John Peterson Date: Tue, 10 Feb 2009 01:25:42 +0000 Subject: [PATCH] nJoy: Fixed settings when multiple pads are connected git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2195 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp | 10 ++++++++-- .../Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp | 15 ++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp index df8ce9c43f..076c908267 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp @@ -292,7 +292,8 @@ void ConfigBox::OnSaveById() // Change Joystick // ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ /* Function: When changing the joystick we save and load the settings and update the PadMapping - and PadState array */ + and PadState array. PadState[].joy is the gamepad handle that is used to access the pad throughout + the plugin. Joyinfo[].joy is only used the first time the pads are checked. */ void ConfigBox::DoChangeJoystick() { // Close the current pad, unless it's used by another slot @@ -443,12 +444,17 @@ void ConfigBox::ChangeSettings( wxCommandEvent& event ) break; case IDC_CONTROLTYPE: - case IDC_TRIGGERTYPE: if(!g_Config.bSaveByID) { PadMapping[notebookpage].controllertype = m_ControlType[notebookpage]->GetSelection(); UpdateGUI(notebookpage); } + case IDC_TRIGGERTYPE: + if(!g_Config.bSaveByID) + { + PadMapping[notebookpage].triggertype = m_TriggerType[notebookpage]->GetSelection(); + UpdateGUI(notebookpage); + } break; case IDC_JOYNAME: diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp index 367beb2780..87b314ba22 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp @@ -268,14 +268,15 @@ void ConfigBox::DoGetButtons(int GetId) int Controller = notebookpage; int PadID = PadMapping[Controller].ID; - /* Open a new joystick. Joysticks[controller].GetId is the system GetId of the physical joystick - that is mapped to controller, for example 0, 1, 2, 3 for the first four PadMapping */ - SDL_Joystick *joy = SDL_JoystickOpen(0); + // Create a shortcut for the pad handle + SDL_Joystick *joy = PadState[Controller].joy; // Get the number of axes, hats and buttons - int buttons = SDL_JoystickNumButtons(joy); - int axes = SDL_JoystickNumAxes(joy); - int hats = SDL_JoystickNumHats(joy); + int Buttons = SDL_JoystickNumButtons(joy); + int Axes = SDL_JoystickNumAxes(joy); + int Hats = SDL_JoystickNumHats(joy); + + Console::Print("PadID: %i Axes: %i\n", PadID, joyinfo[PadID].NumAxes, joyinfo[PadID].joy); // Get the controller and trigger type int ControllerType = PadMapping[Controller].controllertype; @@ -350,7 +351,7 @@ void ConfigBox::DoGetButtons(int GetId) else { InputCommon::GetButton( - joyinfo[PadID].joy, PadID, joyinfo[PadID].NumButtons, joyinfo[PadID].NumAxes, joyinfo[PadID].NumHats, + joy, PadID, Buttons, Axes, Hats, g_Pressed, value, type, pressed, Succeed, Stop, LeftRight, Axis, XInput, Button, Hat, NoTriggerFilter); }