Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ControlMapper refactoring #17210

Merged
merged 18 commits into from
Apr 1, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Common/Input/InputState.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <vector>
#include <cstdio>

#include "Common/Input/InputState.h"
#include "Common/Input/KeyCodes.h"
#include <vector>

const char *GetDeviceName(int deviceId) {
switch (deviceId) {
Expand Down Expand Up @@ -76,3 +78,13 @@ int GetAnalogYDirection(int deviceId) {
return configured->second;
return 0;
}

void InputMapping::FormatDebug(char *buffer, size_t bufSize) const {
if (IsAxis()) {
int direction;
int axis = Axis(&direction);
snprintf(buffer, bufSize, "Device: %d Axis: %d (%d)", deviceId, axis, direction);
} else {
snprintf(buffer, bufSize, "Device: %d Key: %d", deviceId, keyCode);
}
}
10 changes: 9 additions & 1 deletion Common/Input/InputState.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ class InputMapping {
return TranslateKeyCodeToAxis(keyCode, direction);
}

InputMapping FlipDirection() const {
_dbg_assert_(IsAxis());
InputMapping other = *this;
other.keyCode ^= 1;
return other;
}

// If you want to use std::find and match ANY, you need to perform an explicit search for that.
bool operator < (const InputMapping &other) const {
if (deviceId < other.deviceId) return true;
Expand All @@ -129,6 +136,8 @@ class InputMapping {
if (keyCode != other.keyCode) return false;
return true;
}

void FormatDebug(char *buffer, size_t bufSize) const;
};

enum {
Expand Down Expand Up @@ -183,7 +192,6 @@ struct AxisInput {
int deviceId;
int axisId; // Android axis Ids are the canonical ones.
float value;
int flags;
};

// Is there a nicer place for this stuff? It's here to avoid dozens of linking errors in UnitTest..
Expand Down
3 changes: 3 additions & 0 deletions Common/VR/PPSSPPVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include "Common/VR/VRMath.h"
#include "Common/VR/VRRenderer.h"

#include "Common/Input/InputState.h"
#include "Common/Input/KeyCodes.h"

#include "Common/GPU/Vulkan/VulkanContext.h"

#include "Common/Math/lin/matrix4x4.h"
Expand Down
1 change: 0 additions & 1 deletion Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,6 @@ static const ConfigSetting graphicsSettings[] = {
ConfigSetting("FrameRate", &g_Config.iFpsLimit1, 0, true, true),
ConfigSetting("FrameRate2", &g_Config.iFpsLimit2, -1, true, true),
ConfigSetting("AnalogFrameRate", &g_Config.iAnalogFpsLimit, 240, true, true),
ConfigSetting("AnalogFrameRateMode", &g_Config.iAnalogFpsMode, 0, true, true),
ConfigSetting("UnthrottlingMode", &g_Config.iFastForwardMode, &DefaultFastForwardMode, &FastForwardModeToString, &FastForwardModeFromString, true, true),
#if defined(USING_WIN_UI)
ConfigSetting("RestartRequired", &g_Config.bRestartRequired, false, false),
Expand Down
3 changes: 2 additions & 1 deletion Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ struct Config {
int iFpsLimit1;
int iFpsLimit2;
int iAnalogFpsLimit;
int iAnalogFpsMode; // 0 = auto, 1 = single direction, 2 = mapped to opposite
int iMaxRecent;
int iCurrentStateSlot;
int iRewindSnapshotInterval;
Expand Down Expand Up @@ -277,9 +276,11 @@ struct Config {

std::string sThemeName;

// These aren't saved, just for instant debugging.
bool bLogFrameDrops;
bool bShowDebugStats;
bool bShowAudioDebug;
bool bShowControlDebug;
bool bShowGpuProfile;

// Analog stick tilting
Expand Down
6 changes: 0 additions & 6 deletions Core/ConfigValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,6 @@ enum class BackgroundAnimation {
MOVING_BACKGROUND = 4,
};

enum class AnalogFpsMode {
AUTO = 0,
MAPPED_DIRECTION = 1,
MAPPED_DIR_TO_OPPOSITE_DIR = 2,
};

// for Config.iShowStatusFlags
enum class ShowStatusFlags {
FPS_COUNTER = 1 << 1,
Expand Down
Loading