init motion controls for move

This commit is contained in:
kalaposfos13 2026-03-14 14:10:39 +01:00
parent 92f4b885b1
commit d229ab4d8b
3 changed files with 26 additions and 9 deletions

View File

@ -78,7 +78,7 @@ s32 PS4_SYSV_ABI sceMoveReadStateLatest(s32 handle, OrbisMoveData* data) {
if (!controllers.moves(0)->m_sdl_gamepad) {
return ORBIS_MOVE_ERROR_NO_CONTROLLER_CONNECTED;
}
LOG_INFO(Lib_Move, "(called");
LOG_INFO(Lib_Move, "called");
auto m = controllers.moves(0);
Input::State s{};
bool connected;

View File

@ -269,12 +269,29 @@ void GameControllers::TryOpenSDLControllers() {
product == 0x0C5E)) { // PSMove ZCM2
LOG_INFO(Input, "PS Move controller found at slot {}!", j);
if (is_first_check) { // ABSOLUTELY HORRIBLE HACK but I just want it hooked up
// quickly
move_controllers[move_count]->m_sdl_gamepad = pad;
// quickly
auto c = move_controllers[move_count];
c->m_sdl_gamepad = pad;
auto u = UserManagement.GetDefaultUser();
move_controllers[move_count]->user_id = u.user_id;
move_controllers[move_count]->m_connected = true;
c->user_id = u.user_id;
c->m_connected = true;
move_count++;
if (SDL_SetGamepadSensorEnabled(c->m_sdl_gamepad, SDL_SENSOR_GYRO, true)) {
c->gyro_poll_rate =
SDL_GetGamepadSensorDataRate(c->m_sdl_gamepad, SDL_SENSOR_GYRO);
LOG_INFO(Input, "Gyro initialized, poll rate: {}", c->gyro_poll_rate);
} else {
LOG_ERROR(Input, "Failed to initialize gyro controls for gamepad {}",
c->user_id);
}
if (SDL_SetGamepadSensorEnabled(c->m_sdl_gamepad, SDL_SENSOR_ACCEL, true)) {
c->accel_poll_rate =
SDL_GetGamepadSensorDataRate(c->m_sdl_gamepad, SDL_SENSOR_ACCEL);
LOG_INFO(Input, "Accel initialized, poll rate: {}", c->accel_poll_rate);
} else {
LOG_ERROR(Input, "Failed to initialize accel controls for gamepad {}",
c->user_id);
}
}
continue;
}

View File

@ -366,22 +366,22 @@ void WindowSDL::OnGamepadEvent(const SDL_Event* event) {
switch ((SDL_SensorType)event->gsensor.sensor) {
case SDL_SENSOR_GYRO:
gamepad = controllers.GetGamepadIndexFromJoystickId(event->gsensor.which);
if (gamepad >= 0) {
if (gamepad < 4) {
controllers[gamepad]->UpdateGyro(event->gsensor.data);
} else {
gamepad = controllers.GetMoveIndexFromJoystickId(event->gsensor.which);
if (gamepad >= 0) {
if (gamepad < 4) {
controllers.moves(gamepad)->UpdateGyro(event->gsensor.data);
}
}
break;
case SDL_SENSOR_ACCEL:
gamepad = controllers.GetGamepadIndexFromJoystickId(event->gsensor.which);
if (gamepad >= 0) {
if (gamepad < 4) {
controllers[gamepad]->UpdateAcceleration(event->gsensor.data);
} else {
gamepad = controllers.GetMoveIndexFromJoystickId(event->gsensor.which);
if (gamepad >= 0) {
if (gamepad < 4) {
controllers.moves(gamepad)->UpdateAcceleration(event->gsensor.data);
}
}