Solved problems with append function
* Modifiers are not truncated anymore by refresh function * The append function now really appends to previously set keys * Added reference to the wiki with more information on invalid combinations
This commit is contained in:
parent
45967d5728
commit
f4559e6cd8
11
src/main.rs
11
src/main.rs
@ -199,18 +199,11 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Some(Command::Append { cmd }) => {
|
Some(Command::Append { .. }) => {
|
||||||
match cmd {
|
// Since we want to append the key, we want to keep all pedals
|
||||||
Append::AppendKey { pedal, .. } |
|
|
||||||
Append::AppendString { pedal, .. } |
|
|
||||||
Append::AppendModifier { pedal, .. } => {
|
|
||||||
for number in 0..3 {
|
for number in 0..3 {
|
||||||
if !pedal.contains(&(number as u8)) {
|
|
||||||
unused_pedals.push(number);
|
unused_pedals.push(number);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
Some(Command::Clear { pedal }) => {
|
Some(Command::Clear { pedal }) => {
|
||||||
for number in 0..3 {
|
for number in 0..3 {
|
||||||
|
@ -181,7 +181,7 @@ impl Pedals {
|
|||||||
println!("├{}┘", "─".repeat(total_width));
|
println!("├{}┘", "─".repeat(total_width));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the type of the function. False (0) if everything went fine, True (1) if
|
/// Sets the type of the function. False (0) if everything went fine, true (1) if
|
||||||
/// an error occurred.
|
/// an error occurred.
|
||||||
fn set_type(& mut self, ped:usize, typ:Type) {
|
fn set_type(& mut self, ped:usize, typ:Type) {
|
||||||
let set_value = if self.ped_data[ped].data[1] == 0 { true } else { false };
|
let set_value = if self.ped_data[ped].data[1] == 0 { true } else { false };
|
||||||
@ -204,7 +204,7 @@ impl Pedals {
|
|||||||
let ret;
|
let ret;
|
||||||
|
|
||||||
if self.ped_data[ped].data[1] == Type::String as u8 {
|
if self.ped_data[ped].data[1] == Type::String as u8 {
|
||||||
// if type is Key or Mouse, and String is already set, return false
|
// if new type is Key or Mouse, and String is already set, return false
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -218,7 +218,7 @@ impl Pedals {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if ret {
|
if ret {
|
||||||
error!("Invalid combination of options!");
|
error!("Invalid combination of options! Please see https://git.dennispotter.eu/Dennis/footswitch-rs/wiki");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,6 +404,10 @@ impl Pedals {
|
|||||||
match Type::u8_to_enum(key_value[1]) {
|
match Type::u8_to_enum(key_value[1]) {
|
||||||
Some(Type::Key) => {
|
Some(Type::Key) => {
|
||||||
self.set_type(*ped as usize, Type::Key);
|
self.set_type(*ped as usize, Type::Key);
|
||||||
|
// Modifiers
|
||||||
|
self.ped_data[*ped as usize].data[2] = key_value[2];
|
||||||
|
|
||||||
|
// Keys
|
||||||
self.ped_data[*ped as usize].data[3] = key_value[3];
|
self.ped_data[*ped as usize].data[3] = key_value[3];
|
||||||
},
|
},
|
||||||
Some(Type::Mouse) => {
|
Some(Type::Mouse) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user