events

package
v0.0.0-...-1f00af5 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package events manages mouse and keyboard SDL events for Doodle.

Index

Constants

This section is empty.

Variables

View Source
var (
	DebugMouseEvents = false
	DebugClickEvents = true
)

Debug constants, toggle on or off for SUPER VERBOSE debugging.

Functions

This section is empty.

Types

type BoolTick

type BoolTick struct {
	Now  bool
	Last bool
}

BoolTick holds boolean state between this frame and the previous.

func (*BoolTick) Pressed

func (bs *BoolTick) Pressed() bool

Pressed returns true if the button was pressed THIS tick.

func (*BoolTick) Push

func (bs *BoolTick) Push(v bool)

Push a bool state, copying the current Now value to Last.

func (*BoolTick) Read

func (bs *BoolTick) Read() bool

Read a bool state, resetting its value to false.

type Int32Tick

type Int32Tick struct {
	Now  int32
	Last int32
}

Int32Tick manages int32 state between this frame and the previous.

func (*Int32Tick) Push

func (is *Int32Tick) Push(v int32)

Push an int32 state, copying the current Now value to Last.

type State

type State struct {
	// Mouse buttons.
	Button1 *BoolTick // left
	Button2 *BoolTick // right
	Button3 *BoolTick // middle

	EscapeKey     *BoolTick
	EnterKey      *BoolTick
	ShiftActive   *BoolTick
	ControlActive *BoolTick
	KeyName       *StringTick
	Up            *BoolTick
	Left          *BoolTick
	Right         *BoolTick
	Down          *BoolTick

	// Cursor positions.
	CursorX *Int32Tick
	CursorY *Int32Tick

	// Window events: window has changed size.
	Resized *BoolTick
}

State keeps track of event states.

func New

func New() *State

New creates a new event state manager.

func (*State) ReadKey

func (ev *State) ReadKey() string

ReadKey returns the normalized key symbol being pressed, taking the Shift key into account. QWERTY keyboard only, probably.

type StringTick

type StringTick struct {
	Now  string
	Last string
}

StringTick manages strings between this frame and the previous.

func (*StringTick) Push

func (s *StringTick) Push(v string)

Push a string state.

func (*StringTick) Read

func (s *StringTick) Read() string

Read a string state, resetting its value.

Jump to

Keyboard shortcuts

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