-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from daystram/feat/system-processor
Add system processor and U2F flash mode control
- Loading branch information
Showing
7 changed files
with
89 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod none; | ||
pub mod replace; | ||
pub mod rgb; | ||
pub mod system; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use alloc::vec::Vec; | ||
use hal::rom_data; | ||
|
||
use crate::{ | ||
key::{Action, Control, Edge, LayerIndex}, | ||
processor::{Event, EventsProcessor, Result}, | ||
}; | ||
|
||
pub struct SystemProcessor { | ||
u2f_activity_pin: u8, | ||
} | ||
|
||
#[allow(dead_code)] | ||
impl SystemProcessor { | ||
pub fn new(u2f_activity_pin: u8) -> Self { | ||
SystemProcessor { u2f_activity_pin } | ||
} | ||
} | ||
|
||
impl<L: LayerIndex> EventsProcessor<L> for SystemProcessor { | ||
fn process(&mut self, events: &mut Vec<Event<L>>) -> Result { | ||
events.iter_mut().for_each(|e| { | ||
if e.edge == Edge::Rising { | ||
if let Action::Control(c) = e.action { | ||
if c == Control::U2FBootloaderJump { | ||
rom_data::reset_to_usb_boot(1 << self.u2f_activity_pin, 0) | ||
} | ||
} | ||
} | ||
}); | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters