1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00

Tweaked default settings for controller sensitivity

This commit is contained in:
Ivan Savenko
2024-04-30 21:23:43 +03:00
parent 89d6ddd916
commit 73f4ad46ca
3 changed files with 27 additions and 19 deletions

View File

@ -259,19 +259,27 @@ void InputSourceGameController::handleUpdate()
lastCheckTime = nowMs; lastCheckTime = nowMs;
} }
static double scaleAxis(double value, double power)
{
if (value > 0)
return std::pow(value, power);
else
return -std::pow(-value, power);
}
void InputSourceGameController::handleCursorUpdate(int32_t deltaTimeMs) void InputSourceGameController::handleCursorUpdate(int32_t deltaTimeMs)
{ {
float deltaTimeSeconds = static_cast<float>(deltaTimeMs) / 1000; float deltaTimeSeconds = static_cast<float>(deltaTimeMs) / 1000;
if(cursorAxisValueX == 0) if(vstd::isAlmostZero(cursorAxisValueX))
cursorPlanDisX = 0; cursorPlanDisX = 0;
else else
cursorPlanDisX += deltaTimeSeconds * configPointerSpeed * std::pow(cursorAxisValueX, configPointerScale); cursorPlanDisX += deltaTimeSeconds * configPointerSpeed * scaleAxis(cursorAxisValueX, configPointerScale);
if(cursorAxisValueY == 0) if (vstd::isAlmostZero(cursorAxisValueY))
cursorPlanDisY = 0; cursorPlanDisY = 0;
else else
cursorPlanDisY += deltaTimeSeconds * configPointerSpeed * std::pow(cursorAxisValueY, configPointerScale); cursorPlanDisY += deltaTimeSeconds * configPointerSpeed * scaleAxis(cursorAxisValueY, configPointerScale);
int moveDisX = getMoveDis(cursorPlanDisX); int moveDisX = getMoveDis(cursorPlanDisX);
int moveDisY = getMoveDis(cursorPlanDisY); int moveDisY = getMoveDis(cursorPlanDisY);
@ -300,8 +308,8 @@ void InputSourceGameController::handleScrollUpdate(int32_t deltaTimeMs)
return; return;
} }
float deltaTimeSeconds = static_cast<float>(deltaTimeMs) / 1000; float deltaTimeSeconds = static_cast<float>(deltaTimeMs) / 1000;
scrollPlanDisX += deltaTimeSeconds * configPanningSpeed * std::pow(scrollAxisValueX, configPanningScale); scrollPlanDisX += deltaTimeSeconds * configPanningSpeed * scaleAxis(scrollAxisValueX, configPanningScale);
scrollPlanDisY += deltaTimeSeconds * configPanningSpeed * std::pow(scrollAxisValueY, configPanningScale); scrollPlanDisY += deltaTimeSeconds * configPanningSpeed * scaleAxis(scrollAxisValueY, configPanningScale);
int moveDisX = getMoveDis(scrollPlanDisX); int moveDisX = getMoveDis(scrollPlanDisX);
int moveDisY = getMoveDis(scrollPlanDisY); int moveDisY = getMoveDis(scrollPlanDisY);
if(moveDisX != 0 || moveDisY != 0) if(moveDisX != 0 || moveDisY != 0)

View File

@ -31,18 +31,18 @@ class InputSourceGameController
std::set<SDL_GameControllerAxis> pressedAxes; std::set<SDL_GameControllerAxis> pressedAxes;
std::chrono::steady_clock::time_point lastCheckTime; std::chrono::steady_clock::time_point lastCheckTime;
int cursorAxisValueX; double cursorAxisValueX;
int cursorAxisValueY; double cursorAxisValueY;
float cursorPlanDisX; double cursorPlanDisX;
float cursorPlanDisY; double cursorPlanDisY;
bool scrollAxisMoved; bool scrollAxisMoved;
Point scrollStart; Point scrollStart;
Point scrollCurrent; Point scrollCurrent;
int scrollAxisValueX; double scrollAxisValueX;
int scrollAxisValueY; double scrollAxisValueY;
float scrollPlanDisX; double scrollPlanDisX;
float scrollPlanDisY; double scrollPlanDisY;
const double configTriggerTreshold; const double configTriggerTreshold;
const double configAxisDeadZone; const double configAxisDeadZone;

View File

@ -291,23 +291,23 @@
}, },
"controllerAxisFullZone" : { "controllerAxisFullZone" : {
"type" : "number", "type" : "number",
"default" : 0.9 "default" : 1.0
}, },
"controllerPointerSpeed" : { "controllerPointerSpeed" : {
"type" : "number", "type" : "number",
"default" : 1 "default" : 1000
}, },
"controllerPointerScale" : { "controllerPointerScale" : {
"type" : "number", "type" : "number",
"default" : 1 "default" : 2
}, },
"controllerPanningSpeed" : { "controllerPanningSpeed" : {
"type" : "number", "type" : "number",
"default" : 1 "default" : 1000
}, },
"controllerPanningScale" : { "controllerPanningScale" : {
"type" : "number", "type" : "number",
"default" : 1 "default" : 2
}, },
} }
}, },