Mesen/Core/SystemActionManager.h
Souryo 850102bbdc Input: Added support for ~20 new peripherals (Incomplete, more fixes/changes to come)
Movies: Rewrote format to support all IO devices and console types
Netplay: Now supports all IO devices and console types
2017-11-19 23:08:23 -05:00

77 lines
1.3 KiB
C++

#pragma once
#include "stdafx.h"
#include "BaseControlDevice.h"
#include "Console.h"
class SystemActionManager : public BaseControlDevice
{
private:
std::weak_ptr<Console> _console;
bool _needReset = false;
bool _needPowerCycle = false;
protected:
string GetKeyNames() override
{
return "RP";
}
void StreamState(bool saving) override
{
BaseControlDevice::StreamState(saving);
}
public:
enum Buttons { ResetButton = 0, PowerButton = 1 };
SystemActionManager(std::shared_ptr<Console> console) : BaseControlDevice(BaseControlDevice::ConsoleInputPort)
{
_console = console;
}
uint8_t ReadRAM(uint16_t addr) override
{
return 0;
}
void WriteRAM(uint16_t addr, uint8_t value) override
{
}
void OnAfterSetState() override
{
if(_needReset) {
SetBit(SystemActionManager::Buttons::ResetButton);
_needReset = false;
}
if(_needPowerCycle) {
SetBit(SystemActionManager::Buttons::PowerButton);
_needPowerCycle = false;
}
}
void Reset()
{
_needReset = true;
}
void PowerCycle()
{
_needPowerCycle = true;
}
virtual void ProcessSystemActions()
{
shared_ptr<Console> console = _console.lock();
if(console) {
if(IsPressed(SystemActionManager::Buttons::ResetButton)) {
console->ResetComponents(true);
}
if(IsPressed(SystemActionManager::Buttons::PowerButton)) {
console->PowerCycle();
}
}
}
};