mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-20 03:24:49 +00:00
Make F4/F5 adding/removing controllers a full feature instead of an accidentally pushed debug tool
This commit is contained in:
parent
ce359b5b4d
commit
edf14ac019
3 changed files with 25 additions and 17 deletions
|
@ -588,7 +588,7 @@ s32 PS4_SYSV_ABI sceUserServiceGetLoginUserIdList(OrbisUserServiceLoginUserIdLis
|
|||
// TODO only first user, do the others as well
|
||||
for (int i = 0; i < 4; i++) {
|
||||
auto controllers = *Common::Singleton<Input::GameControllers>::Instance();
|
||||
userIdList->user_id[i] = controllers[i]->GetUserId();
|
||||
userIdList->user_id[i] = controllers[i]->user_id;
|
||||
}
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
|
|
@ -65,12 +65,10 @@ public:
|
|||
bool SetVibration(u8 smallMotor, u8 largeMotor);
|
||||
void SetTouchpadState(int touchIndex, bool touchDown, float x, float y);
|
||||
u32 Poll();
|
||||
u32 GetUserId() {
|
||||
return user_id;
|
||||
}
|
||||
|
||||
float gyro_poll_rate;
|
||||
float accel_poll_rate;
|
||||
u32 user_id = -1; // ORBIS_USER_SERVICE_USER_ID_INVALID
|
||||
static void CalculateOrientation(Libraries::Pad::OrbisFVector3& acceleration,
|
||||
Libraries::Pad::OrbisFVector3& angularVelocity,
|
||||
float deltaTime,
|
||||
|
@ -89,7 +87,6 @@ private:
|
|||
u32 m_first_state = 0;
|
||||
std::array<State, MAX_STATES> m_states;
|
||||
std::array<StateInternal, MAX_STATES> m_private;
|
||||
u32 user_id = -1; // ORBIS_USER_SERVICE_USER_ID_INVALID
|
||||
|
||||
SDL_Gamepad* m_sdl_gamepad = nullptr;
|
||||
};
|
||||
|
|
|
@ -194,21 +194,20 @@ void WindowSDL::WaitEvent() {
|
|||
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
|
||||
OnGamepadEvent(&event);
|
||||
break;
|
||||
case SDL_EVENT_GAMEPAD_SENSOR_UPDATE:{
|
||||
case SDL_EVENT_GAMEPAD_SENSOR_UPDATE: {
|
||||
int controller_id = Input::GetGamepadIndexFromJoystickId(event.gsensor.which) - 1;
|
||||
switch ((SDL_SensorType)event.gsensor.sensor) {
|
||||
case SDL_SENSOR_GYRO:
|
||||
controllers[controller_id]->Gyro(
|
||||
0, event.gsensor.data);
|
||||
controllers[controller_id]->Gyro(0, event.gsensor.data);
|
||||
break;
|
||||
case SDL_SENSOR_ACCEL:
|
||||
controllers[controller_id]->Acceleration(
|
||||
0, event.gsensor.data);
|
||||
controllers[controller_id]->Acceleration(0, event.gsensor.data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;}
|
||||
break;
|
||||
}
|
||||
case SDL_EVENT_QUIT:
|
||||
is_open = false;
|
||||
break;
|
||||
|
@ -312,13 +311,25 @@ void WindowSDL::OnKeyboardMouseInput(const SDL_Event* event) {
|
|||
}
|
||||
// test controller connect/disconnect
|
||||
else if (input_id == SDLK_F4) {
|
||||
int player_count = Config::GetNumberOfPlayers();
|
||||
AddUserServiceEvent({OrbisUserServiceEventType::Logout, player_count});
|
||||
Config::SetNumberOfPlayers(player_count - 1);
|
||||
auto controllers = *Common::Singleton<Input::GameControllers>::Instance();
|
||||
for (int i = 3; i >= 0; i--) {
|
||||
if (controllers[i]->user_id != -1) {
|
||||
AddUserServiceEvent(
|
||||
{OrbisUserServiceEventType::Logout, (s32)controllers[i]->user_id});
|
||||
controllers[i]->user_id = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (input_id == SDLK_F5) {
|
||||
int player_count = Config::GetNumberOfPlayers();
|
||||
AddUserServiceEvent({OrbisUserServiceEventType::Login, player_count + 1});
|
||||
Config::SetNumberOfPlayers(player_count + 1);
|
||||
auto controllers = *Common::Singleton<Input::GameControllers>::Instance();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (controllers[i]->user_id == -1) {
|
||||
controllers[i]->user_id = i + 1;
|
||||
AddUserServiceEvent(
|
||||
{OrbisUserServiceEventType::Login, (s32)controllers[i]->user_id});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue