keybind

package
v0.0.0-...-67a1e62 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: MIT Imports: 3 Imported by: 4

Documentation

Index

Constants

View Source
const (
	EventAction             = Event(0x1)
	EventMoveForward        = Event(0x2)
	EventMoveBackward       = Event(0x3)
	EventMoveLeft           = Event(0x4)
	EventMoveRight          = Event(0x5)
	EventJump               = Event(0x6)
	EventToggleInventory    = Event(0x7)
	EventChat               = Event(0x8)
	EventTeamChat           = Event(0x9)
	EventToggleBook         = Event(0xa)
	EventToggleConsole      = Event(0xb)
	EventIncreaseWindowSize = Event(0xc)
	EventDecreaseWindowSize = Event(0xd)
	EventIncreaseGamma      = Event(0xe)
	EventDecreaseGamma      = Event(0xf)
	EventToggleMap          = Event(0x10)
	EventCastQueued         = Event(0x11)
	EventPhonemeUN          = Event(0x12) // up
	EventPhonemeZO          = Event(0x13) // down
	EventPhonemeET          = Event(0x14) // left
	EventPhonemeCHA         = Event(0x15) // right
	EventPhonemeIN          = Event(0x16) // upper-right
	EventPhonemeKA          = Event(0x17) // upper-left
	EventPhonemeDO          = Event(0x18) // lower-right
	EventPhonemeRO          = Event(0x19) // lower-left
	EventSpellEnd           = Event(0x1a)
	EventCastRecent         = Event(0x1b)
	EventInvokeSlot1        = Event(0x1c)
	EventInvokeSlot2        = Event(0x1d)
	EventInvokeSlot3        = Event(0x1e)
	EventInvokeSlot4        = Event(0x1f)
	EventInvokeSlot5        = Event(0x20)
	EventMapZoomIn          = Event(0x21)
	EventMapZoomOut         = Event(0x22)
	EventSwapWeapons        = Event(0x23)
	EventQuickHealth        = Event(0x24)
	EventQuickMana          = Event(0x25)
	EventQuickCurePoison    = Event(0x26)
	EventNextSpellSet       = Event(0x27)
	EventPreviousSpellSet   = Event(0x28)
	EventSelectSpellSet     = Event(0x29)
	EventPlaceTrapBomber    = Event(0x2a)
	EventQuit               = Event(0x2b)
	EventToggleQuitMenu     = Event(0x2c)
	EventToggleServerMenu   = Event(0x2d)
	EventTaunt              = Event(0x2e)
	EventLaugh              = Event(0x2f)
	EventPoint              = Event(0x30)
	EventInvertSpellTarget  = Event(0x31)
	EventToggleRank         = Event(0x32)
	EventToggleNetstat      = Event(0x33)
	EventToggleGUI          = Event(0x34)
	EventAutoSave           = Event(0x35)
	EventAutoLoad           = Event(0x36)
	EventScreenShot         = Event(0x37)
)
View Source
const (
	EventSpellSet1 = Event(0x50 + iota)
	EventSpellSet2
	EventSpellSet3
	EventSpellSet4
	EventSpellSet5
	EventTrapDrop
	EventTrapBomber1
	EventTrapBomber2
	EventTrapBomber3
	EventCreaturesBanish
	EventCreaturesGuard
	EventCreaturesEscort
	EventCreaturesHunt
	EventAcceptItemsBatch
)

Extensions to the key bindings.

