mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
input: Refactoring
This commit is contained in:
parent
486a6134e4
commit
853dbdf19d
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user