Added support to write modifiers to footswitch.
Reading modifiers is not yet supported. This will be supported in the next commit.
This commit is contained in:
parent
3122491557
commit
e6a23707b3
@ -276,13 +276,25 @@ static KEY_MAP : &[(&str, u8)] = &[
|
||||
("<ff>" , 0xff),
|
||||
];
|
||||
|
||||
enum Modifier {
|
||||
pub enum Modifier {
|
||||
Ctrl = 1,
|
||||
Shift = 2,
|
||||
Alt = 4,
|
||||
Win = 8,
|
||||
}
|
||||
|
||||
impl Modifier {
|
||||
pub fn value(modifier:&str) -> Option<Modifier> {
|
||||
match modifier {
|
||||
"ctrl" => Some(Modifier::Ctrl),
|
||||
"shift" => Some(Modifier::Shift),
|
||||
"alt" => Some(Modifier::Alt),
|
||||
"win" => Some(Modifier::Win),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum MouseButton {
|
||||
MouseLeft = 1,
|
||||
MouseRight = 2,
|
||||
|
@ -138,8 +138,11 @@ fn main() {
|
||||
"append_str" => {
|
||||
pedals.set_string(ped_list[i] as usize, val_list[i].as_str());
|
||||
}
|
||||
"append_mod" => {
|
||||
pedals.set_modifier(ped_list[i] as usize, val_list[i].as_str());
|
||||
}
|
||||
_ => {
|
||||
error!("Unkonwn command!");
|
||||
error!("Unknown command!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -220,6 +220,17 @@ impl Pedals {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_modifier(& mut self, ped:usize, modifier:&str) {
|
||||
let modifier = match key_operations::Modifier::value(modifier) {
|
||||
Some(x) => x,
|
||||
None => error!("Unkown modifier! Please use one of the following: ctrl, shift, alt, win."),
|
||||
};
|
||||
|
||||
self.set_type(ped, Type::Key);
|
||||
|
||||
self.ped_data[ped].data[2] |= modifier as u8;
|
||||
}
|
||||
|
||||
pub fn print_string(&self, dev: & hidapi::HidDevice, response: & mut [u8]) -> Option<String> {
|
||||
let mut string = String::new();
|
||||
let mut len = response[0] - 2;
|
||||
|
Loading…
Reference in New Issue
Block a user