input: Rename Reset -> ResetForFrame

This commit is contained in:
Hajime Hoshi 2019-03-31 18:47:06 +09:00
parent 9e5261c156
commit e273618081
6 changed files with 9 additions and 4 deletions

View File

@ -22,6 +22,7 @@ import (
"github.com/hajimehoshi/ebiten/internal/driver"
"github.com/hajimehoshi/ebiten/internal/graphicscommand"
"github.com/hajimehoshi/ebiten/internal/hooks"
"github.com/hajimehoshi/ebiten/internal/input"
"github.com/hajimehoshi/ebiten/internal/shareable"
"github.com/hajimehoshi/ebiten/internal/ui"
)
@ -114,6 +115,8 @@ func (c *graphicsContext) Update(afterFrameUpdate func()) error {
if err := c.f(c.offscreen); err != nil {
return err
}
input.Get().ResetForFrame()
afterFrameUpdate()
}

View File

@ -47,7 +47,7 @@ func (i *Input) RuneBuffer() []rune {
return i.runeBuffer
}
func (i *Input) Reset() {
func (i *Input) ResetForFrame() {
i.m.RLock()
defer i.m.RUnlock()
i.runeBuffer = i.runeBuffer[:0]

View File

@ -49,7 +49,7 @@ func (i *Input) RuneBuffer() []rune {
return i.runeBuffer
}
func (i *Input) Reset() {
func (i *Input) ResetForFrame() {
i.runeBuffer = nil
i.wheelX = 0
i.wheelY = 0

View File

@ -57,3 +57,7 @@ func (i *Input) SetTouches(touches []*Touch) {
}
i.m.Unlock()
}
func (i *Input) ResetForFrame() {
// Do nothing
}

View File

@ -780,7 +780,6 @@ func (u *userInterface) update(g GraphicsContext) error {
return nil
})
if err := g.Update(func() {
input.Get().Reset()
// The offscreens must be updated every frame (#490).
u.updateGraphicsContext(g)
}); err != nil {

View File

@ -206,7 +206,6 @@ func (u *userInterface) update(g GraphicsContext) error {
input.Get().UpdateGamepads()
u.updateGraphicsContext(g)
if err := g.Update(func() {
input.Get().Reset()
u.updateGraphicsContext(g)
}); err != nil {
return err