Skip to content

Commit

Permalink
Remove unimplementeds
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikaël Fourrier committed Aug 22, 2021
1 parent aec9dd4 commit 57b9f96
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 22 deletions.
15 changes: 12 additions & 3 deletions src/config/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ fn map_key(layer: &mut Layer, actions: &[JSMAction]) {
);
layer.on_up = convert_action_mod(action, ClickType::Release);
}
Turbo => unimplemented!(),
Turbo => {
// TODO: Implement turbo keys
eprintln!("Warning: Turbo event modifier is unsupported for now.");
}
}
first = false;
}
Expand Down Expand Up @@ -115,13 +118,19 @@ pub fn parse_file<'a>(
mapping.get(k1, 0).on_up = Some(Action::Layer(k1.to_layer(), false));
map_key(mapping.get(k2, k1.to_layer()), actions);
}
Cmd::Map(Key::Simul(_k1, _k2), ref _actions) => unimplemented!(),
Cmd::Map(Key::Simul(_k1, _k2), ref _actions) => {
// TODO: Support simultaneous key presses
eprintln!("Warning: simultaneous keys are unsupported for now");
}
Cmd::Setting(setting) => settings.apply(setting),
Cmd::Reset => {
settings.reset();
mapping.reset()
}
Cmd::Special(_) => unimplemented!(),
Cmd::Special(s) => {
// TODO: Support special key presses
eprintln!("Warning: special key {:?} is unsupported for now", s);
}
}
}
Ok(())
Expand Down
7 changes: 5 additions & 2 deletions src/config/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ impl From<(ActionType, ClickType)> for ExtAction {
ActionType::Mouse(k) => ExtAction::MousePress(k, b),
ActionType::Special(SpecialKey::GyroOn) => ExtAction::GyroOn(b),
ActionType::Special(SpecialKey::GyroOff) => ExtAction::GyroOff(b),
ActionType::Special(SpecialKey::None) => unimplemented!(),
ActionType::Special(_) => unimplemented!(),
ActionType::Special(s) => {
// TODO: Handle every special key.
eprintln!("Warning: special key {:?} is unimplemented", s);
ExtAction::None
}
#[cfg(feature = "vgamepad")]
ActionType::Gamepad(k) => ExtAction::GamepadKeyPress(k, b),
}
Expand Down
22 changes: 17 additions & 5 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,31 @@ impl Engine {
for action in self.buttons.tick(now) {
match action {
ExtAction::GyroOn(ClickType::Press) | ExtAction::GyroOff(ClickType::Release) => {
self.gyro.enabled = true
self.gyro.enabled = true;
}
ExtAction::GyroOn(ClickType::Release) | ExtAction::GyroOff(ClickType::Press) => {
self.gyro.enabled = false
self.gyro.enabled = false;
}
ExtAction::GyroOn(ClickType::Toggle) | ExtAction::GyroOff(ClickType::Toggle) => {
self.gyro.enabled = !self.gyro.enabled;
}
ExtAction::GyroOn(ClickType::Click) | ExtAction::GyroOff(ClickType::Click) => {
eprintln!("Warning: event type Click has no effect on gyro on/off");
}
ExtAction::GyroOn(_) | ExtAction::GyroOff(_) => unimplemented!(),
ExtAction::KeyPress(c, ClickType::Click) => self.mouse.enigo().key_click(c),
ExtAction::KeyPress(c, ClickType::Press) => self.mouse.enigo().key_down(c),
ExtAction::KeyPress(c, ClickType::Release) => self.mouse.enigo().key_up(c),
ExtAction::KeyPress(_, ClickType::Toggle) => unimplemented!(),
ExtAction::KeyPress(_, ClickType::Toggle) => {
// TODO: Implement key press toggle
eprintln!("Warning: key press toggle is not implemented");
}
ExtAction::MousePress(c, ClickType::Click) => self.mouse.enigo().mouse_click(c),
ExtAction::MousePress(c, ClickType::Press) => self.mouse.enigo().mouse_down(c),
ExtAction::MousePress(c, ClickType::Release) => self.mouse.enigo().mouse_up(c),
ExtAction::MousePress(_, ClickType::Toggle) => unimplemented!(),
ExtAction::MousePress(_, ClickType::Toggle) => {
// TODO: Implement mouse click toggle
eprintln!("Warning: mouse click toggle is not implemented");
}
#[cfg(feature = "vgamepad")]
ExtAction::GamepadKeyPress(key, ClickType::Press) => {
if let Some(gamepad) = &mut self.gamepad {
Expand All @@ -121,6 +132,7 @@ impl Engine {
}
#[cfg(feature = "vgamepad")]
ExtAction::GamepadKeyPress(_, _) => todo!(),
ExtAction::None => {}
}
}
#[cfg(feature = "vgamepad")]
Expand Down
11 changes: 0 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,6 @@ pub enum ClickType {
Toggle,
}

impl ClickType {
pub fn apply(self, val: bool) -> bool {
match self {
ClickType::Press => false,
ClickType::Release => true,
ClickType::Click => unimplemented!(),
ClickType::Toggle => !val,
}
}
}

fn main() {
// https://github.com/rust-cli/human-panic/issues/77
human_panic::setup_panic!(human_panic::Metadata {
Expand Down
3 changes: 2 additions & 1 deletion src/mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub enum Action {

#[derive(Debug, Copy, Clone)]
pub enum ExtAction {
None,
KeyPress(Key, ClickType),
MousePress(MouseButton, ClickType),
#[cfg(feature = "vgamepad")]
Expand Down Expand Up @@ -158,7 +159,7 @@ impl<V: Default> Enum<V> for MapKey {
} else if value < MAP_KEY_SIZE {
<VirtualKey as Enum<()>>::from_usize(value - JOYKEY_SIZE).into()
} else {
unimplemented!()
unreachable!("MapKey value cannot be > MAP_KEY_SIZE");
}
}

Expand Down

0 comments on commit 57b9f96

Please sign in to comment.