Bug fix: input

This commit is contained in:
Hajime Hoshi 2013-07-05 21:46:52 +09:00
parent 50f335d0e9
commit 55ae4a6855

View File

@ -79,9 +79,12 @@ func display() {
//export mouse //export mouse
func mouse(button, state, x, y C.int) { func mouse(button, state, x, y C.int) {
event := GlutInputEvent{false, -1, -1} event := GlutInputEvent{false, -1, -1}
if state == C.GLUT_UP { if state == C.GLUT_DOWN {
currentUI.glutInputting <- event event.IsActive = true
event.X = int(x)
event.Y = int(y)
} }
currentUI.glutInputting <- event
} }
//export motion //export motion
@ -185,6 +188,7 @@ func main() {
ch := currentUI.glutInputting ch := currentUI.glutInputting
for { for {
event := <-ch event := <-ch
inputState := ebiten.InputState{-1, -1}
if event.IsActive { if event.IsActive {
x := event.X / screenScale x := event.X / screenScale
y := event.Y / screenScale y := event.Y / screenScale
@ -198,17 +202,10 @@ func main() {
} else if screenHeight <= y { } else if screenHeight <= y {
y = screenHeight - 1 y = screenHeight - 1
} }
input <- ebiten.InputState{ inputState.X = x
X: x, inputState.Y = y
Y: y,
}
} else {
input <- ebiten.InputState{
X: -1,
Y: -1,
}
} }
input <- inputState
} }
}() }()