View Source Chip8.Interpreter.Keyboard (chip8 v1.1.0)

A keyboard input device.

Users can interact with programs through a hexadecimal keypad that was present in the original Chip-8 computer.

Keys are represented by hexadecimal integers. When a user presses the F key, the key needs to be registered as 15 instead. For this purpose, you can either use the hexadecimal notation (e.g. 0xF returns 15) for a hard-coded mapping or String.to_integer/2 (e.g. String.to_integer("F", 16) returns 15) for a more dynamic approach.

Link to this section Summary

Link to this section Types

@type key() :: 0..15
@type key_state() :: :none | :pressed
@type t() :: %Chip8.Interpreter.Keyboard{keys: %{required(key()) => key_state()}}

Link to this section Functions

Link to this function

is_pressed?(keyboard, key)

View Source
@spec is_pressed?(t(), key()) :: boolean()
@spec keys() :: [key(), ...]
@spec new() :: t()
Link to this function

press_key(keyboard, key)

View Source
@spec press_key(t(), key()) :: t()
Link to this function

release_key(keyboard, key)

View Source
@spec release_key(t(), key()) :: t()