updated ebiten version from 2.7.9 to 2.9.9

This commit is contained in:
2026-06-15 19:06:55 +02:00
parent 21edbc41c4
commit db1b625069
405 changed files with 31913 additions and 12595 deletions
+10 -106
View File
@@ -15,11 +15,9 @@
package ebiten
import (
"io/fs"
"sync"
"github.com/hajimehoshi/ebiten/v2/internal/gamepad"
"github.com/hajimehoshi/ebiten/v2/internal/gamepaddb"
"github.com/hajimehoshi/ebiten/v2/internal/inputstate"
"github.com/hajimehoshi/ebiten/v2/internal/ui"
)
@@ -36,7 +34,7 @@ import (
//
// On Android (ebitenmobile), EbitenView must be focusable to enable to handle keyboard keys.
func AppendInputChars(runes []rune) []rune {
return theInputState.appendInputChars(runes)
return inputstate.Get().AppendInputChars(runes)
}
// InputChars return "printable" runes read from the keyboard at the time Update is called.
@@ -58,7 +56,7 @@ func InputChars() []rune {
//
// On Android (ebitenmobile), EbitenView must be focusable to enable to handle keyboard keys.
func IsKeyPressed(key Key) bool {
return theInputState.isKeyPressed(key)
return inputstate.Get().IsKeyPressed(ui.Key(key))
}
// KeyName returns a key name for the current keyboard layout.
@@ -79,11 +77,11 @@ func KeyName(key Key) string {
//
// CursorPosition returns (0, 0) before the main loop on desktops and browsers.
//
// CursorPosition always returns (0, 0) on mobiles.
// CursorPosition always returns (0, 0) on mobile native applications.
//
// CursorPosition is concurrent-safe.
func CursorPosition() (x, y int) {
cx, cy := theInputState.cursorPosition()
cx, cy := inputstate.Get().CursorPosition()
return int(cx), int(cy)
}
@@ -92,7 +90,7 @@ func CursorPosition() (x, y int) {
//
// Wheel is concurrent-safe.
func Wheel() (xoff, yoff float64) {
return theInputState.wheel()
return inputstate.Get().Wheel()
}
// IsMouseButtonPressed returns a boolean indicating whether mouseButton is pressed.
@@ -102,7 +100,7 @@ func Wheel() (xoff, yoff float64) {
//
// IsMouseButtonPressed is concurrent-safe.
func IsMouseButtonPressed(mouseButton MouseButton) bool {
return theInputState.isMouseButtonPressed(mouseButton)
return inputstate.Get().IsMouseButtonPressed(ui.MouseButton(mouseButton))
}
// GamepadID represents a gamepad identifier.
@@ -350,7 +348,7 @@ func UpdateStandardGamepadLayoutMappings(mappings string) (bool, error) {
}
// TouchID represents a touch's identifier.
type TouchID = ui.TouchID
type TouchID int
// AppendTouchIDs appends the current touch states to touches, and returns the extended buffer.
// Giving a slice that already has enough capacity works efficiently.
@@ -363,7 +361,7 @@ type TouchID = ui.TouchID
//
// AppendTouchIDs is concurrent-safe.
func AppendTouchIDs(touches []TouchID) []TouchID {
return theInputState.appendTouchIDs(touches)
return inputstate.AppendTouchIDs(touches)
}
// TouchIDs returns the current touch states.
@@ -379,99 +377,5 @@ func TouchIDs() []TouchID {
//
// TouchPosition is concurrent-safe.
func TouchPosition(id TouchID) (int, int) {
return theInputState.touchPosition(id)
}
var theInputState inputState
type inputState struct {
state ui.InputState
m sync.Mutex
}
func (i *inputState) update(fn func(*ui.InputState)) {
i.m.Lock()
defer i.m.Unlock()
fn(&i.state)
}
func (i *inputState) appendInputChars(runes []rune) []rune {
i.m.Lock()
defer i.m.Unlock()
return append(runes, i.state.Runes...)
}
func (i *inputState) isKeyPressed(key Key) bool {
if !key.isValid() {
return false
}
i.m.Lock()
defer i.m.Unlock()
switch key {
case KeyAlt:
return i.state.KeyPressed[ui.KeyAltLeft] || i.state.KeyPressed[ui.KeyAltRight]
case KeyControl:
return i.state.KeyPressed[ui.KeyControlLeft] || i.state.KeyPressed[ui.KeyControlRight]
case KeyShift:
return i.state.KeyPressed[ui.KeyShiftLeft] || i.state.KeyPressed[ui.KeyShiftRight]
case KeyMeta:
return i.state.KeyPressed[ui.KeyMetaLeft] || i.state.KeyPressed[ui.KeyMetaRight]
default:
return i.state.KeyPressed[key]
}
}
func (i *inputState) cursorPosition() (float64, float64) {
i.m.Lock()
defer i.m.Unlock()
return i.state.CursorX, i.state.CursorY
}
func (i *inputState) wheel() (float64, float64) {
i.m.Lock()
defer i.m.Unlock()
return i.state.WheelX, i.state.WheelY
}
func (i *inputState) isMouseButtonPressed(mouseButton MouseButton) bool {
i.m.Lock()
defer i.m.Unlock()
return i.state.MouseButtonPressed[mouseButton]
}
func (i *inputState) appendTouchIDs(touches []TouchID) []TouchID {
i.m.Lock()
defer i.m.Unlock()
for _, t := range i.state.Touches {
touches = append(touches, t.ID)
}
return touches
}
func (i *inputState) touchPosition(id TouchID) (int, int) {
i.m.Lock()
defer i.m.Unlock()
for _, t := range i.state.Touches {
if id != t.ID {
continue
}
return t.X, t.Y
}
return 0, 0
}
func (i *inputState) windowBeingClosed() bool {
i.m.Lock()
defer i.m.Unlock()
return i.state.WindowBeingClosed
}
func (i *inputState) droppedFiles() fs.FS {
i.m.Lock()
defer i.m.Unlock()
return i.state.DroppedFiles
return inputstate.Get().TouchPosition(ui.TouchID(id))
}