remove go2cpp support

Closes #2126
This commit is contained in:
Hajime Hoshi 2022-08-07 22:17:47 +09:00
parent 3fe59e75cb
commit 72d5002e72
5 changed files with 7 additions and 59 deletions

View File

@ -19,10 +19,6 @@ import (
) )
func impl(x, y int) float64 { func impl(x, y int) float64 {
if go2cpp := js.Global().Get("go2cpp"); go2cpp.Truthy() {
return go2cpp.Get("devicePixelRatio").Float()
}
window := js.Global().Get("window") window := js.Global().Get("window")
if !window.Truthy() { if !window.Truthy() {
return 1 return 1

View File

@ -22,7 +22,6 @@ import (
var ( var (
object = js.Global().Get("Object") object = js.Global().Get("Object")
go2cpp = js.Global().Get("go2cpp")
) )
type nativeGamepadsImpl struct { type nativeGamepadsImpl struct {
@ -38,7 +37,7 @@ func (g *nativeGamepadsImpl) init(gamepads *gamepads) error {
} }
func (g *nativeGamepadsImpl) update(gamepads *gamepads) error { func (g *nativeGamepadsImpl) update(gamepads *gamepads) error {
// TODO: Use the gamepad events instead of navigator.getGamepads after go2cpp is removed. // TODO: Use the gamepad events instead of navigator.getGamepads.
defer func() { defer func() {
for k := range g.indices { for k := range g.indices {
@ -112,10 +111,6 @@ type nativeGamepadImpl struct {
} }
func (g *nativeGamepadImpl) hasOwnStandardLayoutMapping() bool { func (g *nativeGamepadImpl) hasOwnStandardLayoutMapping() bool {
// With go2cpp, the controller must have the standard
if go2cpp.Truthy() {
return true
}
return g.mapping == "standard" return g.mapping == "standard"
} }

View File

@ -96,7 +96,7 @@ const (
) )
var ( var (
webGL2MightBeAvailable = !forceWebGL1 && (js.Global().Get("WebGL2RenderingContext").Truthy() || js.Global().Get("go2cpp").Truthy()) webGL2MightBeAvailable = !forceWebGL1 && (js.Global().Get("WebGL2RenderingContext").Truthy())
) )
func uint8ArrayToSlice(value js.Value, length int) []byte { func uint8ArrayToSlice(value js.Value, length int) []byte {
@ -152,9 +152,6 @@ func (c *context) initGL() error {
if !gl.Truthy() { if !gl.Truthy() {
return fmt.Errorf("opengl: getContext failed") return fmt.Errorf("opengl: getContext failed")
} }
} else if go2cpp := js.Global().Get("go2cpp"); go2cpp.Truthy() {
gl = go2cpp.Get("gl")
c.webGLVersion = webGLVersion2
} }
c.gl = c.newGL(gl) c.gl = c.newGL(gl)

View File

@ -277,29 +277,6 @@ func (in *Input) updateTouchesFromEvent(e js.Value) {
} }
} }
func (i *Input) updateForGo2Cpp() {
if !go2cpp.Truthy() {
return
}
for k := range i.touches {
delete(i.touches, k)
}
touchCount := go2cpp.Get("touchCount").Int()
for idx := 0; idx < touchCount; idx++ {
id := go2cpp.Call("getTouchId", idx)
x := go2cpp.Call("getTouchX", idx)
y := go2cpp.Call("getTouchY", idx)
if i.touches == nil {
i.touches = map[TouchID]pos{}
}
i.touches[TouchID(id.Int())] = pos{
X: x.Int(),
Y: y.Int(),
}
}
}
func isKeyString(str string) bool { func isKeyString(str string) bool {
// From https://www.w3.org/TR/uievents-key/#keys-unicode, // From https://www.w3.org/TR/uievents-key/#keys-unicode,
// //

View File

@ -100,7 +100,6 @@ var (
canvas js.Value canvas js.Value
requestAnimationFrame = js.Global().Get("requestAnimationFrame") requestAnimationFrame = js.Global().Get("requestAnimationFrame")
setTimeout = js.Global().Get("setTimeout") setTimeout = js.Global().Get("setTimeout")
go2cpp = js.Global().Get("go2cpp")
) )
var ( var (
@ -109,9 +108,6 @@ var (
) )
func init() { func init() {
if go2cpp.Truthy() {
return
}
documentHasFocus = document.Get("hasFocus").Call("bind", document) documentHasFocus = document.Get("hasFocus").Call("bind", document)
documentHidden = js.Global().Get("Object").Call("getOwnPropertyDescriptor", js.Global().Get("Document").Get("prototype"), "hidden").Get("get").Call("bind", document) documentHidden = js.Global().Get("Object").Call("getOwnPropertyDescriptor", js.Global().Get("Document").Get("prototype"), "hidden").Get("get").Call("bind", document)
} }
@ -238,20 +234,15 @@ func (u *userInterfaceImpl) DeviceScaleFactor() float64 {
} }
func (u *userInterfaceImpl) outsideSize() (float64, float64) { func (u *userInterfaceImpl) outsideSize() (float64, float64) {
switch { if document.Truthy() {
case document.Truthy():
body := document.Get("body") body := document.Get("body")
bw := body.Get("clientWidth").Float() bw := body.Get("clientWidth").Float()
bh := body.Get("clientHeight").Float() bh := body.Get("clientHeight").Float()
return bw, bh return bw, bh
case go2cpp.Truthy():
w := go2cpp.Get("screenWidth").Float()
h := go2cpp.Get("screenHeight").Float()
return w, h
default:
// Node.js
return 640, 480
} }
// Node.js
return 640, 480
} }
func (u *userInterfaceImpl) suspended() bool { func (u *userInterfaceImpl) suspended() bool {
@ -262,10 +253,6 @@ func (u *userInterfaceImpl) suspended() bool {
} }
func (u *userInterfaceImpl) isFocused() bool { func (u *userInterfaceImpl) isFocused() bool {
if go2cpp.Truthy() {
return true
}
if !documentHasFocus.Invoke().Bool() { if !documentHasFocus.Invoke().Bool() {
return false return false
} }
@ -294,7 +281,6 @@ func (u *userInterfaceImpl) updateImpl(force bool) error {
if err := gamepad.Update(); err != nil { if err := gamepad.Update(); err != nil {
return err return err
} }
u.input.updateForGo2Cpp()
a := u.DeviceScaleFactor() a := u.DeviceScaleFactor()
if u.lastDeviceScaleFactor != a { if u.lastDeviceScaleFactor != a {
@ -618,15 +604,12 @@ func (u *userInterfaceImpl) Run(game Game) error {
} }
func (u *userInterfaceImpl) updateScreenSize() { func (u *userInterfaceImpl) updateScreenSize() {
switch { if document.Truthy() {
case document.Truthy():
body := document.Get("body") body := document.Get("body")
bw := int(body.Get("clientWidth").Float() * u.DeviceScaleFactor()) bw := int(body.Get("clientWidth").Float() * u.DeviceScaleFactor())
bh := int(body.Get("clientHeight").Float() * u.DeviceScaleFactor()) bh := int(body.Get("clientHeight").Float() * u.DeviceScaleFactor())
canvas.Set("width", bw) canvas.Set("width", bw)
canvas.Set("height", bh) canvas.Set("height", bh)
case go2cpp.Truthy():
// TODO: Implement this
} }
} }