From 853dbdf19dcdf6457c55100e08b2ddab4afd9838 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 31 Mar 2019 00:45:52 +0900 Subject: [PATCH] input: Refactoring --- internal/input/input_glfw.go | 7 +------ internal/input/input_js.go | 5 +---- internal/ui/ui_glfw.go | 3 +-- internal/ui/ui_js.go | 3 +-- 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/internal/input/input_glfw.go b/internal/input/input_glfw.go index f2508b3b7..3aa9da81b 100644 --- a/internal/input/input_glfw.go +++ b/internal/input/input_glfw.go @@ -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 } diff --git a/internal/input/input_js.go b/internal/input/input_js.go index 30b458a66..1bae31a9c 100644 --- a/internal/input/input_js.go +++ b/internal/input/input_js.go @@ -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 } diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index f31e9fb5e..6f4d2ee0a 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -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 { diff --git a/internal/ui/ui_js.go b/internal/ui/ui_js.go index 7ac665189..f0ee2b83c 100644 --- a/internal/ui/ui_js.go +++ b/internal/ui/ui_js.go @@ -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