mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
ui: Adjust cursor positoin on fullscreen mode (#374)
This commit is contained in:
parent
c694851765
commit
ba204c6d3b
@ -28,7 +28,7 @@ func CurrentInput() *Input {
|
|||||||
func (i *Input) CursorPosition() (x, y int) {
|
func (i *Input) CursorPosition() (x, y int) {
|
||||||
i.m.RLock()
|
i.m.RLock()
|
||||||
defer i.m.RUnlock()
|
defer i.m.RUnlock()
|
||||||
return i.cursorX, i.cursorY
|
return adjustCursorPosition(i.cursorX, i.cursorY)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Input) GamepadAxisNum(id int) int {
|
func (i *Input) GamepadAxisNum(id int) int {
|
||||||
|
@ -214,6 +214,20 @@ func ScreenOffset() (float64, float64) {
|
|||||||
return ox, oy
|
return ox, oy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func adjustCursorPosition(x, y int) (int, int) {
|
||||||
|
u := currentUI
|
||||||
|
if !u.isRunning() {
|
||||||
|
return x, y
|
||||||
|
}
|
||||||
|
ox, oy := ScreenOffset()
|
||||||
|
s := 0.0
|
||||||
|
_ = currentUI.runOnMainThread(func() error {
|
||||||
|
s = currentUI.actualScreenScale()
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
return x - int(ox/s), y - int(oy/s)
|
||||||
|
}
|
||||||
|
|
||||||
func SetCursorVisibility(visible bool) {
|
func SetCursorVisibility(visible bool) {
|
||||||
// This can be called before Run: change the state asyncly.
|
// This can be called before Run: change the state asyncly.
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -70,6 +70,10 @@ func ScreenOffset() (float64, float64) {
|
|||||||
return 0, 0
|
return 0, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func adjustCursorPosition(x, y int) (int, int) {
|
||||||
|
return x, y
|
||||||
|
}
|
||||||
|
|
||||||
func SetCursorVisibility(visibility bool) {
|
func SetCursorVisibility(visibility bool) {
|
||||||
if visibility {
|
if visibility {
|
||||||
canvas.Get("style").Set("cursor", "auto")
|
canvas.Get("style").Set("cursor", "auto")
|
||||||
|
@ -110,6 +110,10 @@ func ScreenOffset() (float64, float64) {
|
|||||||
return 0, 0
|
return 0, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func adjustCursorPosition(x, y int) (int, int) {
|
||||||
|
return x, y
|
||||||
|
}
|
||||||
|
|
||||||
func SetCursorVisibility(visibility bool) {
|
func SetCursorVisibility(visibility bool) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user