-
Notifications
You must be signed in to change notification settings - Fork 39
Introduces quadratic scaling for more precise control with small stick movement. #449
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
base: main
Are you sure you want to change the base?
Conversation
make movement less abrupt and smooth it out for more precise control.
|
Can you explain a bit more why this is necessary? As a global change I'm concerned that it might be too opinionated. |
It's better for precise aiming as it changes the scaling algorithm to be more human response like, micro adjustment with small stick movements while keeping high sensitivity for large stick movements. It's not technically necessary, I'm happy to just keep it in my fork if you don't think it fits. |
|
I think this would be a good option to have, but we should make this configurable (and off by default for now). We could add this as a capability config option: #[derive(Debug, Deserialize, Serialize, Clone, JsonSchema, PartialEq)]
#[serde(rename_all = "snake_case")]
pub struct AxisCapability {
pub name: String,
pub direction: Option<String>,
pub deadzone: Option<f64>,
pub quadratic_scaling: Option<bool>,
}Then we can check for the option in the translate function: // Axis -> Axis
Gamepad::Axis(_) => {
let use_scaling = target_config
.gamepad
.as_ref()
.and_then(|gamepad| gamepad.axis.as_ref())
.and_then(|axis| axis.quadratic_scaling)
.unwrap_or(false);
match use_scaling {
false => Ok(self.clone()),
true => match self {
InputValue::Vector2 { x, y } => {
let scaled_x = x.map(|v| v * v.abs());
let scaled_y = y.map(|v| v * v.abs());
Ok(InputValue::Vector2 {
x: scaled_x,
y: scaled_y,
})
}
_ => Ok(self.clone()),
},
}
} |
pastaq
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add as optional setting per @ShadowApex comment
Alright, I'll submit the changes when I can. |
- Add optional 'quadratic_scaling' field to AxisCapability struct - Defaults to false when not specified for backward compatibility - Translation logic now checks the configuration before applying scaling - When disabled, uses original behavior: returns value unchanged - Allows per-axis control over quadratic scaling behavior
|
@ShadowApex @pastaq let me know if you need any other changes. Sorry for the delay. |
This PR changes analog input scaling to scale quadratically instead of linearly which makes small movement less abrupt for more precise control.