View Source
const (
	// StrmanPref is a default prefix for string localisation IDs.
	StrmanPref = "keybind:"
	// StrmanNA is a default localisation ID for unknown keys.
	StrmanNA = "keybind:NA"
)
View Source
const (
	KeyKp0            = Key(0x52)
	KeyKp1            = Key(0x4f)
	KeyKp2            = Key(0x50)
	KeyKp3            = Key(0x51)
	KeyKp4            = Key(0x4b)
	KeyKp5            = Key(0x4c)
	KeyKp6            = Key(0x4d)
	KeyKp7            = Key(0x47)
	KeyKp8            = Key(0x48)
	KeyKp9            = Key(0x49)
	KeyKpPeriod       = Key(0x53)
	KeyKpStar         = Key(0x37)
	KeyKpMinus        = Key(0x4a)
	KeyKpPlus         = Key(0x4e)
	KeyKpEnter        = Key(0x9c)
	KeyKpSlash        = Key(0xb5)
	KeyEsc            = Key(0x1)
	KeyBackspace      = Key(0xe)
	KeyEnter          = Key(0x1c)
	KeySpace          = Key(0x39)
	KeyTab            = Key(0xf)
	KeyF1             = Key(0x3b)
	KeyF2             = Key(0x3c)
	KeyF3             = Key(0x3d)
	KeyF4             = Key(0x3e)
	KeyF5             = Key(0x3f)
	KeyF6             = Key(0x40)
	KeyF7             = Key(0x41)
	KeyF8             = Key(0x42)
	KeyF9             = Key(0x43)
	KeyF10            = Key(0x44)
	KeyF11            = Key(0x57)
	KeyF12            = Key(0x58)
	KeyA              = Key(0x1e)
	KeyB              = Key(0x30)
	KeyC              = Key(0x2e)
	KeyD              = Key(0x20)
	KeyE              = Key(0x12)
	KeyF              = Key(0x21)
	KeyG              = Key(0x22)
	KeyH              = Key(0x23)
	KeyI              = Key(0x17)
	KeyJ              = Key(0x24)
	KeyK              = Key(0x25)
	KeyL              = Key(0x26)
	KeyM              = Key(0x32)
	KeyN              = Key(0x31)
	KeyO              = Key(0x18)
	KeyP              = Key(0x19)
	KeyQ              = Key(0x10)
	KeyR              = Key(0x13)
	KeyS              = Key(0x1f)
	KeyT              = Key(0x14)
	KeyU              = Key(0x16)
	KeyV              = Key(0x2f)
	KeyW              = Key(0x11)
	KeyX              = Key(0x2d)
	KeyY              = Key(0x15)
	KeyZ              = Key(0x2c)
	Key1              = Key(0x2)
	Key2              = Key(0x3)
	Key3              = Key(0x4)
	Key4              = Key(0x5)
	Key5              = Key(0x6)
	Key6              = Key(0x7)
	Key7              = Key(0x8)
	Key8              = Key(0x9)
	Key9              = Key(0xa)
	Key0              = Key(0xb)
	KeyMinus          = Key(0xc)
	KeyEqual          = Key(0xd)
	KeyLBracket       = Key(0x1a)
	KeyRBracket       = Key(0x1b)
	KeySemiColon      = Key(0x27)
	KeySquote         = Key(0x28)
	KeyApos           = Key(0x29)
	KeyBslash         = Key(0x2b)
	KeyComma          = Key(0x33)
	KeyPeriod         = Key(0x34)
	KeySlash          = Key(0x35)
	KeySysReq         = Key(0xb7)
	KeyCaps           = Key(0x3a)
	KeyNumLck         = Key(0x45)
	KeyScroll         = Key(0x46)
	KeyLCtrl          = Key(0x1d)
	KeyLAlt           = Key(0x38)
	KeyLShift         = Key(0x2a)
	KeyRShift         = Key(0x36)
	KeyRAlt           = Key(0xb8)
	KeyRCtrl          = Key(0x9d)
	KeyUp             = Key(0xc8)
	KeyDown           = Key(0xd0)
	KeyLeft           = Key(0xcb)
	KeyRight          = Key(0xcd)
	KeyHome           = Key(0xc7)
	KeyEnd            = Key(0xcf)
	KeyPgUp           = Key(0xc9)
	KeyPgDn           = Key(0xd1)
	KeyIns            = Key(0xd2)
	KeyDel            = Key(0xd3)
	KeyLeftMouse      = Key(KeyMaskMouse + 0x0)
	KeyMiddleMouse    = Key(KeyMaskMouse + 0x1)
	KeyRightMouse     = Key(KeyMaskMouse + 0x2)
	KeyMouseWheelUp   = Key(KeyMaskMouse + 0x3)
	KeyMouseWheelDown = Key(KeyMaskMouse + 0x4)
)
View Source
const (
	KeyMaskMouse    = Key(0x10000)
	KeyMaskJoystick = Key(0x20000)
)

Variables

This section is empty.

Functions

func RegisterKey

func RegisterKey(code Key, name string, titleID strman.ID, titleDef string)

RegisterKey registers a new key with specified code, name and title.

Types

type BindEvent

type BindEvent struct {
	Name  string
	Event Event
	Title string
}

type Binding

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

func New

func New(sm *strman.StringManager) *Binding

func (*Binding) EventByCode

func (kb *Binding) EventByCode(key Event) *BindEvent

func (*Binding) EventByName

func (kb *Binding) EventByName(name string) *BindEvent

func (*Binding) EventByTitle

func (kb *Binding) EventByTitle(title string) *BindEvent

func (*Binding) Events

func (kb *Binding) Events() []BindEvent

type Event

type Event uint32

type Key

type Key uint32

Key represent a key code registered with this package. The code is arbitrary and may not represent key code of the underlying input source.

func KeyByName

func KeyByName(name string) Key

KeyByName finds the key by its name. It returns 0 if there's no such key.

func ListKeys

func ListKeys() []Key

ListKeys lists all keys registered with this package.

func (Key) IsJoystick

func (k Key) IsJoystick() bool

func (Key) IsKeyboard

func (k Key) IsKeyboard() bool

func (Key) IsMouse

func (k Key) IsMouse() bool

func (Key) IsValid

func (k Key) IsValid() bool

IsValid checks if the key is registered.

func (Key) String

func (k Key) String() string

String returns the name of the key.

func (Key) Title

func (k Key) Title(sm *strman.StringManager) string

Title returns key localised key title.

func (Key) TitleID

func (k Key) TitleID() strman.ID

TitleID returns key title ID for localisation.

Jump to

Keyboard shortcuts

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