Hide Input

This commit is contained in:
Hajime Hoshi 2014-12-14 17:07:45 +09:00
parent 8319e0d41d
commit 87bdd1a994
2 changed files with 6 additions and 6 deletions

View File

@ -27,7 +27,7 @@ type canvas struct {
window *glfw.Window window *glfw.Window
scale int scale int
graphicsContext *graphicsContext graphicsContext *graphicsContext
input Input input input
funcs chan func() funcs chan func()
funcsDone chan struct{} funcsDone chan struct{}
} }

View File

@ -21,22 +21,22 @@ import (
"math" "math"
) )
type Input struct { type input struct {
keyPressed [KeyMax]bool keyPressed [KeyMax]bool
mouseButtonPressed [MouseButtonMax]bool mouseButtonPressed [MouseButtonMax]bool
cursorX int cursorX int
cursorY int cursorY int
} }
func (i *Input) IsKeyPressed(key Key) bool { func (i *input) IsKeyPressed(key Key) bool {
return i.keyPressed[key] return i.keyPressed[key]
} }
func (i *Input) IsMouseButtonPressed(button MouseButton) bool { func (i *input) IsMouseButtonPressed(button MouseButton) bool {
return i.mouseButtonPressed[button] return i.mouseButtonPressed[button]
} }
func (i *Input) CursorPosition() (x, y int) { func (i *input) CursorPosition() (x, y int) {
return i.cursorX, i.cursorY return i.cursorX, i.cursorY
} }
@ -48,7 +48,7 @@ var glfwKeyCodeToKey = map[glfw.Key]Key{
glfw.KeyDown: KeyDown, glfw.KeyDown: KeyDown,
} }
func (i *Input) Update(window *glfw.Window, scale int) { func (i *input) Update(window *glfw.Window, scale int) {
for g, u := range glfwKeyCodeToKey { for g, u := range glfwKeyCodeToKey {
i.keyPressed[u] = window.GetKey(g) == glfw.Press i.keyPressed[u] = window.GetKey(g) == glfw.Press
} }