diff --git a/src/backend_piston.rs b/src/backend_piston.rs index 6a0e054..b3b2732 100644 --- a/src/backend_piston.rs +++ b/src/backend_piston.rs @@ -12,35 +12,46 @@ where TUserAction: Clone + Serialize, schema: Schema, } +/// Schema implementation using the Piston backend impl SchemaPiston where TUserAction: Clone + Serialize, { + /// Create a new Schema with given name pub fn new(name: &str) -> Self { SchemaPiston { schema: Schema::new(name) } } + /// Assigns assigns the controller from next registered input event + /// to this schema if it passes through the input flags pub fn assign_controller(&mut self, event: &Event, iaf: InputTypeFlags) -> bool { self.schema.assign_controller(event, iaf) } + /// Assigns specified user action to the next registered event from piston pub fn assign_input(&mut self, event: &Event, action: TUserAction, iaf: InputTypeFlags) -> bool { self.schema.assign_input(event, action, iaf) } + /// Main event processing hook. Will result in ProcessingResult for user's action if + /// a mapping is withing the schema for the given event. pub fn process_event(&mut self, event: &Event) -> Option> { self.schema.process_event(event) } + /// Assigns a player_id to this schema pub fn set_player_id(&mut self, player_id: Option) { self.schema.set_player_id(player_id); } + /// Returns the current player_id (or None if not assigned) pub fn player_id(&self) -> Option { self.schema.player_id } + /// Returns the currently assigned controller (or None if not assigned) + /// *NOTE* keyboard and mouse have no controller ID by definition in piston pub fn controller_id(&self) -> Option { self.schema.controller_id }