input

package
v0.0.0-...-e1c21c9 Latest Latest
Warning

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

Go to latest
Published: May 10, 2019 License: Zlib Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Grave        = Key(glfw.KeyGraveAccent)
	Dash         = Key(glfw.KeyMinus)
	Apostrophe   = Key(glfw.KeyApostrophe)
	Semicolon    = Key(glfw.KeySemicolon)
	Equals       = Key(glfw.KeyEqual)
	Comma        = Key(glfw.KeyComma)
	Period       = Key(glfw.KeyPeriod)
	Slash        = Key(glfw.KeySlash)
	Backslash    = Key(glfw.KeyBackslash)
	Backspace    = Key(glfw.KeyBackspace)
	Tab          = Key(glfw.KeyTab)
	CapsLock     = Key(glfw.KeyCapsLock)
	Space        = Key(glfw.KeySpace)
	Enter        = Key(glfw.KeyEnter)
	Escape       = Key(glfw.KeyEscape)
	Insert       = Key(glfw.KeyInsert)
	PrintScreen  = Key(glfw.KeyPrintScreen)
	Delete       = Key(glfw.KeyDelete)
	PageUp       = Key(glfw.KeyPageUp)
	PageDown     = Key(glfw.KeyPageDown)
	Home         = Key(glfw.KeyHome)
	End          = Key(glfw.KeyEnd)
	Pause        = Key(glfw.KeyPause)
	ScrollLock   = Key(glfw.KeyScrollLock)
	ArrowLeft    = Key(glfw.KeyLeft)
	ArrowRight   = Key(glfw.KeyRight)
	ArrowDown    = Key(glfw.KeyDown)
	ArrowUp      = Key(glfw.KeyUp)
	LeftBracket  = Key(glfw.KeyLeftBracket)
	LeftShift    = Key(glfw.KeyLeftShift)
	LeftControl  = Key(glfw.KeyLeftControl)
	LeftSuper    = Key(glfw.KeyLeftSuper)
	LeftAlt      = Key(glfw.KeyLeftAlt)
	RightBracket = Key(glfw.KeyRightBracket)
	RightShift   = Key(glfw.KeyRightShift)
	RightControl = Key(glfw.KeyRightControl)
	RightSuper   = Key(glfw.KeyRightSuper)
	RightAlt     = Key(glfw.KeyRightAlt)
	Zero         = Key(glfw.Key0)
	One          = Key(glfw.Key1)
	Two          = Key(glfw.Key2)
	Three        = Key(glfw.Key3)
	Four         = Key(glfw.Key4)
	Five         = Key(glfw.Key5)
	Six          = Key(glfw.Key6)
	Seven        = Key(glfw.Key7)
	Eight        = Key(glfw.Key8)
	Nine         = Key(glfw.Key9)
	F1           = Key(glfw.KeyF1)
	F2           = Key(glfw.KeyF2)
	F3           = Key(glfw.KeyF3)
	F4           = Key(glfw.KeyF4)
	F5           = Key(glfw.KeyF5)
	F6           = Key(glfw.KeyF6)
	F7           = Key(glfw.KeyF7)
	F8           = Key(glfw.KeyF8)
	F9           = Key(glfw.KeyF9)
	F10          = Key(glfw.KeyF10)
	F11          = Key(glfw.KeyF11)
	F12          = Key(glfw.KeyF12)
	A            = Key(glfw.KeyA)
	B            = Key(glfw.KeyB)
	C            = Key(glfw.KeyC)
	D            = Key(glfw.KeyD)
	E            = Key(glfw.KeyE)
	F            = Key(glfw.KeyF)
	G            = Key(glfw.KeyG)
	H            = Key(glfw.KeyH)
	I            = Key(glfw.KeyI)
	J            = Key(glfw.KeyJ)
	K            = Key(glfw.KeyK)
	L            = Key(glfw.KeyL)
	M            = Key(glfw.KeyM)
	N            = Key(glfw.KeyN)
	O            = Key(glfw.KeyO)
	P            = Key(glfw.KeyP)
	Q            = Key(glfw.KeyQ)
	R            = Key(glfw.KeyR)
	S            = Key(glfw.KeyS)
	T            = Key(glfw.KeyT)
	U            = Key(glfw.KeyU)
	V            = Key(glfw.KeyV)
	W            = Key(glfw.KeyW)
	X            = Key(glfw.KeyX)
	Y            = Key(glfw.KeyY)
	Z            = Key(glfw.KeyZ)
	NumLock      = Key(glfw.KeyNumLock)
	NumMultiply  = Key(glfw.KeyKPMultiply)
	NumDivide    = Key(glfw.KeyKPDivide)
	NumAdd       = Key(glfw.KeyKPAdd)
	NumSubtract  = Key(glfw.KeyKPSubtract)
	NumZero      = Key(glfw.KeyKP0)
	NumOne       = Key(glfw.KeyKP1)
	NumTwo       = Key(glfw.KeyKP2)
	NumThree     = Key(glfw.KeyKP3)
	NumFour      = Key(glfw.KeyKP4)
	NumFive      = Key(glfw.KeyKP5)
	NumSix       = Key(glfw.KeyKP6)
	NumSeven     = Key(glfw.KeyKP7)
	NumEight     = Key(glfw.KeyKP8)
	NumNine      = Key(glfw.KeyKP9)
	NumDecimal   = Key(glfw.KeyKPDecimal)
	NumEnter     = Key(glfw.KeyKPEnter)
)

