diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h index 97cceb4f8c..b3132f48ef 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h @@ -215,7 +215,7 @@ class ConfigBox : public wxDialog IDTM_CONSTANT, IDTM_BUTTON, - // -------------------------------------------------------------------- + // ============================================== // Keys objects // ----------------------------- @@ -241,7 +241,9 @@ class ConfigBox : public wxDialog ID_DPAD_LEFT, ID_DPAD_RIGHT, - // Buttons controls (it's important that they are placed in this order) + // ------------------------------------- + // Buttons controls (it's important that they are kept in this order) + // ------ IDB_ANALOG_MAIN_X = 3000, IDB_ANALOG_MAIN_Y, IDB_ANALOG_SUB_X, @@ -262,6 +264,7 @@ class ConfigBox : public wxDialog IDB_BUTTONSTART, IDB_BUTTONHALFPRESS, + // ------------------ Keep this order // Text controls IDT_ANALOG_MAIN_X = 4000, @@ -276,6 +279,7 @@ class ConfigBox : public wxDialog IDT_ANALOG_SUB_Y, IDT_WEBSITE, IDT_DEBUGGING, IDT_DEBUGGING2, + // ============ ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values }; diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp index 76383016f0..bf17a8efea 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp @@ -256,7 +256,7 @@ void ConfigBox::DoGetButtons(int GetId) // Collect the accepted buttons for this slot bool LeftRight = (GetId == IDB_SHOULDER_L || GetId == IDB_SHOULDER_R); bool Axis = (GetId >= IDB_ANALOG_MAIN_X && GetId <= IDB_SHOULDER_R); - bool Button = (GetId >= IDB_BUTTON_A && GetId <= IDB_BUTTONSTART) + bool Button = (GetId >= IDB_BUTTON_A && GetId <= IDB_BUTTONHALFPRESS) || (GetId == IDB_SHOULDER_L || GetId == IDB_SHOULDER_R) || (GetId >= IDB_DPAD_UP && GetId <= IDB_DPAD_RIGHT && joysticks[Controller].controllertype == CTL_DPAD_CUSTOM); bool Hat = (GetId >= IDB_DPAD_UP && GetId <= IDB_DPAD_RIGHT) @@ -429,7 +429,7 @@ void ConfigBox::DoGetButtons(int GetId) GetButtonWaitingTimer = 0; } - // We don't need thisgamepad handle any more + // We don't need this gamepad handle any more if(SDL_JoystickOpened(joysticks[Controller].ID)) SDL_JoystickClose(joy); // Update the button mapping @@ -439,126 +439,4 @@ void ConfigBox::DoGetButtons(int GetId) //Console::Print("IsRunning: %i\n", m_ButtonMappingTimer->IsRunning()); } - -#if 0 -// Wait for Analog -// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ -void ConfigBox::GetAxis(wxCommandEvent& event) -{ - int ID = event.GetId(); - int controller = notebookpage; - - SDL_Joystick *joy = SDL_JoystickOpen(joysticks[controller].ID); - - char format[128]; - int axes = SDL_JoystickNumAxes(joy); // Get number of axes - bool waiting = true; - bool succeed = false; - int pressed = 0; - Sint16 value; - - int counter1 = 0; - int counter2 = 10; - - sprintf(format, "[%d]", counter2); - SetButtonText(ID, format); - wxWindow::Update(); // Win only? doesnt seem to work in linux... - - while(waiting) - { - // Go through all axes and read out their values - SDL_JoystickUpdate(); - for(int i = 0; i < axes; i++) - { - value = SDL_JoystickGetAxis(joy, i); - - if(AvoidValues(value)) continue; // Avoid values - - pressed = i; - waiting = false; - succeed = true; - break; // Stop this loop - } - - // Stop waiting for a button - counter1++; - if(counter1 == 100) - { - counter1 = 0; - counter2--; - - sprintf(format, "[%d]", counter2); - SetButtonText(ID, format); - wxWindow::Update(); // win only? doesnt seem to work in linux... - wxYieldIfNeeded(); // Let through debugging events - - if(counter2<0) - waiting = false; - } - SLEEP(10); - } - - sprintf(format, "%d", succeed ? pressed : -1); // Update the status text box - SetButtonText(ID, format); - - if(SDL_JoystickOpened(joysticks[controller].ID)) // Close the handle - SDL_JoystickClose(joy); - - // Update the axises for the advanced settings status - SaveButtonMapping(controller); -} - - -// Wait for D-Pad -// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻ -void ConfigBox::GetHats(int ID) -{ - // Get the active controller - int controller = notebookpage; - - /* Open a new joystick. Joysticks[controller].ID is the system ID of the physical joystick - that is mapped to controller, for example 0, 1, 2, 3 for the first four joysticks */ - SDL_Joystick *joy = SDL_JoystickOpen(joysticks[controller].ID); - - char format[128]; - int hats = SDL_JoystickNumHats(joy); // Get the number of sticks - bool waiting = true; - bool succeed = false; - int pressed = 0; - - int counter1 = 0; - int counter2 = 10; - - sprintf(format, "[%d]", counter2); - SetButtonText(ID, format); - wxWindow::Update(); // win only? doesnt seem to work in linux... - - while(waiting) - { - SDL_JoystickUpdate(); - - counter1++; - if(counter1==100) - { - counter1=0; - counter2--; - - sprintf(format, "[%d]", counter2); - SetButtonText(ID, format); - wxWindow::Update(); // win only? doesnt seem to work in linux... - - if(counter2<0) - waiting = false; - } - SLEEP(10); - } - - sprintf(format, "%d", succeed ? pressed : -1); - SetButtonText(ID, format); - - if(SDL_JoystickOpened(joysticks[controller].ID)) - SDL_JoystickClose(joy); -} -#endif - /////////////////////////////////////////////////////////// Configure button mapping \ No newline at end of file diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp index bd7857ee3c..3aaa8559cc 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp @@ -280,9 +280,9 @@ void Initialize(void *init) // ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ int Search_Devices() { - // load config + // Load config #ifdef _DEBUG - DEBUG_INIT(); + DEBUG_INIT(); #endif int numjoy = SDL_NumJoysticks(); @@ -542,10 +542,9 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus) /* Debugging Console::ClearScreen(); Console::Print( - "(%i %i) Left:%04x Right:%04x\n" + "Left:%04x Right:%04x Value:%i\n" "D-Pad type: %s L:%i R:%i U:%i D:%i", - joysticks[_numPAD].buttons[CTL_L_SHOULDER], joysticks[_numPAD].buttons[CTL_L_SHOULDER], - TriggerLeft, TriggerRight, + TriggerLeft, TriggerRight, triggervalue, (joysticks[_numPAD].controllertype ? "CTL_DPAD_CUSTOM" : "CTL_DPAD_HAT"), 0, 0, 0, 0 );*/ @@ -677,12 +676,15 @@ std::vector Pad_Square_to_Circle(int _x, int _y) vec.push_back(int_y); return vec; } -////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////// Convert stick values ////////////////////////////////////////////////////////////////////////////////////////// -// Supporting functions: Read current joystick status +// Supporting functions +// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ + +// Read current joystick status /* ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ The value joysticks[].buttons[] is the number of the assigned joypad button, joystate[].buttons[] is the status of the button, it becomes 0 (no pressed) or 1 (pressed) */