fix and tweak config

This commit is contained in:
Quaternions 2023-10-09 19:43:55 -07:00
parent ce9a461887
commit 832b359cca

View File

@ -59,14 +59,14 @@ impl UserSettings{
/*
//sensitivity is raw input dots (i.e. dpi = dots per inch) to radians conversion factor
sensitivity_x=0.001
sensitivity_mul_x_to_y=1
sensitivity_y_from_x_ratio=1
Sensitivity::DeriveY{x:0.0.001,y:DerivedSensitivity{ratio:1.0}}
*/
pub fn read_user_settings()->UserSettings{
if let Ok(file)=std::fs::File::open("settings.conf"){
let cfg=configparser::ini::Ini::new();
let (cfg_fov_x,cfg_fov_y)=(cfg.getfloat("camera","fov_x"),cfg.getfloat("camera","fov_x"));
let mut cfg=configparser::ini::Ini::new();
if let Ok(_)=cfg.load("settings.conf"){
let (cfg_fov_x,cfg_fov_y)=(cfg.getfloat("camera","fov_x"),cfg.getfloat("camera","fov_y"));
let fov=match(cfg_fov_x,cfg_fov_y){
(Ok(Some(fov_x)),Ok(Some(fov_y)))=>Fov::Exactly {
x:fov_x,
@ -74,15 +74,15 @@ pub fn read_user_settings()->UserSettings{
},
(Ok(Some(fov_x)),Ok(None))=>Fov::DeriveY{
x:fov_x,
y:if let Ok(Some(fov_mul_x_to_y))=cfg.getfloat("camera","fov_mul_x_to_y"){
DerivedFov::FromAspect(Ratio{ratio:fov_mul_x_to_y})
y:if let Ok(Some(fov_y_from_x_ratio))=cfg.getfloat("camera","fov_y_from_x_ratio"){
DerivedFov::FromAspect(Ratio{ratio:fov_y_from_x_ratio})
}else{
DerivedFov::FromScreenAspect
}
},
(Ok(None),Ok(Some(fov_y)))=>Fov::DeriveX{
x:if let Ok(Some(fov_mul_y_to_x))=cfg.getfloat("camera","fov_mul_y_to_x"){
DerivedFov::FromAspect(Ratio{ratio:fov_mul_y_to_x})
x:if let Ok(Some(fov_x_from_y_ratio))=cfg.getfloat("camera","fov_x_from_y_ratio"){
DerivedFov::FromAspect(Ratio{ratio:fov_x_from_y_ratio})
}else{
DerivedFov::FromScreenAspect
},
@ -92,7 +92,7 @@ pub fn read_user_settings()->UserSettings{
Fov::default()
},
};
let (cfg_sensitivity_x,cfg_sensitivity_y)=(cfg.getfloat("camera","sensitivity_x"),cfg.getfloat("camera","sensitivity_x"));
let (cfg_sensitivity_x,cfg_sensitivity_y)=(cfg.getfloat("camera","sensitivity_x"),cfg.getfloat("camera","sensitivity_y"));
let sensitivity=match(cfg_sensitivity_x,cfg_sensitivity_y){
(Ok(Some(sensitivity_x)),Ok(Some(sensitivity_y)))=>Sensitivity::Exactly {
x:sensitivity_x,
@ -101,12 +101,12 @@ pub fn read_user_settings()->UserSettings{
(Ok(Some(sensitivity_x)),Ok(None))=>Sensitivity::DeriveY{
x:sensitivity_x,
y:Ratio{
ratio:if let Ok(Some(sensitivity_mul_x_to_y))=cfg.getfloat("camera","sensitivity_mul_x_to_y"){sensitivity_mul_x_to_y}else{1.0}
ratio:if let Ok(Some(sensitivity_y_from_x_ratio))=cfg.getfloat("camera","sensitivity_y_from_x_ratio"){sensitivity_y_from_x_ratio}else{1.0}
}
},
(Ok(None),Ok(Some(sensitivity_y)))=>Sensitivity::DeriveX{
x:Ratio{
ratio:if let Ok(Some(sensitivity_mul_y_to_x))=cfg.getfloat("camera","sensitivity_mul_y_to_x"){sensitivity_mul_y_to_x}else{1.0}
ratio:if let Ok(Some(sensitivity_x_from_y_ratio))=cfg.getfloat("camera","sensitivity_x_from_y_ratio"){sensitivity_x_from_y_ratio}else{1.0}
},
y:sensitivity_y,
},