Skip to content

Commit f4559e6

Browse files
committed
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
1 parent 45967d5 commit f4559e6

2 files changed

Lines changed: 11 additions & 14 deletions

File tree

‎src/main.rs‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,10 @@ fn main() {
199199
}
200200
}
201201
},
202-
Some(Command::Append { cmd }) => {
203-
match cmd {
204-
Append::AppendKey { pedal, .. } |
205-
Append::AppendString { pedal, .. } |
206-
Append::AppendModifier { pedal, .. } => {
207-
for number in 0..3 {
208-
if !pedal.contains(&(number as u8)) {
209-
unused_pedals.push(number);
210-
}
211-
}
212-
}
202+
Some(Command::Append { .. }) => {
203+
// Since we want to append the key, we want to keep all pedals
204+
for number in 0..3 {
205+
unused_pedals.push(number);
213206
}
214207
},
215208
Some(Command::Clear { pedal }) => {

‎src/pedal_operations.rs‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl Pedals {
181181
println!("├{}┘", "─".repeat(total_width));
182182
}
183183

184-
/// Sets the type of the function. False (0) if everything went fine, True (1) if
184+
/// Sets the type of the function. False (0) if everything went fine, true (1) if
185185
/// an error occurred.
186186
fn set_type(& mut self, ped:usize, typ:Type) {
187187
let set_value = if self.ped_data[ped].data[1] == 0 { true } else { false };
@@ -204,7 +204,7 @@ impl Pedals {
204204
let ret;
205205

206206
if self.ped_data[ped].data[1] == Type::String as u8 {
207-
// if type is Key or Mouse, and String is already set, return false
207+
// if new type is Key or Mouse, and String is already set, return false
208208
ret = true;
209209
}
210210
else {
@@ -218,7 +218,7 @@ impl Pedals {
218218
};
219219

220220
if ret {
221-
error!("Invalid combination of options!");
221+
error!("Invalid combination of options! Please see https://git.dennispotter.eu/Dennis/footswitch-rs/wiki");
222222
}
223223
}
224224

@@ -404,6 +404,10 @@ impl Pedals {
404404
match Type::u8_to_enum(key_value[1]) {
405405
Some(Type::Key) => {
406406
self.set_type(*ped as usize, Type::Key);
407+
// Modifiers
408+
self.ped_data[*ped as usize].data[2] = key_value[2];
409+
410+
// Keys
407411
self.ped_data[*ped as usize].data[3] = key_value[3];
408412
},
409413
Some(Type::Mouse) => {

0 commit comments

Comments
 (0)