mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-13 20:42:07 +01:00
internal/ui: bug fix: native APIs must be called from the main thread
Updates #2763
This commit is contained in:
parent
0475baf9e2
commit
7becaa19e6
@ -47,8 +47,16 @@ func (u *userInterfaceImpl) registerInputCallbacks() {
|
||||
}))
|
||||
}
|
||||
|
||||
// updateInput must be called from the main thread.
|
||||
func (u *userInterfaceImpl) updateInputState() error {
|
||||
var err error
|
||||
u.mainThread.Call(func() {
|
||||
err = u.updateInputStateImpl()
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
// updateInputStateImpl must be called from the main thread.
|
||||
func (u *userInterfaceImpl) updateInputStateImpl() error {
|
||||
u.m.Lock()
|
||||
defer u.m.Unlock()
|
||||
|
||||
|
@ -30,18 +30,19 @@ import (
|
||||
)
|
||||
|
||||
func (u *userInterfaceImpl) updateInputState() error {
|
||||
var ferr error
|
||||
var err error
|
||||
u.mainThread.Call(func() {
|
||||
if err := gamepad.Update(); err != nil {
|
||||
ferr = err
|
||||
return
|
||||
}
|
||||
u.updateInputStateImpl()
|
||||
err = u.updateInputStateImpl()
|
||||
})
|
||||
return ferr
|
||||
return err
|
||||
}
|
||||
|
||||
func (u *userInterfaceImpl) updateInputStateImpl() {
|
||||
// updateInputStateImpl must be called from the main thread.
|
||||
func (u *userInterfaceImpl) updateInputStateImpl() error {
|
||||
if err := gamepad.Update(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
C.ebitengine_UpdateTouches()
|
||||
|
||||
u.nativeTouches = u.nativeTouches[:0]
|
||||
@ -66,6 +67,8 @@ func (u *userInterfaceImpl) updateInputStateImpl() {
|
||||
Y: int(y),
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func KeyName(key Key) string {
|
||||
|
Loading…
Reference in New Issue
Block a user