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
}
func (i *Input) ClearRuneBuffer() {
func (i *Input) Reset() {
i.m.RLock()
defer i.m.RUnlock()
i.runeBuffer = i.runeBuffer[:0]
}
func (i *Input) ResetScrollValues() {
i.m.RLock()
defer i.m.RUnlock()
i.scrollX, i.scrollY = 0, 0
}

View File

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

View File

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

View File

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