mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
Avoid comparing to js.Undefined() for consistency
This commit is contained in:
parent
5d8c39028c
commit
4df958c9fd
@ -98,7 +98,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if !jsutil.Equal(js.Global().Get("WebGL2RenderingContext"), js.Undefined()) {
|
if js.Global().Get("WebGL2RenderingContext").Truthy() {
|
||||||
isWebGL2Available = true
|
isWebGL2Available = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/jsutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type pos struct {
|
type pos struct {
|
||||||
@ -245,7 +244,7 @@ func (i *Input) setMouseCursor(x, y int) {
|
|||||||
|
|
||||||
func (i *Input) UpdateGamepads() {
|
func (i *Input) UpdateGamepads() {
|
||||||
nav := js.Global().Get("navigator")
|
nav := js.Global().Get("navigator")
|
||||||
if jsutil.Equal(nav.Get("getGamepads"), js.Undefined()) {
|
if !nav.Get("getGamepads").Truthy() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
gamepads := nav.Call("getGamepads")
|
gamepads := nav.Call("getGamepads")
|
||||||
@ -253,7 +252,7 @@ func (i *Input) UpdateGamepads() {
|
|||||||
for id := 0; id < l; id++ {
|
for id := 0; id < l; id++ {
|
||||||
i.gamepads[id].valid = false
|
i.gamepads[id].valid = false
|
||||||
gamepad := gamepads.Index(id)
|
gamepad := gamepads.Index(id)
|
||||||
if jsutil.Equal(gamepad, js.Undefined()) || jsutil.Equal(gamepad, js.Null()) {
|
if !gamepad.Truthy() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
i.gamepads[id].valid = true
|
i.gamepads[id].valid = true
|
||||||
@ -287,7 +286,7 @@ func (i *Input) Update(e js.Value) {
|
|||||||
switch e.Get("type").String() {
|
switch e.Get("type").String() {
|
||||||
case "keydown":
|
case "keydown":
|
||||||
c := e.Get("code")
|
c := e.Get("code")
|
||||||
if jsutil.Equal(c, js.Undefined()) {
|
if c.Type() != js.TypeString {
|
||||||
code := e.Get("keyCode").Int()
|
code := e.Get("keyCode").Int()
|
||||||
if edgeKeyCodeToDriverKey[code] == driver.KeyUp ||
|
if edgeKeyCodeToDriverKey[code] == driver.KeyUp ||
|
||||||
edgeKeyCodeToDriverKey[code] == driver.KeyDown ||
|
edgeKeyCodeToDriverKey[code] == driver.KeyDown ||
|
||||||
@ -315,7 +314,7 @@ func (i *Input) Update(e js.Value) {
|
|||||||
i.runeBuffer = append(i.runeBuffer, r)
|
i.runeBuffer = append(i.runeBuffer, r)
|
||||||
}
|
}
|
||||||
case "keyup":
|
case "keyup":
|
||||||
if jsutil.Equal(e.Get("code"), js.Undefined()) {
|
if e.Get("code").Type() != js.TypeString {
|
||||||
// Assume that UA is Edge.
|
// Assume that UA is Edge.
|
||||||
code := e.Get("keyCode").Int()
|
code := e.Get("keyCode").Int()
|
||||||
i.keyUpEdge(code)
|
i.keyUpEdge(code)
|
||||||
|
Loading…
Reference in New Issue
Block a user