mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
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:
parent
ad3c76b6d9
commit
0246a6407e
4
input.go
4
input.go
@ -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()
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user