aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--stockton-input-codegen/src/lib.rs8
-rw-r--r--stockton-input/src/manager.rs3
2 files changed, 11 insertions, 0 deletions
diff --git a/stockton-input-codegen/src/lib.rs b/stockton-input-codegen/src/lib.rs
index a6e8215..d3ee525 100644
--- a/stockton-input-codegen/src/lib.rs
+++ b/stockton-input-codegen/src/lib.rs
@@ -51,6 +51,7 @@ pub fn derive_inputmanager(input: TokenStream) -> TokenStream {
);
let trait_impl = gen_trait_impl(
&manager_ident,
+ &struct_ident,
&fields_enum_ident,
&buttons,
&axes,
@@ -234,6 +235,7 @@ fn gen_manager_struct(
/// ```
fn gen_trait_impl(
manager: &Ident,
+ struct_ident: &Ident,
fields_enum: &Ident,
buttons: &[Ident],
axes: &[Ident],
@@ -246,6 +248,8 @@ fn gen_trait_impl(
quote!(
impl InputManager for #manager {
+ type Inputs = #struct_ident;
+
fn handle_frame<'a, X: IntoIterator<Item = &'a ::stockton_input::Action>>(&mut self, actions: X) -> () {
#(#just_hot_resets)*
@@ -267,6 +271,10 @@ fn gen_trait_impl(
}
}
}
+
+ fn get_inputs(&self) -> &Self::Inputs {
+ &self.inputs
+ }
}
)
}
diff --git a/stockton-input/src/manager.rs b/stockton-input/src/manager.rs
index 4d2d001..f0786b0 100644
--- a/stockton-input/src/manager.rs
+++ b/stockton-input/src/manager.rs
@@ -46,5 +46,8 @@ impl Action {
}
pub trait InputManager {
+ type Inputs;
+
fn handle_frame<'a, X: IntoIterator<Item = &'a Action>>(&mut self, actions: X);
+ fn get_inputs(&self) -> &Self::Inputs;
}