shadPS4/src/Emulator/Host/controller.h
2023-11-05 13:41:26 +02:00

34 lines
753 B
C++

#pragma once
#include "common/types.h"
#include <mutex>
namespace Emulator::Host::Controller {
struct State {
u32 buttonsState =0;
u64 time = 0;
};
constexpr u32 MAX_STATES = 64;
class GameController {
public:
GameController();
virtual ~GameController() = default;
void readState(State* state, bool* isConnected, int* connectedCount);
State getLastState() const;
void checKButton(int id, u32 button, bool isPressed);
void addState(const State& state);
private:
std::mutex m_mutex;
bool m_connected = false;
State m_last_state;
int m_connected_count = 0;
u32 m_states_num = 0;
u32 m_first_state = 0;
State m_states[MAX_STATES];
};
} // namespace Emulator::HLE::Libraries::Controller