v0.1.0 initial commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package input
|
||||
|
||||
// Key is a platform-neutral physical key identifier. Terminal and raylib
|
||||
// frontends translate native key events to Key before consulting KeyMap.
|
||||
// Android/gomobile bypasses this package: Kotlin translates touch/gesture
|
||||
// input to game.Action directly
|
||||
type Key uint8
|
||||
|
||||
const (
|
||||
KeyNone Key = iota
|
||||
KeyH // MoveLeft
|
||||
KeyJ // MoveDown
|
||||
KeyK // MoveUp
|
||||
KeyL // MoveRight
|
||||
KeySemicolon // stub
|
||||
KeyA // stub
|
||||
KeyS // stub
|
||||
KeyD // stub
|
||||
KeyF // stub
|
||||
KeySpace
|
||||
KeyEnter
|
||||
)
|
||||
@@ -0,0 +1,26 @@
|
||||
package input
|
||||
|
||||
import "symph/game"
|
||||
|
||||
// KeyMap is the default vim-style binding
|
||||
var KeyMap = map[Key]game.Action{
|
||||
KeyH: game.ActionMoveLeft,
|
||||
KeyJ: game.ActionMoveDown,
|
||||
KeyK: game.ActionMoveUp,
|
||||
KeyL: game.ActionMoveRight,
|
||||
KeySemicolon: game.ActionStubSemicolon,
|
||||
KeyA: game.ActionStubA,
|
||||
KeyS: game.ActionStubS,
|
||||
KeyD: game.ActionStubD,
|
||||
KeyF: game.ActionStubF,
|
||||
KeySpace: game.ActionSpace,
|
||||
KeyEnter: game.ActionConfirm,
|
||||
}
|
||||
|
||||
// Translate resolves a Key to its bound Action, ActionNone if unbound
|
||||
func Translate(k Key) game.Action {
|
||||
if a, ok := KeyMap[k]; ok {
|
||||
return a
|
||||
}
|
||||
return game.ActionNone
|
||||
}
|
||||
Reference in New Issue
Block a user