shadPS4/src/Emulator/Host/controller.h

33 lines
738 B
C
Raw Normal View History

2023-10-13 06:40:59 +00:00
#pragma once
#include <mutex>
#include "common/types.h"
2023-10-13 06:40:59 +00:00
namespace Emulator::Host::Controller {
struct State {
u32 buttonsState = 0;
2023-10-30 06:57:43 +00:00
u64 time = 0;
2023-10-13 06:40:59 +00:00
};
constexpr u32 MAX_STATES = 64;
class GameController {
public:
2023-10-13 06:40:59 +00:00
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;
2023-10-13 06:40:59 +00:00
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::Host::Controller