mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-10 18:13:18 +01:00
29 lines
584 B
Go
29 lines
584 B
Go
package glfw
|
|
|
|
import (
|
|
glfw "github.com/go-gl/glfw3"
|
|
"github.com/hajimehoshi/ebiten/input"
|
|
)
|
|
|
|
type keyboard struct {
|
|
keyPressed [input.KeyMax]bool
|
|
}
|
|
|
|
func (k *keyboard) IsKeyPressed(key input.Key) bool {
|
|
return k.keyPressed[key]
|
|
}
|
|
|
|
var glfwKeyCodeToKey = map[glfw.Key]input.Key{
|
|
glfw.KeySpace: input.KeySpace,
|
|
glfw.KeyLeft: input.KeyLeft,
|
|
glfw.KeyRight: input.KeyRight,
|
|
glfw.KeyUp: input.KeyUp,
|
|
glfw.KeyDown: input.KeyDown,
|
|
}
|
|
|
|
func (k *keyboard) update(window *glfw.Window) {
|
|
for g, u := range glfwKeyCodeToKey {
|
|
k.keyPressed[u] = window.GetKey(g) == glfw.Press
|
|
}
|
|
}
|