mirror of https://github.com/AxioDL/metaforce.git
Merge pull request #96 from lioncash/array2
CFinalInput, ControlMapper: Use std::array where applicable
This commit is contained in:
commit
d2e9495686
|
@ -486,7 +486,7 @@ void CAutoMapper::ProcessMapRotateInput(const CFinalInput& input, const CStateMa
|
||||||
float dirs[4] = {};
|
float dirs[4] = {};
|
||||||
bool mouseHeld = false;
|
bool mouseHeld = false;
|
||||||
if (const auto& kbm = input.GetKBM()) {
|
if (const auto& kbm = input.GetKBM()) {
|
||||||
if (kbm->m_mouseButtons[int(boo::EMouseButton::Primary)]) {
|
if (kbm->m_mouseButtons[size_t(boo::EMouseButton::Primary)]) {
|
||||||
mouseHeld = true;
|
mouseHeld = true;
|
||||||
if (float(m_mouseDelta.x()) < 0.f)
|
if (float(m_mouseDelta.x()) < 0.f)
|
||||||
dirs[3] = -m_mouseDelta.x();
|
dirs[3] = -m_mouseDelta.x();
|
||||||
|
@ -664,8 +664,8 @@ void CAutoMapper::ProcessMapPanInput(const CFinalInput& input, const CStateManag
|
||||||
|
|
||||||
bool mouseHeld = false;
|
bool mouseHeld = false;
|
||||||
if (const auto& kbm = input.GetKBM()) {
|
if (const auto& kbm = input.GetKBM()) {
|
||||||
if (kbm->m_mouseButtons[int(boo::EMouseButton::Middle)] ||
|
if (kbm->m_mouseButtons[size_t(boo::EMouseButton::Middle)] ||
|
||||||
kbm->m_mouseButtons[int(boo::EMouseButton::Secondary)]) {
|
kbm->m_mouseButtons[size_t(boo::EMouseButton::Secondary)]) {
|
||||||
mouseHeld = true;
|
mouseHeld = true;
|
||||||
if (float(m_mouseDelta.x()) < 0.f)
|
if (float(m_mouseDelta.x()) < 0.f)
|
||||||
right += -m_mouseDelta.x();
|
right += -m_mouseDelta.x();
|
||||||
|
|
|
@ -227,7 +227,7 @@ bool CGuiFrame::ProcessMouseInput(const CFinalInput& input, const CGuiWidgetDraw
|
||||||
hit->m_integerScroll.delta[1] -= std::trunc(hit->m_integerScroll.delta[1]);
|
hit->m_integerScroll.delta[1] -= std::trunc(hit->m_integerScroll.delta[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!m_inMouseDown && kbm->m_mouseButtons[int(boo::EMouseButton::Primary)]) {
|
if (!m_inMouseDown && kbm->m_mouseButtons[size_t(boo::EMouseButton::Primary)]) {
|
||||||
m_inMouseDown = true;
|
m_inMouseDown = true;
|
||||||
m_inCancel = false;
|
m_inCancel = false;
|
||||||
m_mouseDownWidget = hit;
|
m_mouseDownWidget = hit;
|
||||||
|
@ -235,7 +235,7 @@ bool CGuiFrame::ProcessMouseInput(const CFinalInput& input, const CGuiWidgetDraw
|
||||||
m_mouseDownCb(hit, false);
|
m_mouseDownCb(hit, false);
|
||||||
if (hit)
|
if (hit)
|
||||||
return true;
|
return true;
|
||||||
} else if (m_inMouseDown && !kbm->m_mouseButtons[int(boo::EMouseButton::Primary)]) {
|
} else if (m_inMouseDown && !kbm->m_mouseButtons[size_t(boo::EMouseButton::Primary)]) {
|
||||||
m_inMouseDown = false;
|
m_inMouseDown = false;
|
||||||
m_inCancel = false;
|
m_inCancel = false;
|
||||||
if (m_mouseDownWidget == m_lastMouseOverWidget) {
|
if (m_mouseDownWidget == m_lastMouseOverWidget) {
|
||||||
|
|
|
@ -118,10 +118,10 @@ CFinalInput::CFinalInput(int cIdx, float dt, const CKeyboardMouseControllerData&
|
||||||
, x2c_b28_Z(false)
|
, x2c_b28_Z(false)
|
||||||
, x2c_b29_L(false)
|
, x2c_b29_L(false)
|
||||||
, x2c_b30_R(false)
|
, x2c_b30_R(false)
|
||||||
, x2c_b31_DPUp(data.m_specialKeys[int(boo::ESpecialKey::Up)])
|
, x2c_b31_DPUp(data.m_specialKeys[size_t(boo::ESpecialKey::Up)])
|
||||||
, x2d_b24_DPRight(data.m_specialKeys[int(boo::ESpecialKey::Right)])
|
, x2d_b24_DPRight(data.m_specialKeys[size_t(boo::ESpecialKey::Right)])
|
||||||
, x2d_b25_DPDown(data.m_specialKeys[int(boo::ESpecialKey::Down)])
|
, x2d_b25_DPDown(data.m_specialKeys[size_t(boo::ESpecialKey::Down)])
|
||||||
, x2d_b26_DPLeft(data.m_specialKeys[int(boo::ESpecialKey::Left)])
|
, x2d_b26_DPLeft(data.m_specialKeys[size_t(boo::ESpecialKey::Left)])
|
||||||
, x2d_b27_Start(false)
|
, x2d_b27_Start(false)
|
||||||
, x2d_b28_PA(DA() && !prevInput.DA())
|
, x2d_b28_PA(DA() && !prevInput.DA())
|
||||||
, x2d_b29_PB(DB() && !prevInput.DB())
|
, x2d_b29_PB(DB() && !prevInput.DB())
|
||||||
|
@ -137,14 +137,17 @@ CFinalInput::CFinalInput(int cIdx, float dt, const CKeyboardMouseControllerData&
|
||||||
, x2e_b31_PStart(DStart() && !prevInput.DStart())
|
, x2e_b31_PStart(DStart() && !prevInput.DStart())
|
||||||
, m_kbm(data) {
|
, m_kbm(data) {
|
||||||
if (prevInput.m_kbm) {
|
if (prevInput.m_kbm) {
|
||||||
for (int i = 0; i < 256; ++i)
|
for (size_t i = 0; i < m_PCharKeys.size(); ++i) {
|
||||||
m_PCharKeys[i] = data.m_charKeys[i] && !prevInput.m_kbm->m_charKeys[i];
|
m_PCharKeys[i] = data.m_charKeys[i] && !prevInput.m_kbm->m_charKeys[i];
|
||||||
for (int i = 0; i < 26; ++i)
|
}
|
||||||
|
for (size_t i = 0; i < m_PSpecialKeys.size(); ++i) {
|
||||||
m_PSpecialKeys[i] = data.m_specialKeys[i] && !prevInput.m_kbm->m_specialKeys[i];
|
m_PSpecialKeys[i] = data.m_specialKeys[i] && !prevInput.m_kbm->m_specialKeys[i];
|
||||||
for (int i = 0; i < 6; ++i)
|
}
|
||||||
|
for (size_t i = 0; i < m_PMouseButtons.size(); ++i) {
|
||||||
m_PMouseButtons[i] = data.m_mouseButtons[i] && !prevInput.m_kbm->m_mouseButtons[i];
|
m_PMouseButtons[i] = data.m_mouseButtons[i] && !prevInput.m_kbm->m_mouseButtons[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CFinalInput& CFinalInput::operator|=(const CFinalInput& other) {
|
CFinalInput& CFinalInput::operator|=(const CFinalInput& other) {
|
||||||
if (std::fabs(other.x8_anaLeftX) > std::fabs(x8_anaLeftX))
|
if (std::fabs(other.x8_anaLeftX) > std::fabs(x8_anaLeftX))
|
||||||
|
@ -195,12 +198,9 @@ CFinalInput& CFinalInput::operator|=(const CFinalInput& other) {
|
||||||
x2e_b31_PStart |= other.x2e_b31_PStart;
|
x2e_b31_PStart |= other.x2e_b31_PStart;
|
||||||
if (other.m_kbm) {
|
if (other.m_kbm) {
|
||||||
m_kbm = other.m_kbm;
|
m_kbm = other.m_kbm;
|
||||||
for (int i = 0; i < 256; ++i)
|
m_PCharKeys = other.m_PCharKeys;
|
||||||
m_PCharKeys[i] = other.m_PCharKeys[i];
|
m_PSpecialKeys = other.m_PSpecialKeys;
|
||||||
for (int i = 0; i < 26; ++i)
|
m_PMouseButtons = other.m_PMouseButtons;
|
||||||
m_PSpecialKeys[i] = other.m_PSpecialKeys[i];
|
|
||||||
for (int i = 0; i < 6; ++i)
|
|
||||||
m_PMouseButtons[i] = other.m_PMouseButtons[i];
|
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "Runtime/RetroTypes.hpp"
|
#include "Runtime/RetroTypes.hpp"
|
||||||
#include "Runtime/Input/CKeyboardMouseController.hpp"
|
#include "Runtime/Input/CKeyboardMouseController.hpp"
|
||||||
|
|
||||||
|
@ -62,9 +64,9 @@ struct CFinalInput {
|
||||||
|
|
||||||
std::optional<CKeyboardMouseControllerData> m_kbm;
|
std::optional<CKeyboardMouseControllerData> m_kbm;
|
||||||
|
|
||||||
bool m_PCharKeys[256] = {};
|
std::array<bool, 256> m_PCharKeys{};
|
||||||
bool m_PSpecialKeys[26] = {};
|
std::array<bool, 26> m_PSpecialKeys{};
|
||||||
bool m_PMouseButtons[6] = {};
|
std::array<bool, 6> m_PMouseButtons{};
|
||||||
|
|
||||||
float m_leftMul = 1.f;
|
float m_leftMul = 1.f;
|
||||||
float m_rightMul = 1.f;
|
float m_rightMul = 1.f;
|
||||||
|
@ -158,12 +160,12 @@ struct CFinalInput {
|
||||||
|
|
||||||
CFinalInput ScaleAnalogueSticks(float leftDiv, float rightDiv) const;
|
CFinalInput ScaleAnalogueSticks(float leftDiv, float rightDiv) const;
|
||||||
|
|
||||||
bool PKey(char k) const { return m_kbm && m_PCharKeys[int(k)]; }
|
bool PKey(char k) const { return m_kbm && m_PCharKeys[size_t(k)]; }
|
||||||
bool PSpecialKey(boo::ESpecialKey k) const { return m_kbm && m_PSpecialKeys[int(k)]; }
|
bool PSpecialKey(boo::ESpecialKey k) const { return m_kbm && m_PSpecialKeys[size_t(k)]; }
|
||||||
bool PMouseButton(boo::EMouseButton k) const { return m_kbm && m_PMouseButtons[int(k)]; }
|
bool PMouseButton(boo::EMouseButton k) const { return m_kbm && m_PMouseButtons[size_t(k)]; }
|
||||||
bool DKey(char k) const { return m_kbm && m_kbm->m_charKeys[int(k)]; }
|
bool DKey(char k) const { return m_kbm && m_kbm->m_charKeys[size_t(k)]; }
|
||||||
bool DSpecialKey(boo::ESpecialKey k) const { return m_kbm && m_kbm->m_specialKeys[int(k)]; }
|
bool DSpecialKey(boo::ESpecialKey k) const { return m_kbm && m_kbm->m_specialKeys[size_t(k)]; }
|
||||||
bool DMouseButton(boo::EMouseButton k) const { return m_kbm && m_kbm->m_mouseButtons[int(k)]; }
|
bool DMouseButton(boo::EMouseButton k) const { return m_kbm && m_kbm->m_mouseButtons[size_t(k)]; }
|
||||||
float AKey(char k) const { return DKey(k) ? 1.f : 0.f; }
|
float AKey(char k) const { return DKey(k) ? 1.f : 0.f; }
|
||||||
float ASpecialKey(boo::ESpecialKey k) const { return DSpecialKey(k) ? 1.f : 0.f; }
|
float ASpecialKey(boo::ESpecialKey k) const { return DSpecialKey(k) ? 1.f : 0.f; }
|
||||||
float AMouseButton(boo::EMouseButton k) const { return DMouseButton(k) ? 1.f : 0.f; }
|
float AMouseButton(boo::EMouseButton k) const { return DMouseButton(k) ? 1.f : 0.f; }
|
||||||
|
|
|
@ -49,10 +49,10 @@ public:
|
||||||
* is necessary, only absolute state tracking. */
|
* is necessary, only absolute state tracking. */
|
||||||
|
|
||||||
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton button, boo::EModifierKey) {
|
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton button, boo::EModifierKey) {
|
||||||
m_data.m_mouseButtons[int(button)] = true;
|
m_data.m_mouseButtons[size_t(button)] = true;
|
||||||
}
|
}
|
||||||
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton button, boo::EModifierKey) {
|
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton button, boo::EModifierKey) {
|
||||||
m_data.m_mouseButtons[int(button)] = false;
|
m_data.m_mouseButtons[size_t(button)] = false;
|
||||||
}
|
}
|
||||||
void mouseMove(const boo::SWindowCoord& coord) { m_data.m_mouseCoord = coord; }
|
void mouseMove(const boo::SWindowCoord& coord) { m_data.m_mouseCoord = coord; }
|
||||||
void scroll(const boo::SWindowCoord&, const boo::SScrollDelta& scroll) { m_data.m_accumScroll += scroll; }
|
void scroll(const boo::SWindowCoord&, const boo::SScrollDelta& scroll) { m_data.m_accumScroll += scroll; }
|
||||||
|
@ -69,8 +69,8 @@ public:
|
||||||
return;
|
return;
|
||||||
m_data.m_charKeys[charCode] = false;
|
m_data.m_charKeys[charCode] = false;
|
||||||
}
|
}
|
||||||
void specialKeyDown(boo::ESpecialKey key, boo::EModifierKey, bool) { m_data.m_specialKeys[int(key)] = true; }
|
void specialKeyDown(boo::ESpecialKey key, boo::EModifierKey, bool) { m_data.m_specialKeys[size_t(key)] = true; }
|
||||||
void specialKeyUp(boo::ESpecialKey key, boo::EModifierKey) { m_data.m_specialKeys[int(key)] = false; }
|
void specialKeyUp(boo::ESpecialKey key, boo::EModifierKey) { m_data.m_specialKeys[size_t(key)] = false; }
|
||||||
void modKeyDown(boo::EModifierKey mod, bool) { m_data.m_modMask = m_data.m_modMask | mod; }
|
void modKeyDown(boo::EModifierKey mod, bool) { m_data.m_modMask = m_data.m_modMask | mod; }
|
||||||
void modKeyUp(boo::EModifierKey mod) { m_data.m_modMask = m_data.m_modMask & ~mod; }
|
void modKeyUp(boo::EModifierKey mod) { m_data.m_modMask = m_data.m_modMask & ~mod; }
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boo/boo.hpp>
|
#include <array>
|
||||||
|
#include <boo/IWindow.hpp>
|
||||||
|
|
||||||
namespace urde {
|
namespace urde {
|
||||||
|
|
||||||
struct CKeyboardMouseControllerData {
|
struct CKeyboardMouseControllerData {
|
||||||
bool m_charKeys[256] = {};
|
std::array<bool, 256> m_charKeys{};
|
||||||
bool m_specialKeys[26] = {};
|
std::array<bool, 26> m_specialKeys{};
|
||||||
bool m_mouseButtons[6] = {};
|
std::array<bool, 6> m_mouseButtons{};
|
||||||
boo::EModifierKey m_modMask = boo::EModifierKey::None;
|
boo::EModifierKey m_modMask = boo::EModifierKey::None;
|
||||||
boo::SWindowCoord m_mouseCoord;
|
boo::SWindowCoord m_mouseCoord;
|
||||||
boo::SScrollDelta m_accumScroll;
|
boo::SScrollDelta m_accumScroll;
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
#include "../RetroTypes.hpp"
|
#include "Runtime/Input/ControlMapper.hpp"
|
||||||
#include "ControlMapper.hpp"
|
|
||||||
#include "CFinalInput.hpp"
|
#include <array>
|
||||||
|
|
||||||
#include "DataSpec/DNACommon/Tweaks/ITweakPlayerControl.hpp"
|
#include "DataSpec/DNACommon/Tweaks/ITweakPlayerControl.hpp"
|
||||||
#include "../GameGlobalObjects.hpp"
|
|
||||||
|
#include "Runtime/GameGlobalObjects.hpp"
|
||||||
|
#include "Runtime/RetroTypes.hpp"
|
||||||
|
#include "Runtime/Input/CFinalInput.hpp"
|
||||||
|
|
||||||
namespace urde {
|
namespace urde {
|
||||||
|
namespace {
|
||||||
static const char* skCommandDescs[] = {
|
constexpr std::array skCommandDescs{
|
||||||
"Forward", "Backward", "Turn Left",
|
"Forward", "Backward", "Turn Left",
|
||||||
"Turn Right", "Strafe Left", "Strafe Right",
|
"Turn Right", "Strafe Left", "Strafe Right",
|
||||||
"Look Left", "Look Right", "Look Up",
|
"Look Left", "Look Right", "Look Up",
|
||||||
|
@ -32,7 +36,8 @@ static const char* skCommandDescs[] = {
|
||||||
"Next Pause Screen", "UNKNOWN", "None",
|
"Next Pause Screen", "UNKNOWN", "None",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char* skFunctionDescs[] = {"None",
|
constexpr std::array skFunctionDescs{
|
||||||
|
"None",
|
||||||
"Left Stick Up",
|
"Left Stick Up",
|
||||||
"Left Stick Down",
|
"Left Stick Down",
|
||||||
"Left Stick Left",
|
"Left Stick Left",
|
||||||
|
@ -54,12 +59,14 @@ static const char* skFunctionDescs[] = {"None",
|
||||||
"Z Button",
|
"Z Button",
|
||||||
"Left Trigger Press",
|
"Left Trigger Press",
|
||||||
"Right Trigger Press",
|
"Right Trigger Press",
|
||||||
"Start"};
|
"Start",
|
||||||
|
};
|
||||||
|
|
||||||
typedef bool (CFinalInput::*BoolReturnFn)() const;
|
using BoolReturnFn = bool (CFinalInput::*)() const;
|
||||||
typedef float (CFinalInput::*FloatReturnFn)() const;
|
using FloatReturnFn = float (CFinalInput::*)() const;
|
||||||
|
|
||||||
static BoolReturnFn skPressFuncs[] = {nullptr,
|
constexpr std::array<BoolReturnFn, 24> skPressFuncs{
|
||||||
|
nullptr,
|
||||||
&CFinalInput::PLAUp,
|
&CFinalInput::PLAUp,
|
||||||
&CFinalInput::PLADown,
|
&CFinalInput::PLADown,
|
||||||
&CFinalInput::PLALeft,
|
&CFinalInput::PLALeft,
|
||||||
|
@ -82,9 +89,11 @@ static BoolReturnFn skPressFuncs[] = {nullptr,
|
||||||
&CFinalInput::PL,
|
&CFinalInput::PL,
|
||||||
&CFinalInput::PR,
|
&CFinalInput::PR,
|
||||||
&CFinalInput::PStart,
|
&CFinalInput::PStart,
|
||||||
nullptr};
|
nullptr,
|
||||||
|
};
|
||||||
|
|
||||||
static BoolReturnFn skDigitalFuncs[] = {nullptr,
|
constexpr std::array<BoolReturnFn, 24> skDigitalFuncs{
|
||||||
|
nullptr,
|
||||||
&CFinalInput::DLAUp,
|
&CFinalInput::DLAUp,
|
||||||
&CFinalInput::DLADown,
|
&CFinalInput::DLADown,
|
||||||
&CFinalInput::DLALeft,
|
&CFinalInput::DLALeft,
|
||||||
|
@ -107,9 +116,11 @@ static BoolReturnFn skDigitalFuncs[] = {nullptr,
|
||||||
&CFinalInput::DL,
|
&CFinalInput::DL,
|
||||||
&CFinalInput::DR,
|
&CFinalInput::DR,
|
||||||
&CFinalInput::DStart,
|
&CFinalInput::DStart,
|
||||||
nullptr};
|
nullptr,
|
||||||
|
};
|
||||||
|
|
||||||
static FloatReturnFn skAnalogFuncs[] = {nullptr,
|
constexpr std::array<FloatReturnFn, 24> skAnalogFuncs{
|
||||||
|
nullptr,
|
||||||
&CFinalInput::ALAUp,
|
&CFinalInput::ALAUp,
|
||||||
&CFinalInput::ALADown,
|
&CFinalInput::ALADown,
|
||||||
&CFinalInput::ALALeft,
|
&CFinalInput::ALALeft,
|
||||||
|
@ -132,9 +143,10 @@ static FloatReturnFn skAnalogFuncs[] = {nullptr,
|
||||||
&CFinalInput::AL,
|
&CFinalInput::AL,
|
||||||
&CFinalInput::AR,
|
&CFinalInput::AR,
|
||||||
&CFinalInput::AStart,
|
&CFinalInput::AStart,
|
||||||
nullptr};
|
nullptr,
|
||||||
|
};
|
||||||
|
|
||||||
static const ControlMapper::EKBMFunctionList skKBMMapping[] = {
|
constexpr std::array<ControlMapper::EKBMFunctionList, 70> skKBMMapping{
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'w', // Forward,
|
ControlMapper::EKBMFunctionList::KeyPress + 'w', // Forward,
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 's', // Backward,
|
ControlMapper::EKBMFunctionList::KeyPress + 's', // Backward,
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'a', // TurnLeft,
|
ControlMapper::EKBMFunctionList::KeyPress + 'a', // TurnLeft,
|
||||||
|
@ -204,60 +216,66 @@ static const ControlMapper::EKBMFunctionList skKBMMapping[] = {
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'e', // NextPauseScreen = 0x42,
|
ControlMapper::EKBMFunctionList::KeyPress + 'e', // NextPauseScreen = 0x42,
|
||||||
ControlMapper::EKBMFunctionList::None, // UNKNOWN,
|
ControlMapper::EKBMFunctionList::None, // UNKNOWN,
|
||||||
ControlMapper::EKBMFunctionList::None, // None,
|
ControlMapper::EKBMFunctionList::None, // None,
|
||||||
ControlMapper::EKBMFunctionList::None
|
ControlMapper::EKBMFunctionList::None,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define kCommandFilterCount 67
|
std::array<bool, 67> skCommandFilterFlag{true};
|
||||||
static bool skCommandFilterFlag[kCommandFilterCount] = {true};
|
} // Anonymous namespace
|
||||||
|
|
||||||
void ControlMapper::SetCommandFiltered(ECommands cmd, bool filtered) { skCommandFilterFlag[int(cmd)] = filtered; }
|
void ControlMapper::SetCommandFiltered(ECommands cmd, bool filtered) { skCommandFilterFlag[size_t(cmd)] = filtered; }
|
||||||
|
|
||||||
void ControlMapper::ResetCommandFilters() {
|
void ControlMapper::ResetCommandFilters() {
|
||||||
for (int i = 0; i < kCommandFilterCount; ++i)
|
skCommandFilterFlag.fill(true);
|
||||||
skCommandFilterFlag[i] = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ControlMapper::GetPressInput(ECommands cmd, const CFinalInput& input) {
|
bool ControlMapper::GetPressInput(ECommands cmd, const CFinalInput& input) {
|
||||||
if (!skCommandFilterFlag[int(cmd)])
|
if (!skCommandFilterFlag[size_t(cmd)]) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
EFunctionList func = EFunctionList(g_currentPlayerControl->GetMapping(atUint32(cmd)));
|
const auto func = EFunctionList(g_currentPlayerControl->GetMapping(atUint32(cmd)));
|
||||||
if (func < EFunctionList::MAX) {
|
if (func < EFunctionList::MAX) {
|
||||||
if (BoolReturnFn fn = skPressFuncs[int(func)])
|
if (BoolReturnFn fn = skPressFuncs[size_t(func)]) {
|
||||||
ret = (input.*fn)();
|
ret = (input.*fn)();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (const auto& kbm = input.GetKBM()) {
|
if (const auto& kbm = input.GetKBM()) {
|
||||||
EKBMFunctionList kbmfunc = skKBMMapping[int(cmd)];
|
const EKBMFunctionList kbmfunc = skKBMMapping[size_t(cmd)];
|
||||||
if (kbmfunc < EKBMFunctionList::MAX) {
|
if (kbmfunc < EKBMFunctionList::MAX) {
|
||||||
if (kbmfunc >= EKBMFunctionList::MousePress)
|
if (kbmfunc >= EKBMFunctionList::MousePress) {
|
||||||
ret |= input.m_PMouseButtons[int(kbmfunc) - int(EKBMFunctionList::MousePress)];
|
ret |= input.m_PMouseButtons[size_t(kbmfunc) - size_t(EKBMFunctionList::MousePress)];
|
||||||
else if (kbmfunc >= EKBMFunctionList::SpecialKeyPress)
|
} else if (kbmfunc >= EKBMFunctionList::SpecialKeyPress) {
|
||||||
ret |= input.m_PSpecialKeys[int(kbmfunc) - int(EKBMFunctionList::SpecialKeyPress)];
|
ret |= input.m_PSpecialKeys[size_t(kbmfunc) - size_t(EKBMFunctionList::SpecialKeyPress)];
|
||||||
else if (kbmfunc >= EKBMFunctionList::KeyPress)
|
} else if (kbmfunc >= EKBMFunctionList::KeyPress) {
|
||||||
ret |= input.m_PCharKeys[int(kbmfunc) - int(EKBMFunctionList::KeyPress)];
|
ret |= input.m_PCharKeys[size_t(kbmfunc) - size_t(EKBMFunctionList::KeyPress)];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ControlMapper::GetDigitalInput(ECommands cmd, const CFinalInput& input) {
|
bool ControlMapper::GetDigitalInput(ECommands cmd, const CFinalInput& input) {
|
||||||
if (!skCommandFilterFlag[int(cmd)])
|
if (!skCommandFilterFlag[size_t(cmd)]) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
EFunctionList func = EFunctionList(g_currentPlayerControl->GetMapping(atUint32(cmd)));
|
const auto func = EFunctionList(g_currentPlayerControl->GetMapping(atUint32(cmd)));
|
||||||
if (func < EFunctionList::MAX) {
|
if (func < EFunctionList::MAX) {
|
||||||
if (BoolReturnFn fn = skDigitalFuncs[int(func)])
|
if (BoolReturnFn fn = skDigitalFuncs[size_t(func)])
|
||||||
ret = (input.*fn)();
|
ret = (input.*fn)();
|
||||||
}
|
}
|
||||||
if (const auto& kbm = input.GetKBM()) {
|
if (const auto& kbm = input.GetKBM()) {
|
||||||
EKBMFunctionList kbmfunc = skKBMMapping[int(cmd)];
|
EKBMFunctionList kbmfunc = skKBMMapping[size_t(cmd)];
|
||||||
if (kbmfunc < EKBMFunctionList::MAX) {
|
if (kbmfunc < EKBMFunctionList::MAX) {
|
||||||
if (kbmfunc >= EKBMFunctionList::MousePress)
|
if (kbmfunc >= EKBMFunctionList::MousePress) {
|
||||||
ret |= kbm->m_mouseButtons[int(kbmfunc) - int(EKBMFunctionList::MousePress)];
|
ret |= kbm->m_mouseButtons[size_t(kbmfunc) - size_t(EKBMFunctionList::MousePress)];
|
||||||
else if (kbmfunc >= EKBMFunctionList::SpecialKeyPress)
|
} else if (kbmfunc >= EKBMFunctionList::SpecialKeyPress) {
|
||||||
ret |= kbm->m_specialKeys[int(kbmfunc) - int(EKBMFunctionList::SpecialKeyPress)];
|
ret |= kbm->m_specialKeys[size_t(kbmfunc) - size_t(EKBMFunctionList::SpecialKeyPress)];
|
||||||
else if (kbmfunc >= EKBMFunctionList::KeyPress)
|
} else if (kbmfunc >= EKBMFunctionList::KeyPress) {
|
||||||
ret |= kbm->m_charKeys[int(kbmfunc) - int(EKBMFunctionList::KeyPress)];
|
ret |= kbm->m_charKeys[size_t(kbmfunc) - size_t(EKBMFunctionList::KeyPress)];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -265,53 +283,66 @@ bool ControlMapper::GetDigitalInput(ECommands cmd, const CFinalInput& input) {
|
||||||
|
|
||||||
static float KBToWASDX(const CKeyboardMouseControllerData& data) {
|
static float KBToWASDX(const CKeyboardMouseControllerData& data) {
|
||||||
float retval = 0.0;
|
float retval = 0.0;
|
||||||
if (data.m_charKeys[int('a')])
|
if (data.m_charKeys[size_t('a')]) {
|
||||||
retval -= 1.0;
|
retval -= 1.0;
|
||||||
if (data.m_charKeys[int('d')])
|
}
|
||||||
|
if (data.m_charKeys[size_t('d')]) {
|
||||||
retval += 1.0;
|
retval += 1.0;
|
||||||
if (data.m_charKeys[int('w')] ^ data.m_charKeys[int('s')])
|
}
|
||||||
|
if (data.m_charKeys[size_t('w')] ^ data.m_charKeys[size_t('s')]) {
|
||||||
retval *= 0.555f;
|
retval *= 0.555f;
|
||||||
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float KBToWASDY(const CKeyboardMouseControllerData& data) {
|
static float KBToWASDY(const CKeyboardMouseControllerData& data) {
|
||||||
float retval = 0.0;
|
float retval = 0.0;
|
||||||
if (data.m_charKeys[int('s')])
|
if (data.m_charKeys[size_t('s')]) {
|
||||||
retval -= 1.0;
|
retval -= 1.0;
|
||||||
if (data.m_charKeys[int('w')])
|
}
|
||||||
|
if (data.m_charKeys[size_t('w')]) {
|
||||||
retval += 1.0;
|
retval += 1.0;
|
||||||
if (data.m_charKeys[int('a')] ^ data.m_charKeys[int('d')])
|
}
|
||||||
|
if (data.m_charKeys[size_t('a')] ^ data.m_charKeys[size_t('d')]) {
|
||||||
retval *= 0.555f;
|
retval *= 0.555f;
|
||||||
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float KBToArrowsX(const CKeyboardMouseControllerData& data) {
|
static float KBToArrowsX(const CKeyboardMouseControllerData& data) {
|
||||||
float retval = 0.0;
|
float retval = 0.0;
|
||||||
if (data.m_specialKeys[int(boo::ESpecialKey::Left)])
|
if (data.m_specialKeys[size_t(boo::ESpecialKey::Left)]) {
|
||||||
retval -= 1.0;
|
retval -= 1.0;
|
||||||
if (data.m_specialKeys[int(boo::ESpecialKey::Right)])
|
}
|
||||||
|
if (data.m_specialKeys[size_t(boo::ESpecialKey::Right)]) {
|
||||||
retval += 1.0;
|
retval += 1.0;
|
||||||
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float KBToArrowsY(const CKeyboardMouseControllerData& data) {
|
static float KBToArrowsY(const CKeyboardMouseControllerData& data) {
|
||||||
float retval = 0.0;
|
float retval = 0.0;
|
||||||
if (data.m_specialKeys[int(boo::ESpecialKey::Down)])
|
if (data.m_specialKeys[size_t(boo::ESpecialKey::Down)]) {
|
||||||
retval -= 1.0;
|
retval -= 1.0;
|
||||||
if (data.m_specialKeys[int(boo::ESpecialKey::Up)])
|
}
|
||||||
|
if (data.m_specialKeys[size_t(boo::ESpecialKey::Up)]) {
|
||||||
retval += 1.0;
|
retval += 1.0;
|
||||||
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ControlMapper::GetAnalogInput(ECommands cmd, const CFinalInput& input) {
|
float ControlMapper::GetAnalogInput(ECommands cmd, const CFinalInput& input) {
|
||||||
if (!skCommandFilterFlag[int(cmd)])
|
if (!skCommandFilterFlag[size_t(cmd)]) {
|
||||||
return 0.f;
|
return 0.f;
|
||||||
|
}
|
||||||
|
|
||||||
float ret = 0.f;
|
float ret = 0.f;
|
||||||
EFunctionList func = EFunctionList(g_currentPlayerControl->GetMapping(atUint32(cmd)));
|
const auto func = EFunctionList(g_currentPlayerControl->GetMapping(atUint32(cmd)));
|
||||||
if (func < EFunctionList::MAX) {
|
if (func < EFunctionList::MAX) {
|
||||||
if (FloatReturnFn fn = skAnalogFuncs[int(func)])
|
if (FloatReturnFn fn = skAnalogFuncs[size_t(func)]) {
|
||||||
ret = (input.*fn)();
|
ret = (input.*fn)();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (const auto& kbm = input.GetKBM()) {
|
if (const auto& kbm = input.GetKBM()) {
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case ECommands::Forward:
|
case ECommands::Forward:
|
||||||
|
@ -353,14 +384,16 @@ float ControlMapper::GetAnalogInput(ECommands cmd, const CFinalInput& input) {
|
||||||
ret = std::max(ret, KBToArrowsX(*kbm));
|
ret = std::max(ret, KBToArrowsX(*kbm));
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
EKBMFunctionList kbmfunc = skKBMMapping[int(cmd)];
|
const EKBMFunctionList kbmfunc = skKBMMapping[size_t(cmd)];
|
||||||
if (kbmfunc < EKBMFunctionList::MAX) {
|
if (kbmfunc < EKBMFunctionList::MAX) {
|
||||||
if (kbmfunc >= EKBMFunctionList::MousePress)
|
if (kbmfunc >= EKBMFunctionList::MousePress) {
|
||||||
ret = std::max(ret, kbm->m_mouseButtons[int(kbmfunc) - int(EKBMFunctionList::MousePress)] ? 1.f : 0.f);
|
ret = std::max(ret, kbm->m_mouseButtons[size_t(kbmfunc) - size_t(EKBMFunctionList::MousePress)] ? 1.f : 0.f);
|
||||||
else if (kbmfunc >= EKBMFunctionList::SpecialKeyPress)
|
} else if (kbmfunc >= EKBMFunctionList::SpecialKeyPress) {
|
||||||
ret = std::max(ret, kbm->m_specialKeys[int(kbmfunc) - int(EKBMFunctionList::SpecialKeyPress)] ? 1.f : 0.f);
|
ret = std::max(ret,
|
||||||
else if (kbmfunc >= EKBMFunctionList::KeyPress)
|
kbm->m_specialKeys[size_t(kbmfunc) - size_t(EKBMFunctionList::SpecialKeyPress)] ? 1.f : 0.f);
|
||||||
ret = std::max(ret, kbm->m_charKeys[int(kbmfunc) - int(EKBMFunctionList::KeyPress)] ? 1.f : 0.f);
|
} else if (kbmfunc >= EKBMFunctionList::KeyPress) {
|
||||||
|
ret = std::max(ret, kbm->m_charKeys[size_t(kbmfunc) - size_t(EKBMFunctionList::KeyPress)] ? 1.f : 0.f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -373,14 +406,14 @@ const char* ControlMapper::GetDescriptionForCommand(ECommands cmd) {
|
||||||
if (cmd >= ECommands::MAX) {
|
if (cmd >= ECommands::MAX) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return skCommandDescs[int(cmd)];
|
return skCommandDescs[size_t(cmd)];
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* ControlMapper::GetDescriptionForFunction(EFunctionList func) {
|
const char* ControlMapper::GetDescriptionForFunction(EFunctionList func) {
|
||||||
if (func >= EFunctionList::MAX) {
|
if (func >= EFunctionList::MAX) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return skFunctionDescs[int(func)];
|
return skFunctionDescs[size_t(func)];
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
|
|
@ -158,8 +158,8 @@ void CInventoryScreen::ProcessControllerInput(const CFinalInput& input) {
|
||||||
m_lastMouseCoord = mouseCoord;
|
m_lastMouseCoord = mouseCoord;
|
||||||
mouseDelta.x() *= g_Viewport.aspect;
|
mouseDelta.x() *= g_Viewport.aspect;
|
||||||
mouseDelta *= 100.f;
|
mouseDelta *= 100.f;
|
||||||
if (kbm->m_mouseButtons[int(boo::EMouseButton::Middle)] ||
|
if (kbm->m_mouseButtons[size_t(boo::EMouseButton::Middle)] ||
|
||||||
kbm->m_mouseButtons[int(boo::EMouseButton::Secondary)]) {
|
kbm->m_mouseButtons[size_t(boo::EMouseButton::Secondary)]) {
|
||||||
if (float(mouseDelta.x()) < 0.f)
|
if (float(mouseDelta.x()) < 0.f)
|
||||||
moveRight += -mouseDelta.x();
|
moveRight += -mouseDelta.x();
|
||||||
else if (float(mouseDelta.x()) > 0.f)
|
else if (float(mouseDelta.x()) > 0.f)
|
||||||
|
@ -169,7 +169,7 @@ void CInventoryScreen::ProcessControllerInput(const CFinalInput& input) {
|
||||||
else if (float(mouseDelta.y()) > 0.f)
|
else if (float(mouseDelta.y()) > 0.f)
|
||||||
moveBack += mouseDelta.y();
|
moveBack += mouseDelta.y();
|
||||||
}
|
}
|
||||||
if (kbm->m_mouseButtons[int(boo::EMouseButton::Primary)]) {
|
if (kbm->m_mouseButtons[size_t(boo::EMouseButton::Primary)]) {
|
||||||
if (float(mouseDelta.x()) < 0.f)
|
if (float(mouseDelta.x()) < 0.f)
|
||||||
circleRight += -mouseDelta.x();
|
circleRight += -mouseDelta.x();
|
||||||
else if (float(mouseDelta.x()) > 0.f)
|
else if (float(mouseDelta.x()) > 0.f)
|
||||||
|
|
Loading…
Reference in New Issue