mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-29 14:53:18 +00:00
Add poll interval to libScePad (#1415)
This commit is contained in:
parent
87f8fea4de
commit
c38e3f77f9
5 changed files with 38 additions and 2 deletions
|
@ -1,10 +1,13 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include "controller.h"
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "core/libraries/kernel/time_management.h"
|
||||
#include "core/libraries/pad/pad.h"
|
||||
#include "input/controller.h"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
namespace Input {
|
||||
|
||||
|
@ -157,4 +160,23 @@ void GameController::TryOpenSDLController() {
|
|||
}
|
||||
}
|
||||
|
||||
u32 GameController::Poll() {
|
||||
if (m_connected) {
|
||||
auto time = Libraries::Kernel::sceKernelGetProcessTime();
|
||||
if (m_states_num == 0) {
|
||||
auto diff = (time - m_last_state.time) / 1000;
|
||||
if (diff >= 100) {
|
||||
AddState(GetLastState());
|
||||
}
|
||||
} else {
|
||||
auto index = (m_first_state - 1 + m_states_num) % MAX_STATES;
|
||||
auto diff = (time - m_states[index].time) / 1000;
|
||||
if (m_private[index].obtained && diff >= 100) {
|
||||
AddState(GetLastState());
|
||||
}
|
||||
}
|
||||
}
|
||||
return 100;
|
||||
}
|
||||
|
||||
} // namespace Input
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
bool SetVibration(u8 smallMotor, u8 largeMotor);
|
||||
void SetTouchpadState(int touchIndex, bool touchDown, float x, float y);
|
||||
void TryOpenSDLController();
|
||||
u32 Poll();
|
||||
|
||||
private:
|
||||
struct StateInternal {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue