mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-12 22:59:04 +00:00
Multiple controllers: Select active controller and set default controller (#3169)
* initial commit - not cleanup yet, not usable with imGUI * Ugly solution to working with ImGUI * Populate the default controller labels * Add remove default button * missing tr calls * edit imgui flag after updating * Refactor * Update sirit
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
#include "core/libraries/pad/pad.h"
|
||||
#include "input/controller.h"
|
||||
|
||||
static std::string SelectedGamepad = "";
|
||||
|
||||
namespace Input {
|
||||
|
||||
using Libraries::Pad::OrbisPadButtonDataOffset;
|
||||
@@ -324,3 +326,48 @@ u32 GameController::Poll() {
|
||||
}
|
||||
|
||||
} // namespace Input
|
||||
|
||||
namespace GamepadSelect {
|
||||
|
||||
int GetDefaultGamepad(SDL_JoystickID* gamepadIDs, int gamepadCount) {
|
||||
char GUIDbuf[33];
|
||||
if (Config::getDefaultControllerID() != "") {
|
||||
for (int i = 0; i < gamepadCount; i++) {
|
||||
SDL_GUIDToString(SDL_GetGamepadGUIDForID(gamepadIDs[i]), GUIDbuf, 33);
|
||||
std::string currentGUID = std::string(GUIDbuf);
|
||||
if (currentGUID == Config::getDefaultControllerID()) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int GetIndexfromGUID(SDL_JoystickID* gamepadIDs, int gamepadCount, std::string GUID) {
|
||||
char GUIDbuf[33];
|
||||
for (int i = 0; i < gamepadCount; i++) {
|
||||
SDL_GUIDToString(SDL_GetGamepadGUIDForID(gamepadIDs[i]), GUIDbuf, 33);
|
||||
std::string currentGUID = std::string(GUIDbuf);
|
||||
if (currentGUID == GUID) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::string GetGUIDString(SDL_JoystickID* gamepadIDs, int index) {
|
||||
char GUIDbuf[33];
|
||||
SDL_GUIDToString(SDL_GetGamepadGUIDForID(gamepadIDs[index]), GUIDbuf, 33);
|
||||
std::string GUID = std::string(GUIDbuf);
|
||||
return GUID;
|
||||
}
|
||||
|
||||
std::string GetSelectedGamepad() {
|
||||
return SelectedGamepad;
|
||||
}
|
||||
|
||||
void SetSelectedGamepad(std::string GUID) {
|
||||
SelectedGamepad = GUID;
|
||||
}
|
||||
|
||||
} // namespace GamepadSelect
|
||||
|
||||
Reference in New Issue
Block a user