Variables

This section is empty.

Functions

func AnyKeyChanged

func AnyKeyChanged() bool

func Button

func Button(name string) button

short API

func Mouse

func Mouse(key int) (btn *button, pos, delta f32.Vec2)

Mouse event

func NewButton

func NewButton() (btn *button)

func PointerButton

func PointerButton(pb KeyPoint) button

func RegisterButton

func RegisterButton(name string, keys ...Key)

func Touch

func Touch(fi FingerId) (btn button, pos, delta f32.Vec2)

Touch event

Types

type FingerId

type FingerId int

type InputSystem

type InputSystem struct {
	// contains filtered or unexported fields
}
var Input *InputSystem

func NewInputSystem

func NewInputSystem() *InputSystem

func (*InputSystem) AdvanceFrame

func (in *InputSystem) AdvanceFrame()

更新 Button 状态.... TODO 此处的输入状态,更新有bug!!

func (*InputSystem) AnyKeyChanged

func (in *InputSystem) AnyKeyChanged() bool

func (*InputSystem) Button

func (in *InputSystem) Button(name string) *button

/ 查询虚拟按键的状态

func (*InputSystem) RegisterButton

func (in *InputSystem) RegisterButton(name string, keys ...Key)

/ 将物理按键映射到虚拟按键

func (*InputSystem) Reset

func (in *InputSystem) Reset()

func (*InputSystem) SetKeyEvent

func (in *InputSystem) SetKeyEvent(key int, pressed bool)

更新 key 的状态

func (*InputSystem) SetPointerEvent

func (in *InputSystem) SetPointerEvent(key int, pressed bool, x, y float32)

更新 Mouse/Touch 状态

type Key

type Key int

type KeyBind

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

type KeyPoint

type KeyPoint int

mouse or finger button

const (
	KeyPoint1 KeyPoint = iota
	KeyPoint2
	KeyPoint3
	KeyPoint4
	KeyPoint5
	KeyPoint6
	KeyPoint7
	KeyPoint8
	KeyPoint9
	KeyPointX
)

type PointerInput

type PointerInput struct {
	// The mouse pointer always has a pointer-id of 0
	Id FingerId

	// The position and moved amount of pointer
	MousePos, MouseDelta f32.Vec2
	// contains filtered or unexported fields
}

// Touch & Mouse input go here

func PointerPosition

func PointerPosition(pb KeyPoint) PointerInput

type SparseMap

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

记录一帧之内的按键,一帧时间做多支持同时按6个按键

func (*SparseMap) Clear

func (m *SparseMap) Clear()

func (*SparseMap) Get

func (m *SparseMap) Get(k Key) (st, ok bool)

func (*SparseMap) Put

func (m *SparseMap) Put(k Key, st bool)

type VAxis

type VAxis struct {
}

/ 虚拟遥感

Jump to

Keyboard shortcuts

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