Skip to content

Commit

Permalink
Implement Action for toggling bt compatibility mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ah- committed Mar 10, 2018
1 parent 533667a commit 2247a2b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub enum Action {
BtDeleteHost(u8),
BtBroadcast,
BtCompatibilityMode(bool),
BtToggleCompatibilityMode,
BtHostListQuery, // TODO: remove? this shouldn't really be here
}

Expand Down
7 changes: 6 additions & 1 deletion src/bluetooth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use debug::UnwrapLog;
use nb;
use rtfm::Threshold;

#[derive(Copy, Clone)]
#[derive(Copy, Clone, PartialEq)]
pub enum BluetoothMode {
Unknown,
Legacy,
Expand Down Expand Up @@ -73,6 +73,11 @@ where
.send(MsgType::Ble, BleOp::CompatibilityMode as u8, &[on])
}

pub fn toggle_compatibility_mode(&mut self) -> nb::Result<(), !> {
let enabled: bool = self.mode == BluetoothMode::Ble;
self.enable_compatibility_mode(enabled)
}

pub fn host_list_query(&mut self) -> nb::Result<(), !> {
self.serial
.send(MsgType::Ble, BleOp::HostListQuery as u8, &[])
Expand Down
1 change: 1 addition & 0 deletions src/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ where
Action::BtDeleteHost(host) => self.delete_host(host),
Action::BtBroadcast => self.broadcast(),
Action::BtCompatibilityMode(on) => self.enable_compatibility_mode(on),
Action::BtToggleCompatibilityMode => self.toggle_compatibility_mode(),
Action::BtHostListQuery => self.host_list_query(),
_ => Ok(()),
};
Expand Down
2 changes: 1 addition & 1 deletion src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub const FN2: Layout = layout![

#[cfg_attr(rustfmt, rustfmt_skip)]
pub const BT: Layout = layout![
LayerOff(LAYER_BT) BtConnectHost(0) BtConnectHost(1) BtConnectHost(2) BtConnectHost(3) __ __ __ __ BtCompatibilityMode(false) BtCompatibilityMode(true) BtOff BtBroadcast BtOn
LayerOff(LAYER_BT) BtConnectHost(0) BtConnectHost(1) BtConnectHost(2) BtConnectHost(3) __ __ __ __ __ BtToggleCompatibilityMode BtOff BtBroadcast BtOn
__ BtSaveHost(0) BtSaveHost(1) BtSaveHost(2) BtSaveHost(3) __ __ __ __ __ __ __ __ __
__ BtDeleteHost(0) BtDeleteHost(1) BtDeleteHost(2) BtDeleteHost(3) __ __ __ __ __ __ __ No __
__ __ __ __ __ LayerOff(LAYER_BT) __ __ __ __ __ __ __ __
Expand Down

0 comments on commit 2247a2b

Please sign in to comment.