2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-05-13 13:51:21 +00:00
metaforce/Runtime/Input/CInputGenerator.cpp
Phillip Stephens d9b7229e79
Add input visualization, protect first 7 object slots from deletion
The first 7 slots in the game are related to the player, we don't want to allow anyone to delete them because the game *will* crash
2021-05-30 00:52:20 -07:00

44 lines
1.2 KiB
C++

#include "Runtime/Input/CInputGenerator.hpp"
#include "Runtime/CArchitectureMessage.hpp"
#include "Runtime/CArchitectureQueue.hpp"
namespace metaforce {
void CInputGenerator::Update(float dt, CArchitectureQueue& queue) {
if (m_firstFrame) {
m_firstFrame = false;
return;
}
/* Keyboard/Mouse first */
CFinalInput kbInput = getFinalInput(0, dt);
bool kbUsed = false;
/* Dolphin controllers next */
for (int i = 0; i < 4; ++i) {
bool connected;
EStatusChange change = m_dolphinCb.getStatusChange(i, connected);
if (change != EStatusChange::NoChange)
queue.Push(MakeMsg::CreateControllerStatus(EArchMsgTarget::Game, i, connected));
if (connected) {
CFinalInput input = m_dolphinCb.getFinalInput(i, dt, m_leftDiv, m_rightDiv);
if (i == 0) /* Merge KB input with first controller */
{
input |= kbInput;
kbUsed = true;
}
m_lastUpdate = input;
queue.Push(MakeMsg::CreateUserInput(EArchMsgTarget::Game, input));
}
}
/* Send straight keyboard input if no first controller present */
if (!kbUsed) {
m_lastUpdate = kbInput;
queue.Push(MakeMsg::CreateUserInput(EArchMsgTarget::Game, kbInput));
}
}
} // namespace metaforce