io

package
v0.0.0-...-91496d5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2017 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Frontend

type Frontend interface {
	Initialize()
	Draw(emulator emu.Chip8)
	Close()
}

Frontend is the basic interface for graphical output. A frontend might be implemented by SDL, opengl or similar libraries.

type Input

type Input interface {
	Poll() *KeyEvent
}

Input is an interface for a provider of keypresses.

type Key

type Key uint8

Key is the type for identifying a key on the Chip8 keypad.

const (
	Key0 Key = iota
	Key1
	Key2
	Key3
	Key4
	Key5
	Key6
	Key7
	Key8
	Key9
	KeyA
	KeyB
	KeyC
	KeyD
	KeyE
	KeyF
	KeyQuit
	KeyNone
)

The possible values for keys

type KeyEvent

type KeyEvent struct {
	Key Key
	Up  bool
}

KeyEvent is a type for representing keydown or keyup events.

type SdlFrontend

type SdlFrontend struct {
	// contains filtered or unexported fields
}

SdlFrontend implements basic drawing using SDL2.

func NewSdlFrontend

func NewSdlFrontend() SdlFrontend

NewSdlFrontend creates a new uninitialized frontend that uses SDL2.

func (*SdlFrontend) Close

func (sf *SdlFrontend) Close()

Close will free any resources, the window and quit the application. Best used with defer.

func (*SdlFrontend) Draw

func (sf *SdlFrontend) Draw(framebuffer []uint8)

Draw will draw on the window the contents of the emulator framebuffer.

func (*SdlFrontend) Initialize

func (sf *SdlFrontend) Initialize()

Initialize creates the window and sets up any internal state for the frontend.

type SdlInput

type SdlInput struct {
}

SdlInput implements basic drawing using SDL2.

func NewSdlInput

func NewSdlInput() SdlInput

NewSdlInput creates a new uninitialized Input that uses SDL2.

func (*SdlInput) Poll

func (i *SdlInput) Poll() *KeyEvent

Poll polls for an input event and return the key that was pressed (mapped to Chip8 keys) and whether the event was for a key up or down event.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL