mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-02 11:03:34 -06:00
init motion controls for move
This commit is contained in:
parent
92f4b885b1
commit
d229ab4d8b
@ -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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user