input: Refactoring

This commit is contained in:
Hajime Hoshi 2019-03-31 00:45:52 +09:00
parent 486a6134e4
commit 853dbdf19d
4 changed files with 4 additions and 14 deletions

View File

@ -47,15 +47,10 @@ func (i *Input) RuneBuffer() []rune {
return i.runeBuffer return i.runeBuffer
} }
func (i *Input) ClearRuneBuffer() { func (i *Input) Reset() {
i.m.RLock() i.m.RLock()
defer i.m.RUnlock() defer i.m.RUnlock()
i.runeBuffer = i.runeBuffer[:0] i.runeBuffer = i.runeBuffer[:0]
}
func (i *Input) ResetScrollValues() {
i.m.RLock()
defer i.m.RUnlock()
i.scrollX, i.scrollY = 0, 0 i.scrollX, i.scrollY = 0, 0
} }

View File

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

View File

@ -789,8 +789,7 @@ func (u *userInterface) update(g GraphicsContext) error {
return nil return nil
}) })
if err := g.Update(func() { if err := g.Update(func() {
input.Get().ClearRuneBuffer() input.Get().Reset()
input.Get().ResetScrollValues()
// 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

@ -220,8 +220,7 @@ 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().ClearRuneBuffer() input.Get().Reset()
input.Get().ResetWheelValues()
u.updateGraphicsContext(g) u.updateGraphicsContext(g)
}); err != nil { }); err != nil {
return err return err