ebiten: Guarantee that CursorPosition returns (0, 0) in the very initial state on desktops

This change also guarantees that CursorPosition always returns (0, 0)
on mobiles.
This commit is contained in:
Hajime Hoshi 2021-04-07 02:53:57 +09:00
parent ad3c76b6d9
commit 0246a6407e
2 changed files with 5 additions and 5 deletions

View File

@ -81,6 +81,10 @@ func IsKeyPressed(key Key) bool {
// CursorPosition returns a position of a mouse cursor relative to the game screen (window). The cursor position is
// 'logical' position and this considers the scale of the screen.
//
// CursorPosition returns (0, 0) before the main loop on desktops and browsers.
//
// CursorPosition always returns (0, 0) on mobiles.
//
// CursorPosition is concurrent-safe.
func CursorPosition() (x, y int) {
return uiDriver().Input().CursorPosition()

View File

@ -26,8 +26,6 @@ type pos struct {
}
type Input struct {
cursorX int
cursorY int
keys map[driver.Key]struct{}
runes []rune
touches map[driver.TouchID]pos
@ -36,9 +34,7 @@ type Input struct {
}
func (i *Input) CursorPosition() (x, y int) {
i.ui.m.RLock()
defer i.ui.m.RUnlock()
return i.ui.adjustPosition(i.cursorX, i.cursorY)
return 0, 0
}
func (i *Input) GamepadIDs() []driver.GamepadID {