pub struct Input { /* private fields */ }Expand description
The anvil-overlay.input service.
Implementations§
Source§impl Input
impl Input
Sourcepub fn get(host: &Host) -> Option<Self>
pub fn get(host: &Host) -> Option<Self>
The service; None without the overlay or with one older than 1.18.
Sourcepub fn c_api(&self) -> Table<AnvilInputService>
pub fn c_api(&self) -> Table<AnvilInputService>
The C table, for what this crate does not wrap.
Sourcepub fn state(&self) -> Option<State>
pub fn state(&self) -> Option<State>
What holds input back now; None when the service lacks the call.
Sourcepub fn bind<F>(
&self,
code: Key,
flags: BindFlags,
handler: F,
) -> Result<Binding>
pub fn bind<F>( &self, code: Key, flags: BindFlags, handler: F, ) -> Result<Binding>
Binds code (Key(0) for none yet). A code another binding holds is
ErrorCode::Conflict, and the overlay’s inert binding is dropped:
use Input::bind_or_inert to keep it and give it a free code later.
256 bindings a process, a dropped one included.
Sourcepub fn bind_or_inert<F>(
&self,
code: Key,
flags: BindFlags,
handler: F,
) -> Result<(Binding, Option<Error>)>
pub fn bind_or_inert<F>( &self, code: Key, flags: BindFlags, handler: F, ) -> Result<(Binding, Option<Error>)>
Binds code as Input::bind does, but keeps the binding when
another one holds the code, as the C API does: it is inert (code 0)
until Binding::set_code gives it a free one, such as from the key
setting’s callback once the player picks another key. The error is
Some with ErrorCode::Conflict for such a binding, None when the
binding holds code. Other errors make no binding.