Skip to main content

ReadInputState

Trait ReadInputState 

Source
pub trait ReadInputState {
    // Required methods
    fn read_keys_state(&self) -> Result<[u8; 16], String>;
    fn reset_keys_state(&mut self);
}
Expand description

Implement this trait on a type and use it to read input state.

Required Methods§

Source

fn read_keys_state(&self) -> Result<[u8; 16], String>

This function is called whenever the interpreter needs to read keyboard state. You need to give back an array of 16 characters, each mapping to the 0x0 - 0xF keys on the hex keyboard

Source

fn reset_keys_state(&mut self)

This is a method that most of the time doesn’t need to be implemented, you can just perform a no-op, but it does give you access to when the emulator is no longer reading a key. This helps particularly only when you are in an environment where you don’t have continuous access to the keys state and you have to keep track of it yourself. I mean, I ran into this in the examples directory under my silly implementation for the normal terminal window, but it could just be a skill issue.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§