mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-27 12:34:37 +00:00
Revert "Fix for XInput controllers having a different ID range"
This reverts commit 858dda2bd0
.
This is even worse than the previous version
This commit is contained in:
parent
b56fbe1440
commit
38aaa2530f
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <common/singleton.h>
|
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/libraries/kernel/time.h"
|
#include "core/libraries/kernel/time.h"
|
||||||
@ -359,15 +358,4 @@ u32 GameController::Poll() {
|
|||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 GameControllers::GetGamepadIndexFromJoystickId(SDL_JoystickID id) {
|
|
||||||
auto controllers = *Common::Singleton<GameControllers>::Instance();
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
if (controllers[i]->m_sdl_gamepad &&
|
|
||||||
SDL_GetGamepadID(controllers[i]->m_sdl_gamepad) == id) {
|
|
||||||
return i + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1; // Not found
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Input
|
} // namespace Input
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
#include "core/libraries/pad/pad.h"
|
#include "core/libraries/pad/pad.h"
|
||||||
|
|
||||||
#include "SDL3/SDL_joystick.h"
|
|
||||||
|
|
||||||
struct SDL_Gamepad;
|
struct SDL_Gamepad;
|
||||||
|
|
||||||
namespace Input {
|
namespace Input {
|
||||||
@ -108,8 +106,6 @@ public:
|
|||||||
return controllers[i];
|
return controllers[i];
|
||||||
}
|
}
|
||||||
static void TryOpenSDLControllers(GameControllers& controllers);
|
static void TryOpenSDLControllers(GameControllers& controllers);
|
||||||
|
|
||||||
static u8 GetGamepadIndexFromJoystickId(SDL_JoystickID id);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Input
|
} // namespace Input
|
||||||
|
@ -468,11 +468,11 @@ InputEvent InputBinding::GetInputEventFromSDLEvent(const SDL_Event& e) {
|
|||||||
e.type == SDL_EVENT_MOUSE_WHEEL, 0);
|
e.type == SDL_EVENT_MOUSE_WHEEL, 0);
|
||||||
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
||||||
case SDL_EVENT_GAMEPAD_BUTTON_UP:
|
case SDL_EVENT_GAMEPAD_BUTTON_UP:
|
||||||
gamepad = Input::GameControllers::GetGamepadIndexFromJoystickId(e.gbutton.which);
|
gamepad = GetGamepadIndexFromJoystickId(e.gbutton.which);
|
||||||
return InputEvent({InputType::Controller, (u32)e.gbutton.button, gamepad}, e.gbutton.down,
|
return InputEvent({InputType::Controller, (u32)e.gbutton.button, gamepad}, e.gbutton.down,
|
||||||
0);
|
0);
|
||||||
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
|
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
|
||||||
gamepad = Input::GameControllers::GetGamepadIndexFromJoystickId(e.gaxis.which);
|
gamepad = GetGamepadIndexFromJoystickId(e.gaxis.which);
|
||||||
return InputEvent({InputType::Axis, (u32)e.gaxis.axis, gamepad}, true, e.gaxis.value / 256);
|
return InputEvent({InputType::Axis, (u32)e.gaxis.axis, gamepad}, true, e.gaxis.value / 256);
|
||||||
default:
|
default:
|
||||||
return InputEvent();
|
return InputEvent();
|
||||||
@ -753,4 +753,8 @@ void ActivateOutputsFromInputs() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u8 GetGamepadIndexFromJoystickId(SDL_JoystickID id) {
|
||||||
|
return SDL_GetGamepadPlayerIndex(SDL_GetGamepadFromID(id)) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Input
|
} // namespace Input
|
||||||
|
@ -471,4 +471,6 @@ bool UpdatePressedKeys(InputEvent event);
|
|||||||
|
|
||||||
void ActivateOutputsFromInputs();
|
void ActivateOutputsFromInputs();
|
||||||
|
|
||||||
|
u8 GetGamepadIndexFromJoystickId(SDL_JoystickID id);
|
||||||
|
|
||||||
} // namespace Input
|
} // namespace Input
|
||||||
|
@ -191,8 +191,7 @@ void WindowSDL::WaitEvent() {
|
|||||||
OnGamepadEvent(&event);
|
OnGamepadEvent(&event);
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_GAMEPAD_SENSOR_UPDATE: {
|
case SDL_EVENT_GAMEPAD_SENSOR_UPDATE: {
|
||||||
int controller_id =
|
int controller_id = Input::GetGamepadIndexFromJoystickId(event.gsensor.which) - 1;
|
||||||
Input::GameControllers::GetGamepadIndexFromJoystickId(event.gsensor.which) - 1;
|
|
||||||
switch ((SDL_SensorType)event.gsensor.sensor) {
|
switch ((SDL_SensorType)event.gsensor.sensor) {
|
||||||
case SDL_SENSOR_GYRO:
|
case SDL_SENSOR_GYRO:
|
||||||
controllers[controller_id]->Gyro(0, event.gsensor.data);
|
controllers[controller_id]->Gyro(0, event.gsensor.data);
|
||||||
@ -355,8 +354,8 @@ void WindowSDL::OnGamepadEvent(const SDL_Event* event) {
|
|||||||
// as it would break the entire touchpad handling
|
// as it would break the entire touchpad handling
|
||||||
// You can still bind other things to it though
|
// You can still bind other things to it though
|
||||||
if (event->gbutton.button == SDL_GAMEPAD_BUTTON_TOUCHPAD) {
|
if (event->gbutton.button == SDL_GAMEPAD_BUTTON_TOUCHPAD) {
|
||||||
controllers[Input::GameControllers::GetGamepadIndexFromJoystickId(event->gbutton.which)]
|
controllers[Input::GetGamepadIndexFromJoystickId(event->gbutton.which)]->CheckButton(
|
||||||
->CheckButton(0, OrbisPadButtonDataOffset::TouchPad, input_down);
|
0, OrbisPadButtonDataOffset::TouchPad, input_down);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,12 +363,12 @@ void WindowSDL::OnGamepadEvent(const SDL_Event* event) {
|
|||||||
case SDL_EVENT_GAMEPAD_SENSOR_UPDATE:
|
case SDL_EVENT_GAMEPAD_SENSOR_UPDATE:
|
||||||
switch ((SDL_SensorType)event->gsensor.sensor) {
|
switch ((SDL_SensorType)event->gsensor.sensor) {
|
||||||
case SDL_SENSOR_GYRO:
|
case SDL_SENSOR_GYRO:
|
||||||
controllers[Input::GameControllers::GetGamepadIndexFromJoystickId(event->gsensor.which)]
|
controllers[Input::GetGamepadIndexFromJoystickId(event->gsensor.which)]->Gyro(
|
||||||
->Gyro(0, event->gsensor.data);
|
0, event->gsensor.data);
|
||||||
break;
|
break;
|
||||||
case SDL_SENSOR_ACCEL:
|
case SDL_SENSOR_ACCEL:
|
||||||
controllers[Input::GameControllers::GetGamepadIndexFromJoystickId(event->gsensor.which)]
|
controllers[Input::GetGamepadIndexFromJoystickId(event->gsensor.which)]->Acceleration(
|
||||||
->Acceleration(0, event->gsensor.data);
|
0, event->gsensor.data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -378,10 +377,9 @@ void WindowSDL::OnGamepadEvent(const SDL_Event* event) {
|
|||||||
case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN:
|
case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN:
|
||||||
case SDL_EVENT_GAMEPAD_TOUCHPAD_UP:
|
case SDL_EVENT_GAMEPAD_TOUCHPAD_UP:
|
||||||
case SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION:
|
case SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION:
|
||||||
controllers[Input::GameControllers::GetGamepadIndexFromJoystickId(event->gtouchpad.which)]
|
controllers[Input::GetGamepadIndexFromJoystickId(event->gtouchpad.which)]->SetTouchpadState(
|
||||||
->SetTouchpadState(event->gtouchpad.finger,
|
event->gtouchpad.finger, event->type != SDL_EVENT_GAMEPAD_TOUCHPAD_UP,
|
||||||
event->type != SDL_EVENT_GAMEPAD_TOUCHPAD_UP, event->gtouchpad.x,
|
event->gtouchpad.x, event->gtouchpad.y);
|
||||||
event->gtouchpad.y);
|
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user