CFinalInput: Use std::array where applicable

Allows simplifying copies and gets rid of hardcoded size values.
This commit is contained in:
Lioncash 2019-10-01 01:25:19 -04:00
parent 81a019b1e0
commit dc565969e6
8 changed files with 106 additions and 81 deletions

View File

@ -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();

View File

@ -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) {

View File

@ -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,13 +137,16 @@ 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) {
@ -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;
} }

View File

@ -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; }

View File

@ -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; }

View File

@ -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;

View File

@ -210,7 +210,7 @@ static const ControlMapper::EKBMFunctionList skKBMMapping[] = {
#define kCommandFilterCount 67 #define kCommandFilterCount 67
static bool skCommandFilterFlag[kCommandFilterCount] = {true}; static bool skCommandFilterFlag[kCommandFilterCount] = {true};
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) for (int i = 0; i < kCommandFilterCount; ++i)
@ -218,46 +218,53 @@ void ControlMapper::ResetCommandFilters() {
} }
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 +272,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 +373,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 +395,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

View File

@ -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)