Skip to content

Commit

Permalink
#231 Make groups available for controller mappings and presets as well
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Mar 22, 2021
1 parent e9af6f5 commit 99aecee
Show file tree
Hide file tree
Showing 13 changed files with 374 additions and 194 deletions.
2 changes: 1 addition & 1 deletion 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 main/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "realearn"
version = "2.8.0-pre4"
version = "2.8.0-pre5"
authors = ["Benjamin Klum <[email protected]>"]
edition = "2018"
build = "build.rs"
Expand Down
19 changes: 16 additions & 3 deletions main/src/application/controller_preset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use std::fmt;
pub struct ControllerPreset {
id: String,
name: String,
default_group: GroupModel,
groups: Vec<GroupModel>,
mappings: Vec<MappingModel>,
custom_data: HashMap<String, serde_json::Value>,
}
Expand All @@ -14,12 +16,16 @@ impl ControllerPreset {
pub fn new(
id: String,
name: String,
default_group: GroupModel,
groups: Vec<GroupModel>,
mappings: Vec<MappingModel>,
custom_data: HashMap<String, serde_json::Value>,
) -> ControllerPreset {
ControllerPreset {
id,
name,
default_group,
groups,
mappings,
custom_data,
}
Expand All @@ -36,7 +42,14 @@ impl ControllerPreset {
self.custom_data.insert(key, value);
}

pub fn update_realearn_data(&mut self, mappings: Vec<MappingModel>) {
pub fn update_realearn_data(
&mut self,
default_group: GroupModel,
groups: Vec<GroupModel>,
mappings: Vec<MappingModel>,
) {
self.default_group = default_group;
self.groups = groups;
self.mappings = mappings;
}
}
Expand All @@ -47,11 +60,11 @@ impl Preset for ControllerPreset {
}

fn default_group(&self) -> &GroupModel {
unimplemented!("controller presets don't support groups")
&self.default_group
}

fn groups(&self) -> &Vec<GroupModel> {
unimplemented!("controller presets don't support groups")
&self.groups
}

fn mappings(&self) -> &Vec<MappingModel> {
Expand Down
10 changes: 3 additions & 7 deletions main/src/application/mapping_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,9 @@ impl MappingModel {
let source = self.source_model.create_source();
let mode = self.mode_model.create_mode();
let unresolved_target = self.target_model.create_target().ok();
let activation_condition = if self.compartment == MappingCompartment::ControllerMappings {
// Controller mappings are always active, no matter what weird stuff is in the model.
ActivationCondition::Always
} else {
self.activation_condition_model
.create_activation_condition()
};
let activation_condition = self
.activation_condition_model
.create_activation_condition();
let options = ProcessorMappingOptions {
// TODO-medium Encapsulate, don't set here
target_is_active: false,
Expand Down
Loading

0 comments on commit 99aecee

Please sign in to comment.