mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-03 07:52:31 +00:00
controller select crash fix + minor changes (#3355)
* fix crash and ingame controller check * performance issue fix * add change controller event to imgui
This commit is contained in:
parent
ecc924791d
commit
1b195c9613
@ -9,6 +9,7 @@
|
|||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
#include "imgui_impl_sdl3.h"
|
#include "imgui_impl_sdl3.h"
|
||||||
#include "input/controller.h"
|
#include "input/controller.h"
|
||||||
|
#include "sdl_window.h"
|
||||||
|
|
||||||
// SDL
|
// SDL
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
@ -502,6 +503,9 @@ bool ProcessEvent(const SDL_Event* event) {
|
|||||||
bd->want_update_gamepads_list = true;
|
bd->want_update_gamepads_list = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case SDL_EVENT_CHANGE_CONTROLLER:
|
||||||
|
bd->want_update_gamepads_list = true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -732,18 +736,15 @@ static void UpdateGamepads() {
|
|||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
SdlData* bd = GetBackendData();
|
SdlData* bd = GetBackendData();
|
||||||
|
|
||||||
auto memory = Core::Memory::Instance();
|
|
||||||
auto controller = Common::Singleton<Input::GameController>::Instance();
|
auto controller = Common::Singleton<Input::GameController>::Instance();
|
||||||
auto engine = controller->GetEngine();
|
auto engine = controller->GetEngine();
|
||||||
SDL_Gamepad* SDLGamepad = engine->m_gamepad;
|
SDL_Gamepad* SDLGamepad = engine->m_gamepad;
|
||||||
|
// Update list of gamepads to use
|
||||||
|
if (bd->want_update_gamepads_list && bd->gamepad_mode != ImGui_ImplSDL3_GamepadMode_Manual) {
|
||||||
if (SDLGamepad) {
|
if (SDLGamepad) {
|
||||||
bd->gamepads.push_back(SDLGamepad);
|
bd->gamepads.push_back(SDLGamepad);
|
||||||
bd->want_update_gamepads_list = false;
|
bd->want_update_gamepads_list = false;
|
||||||
} else {
|
} else {
|
||||||
// Update list of gamepads to use
|
|
||||||
if (bd->want_update_gamepads_list &&
|
|
||||||
bd->gamepad_mode != ImGui_ImplSDL3_GamepadMode_Manual) {
|
|
||||||
CloseGamepads();
|
CloseGamepads();
|
||||||
int sdl_gamepads_count = 0;
|
int sdl_gamepads_count = 0;
|
||||||
const SDL_JoystickID* sdl_gamepads = SDL_GetGamepads(&sdl_gamepads_count);
|
const SDL_JoystickID* sdl_gamepads = SDL_GetGamepads(&sdl_gamepads_count);
|
||||||
|
@ -685,7 +685,6 @@ void ControlSettings::CheckGamePad() {
|
|||||||
gamepad = nullptr;
|
gamepad = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_free(gamepads);
|
|
||||||
gamepads = SDL_GetGamepads(&gamepad_count);
|
gamepads = SDL_GetGamepads(&gamepad_count);
|
||||||
|
|
||||||
if (!gamepads) {
|
if (!gamepads) {
|
||||||
@ -974,6 +973,11 @@ void ControlSettings::processSDLEvents(int Type, int Input, int Value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Type == SDL_EVENT_GAMEPAD_ADDED || SDL_EVENT_GAMEPAD_REMOVED) {
|
||||||
|
ui->ActiveGamepadBox->clear();
|
||||||
|
CheckGamePad();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlSettings::pollSDLEvents() {
|
void ControlSettings::pollSDLEvents() {
|
||||||
@ -988,11 +992,6 @@ void ControlSettings::pollSDLEvents() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type == SDL_EVENT_GAMEPAD_ADDED) {
|
|
||||||
ui->ActiveGamepadBox->clear();
|
|
||||||
CheckGamePad();
|
|
||||||
}
|
|
||||||
|
|
||||||
SdlEventWrapper::Wrapper::GetInstance()->Wrapper::ProcessEvent(&event);
|
SdlEventWrapper::Wrapper::GetInstance()->Wrapper::ProcessEvent(&event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,34 +252,6 @@
|
|||||||
<string>L1 and L2</string>
|
<string>L1 and L2</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_13">
|
<layout class="QHBoxLayout" name="horizontalLayout_13">
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="gb_l2">
|
|
||||||
<property name="title">
|
|
||||||
<string>L2</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="gb_l2_layout">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="L2Button">
|
|
||||||
<property name="text">
|
|
||||||
<string>unmapped</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="gb_l1">
|
<widget class="QGroupBox" name="gb_l1">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -314,6 +286,34 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="gb_l2">
|
||||||
|
<property name="title">
|
||||||
|
<string>L2</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="gb_l2_layout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="L2Button">
|
||||||
|
<property name="text">
|
||||||
|
<string>unmapped</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -1342,34 +1342,6 @@
|
|||||||
<string>R1 and R2</string>
|
<string>R1 and R2</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_14">
|
<layout class="QHBoxLayout" name="horizontalLayout_14">
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="gb_r2">
|
|
||||||
<property name="title">
|
|
||||||
<string>R2</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="gb_r2_layout">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="R2Button">
|
|
||||||
<property name="text">
|
|
||||||
<string>unmapped</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="gb_r1">
|
<widget class="QGroupBox" name="gb_r1">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -1404,6 +1376,34 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="gb_r2">
|
||||||
|
<property name="title">
|
||||||
|
<string>R2</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="gb_r2_layout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="R2Button">
|
||||||
|
<property name="text">
|
||||||
|
<string>unmapped</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -24,8 +24,10 @@ bool Wrapper::ProcessEvent(SDL_Event* event) {
|
|||||||
case SDL_EVENT_WINDOW_EXPOSED:
|
case SDL_EVENT_WINDOW_EXPOSED:
|
||||||
return false;
|
return false;
|
||||||
case SDL_EVENT_GAMEPAD_ADDED:
|
case SDL_EVENT_GAMEPAD_ADDED:
|
||||||
|
emit SDLEvent(SDL_EVENT_GAMEPAD_ADDED, 0, 0);
|
||||||
return false;
|
return false;
|
||||||
case SDL_EVENT_GAMEPAD_REMOVED:
|
case SDL_EVENT_GAMEPAD_REMOVED:
|
||||||
|
emit SDLEvent(SDL_EVENT_GAMEPAD_REMOVED, 0, 0);
|
||||||
return false;
|
return false;
|
||||||
case SDL_EVENT_QUIT:
|
case SDL_EVENT_QUIT:
|
||||||
emit SDLEvent(SDL_EVENT_QUIT, 0, 0);
|
emit SDLEvent(SDL_EVENT_QUIT, 0, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user