2014-06-21 15:43:41 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
2016-02-05 23:14:27 -05:00
|
|
|
#include "BaseControlDevice.h"
|
2014-06-21 15:43:41 -04:00
|
|
|
#include "IMemoryHandler.h"
|
2014-07-01 12:44:01 -04:00
|
|
|
#include "Movie.h"
|
2014-07-06 19:54:47 -04:00
|
|
|
#include "IGameBroadcaster.h"
|
|
|
|
#include "Snapshotable.h"
|
2014-07-06 21:11:52 -04:00
|
|
|
#include "../Utilities/SimpleLock.h"
|
2015-07-10 21:07:24 -04:00
|
|
|
#include "IKeyManager.h"
|
2014-06-21 15:43:41 -04:00
|
|
|
|
2016-02-05 23:14:27 -05:00
|
|
|
class BaseControlDevice;
|
|
|
|
class Zapper;
|
|
|
|
|
2016-02-14 12:58:35 -05:00
|
|
|
struct MousePosition
|
|
|
|
{
|
|
|
|
int32_t X;
|
|
|
|
int32_t Y;
|
|
|
|
};
|
|
|
|
|
2014-07-06 19:54:47 -04:00
|
|
|
class ControlManager : public Snapshotable, public IMemoryHandler
|
2014-06-21 15:43:41 -04:00
|
|
|
{
|
|
|
|
private:
|
2015-07-10 21:07:24 -04:00
|
|
|
static unique_ptr<IKeyManager> _keyManager;
|
2016-02-05 23:14:27 -05:00
|
|
|
static shared_ptr<BaseControlDevice> _controlDevices[2];
|
|
|
|
static IGameBroadcaster* _gameBroadcaster;
|
2016-02-14 12:58:35 -05:00
|
|
|
static MousePosition _mousePosition;
|
2014-07-06 19:54:47 -04:00
|
|
|
|
2014-06-21 15:43:41 -04:00
|
|
|
bool _refreshState = false;
|
|
|
|
|
|
|
|
void RefreshAllPorts();
|
|
|
|
uint8_t GetPortValue(uint8_t port);
|
|
|
|
|
2016-02-05 23:14:27 -05:00
|
|
|
static void RegisterControlDevice(shared_ptr<BaseControlDevice> controlDevice, uint8_t port);
|
|
|
|
void UnregisterControlDevice(uint8_t port);
|
|
|
|
|
2014-07-06 19:54:47 -04:00
|
|
|
protected:
|
|
|
|
virtual void StreamState(bool saving);
|
|
|
|
|
2014-06-21 15:43:41 -04:00
|
|
|
public:
|
|
|
|
ControlManager();
|
|
|
|
|
2016-02-05 23:14:27 -05:00
|
|
|
void UpdateControlDevices();
|
|
|
|
|
2014-07-06 19:54:47 -04:00
|
|
|
static void RegisterBroadcaster(IGameBroadcaster* gameBroadcaster);
|
|
|
|
static void UnregisterBroadcaster(IGameBroadcaster* gameBroadcaster);
|
|
|
|
|
2015-07-10 21:07:24 -04:00
|
|
|
static void RegisterKeyManager(IKeyManager* keyManager);
|
|
|
|
static bool IsKeyPressed(uint32_t keyCode);
|
2016-02-14 12:58:35 -05:00
|
|
|
static bool IsMouseButtonPressed(MouseButton button);
|
2015-07-10 21:07:24 -04:00
|
|
|
static uint32_t GetPressedKey();
|
2015-07-11 08:27:22 -04:00
|
|
|
static string GetKeyName(uint32_t keyCode);
|
|
|
|
static uint32_t GetKeyCode(string keyName);
|
2016-02-05 23:14:27 -05:00
|
|
|
|
|
|
|
static shared_ptr<BaseControlDevice> GetControlDevice(uint8_t port);
|
|
|
|
|
2016-02-14 12:58:35 -05:00
|
|
|
static void SetMousePosition(double x, double y);
|
|
|
|
static MousePosition GetMousePosition();
|
2015-07-10 21:07:24 -04:00
|
|
|
|
2016-02-05 23:14:27 -05:00
|
|
|
static void BroadcastInput(uint8_t port, uint8_t state);
|
2014-06-21 15:43:41 -04:00
|
|
|
|
2014-06-25 12:22:48 -04:00
|
|
|
void GetMemoryRanges(MemoryRanges &ranges)
|
2014-06-21 15:43:41 -04:00
|
|
|
{
|
2015-07-29 22:10:34 -04:00
|
|
|
ranges.AddHandler(MemoryOperation::Read, 0x4016, 0x4017);
|
|
|
|
ranges.AddHandler(MemoryOperation::Write, 0x4016);
|
2014-06-21 15:43:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t ReadRAM(uint16_t addr);
|
|
|
|
void WriteRAM(uint16_t addr, uint8_t value);
|
|
|
|
};
|