ControllerInterface: Implement axis scaling for axis-to-axis mappings
This feature allows us to work around analog stick range issues at the intercardinal directions in certain titles (e.g. Rockman DASH 2) caused by modern controllers having a tighter logical range of reporting than PS1 analog controllers.
This commit is contained in:
@ -289,7 +289,8 @@ bool SDLControllerInterface::HandleControllerAxisEvent(const SDL_Event* ev)
|
||||
const AxisCallback& cb = it->axis_mapping[ev->caxis.axis];
|
||||
if (cb)
|
||||
{
|
||||
cb(value);
|
||||
// Apply axis scaling only when controller axis is mapped to an axis
|
||||
cb(std::clamp(it->axis_scale * value, -1.0f, 1.0f));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -386,3 +387,14 @@ void SDLControllerInterface::SetControllerRumbleStrength(int controller_index, c
|
||||
SDL_HapticRumbleStop(haptic);
|
||||
}
|
||||
}
|
||||
|
||||
bool SDLControllerInterface::SetControllerAxisScale(int controller_index, float scale /* = 1.00f */)
|
||||
{
|
||||
auto it = GetControllerDataForPlayerId(controller_index);
|
||||
if (it == m_controllers.end())
|
||||
return false;
|
||||
|
||||
it->axis_scale = std::clamp(std::abs(scale), 0.01f, 1.50f);
|
||||
Log_InfoPrintf("Controller %d axis scale set to %f", controller_index, it->axis_scale);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user