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,12 +137,15 @@ 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];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,232 +36,246 @@ static const char* skCommandDescs[] = {
|
||||||
"Next Pause Screen", "UNKNOWN", "None",
|
"Next Pause Screen", "UNKNOWN", "None",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char* skFunctionDescs[] = {"None",
|
constexpr std::array skFunctionDescs{
|
||||||
"Left Stick Up",
|
"None",
|
||||||
"Left Stick Down",
|
"Left Stick Up",
|
||||||
"Left Stick Left",
|
"Left Stick Down",
|
||||||
"Left Stick Right",
|
"Left Stick Left",
|
||||||
"Right Stick Up",
|
"Left Stick Right",
|
||||||
"Right Stick Down",
|
"Right Stick Up",
|
||||||
"Right Stick Left",
|
"Right Stick Down",
|
||||||
"Right Stick Right",
|
"Right Stick Left",
|
||||||
"Left Trigger",
|
"Right Stick Right",
|
||||||
"Right Trigger",
|
"Left Trigger",
|
||||||
"D-Pad Up ",
|
"Right Trigger",
|
||||||
"D-Pad Down ",
|
"D-Pad Up ",
|
||||||
"D-Pad Left ",
|
"D-Pad Down ",
|
||||||
"D-Pad Right",
|
"D-Pad Left ",
|
||||||
"A Button",
|
"D-Pad Right",
|
||||||
"B Button",
|
"A Button",
|
||||||
"X Button",
|
"B Button",
|
||||||
"Y Button",
|
"X Button",
|
||||||
"Z Button",
|
"Y Button",
|
||||||
"Left Trigger Press",
|
"Z Button",
|
||||||
"Right Trigger Press",
|
"Left Trigger Press",
|
||||||
"Start"};
|
"Right Trigger Press",
|
||||||
|
"Start",
|
||||||
typedef bool (CFinalInput::*BoolReturnFn)() const;
|
|
||||||
typedef float (CFinalInput::*FloatReturnFn)() const;
|
|
||||||
|
|
||||||
static BoolReturnFn skPressFuncs[] = {nullptr,
|
|
||||||
&CFinalInput::PLAUp,
|
|
||||||
&CFinalInput::PLADown,
|
|
||||||
&CFinalInput::PLALeft,
|
|
||||||
&CFinalInput::PLARight,
|
|
||||||
&CFinalInput::PRAUp,
|
|
||||||
&CFinalInput::PRADown,
|
|
||||||
&CFinalInput::PRALeft,
|
|
||||||
&CFinalInput::PRARight,
|
|
||||||
&CFinalInput::PLTrigger,
|
|
||||||
&CFinalInput::PRTrigger,
|
|
||||||
&CFinalInput::PDPUp,
|
|
||||||
&CFinalInput::PDPDown,
|
|
||||||
&CFinalInput::PDPLeft,
|
|
||||||
&CFinalInput::PDPRight,
|
|
||||||
&CFinalInput::PA,
|
|
||||||
&CFinalInput::PB,
|
|
||||||
&CFinalInput::PX,
|
|
||||||
&CFinalInput::PY,
|
|
||||||
&CFinalInput::PZ,
|
|
||||||
&CFinalInput::PL,
|
|
||||||
&CFinalInput::PR,
|
|
||||||
&CFinalInput::PStart,
|
|
||||||
nullptr};
|
|
||||||
|
|
||||||
static BoolReturnFn skDigitalFuncs[] = {nullptr,
|
|
||||||
&CFinalInput::DLAUp,
|
|
||||||
&CFinalInput::DLADown,
|
|
||||||
&CFinalInput::DLALeft,
|
|
||||||
&CFinalInput::DLARight,
|
|
||||||
&CFinalInput::DRAUp,
|
|
||||||
&CFinalInput::DRADown,
|
|
||||||
&CFinalInput::DRALeft,
|
|
||||||
&CFinalInput::DRARight,
|
|
||||||
&CFinalInput::DLTrigger,
|
|
||||||
&CFinalInput::DRTrigger,
|
|
||||||
&CFinalInput::DDPUp,
|
|
||||||
&CFinalInput::DDPDown,
|
|
||||||
&CFinalInput::DDPLeft,
|
|
||||||
&CFinalInput::DDPRight,
|
|
||||||
&CFinalInput::DA,
|
|
||||||
&CFinalInput::DB,
|
|
||||||
&CFinalInput::DX,
|
|
||||||
&CFinalInput::DY,
|
|
||||||
&CFinalInput::DZ,
|
|
||||||
&CFinalInput::DL,
|
|
||||||
&CFinalInput::DR,
|
|
||||||
&CFinalInput::DStart,
|
|
||||||
nullptr};
|
|
||||||
|
|
||||||
static FloatReturnFn skAnalogFuncs[] = {nullptr,
|
|
||||||
&CFinalInput::ALAUp,
|
|
||||||
&CFinalInput::ALADown,
|
|
||||||
&CFinalInput::ALALeft,
|
|
||||||
&CFinalInput::ALARight,
|
|
||||||
&CFinalInput::ARAUp,
|
|
||||||
&CFinalInput::ARADown,
|
|
||||||
&CFinalInput::ARALeft,
|
|
||||||
&CFinalInput::ARARight,
|
|
||||||
&CFinalInput::ALTrigger,
|
|
||||||
&CFinalInput::ARTrigger,
|
|
||||||
&CFinalInput::ADPUp,
|
|
||||||
&CFinalInput::ADPDown,
|
|
||||||
&CFinalInput::ADPLeft,
|
|
||||||
&CFinalInput::ADPRight,
|
|
||||||
&CFinalInput::AA,
|
|
||||||
&CFinalInput::AB,
|
|
||||||
&CFinalInput::AX,
|
|
||||||
&CFinalInput::AY,
|
|
||||||
&CFinalInput::AZ,
|
|
||||||
&CFinalInput::AL,
|
|
||||||
&CFinalInput::AR,
|
|
||||||
&CFinalInput::AStart,
|
|
||||||
nullptr};
|
|
||||||
|
|
||||||
static const ControlMapper::EKBMFunctionList skKBMMapping[] = {
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'w', // Forward,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 's', // Backward,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'a', // TurnLeft,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'd', // TurnRight,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'a', // StrafeLeft,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'd', // StrafeRight,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'a', // LookLeft,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'd', // LookRight,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 's', // LookUp,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'w', // LookDown,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + ' ', // JumpOrBoost = 10,
|
|
||||||
ControlMapper::EKBMFunctionList::MousePress + boo::EMouseButton::Primary, // FireOrBomb = 11,
|
|
||||||
ControlMapper::EKBMFunctionList::MousePress + boo::EMouseButton::Secondary, // MissileOrPowerBomb = 12,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'c', // Morph,
|
|
||||||
ControlMapper::EKBMFunctionList::None, // AimUp,
|
|
||||||
ControlMapper::EKBMFunctionList::None, // AimDown,
|
|
||||||
ControlMapper::EKBMFunctionList::None, // CycleBeamUp,
|
|
||||||
ControlMapper::EKBMFunctionList::None, // CycleBeamDown,
|
|
||||||
ControlMapper::EKBMFunctionList::None, // CycleItem,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + '1', // PowerBeam,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + '3', // IceBeam,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + '2', // WaveBeam,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + '4', // PlasmaBeam,
|
|
||||||
ControlMapper::EKBMFunctionList::None, // ToggleHolster = 23,
|
|
||||||
ControlMapper::EKBMFunctionList::None, // OrbitClose,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'q', // OrbitFar,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'q', // OrbitObject,
|
|
||||||
ControlMapper::EKBMFunctionList::None, // OrbitSelect,
|
|
||||||
ControlMapper::EKBMFunctionList::None, // OrbitConfirm,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'a', // OrbitLeft,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'd', // OrbitRight,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'w', // OrbitUp,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 's', // OrbitDown,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'e', // LookHold1,
|
|
||||||
ControlMapper::EKBMFunctionList::None, // LookHold2,
|
|
||||||
ControlMapper::EKBMFunctionList::None, // LookZoomIn,
|
|
||||||
ControlMapper::EKBMFunctionList::None, // LookZoomOut,
|
|
||||||
ControlMapper::EKBMFunctionList::None, // AimHold,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 's', // MapCircleUp,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'w', // MapCircleDown,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'a', // MapCircleLeft,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'd', // MapCircleRight,
|
|
||||||
ControlMapper::EKBMFunctionList::SpecialKeyPress + boo::ESpecialKey::Up, // MapMoveForward,
|
|
||||||
ControlMapper::EKBMFunctionList::SpecialKeyPress + boo::ESpecialKey::Down, // MapMoveBack,
|
|
||||||
ControlMapper::EKBMFunctionList::SpecialKeyPress + boo::ESpecialKey::Left, // MapMoveLeft,
|
|
||||||
ControlMapper::EKBMFunctionList::SpecialKeyPress + boo::ESpecialKey::Right, // MapMoveRight,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'e', // MapZoomIn,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'q', // MapZoomOut,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'e', // SpiderBall,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'q', // ChaseCamera,
|
|
||||||
ControlMapper::EKBMFunctionList::SpecialKeyPress + boo::ESpecialKey::Right, // XrayVisor = 50,
|
|
||||||
ControlMapper::EKBMFunctionList::SpecialKeyPress + boo::ESpecialKey::Down, // ThermoVisor = 51,
|
|
||||||
ControlMapper::EKBMFunctionList::SpecialKeyPress + boo::ESpecialKey::Left, // InviroVisor = 52,
|
|
||||||
ControlMapper::EKBMFunctionList::SpecialKeyPress + boo::ESpecialKey::Up, // NoVisor = 53,
|
|
||||||
ControlMapper::EKBMFunctionList::None, // VisorMenu,
|
|
||||||
ControlMapper::EKBMFunctionList::None, // VisorUp,
|
|
||||||
ControlMapper::EKBMFunctionList::None, // VisorDown,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'e', // ShowCrosshairs,
|
|
||||||
ControlMapper::EKBMFunctionList::None, // UNKNOWN
|
|
||||||
ControlMapper::EKBMFunctionList::None, // UseSheild = 0x3B,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'q', // ScanItem = 0x3C,
|
|
||||||
ControlMapper::EKBMFunctionList::None, // UNKNOWN
|
|
||||||
ControlMapper::EKBMFunctionList::None, // UNKNOWN
|
|
||||||
ControlMapper::EKBMFunctionList::None, // UNKNOWN
|
|
||||||
ControlMapper::EKBMFunctionList::None, // UNKNOWN
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'q', // PreviousPauseScreen = 0x41,
|
|
||||||
ControlMapper::EKBMFunctionList::KeyPress + 'e', // NextPauseScreen = 0x42,
|
|
||||||
ControlMapper::EKBMFunctionList::None, // UNKNOWN,
|
|
||||||
ControlMapper::EKBMFunctionList::None, // None,
|
|
||||||
ControlMapper::EKBMFunctionList::None
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define kCommandFilterCount 67
|
using BoolReturnFn = bool (CFinalInput::*)() const;
|
||||||
static bool skCommandFilterFlag[kCommandFilterCount] = {true};
|
using FloatReturnFn = float (CFinalInput::*)() const;
|
||||||
|
|
||||||
void ControlMapper::SetCommandFiltered(ECommands cmd, bool filtered) { skCommandFilterFlag[int(cmd)] = filtered; }
|
constexpr std::array<BoolReturnFn, 24> skPressFuncs{
|
||||||
|
nullptr,
|
||||||
|
&CFinalInput::PLAUp,
|
||||||
|
&CFinalInput::PLADown,
|
||||||
|
&CFinalInput::PLALeft,
|
||||||
|
&CFinalInput::PLARight,
|
||||||
|
&CFinalInput::PRAUp,
|
||||||
|
&CFinalInput::PRADown,
|
||||||
|
&CFinalInput::PRALeft,
|
||||||
|
&CFinalInput::PRARight,
|
||||||
|
&CFinalInput::PLTrigger,
|
||||||
|
&CFinalInput::PRTrigger,
|
||||||
|
&CFinalInput::PDPUp,
|
||||||
|
&CFinalInput::PDPDown,
|
||||||
|
&CFinalInput::PDPLeft,
|
||||||
|
&CFinalInput::PDPRight,
|
||||||
|
&CFinalInput::PA,
|
||||||
|
&CFinalInput::PB,
|
||||||
|
&CFinalInput::PX,
|
||||||
|
&CFinalInput::PY,
|
||||||
|
&CFinalInput::PZ,
|
||||||
|
&CFinalInput::PL,
|
||||||
|
&CFinalInput::PR,
|
||||||
|
&CFinalInput::PStart,
|
||||||
|
nullptr,
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr std::array<BoolReturnFn, 24> skDigitalFuncs{
|
||||||
|
nullptr,
|
||||||
|
&CFinalInput::DLAUp,
|
||||||
|
&CFinalInput::DLADown,
|
||||||
|
&CFinalInput::DLALeft,
|
||||||
|
&CFinalInput::DLARight,
|
||||||
|
&CFinalInput::DRAUp,
|
||||||
|
&CFinalInput::DRADown,
|
||||||
|
&CFinalInput::DRALeft,
|
||||||
|
&CFinalInput::DRARight,
|
||||||
|
&CFinalInput::DLTrigger,
|
||||||
|
&CFinalInput::DRTrigger,
|
||||||
|
&CFinalInput::DDPUp,
|
||||||
|
&CFinalInput::DDPDown,
|
||||||
|
&CFinalInput::DDPLeft,
|
||||||
|
&CFinalInput::DDPRight,
|
||||||
|
&CFinalInput::DA,
|
||||||
|
&CFinalInput::DB,
|
||||||
|
&CFinalInput::DX,
|
||||||
|
&CFinalInput::DY,
|
||||||
|
&CFinalInput::DZ,
|
||||||
|
&CFinalInput::DL,
|
||||||
|
&CFinalInput::DR,
|
||||||
|
&CFinalInput::DStart,
|
||||||
|
nullptr,
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr std::array<FloatReturnFn, 24> skAnalogFuncs{
|
||||||
|
nullptr,
|
||||||
|
&CFinalInput::ALAUp,
|
||||||
|
&CFinalInput::ALADown,
|
||||||
|
&CFinalInput::ALALeft,
|
||||||
|
&CFinalInput::ALARight,
|
||||||
|
&CFinalInput::ARAUp,
|
||||||
|
&CFinalInput::ARADown,
|
||||||
|
&CFinalInput::ARALeft,
|
||||||
|
&CFinalInput::ARARight,
|
||||||
|
&CFinalInput::ALTrigger,
|
||||||
|
&CFinalInput::ARTrigger,
|
||||||
|
&CFinalInput::ADPUp,
|
||||||
|
&CFinalInput::ADPDown,
|
||||||
|
&CFinalInput::ADPLeft,
|
||||||
|
&CFinalInput::ADPRight,
|
||||||
|
&CFinalInput::AA,
|
||||||
|
&CFinalInput::AB,
|
||||||
|
&CFinalInput::AX,
|
||||||
|
&CFinalInput::AY,
|
||||||
|
&CFinalInput::AZ,
|
||||||
|
&CFinalInput::AL,
|
||||||
|
&CFinalInput::AR,
|
||||||
|
&CFinalInput::AStart,
|
||||||
|
nullptr,
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr std::array<ControlMapper::EKBMFunctionList, 70> skKBMMapping{
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'w', // Forward,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 's', // Backward,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'a', // TurnLeft,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'd', // TurnRight,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'a', // StrafeLeft,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'd', // StrafeRight,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'a', // LookLeft,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'd', // LookRight,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 's', // LookUp,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'w', // LookDown,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + ' ', // JumpOrBoost = 10,
|
||||||
|
ControlMapper::EKBMFunctionList::MousePress + boo::EMouseButton::Primary, // FireOrBomb = 11,
|
||||||
|
ControlMapper::EKBMFunctionList::MousePress + boo::EMouseButton::Secondary, // MissileOrPowerBomb = 12,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'c', // Morph,
|
||||||
|
ControlMapper::EKBMFunctionList::None, // AimUp,
|
||||||
|
ControlMapper::EKBMFunctionList::None, // AimDown,
|
||||||
|
ControlMapper::EKBMFunctionList::None, // CycleBeamUp,
|
||||||
|
ControlMapper::EKBMFunctionList::None, // CycleBeamDown,
|
||||||
|
ControlMapper::EKBMFunctionList::None, // CycleItem,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + '1', // PowerBeam,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + '3', // IceBeam,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + '2', // WaveBeam,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + '4', // PlasmaBeam,
|
||||||
|
ControlMapper::EKBMFunctionList::None, // ToggleHolster = 23,
|
||||||
|
ControlMapper::EKBMFunctionList::None, // OrbitClose,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'q', // OrbitFar,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'q', // OrbitObject,
|
||||||
|
ControlMapper::EKBMFunctionList::None, // OrbitSelect,
|
||||||
|
ControlMapper::EKBMFunctionList::None, // OrbitConfirm,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'a', // OrbitLeft,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'd', // OrbitRight,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'w', // OrbitUp,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 's', // OrbitDown,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'e', // LookHold1,
|
||||||
|
ControlMapper::EKBMFunctionList::None, // LookHold2,
|
||||||
|
ControlMapper::EKBMFunctionList::None, // LookZoomIn,
|
||||||
|
ControlMapper::EKBMFunctionList::None, // LookZoomOut,
|
||||||
|
ControlMapper::EKBMFunctionList::None, // AimHold,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 's', // MapCircleUp,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'w', // MapCircleDown,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'a', // MapCircleLeft,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'd', // MapCircleRight,
|
||||||
|
ControlMapper::EKBMFunctionList::SpecialKeyPress + boo::ESpecialKey::Up, // MapMoveForward,
|
||||||
|
ControlMapper::EKBMFunctionList::SpecialKeyPress + boo::ESpecialKey::Down, // MapMoveBack,
|
||||||
|
ControlMapper::EKBMFunctionList::SpecialKeyPress + boo::ESpecialKey::Left, // MapMoveLeft,
|
||||||
|
ControlMapper::EKBMFunctionList::SpecialKeyPress + boo::ESpecialKey::Right, // MapMoveRight,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'e', // MapZoomIn,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'q', // MapZoomOut,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'e', // SpiderBall,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'q', // ChaseCamera,
|
||||||
|
ControlMapper::EKBMFunctionList::SpecialKeyPress + boo::ESpecialKey::Right, // XrayVisor = 50,
|
||||||
|
ControlMapper::EKBMFunctionList::SpecialKeyPress + boo::ESpecialKey::Down, // ThermoVisor = 51,
|
||||||
|
ControlMapper::EKBMFunctionList::SpecialKeyPress + boo::ESpecialKey::Left, // InviroVisor = 52,
|
||||||
|
ControlMapper::EKBMFunctionList::SpecialKeyPress + boo::ESpecialKey::Up, // NoVisor = 53,
|
||||||
|
ControlMapper::EKBMFunctionList::None, // VisorMenu,
|
||||||
|
ControlMapper::EKBMFunctionList::None, // VisorUp,
|
||||||
|
ControlMapper::EKBMFunctionList::None, // VisorDown,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'e', // ShowCrosshairs,
|
||||||
|
ControlMapper::EKBMFunctionList::None, // UNKNOWN
|
||||||
|
ControlMapper::EKBMFunctionList::None, // UseSheild = 0x3B,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'q', // ScanItem = 0x3C,
|
||||||
|
ControlMapper::EKBMFunctionList::None, // UNKNOWN
|
||||||
|
ControlMapper::EKBMFunctionList::None, // UNKNOWN
|
||||||
|
ControlMapper::EKBMFunctionList::None, // UNKNOWN
|
||||||
|
ControlMapper::EKBMFunctionList::None, // UNKNOWN
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'q', // PreviousPauseScreen = 0x41,
|
||||||
|
ControlMapper::EKBMFunctionList::KeyPress + 'e', // NextPauseScreen = 0x42,
|
||||||
|
ControlMapper::EKBMFunctionList::None, // UNKNOWN,
|
||||||
|
ControlMapper::EKBMFunctionList::None, // None,
|
||||||
|
ControlMapper::EKBMFunctionList::None,
|
||||||
|
};
|
||||||
|
|
||||||
|
std::array<bool, 67> skCommandFilterFlag{true};
|
||||||
|
} // Anonymous namespace
|
||||||
|
|
||||||
|
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,52 +283,65 @@ 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) {
|
||||||
|
@ -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