Skip to main content

oak_type/
inputs.rs

1//! Inputs are things that a person or other device (such as the host) can do to cause a behavior.
2//!
3//! Examples include:
4//! * Analog inputs from hall effect sensors or a varistor
5//! * Momentary switches from a traditional keyboard switch
6//! * Messages from software on a host machine or other device
7
8pub mod analog;
9pub mod binary;
10mod matrix;
11mod multiplex;
12
13/// Structs that implement the Input trait represent physical or logical inputs
14/// to the keyboard. They can be anything from a momentary switch seen in typical keyboards
15/// to analog inputs from hall effect sensors or a varistor, to inputs from software on a host
16/// machine
17pub trait Input
18{
19    type Signal;
20
21    fn get_input(&self) -> Self::Signal;
22}
23
24/// Marker trait indicating that the implementing struct can be used as a configuration
25/// which read a signal of type S
26pub trait InputConfig<S> {}
27
28/// Defines (typically at the hardware level) how a configured input is read.
29///
30/// For example:
31/// * For an input configuration _IC_, what does the hardware do to _read the signal S_?
32/// * For an input  configuration _analog GPIO2_, what does the hardware do to _read GPIO2_?
33pub trait InputConfigurator<IC, S>
34    where
35        IC: InputConfig<S>,
36{
37    fn configure(&self, in_conf: IC) -> fn() -> S;
38}