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/driver"
"github.com/hajimehoshi/ebiten/internal/graphicscommand" "github.com/hajimehoshi/ebiten/internal/graphicscommand"
"github.com/hajimehoshi/ebiten/internal/hooks" "github.com/hajimehoshi/ebiten/internal/hooks"
"github.com/hajimehoshi/ebiten/internal/input"
"github.com/hajimehoshi/ebiten/internal/shareable" "github.com/hajimehoshi/ebiten/internal/shareable"
"github.com/hajimehoshi/ebiten/internal/ui" "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 { if err := c.f(c.offscreen); err != nil {
return err return err
} }
input.Get().ResetForFrame()
afterFrameUpdate() afterFrameUpdate()
} }

View File

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

View File

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

View File

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

View File

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

View File

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