Skip to content

Commit

Permalink
Fix bug where rotators were mistaken as Linears.
Browse files Browse the repository at this point in the history
Improve detection of corrupted features within a config file.
  • Loading branch information
SutekhVRC committed Feb 5, 2024
1 parent d0a26d9 commit 9ed037b
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vibecheck"
version = "0.4.1"
version = "0.4.2"
edition = "2021"
authors = ["SutekhVRC"]
rust-version = "1.57"
Expand Down
63 changes: 59 additions & 4 deletions src-tauri/src/toy_handling/toyops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl VCToy {
self.parsed_toy_features.features.push(VCToyFeature::new(
vec![],
indexer,
VCFeatureType::Linear,
VCFeatureType::Rotator,
));

indexer += 1;
Expand Down Expand Up @@ -199,36 +199,53 @@ impl VCToy {
let mut conn_toy_feature_count = 0;

if self.toy_features.scalar_cmd().is_some() {
conn_toy_feature_count += self
debug!("Found Scalar CMD");
let conf_file_scalar_count = conf.features.get_feature_scalar_count();
let connected_toy_scalar_count = self
.toy_features
.scalar_cmd()
.as_ref()
.unwrap()
.iter()
.len();
if conf_file_scalar_count == connected_toy_scalar_count {
conn_toy_feature_count += connected_toy_scalar_count;
}
}

if self.toy_features.rotate_cmd().is_some() {
conn_toy_feature_count += self
debug!("Found Rotate CMD");
let conf_file_rotate_count = conf.features.get_feature_rotator_count();
let connected_toy_rotate_count = self
.toy_features
.rotate_cmd()
.as_ref()
.unwrap()
.iter()
.len();
if conf_file_rotate_count == connected_toy_rotate_count {
conn_toy_feature_count += connected_toy_rotate_count;
}
}

if self.toy_features.linear_cmd().is_some() {
conn_toy_feature_count += self
debug!("Found Linear CMD");
let conf_file_linear_count = conf.features.get_feature_linear_count();
let connected_toy_linear_count = self
.toy_features
.linear_cmd()
.as_ref()
.unwrap()
.iter()
.len();
if conf_file_linear_count == connected_toy_linear_count {
conn_toy_feature_count += connected_toy_linear_count;
}
}

// If Toy has a different count of features repopulate config
if conn_toy_feature_count != conf.features.features.len() {
warn!("Config is likely corrupted! Repopulating features!");
self.populate_routine();
return;
}
Expand Down Expand Up @@ -719,6 +736,44 @@ impl VCToyFeatures {
}
}

pub fn get_feature_linear_count(&self) -> usize {
let mut count = 0;
for f in self.features.iter() {
match f.feature_type {
VCFeatureType::Linear => count += 1,
_ => {}
}
}
count
}

pub fn get_feature_rotator_count(&self) -> usize {
let mut count = 0;
for f in self.features.iter() {
match f.feature_type {
VCFeatureType::Rotator => count += 1,
_ => {}
}
}
count
}

pub fn get_feature_scalar_count(&self) -> usize {
let mut count = 0;
for f in self.features.iter() {
match f.feature_type {
VCFeatureType::Constrict => count += 1,
VCFeatureType::Inflate => count += 1,
VCFeatureType::Oscillate => count += 1,
VCFeatureType::Position => count += 1,
VCFeatureType::Vibrator => count += 1,
VCFeatureType::ScalarRotator => count += 1,
_ => {}
}
}
count
}

pub fn get_features_from_param(&mut self, param: &String) -> Option<Vec<&mut VCToyFeature>> {
let mut out = Vec::new();

Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "VibeCheck",
"version": "0.4.1"
"version": "0.4.2"
},
"tauri": {
"systemTray": {
Expand Down

0 comments on commit 9ed037b

Please sign in to comment.