rpcsx/rpcs3/pad_thread.h

56 lines
1.1 KiB
C
Raw Normal View History

#pragma once
#include <map>
#include <thread>
2018-12-17 19:13:35 +01:00
#include <mutex>
#include "../Utilities/types.h"
#include "Emu/Io/PadHandler.h"
struct PadInfo
{
u32 now_connect;
u32 system_info;
};
class pad_thread
{
public:
2018-10-02 20:27:13 +02:00
pad_thread(void *_curthread, void *_curwindow); // void * instead of QThread * and QWindow * because of include in emucore
~pad_thread();
PadInfo& GetInfo() { return m_info; }
std::vector<std::shared_ptr<Pad>>& GetPads() { return m_pads; }
void SetRumble(const u32 pad, u8 largeMotor, bool smallMotor);
2018-12-17 19:13:35 +01:00
void Init();
void Reset();
protected:
void ThreadFunc();
2018-10-02 20:27:13 +02:00
// List of all handlers
std::map<pad_handler, std::shared_ptr<PadHandlerBase>> handlers;
2018-10-02 20:27:13 +02:00
// Used for pad_handler::keyboard
void *curthread;
void *curwindow;
PadInfo m_info;
std::vector<std::shared_ptr<Pad>> m_pads;
2018-12-17 19:13:35 +01:00
atomic_t<bool> active{ false };
atomic_t<bool> reset{ false };
std::shared_ptr<std::thread> thread;
};
namespace pad
{
extern atomic_t<pad_thread*> g_current;
2018-12-17 19:13:35 +01:00
extern std::recursive_mutex g_pad_mutex;
static inline class pad_thread* get_current_handler()
{
return verify(HERE, g_current.load());
};
}