mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
parent
887a3ff749
commit
80c03792cb
197
genkeys.go
197
genkeys.go
@ -33,13 +33,13 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
glfwKeyNameToGLFWKey map[string]glfw.Key
|
||||
driverKeyNameToGLFWKeyName map[string]string
|
||||
androidKeyToDriverKeyName map[int]string
|
||||
gbuildKeyToDriverKeyName map[key.Code]string
|
||||
driverKeyNameToJSKey map[string]string
|
||||
edgeKeyCodeToName map[int]string
|
||||
oldEbitenKeyNameToDriverKeyName map[string]string
|
||||
glfwKeyNameToGLFWKey map[string]glfw.Key
|
||||
uiKeyNameToGLFWKeyName map[string]string
|
||||
androidKeyToUIKeyName map[int]string
|
||||
gbuildKeyToUIKeyName map[key.Code]string
|
||||
uiKeyNameToJSKey map[string]string
|
||||
edgeKeyCodeToName map[int]string
|
||||
oldEbitenKeyNameToUIKeyName map[string]string
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -97,7 +97,7 @@ func init() {
|
||||
"Last": glfw.KeyLast,
|
||||
}
|
||||
|
||||
driverKeyNameToGLFWKeyName = map[string]string{
|
||||
uiKeyNameToGLFWKeyName = map[string]string{
|
||||
"Space": "Space",
|
||||
"Quote": "Apostrophe",
|
||||
"Comma": "Comma",
|
||||
@ -148,7 +148,7 @@ func init() {
|
||||
}
|
||||
|
||||
// https://developer.android.com/reference/android/view/KeyEvent
|
||||
androidKeyToDriverKeyName = map[int]string{
|
||||
androidKeyToUIKeyName = map[int]string{
|
||||
55: "Comma",
|
||||
56: "Period",
|
||||
57: "AltLeft",
|
||||
@ -198,7 +198,7 @@ func init() {
|
||||
118: "MetaRight",
|
||||
}
|
||||
|
||||
gbuildKeyToDriverKeyName = map[key.Code]string{
|
||||
gbuildKeyToUIKeyName = map[key.Code]string{
|
||||
key.CodeComma: "Comma",
|
||||
key.CodeFullStop: "Period",
|
||||
key.CodeLeftAlt: "AltLeft",
|
||||
@ -245,13 +245,13 @@ func init() {
|
||||
key.CodeRightGUI: "MetaRight",
|
||||
|
||||
// Missing keys:
|
||||
// driver.KeyPrintScreen
|
||||
// driver.KeyScrollLock
|
||||
// driver.KeyMenu
|
||||
// ui.KeyPrintScreen
|
||||
// ui.KeyScrollLock
|
||||
// ui.KeyMenu
|
||||
}
|
||||
|
||||
// The driver key and JS key are almost same but very slightly different (e.g., 'A' vs 'KeyA').
|
||||
driverKeyNameToJSKey = map[string]string{
|
||||
// The UI key and JS key are almost same but very slightly different (e.g., 'A' vs 'KeyA').
|
||||
uiKeyNameToJSKey = map[string]string{
|
||||
"Comma": "Comma",
|
||||
"Period": "Period",
|
||||
"AltLeft": "AltLeft",
|
||||
@ -305,53 +305,53 @@ func init() {
|
||||
for c := '0'; c <= '9'; c++ {
|
||||
glfwKeyNameToGLFWKey[string(c)] = glfw.Key0 + glfw.Key(c) - '0'
|
||||
name := "Digit" + string(c)
|
||||
driverKeyNameToGLFWKeyName[name] = string(c)
|
||||
androidKeyToDriverKeyName[7+int(c)-'0'] = name
|
||||
uiKeyNameToGLFWKeyName[name] = string(c)
|
||||
androidKeyToUIKeyName[7+int(c)-'0'] = name
|
||||
// Gomobile's key code (= USB HID key codes) has successive key codes for 1, 2, ..., 9, 0
|
||||
// in this order.
|
||||
if c == '0' {
|
||||
gbuildKeyToDriverKeyName[key.Code0] = name
|
||||
gbuildKeyToUIKeyName[key.Code0] = name
|
||||
} else {
|
||||
gbuildKeyToDriverKeyName[key.Code1+key.Code(c)-'1'] = name
|
||||
gbuildKeyToUIKeyName[key.Code1+key.Code(c)-'1'] = name
|
||||
}
|
||||
driverKeyNameToJSKey[name] = name
|
||||
uiKeyNameToJSKey[name] = name
|
||||
}
|
||||
// ASCII: A - Z
|
||||
for c := 'A'; c <= 'Z'; c++ {
|
||||
glfwKeyNameToGLFWKey[string(c)] = glfw.KeyA + glfw.Key(c) - 'A'
|
||||
driverKeyNameToGLFWKeyName[string(c)] = string(c)
|
||||
androidKeyToDriverKeyName[29+int(c)-'A'] = string(c)
|
||||
gbuildKeyToDriverKeyName[key.CodeA+key.Code(c)-'A'] = string(c)
|
||||
driverKeyNameToJSKey[string(c)] = "Key" + string(c)
|
||||
uiKeyNameToGLFWKeyName[string(c)] = string(c)
|
||||
androidKeyToUIKeyName[29+int(c)-'A'] = string(c)
|
||||
gbuildKeyToUIKeyName[key.CodeA+key.Code(c)-'A'] = string(c)
|
||||
uiKeyNameToJSKey[string(c)] = "Key" + string(c)
|
||||
}
|
||||
// Function keys
|
||||
for i := 1; i <= 12; i++ {
|
||||
name := "F" + strconv.Itoa(i)
|
||||
glfwKeyNameToGLFWKey[name] = glfw.KeyF1 + glfw.Key(i) - 1
|
||||
driverKeyNameToGLFWKeyName[name] = name
|
||||
androidKeyToDriverKeyName[131+i-1] = name
|
||||
gbuildKeyToDriverKeyName[key.CodeF1+key.Code(i)-1] = name
|
||||
driverKeyNameToJSKey[name] = name
|
||||
uiKeyNameToGLFWKeyName[name] = name
|
||||
androidKeyToUIKeyName[131+i-1] = name
|
||||
gbuildKeyToUIKeyName[key.CodeF1+key.Code(i)-1] = name
|
||||
uiKeyNameToJSKey[name] = name
|
||||
}
|
||||
// Numpad
|
||||
// https://www.w3.org/TR/uievents-code/#key-numpad-section
|
||||
for c := '0'; c <= '9'; c++ {
|
||||
name := "Numpad" + string(c)
|
||||
glfwKeyNameToGLFWKey["KP"+string(c)] = glfw.KeyKP0 + glfw.Key(c) - '0'
|
||||
driverKeyNameToGLFWKeyName[name] = "KP" + string(c)
|
||||
androidKeyToDriverKeyName[144+int(c)-'0'] = name
|
||||
uiKeyNameToGLFWKeyName[name] = "KP" + string(c)
|
||||
androidKeyToUIKeyName[144+int(c)-'0'] = name
|
||||
// Gomobile's key code (= USB HID key codes) has successive key codes for 1, 2, ..., 9, 0
|
||||
// in this order.
|
||||
if c == '0' {
|
||||
gbuildKeyToDriverKeyName[key.CodeKeypad0] = name
|
||||
gbuildKeyToUIKeyName[key.CodeKeypad0] = name
|
||||
} else {
|
||||
gbuildKeyToDriverKeyName[key.CodeKeypad1+key.Code(c)-'1'] = name
|
||||
gbuildKeyToUIKeyName[key.CodeKeypad1+key.Code(c)-'1'] = name
|
||||
}
|
||||
driverKeyNameToJSKey[name] = name
|
||||
uiKeyNameToJSKey[name] = name
|
||||
}
|
||||
|
||||
// Keys for backward compatibility
|
||||
oldEbitenKeyNameToDriverKeyName = map[string]string{
|
||||
oldEbitenKeyNameToUIKeyName = map[string]string{
|
||||
"0": "Digit0",
|
||||
"1": "Digit1",
|
||||
"2": "Digit2",
|
||||
@ -470,7 +470,7 @@ package ebiten
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/ui"
|
||||
)
|
||||
|
||||
// A Key represents a keyboard key.
|
||||
@ -480,16 +480,16 @@ type Key int
|
||||
|
||||
// Keys.
|
||||
const (
|
||||
{{range $index, $name := .EbitenKeyNamesWithoutMods}}Key{{$name}} Key = Key(driver.Key{{$name}})
|
||||
{{end}} KeyAlt Key = Key(driver.KeyReserved0)
|
||||
KeyControl Key = Key(driver.KeyReserved1)
|
||||
KeyShift Key = Key(driver.KeyReserved2)
|
||||
KeyMeta Key = Key(driver.KeyReserved3)
|
||||
{{range $index, $name := .EbitenKeyNamesWithoutMods}}Key{{$name}} Key = Key(ui.Key{{$name}})
|
||||
{{end}} KeyAlt Key = Key(ui.KeyReserved0)
|
||||
KeyControl Key = Key(ui.KeyReserved1)
|
||||
KeyShift Key = Key(ui.KeyReserved2)
|
||||
KeyMeta Key = Key(ui.KeyReserved3)
|
||||
KeyMax Key = KeyMeta
|
||||
|
||||
// Keys for backward compatibility.
|
||||
// Deprecated: as of v2.1.
|
||||
{{range $old, $new := .OldEbitenKeyNameToDriverKeyName}}Key{{$old}} Key = Key(driver.Key{{$new}})
|
||||
{{range $old, $new := .OldEbitenKeyNameToUIKeyName}}Key{{$old}} Key = Key(ui.Key{{$new}})
|
||||
{{end}}
|
||||
)
|
||||
|
||||
@ -523,11 +523,11 @@ func keyNameToKeyCode(name string) (Key, bool) {
|
||||
}
|
||||
`
|
||||
|
||||
const driverKeysTmpl = `{{.License}}
|
||||
const uiKeysTmpl = `{{.License}}
|
||||
|
||||
{{.DoNotEdit}}
|
||||
|
||||
package driver
|
||||
package ui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -536,7 +536,7 @@ import (
|
||||
type Key int
|
||||
|
||||
const (
|
||||
{{range $index, $name := .DriverKeyNames}}Key{{$name}}{{if eq $index 0}} Key = iota{{end}}
|
||||
{{range $index, $name := .UIKeyNames}}Key{{$name}}{{if eq $index 0}} Key = iota{{end}}
|
||||
{{end}} KeyReserved0
|
||||
KeyReserved1
|
||||
KeyReserved2
|
||||
@ -545,10 +545,10 @@ const (
|
||||
|
||||
func (k Key) String() string {
|
||||
switch k {
|
||||
{{range $index, $name := .DriverKeyNames}}case Key{{$name}}:
|
||||
{{range $index, $name := .UIKeyNames}}case Key{{$name}}:
|
||||
return {{$name | printf "Key%s" | printf "%q"}}
|
||||
{{end}}}
|
||||
panic(fmt.Sprintf("driver: invalid key: %d", k))
|
||||
panic(fmt.Sprintf("ui: invalid key: %d", k))
|
||||
}
|
||||
`
|
||||
|
||||
@ -559,13 +559,13 @@ const eventKeysTmpl = `{{.License}}
|
||||
package event
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/ui"
|
||||
)
|
||||
|
||||
type Key = driver.Key
|
||||
type Key = ui.Key
|
||||
|
||||
const (
|
||||
{{range $index, $name := .DriverKeyNames}}Key{{$name}} = driver.Key{{$name}}
|
||||
{{range $index, $name := .UIKeyNames}}Key{{$name}} = ui.Key{{$name}}
|
||||
{{end}}
|
||||
)
|
||||
`
|
||||
@ -579,17 +579,16 @@ const uiGLFWKeysTmpl = `{{.License}}
|
||||
package ui
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/glfw"
|
||||
)
|
||||
|
||||
var glfwKeyToDriverKey = map[glfw.Key]driver.Key{
|
||||
{{range $dname, $gname := .DriverKeyNameToGLFWKeyName}}glfw.Key{{$gname}}: driver.Key{{$dname}},
|
||||
var glfwKeyToUIKey = map[glfw.Key]Key{
|
||||
{{range $dname, $gname := .UIKeyNameToGLFWKeyName}}glfw.Key{{$gname}}: Key{{$dname}},
|
||||
{{end}}
|
||||
}
|
||||
|
||||
var driverKeyToGLFWKey = map[driver.Key]glfw.Key{
|
||||
{{range $dname, $gname := .DriverKeyNameToGLFWKeyName}}driver.Key{{$dname}}: glfw.Key{{$gname}},
|
||||
var uiKeyToGLFWKey = map[Key]glfw.Key{
|
||||
{{range $dname, $gname := .UIKeyNameToGLFWKeyName}}Key{{$dname}}: glfw.Key{{$gname}},
|
||||
{{end}}
|
||||
}
|
||||
`
|
||||
@ -604,17 +603,15 @@ package ui
|
||||
|
||||
import (
|
||||
"syscall/js"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
)
|
||||
|
||||
var driverKeyToJSKey = map[driver.Key]js.Value{
|
||||
{{range $name, $code := .DriverKeyNameToJSKey}}driver.Key{{$name}}: js.ValueOf({{$code | printf "%q"}}),
|
||||
var uiKeyToJSKey = map[Key]js.Value{
|
||||
{{range $name, $code := .UIKeyNameToJSKey}}Key{{$name}}: js.ValueOf({{$code | printf "%q"}}),
|
||||
{{end}}
|
||||
}
|
||||
|
||||
var edgeKeyCodeToDriverKey = map[int]driver.Key{
|
||||
{{range $code, $name := .EdgeKeyCodeToName}}{{$code}}: driver.Key{{$name}},
|
||||
var edgeKeyCodeToUIKey = map[int]Key{
|
||||
{{range $code, $name := .EdgeKeyCodeToName}}{{$code}}: Key{{$name}},
|
||||
{{end}}
|
||||
}
|
||||
`
|
||||
@ -642,11 +639,11 @@ const mobileAndroidKeysTmpl = `{{.License}}
|
||||
package ebitenmobileview
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/ui"
|
||||
)
|
||||
|
||||
var androidKeyToDriverKey = map[int]driver.Key{
|
||||
{{range $key, $name := .AndroidKeyToDriverKeyName}}{{$key}}: driver.Key{{$name}},
|
||||
var androidKeyToUIKey = map[int]ui.Key{
|
||||
{{range $key, $name := .AndroidKeyToUIKeyName}}{{$key}}: ui.Key{{$name}},
|
||||
{{end}}
|
||||
}
|
||||
`
|
||||
@ -661,12 +658,10 @@ package ui
|
||||
|
||||
import (
|
||||
"golang.org/x/mobile/event/key"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
)
|
||||
|
||||
var gbuildKeyToDriverKey = map[key.Code]driver.Key{
|
||||
{{range $key, $name := .GBuildKeyToDriverKeyName}}key.{{$key}}: driver.Key{{$name}},
|
||||
var gbuildKeyToUIKey = map[key.Code]Key{
|
||||
{{range $key, $name := .GBuildKeyToUIKeyName}}key.{{$key}}: Key{{$name}},
|
||||
{{end}}
|
||||
}
|
||||
`
|
||||
@ -763,15 +758,15 @@ func main() {
|
||||
ebitenKeyNames := []string{}
|
||||
ebitenKeyNamesWithoutOld := []string{}
|
||||
ebitenKeyNamesWithoutMods := []string{}
|
||||
driverKeyNames := []string{}
|
||||
uiKeyNames := []string{}
|
||||
|
||||
for name := range driverKeyNameToJSKey {
|
||||
driverKeyNames = append(driverKeyNames, name)
|
||||
for name := range uiKeyNameToJSKey {
|
||||
uiKeyNames = append(uiKeyNames, name)
|
||||
ebitenKeyNames = append(ebitenKeyNames, name)
|
||||
ebitenKeyNamesWithoutOld = append(ebitenKeyNamesWithoutOld, name)
|
||||
ebitenKeyNamesWithoutMods = append(ebitenKeyNamesWithoutMods, name)
|
||||
}
|
||||
for old := range oldEbitenKeyNameToDriverKeyName {
|
||||
for old := range oldEbitenKeyNameToUIKeyName {
|
||||
ebitenKeyNames = append(ebitenKeyNames, old)
|
||||
}
|
||||
// Keys for modifiers
|
||||
@ -781,15 +776,15 @@ func main() {
|
||||
sort.Slice(ebitenKeyNames, keyNamesLess(ebitenKeyNames))
|
||||
sort.Slice(ebitenKeyNamesWithoutOld, keyNamesLess(ebitenKeyNamesWithoutOld))
|
||||
sort.Slice(ebitenKeyNamesWithoutMods, keyNamesLess(ebitenKeyNamesWithoutMods))
|
||||
sort.Slice(driverKeyNames, keyNamesLess(driverKeyNames))
|
||||
sort.Slice(uiKeyNames, keyNamesLess(uiKeyNames))
|
||||
|
||||
// TODO: Add this line for event package (#926).
|
||||
//
|
||||
// filepath.Join("event", "keys.go"): eventKeysTmpl,
|
||||
|
||||
for path, tmpl := range map[string]string{
|
||||
filepath.Join("internal", "driver", "keys.go"): driverKeysTmpl,
|
||||
filepath.Join("internal", "glfw", "keys.go"): glfwKeysTmpl,
|
||||
filepath.Join("internal", "ui", "keys.go"): uiKeysTmpl,
|
||||
filepath.Join("internal", "ui", "keys_glfw.go"): uiGLFWKeysTmpl,
|
||||
filepath.Join("internal", "ui", "keys_mobile.go"): uiMobileKeysTmpl,
|
||||
filepath.Join("internal", "ui", "keys_js.go"): uiJSKeysTmpl,
|
||||
@ -827,35 +822,35 @@ func main() {
|
||||
}
|
||||
// NOTE: According to godoc, maps are automatically sorted by key.
|
||||
if err := tmpl.Execute(f, struct {
|
||||
License string
|
||||
DoNotEdit string
|
||||
BuildTag string
|
||||
DriverKeyNameToJSKey map[string]string
|
||||
EdgeKeyCodeToName map[int]string
|
||||
EbitenKeyNames []string
|
||||
EbitenKeyNamesWithoutOld []string
|
||||
EbitenKeyNamesWithoutMods []string
|
||||
GLFWKeyNameToGLFWKey map[string]glfw.Key
|
||||
DriverKeyNames []string
|
||||
DriverKeyNameToGLFWKeyName map[string]string
|
||||
AndroidKeyToDriverKeyName map[int]string
|
||||
GBuildKeyToDriverKeyName map[key.Code]string
|
||||
OldEbitenKeyNameToDriverKeyName map[string]string
|
||||
License string
|
||||
DoNotEdit string
|
||||
BuildTag string
|
||||
UIKeyNameToJSKey map[string]string
|
||||
EdgeKeyCodeToName map[int]string
|
||||
EbitenKeyNames []string
|
||||
EbitenKeyNamesWithoutOld []string
|
||||
EbitenKeyNamesWithoutMods []string
|
||||
GLFWKeyNameToGLFWKey map[string]glfw.Key
|
||||
UIKeyNames []string
|
||||
UIKeyNameToGLFWKeyName map[string]string
|
||||
AndroidKeyToUIKeyName map[int]string
|
||||
GBuildKeyToUIKeyName map[key.Code]string
|
||||
OldEbitenKeyNameToUIKeyName map[string]string
|
||||
}{
|
||||
License: license,
|
||||
DoNotEdit: doNotEdit,
|
||||
BuildTag: buildTag,
|
||||
DriverKeyNameToJSKey: driverKeyNameToJSKey,
|
||||
EdgeKeyCodeToName: edgeKeyCodeToName,
|
||||
EbitenKeyNames: ebitenKeyNames,
|
||||
EbitenKeyNamesWithoutOld: ebitenKeyNamesWithoutOld,
|
||||
EbitenKeyNamesWithoutMods: ebitenKeyNamesWithoutMods,
|
||||
GLFWKeyNameToGLFWKey: glfwKeyNameToGLFWKey,
|
||||
DriverKeyNames: driverKeyNames,
|
||||
DriverKeyNameToGLFWKeyName: driverKeyNameToGLFWKeyName,
|
||||
AndroidKeyToDriverKeyName: androidKeyToDriverKeyName,
|
||||
GBuildKeyToDriverKeyName: gbuildKeyToDriverKeyName,
|
||||
OldEbitenKeyNameToDriverKeyName: oldEbitenKeyNameToDriverKeyName,
|
||||
License: license,
|
||||
DoNotEdit: doNotEdit,
|
||||
BuildTag: buildTag,
|
||||
UIKeyNameToJSKey: uiKeyNameToJSKey,
|
||||
EdgeKeyCodeToName: edgeKeyCodeToName,
|
||||
EbitenKeyNames: ebitenKeyNames,
|
||||
EbitenKeyNamesWithoutOld: ebitenKeyNamesWithoutOld,
|
||||
EbitenKeyNamesWithoutMods: ebitenKeyNamesWithoutMods,
|
||||
GLFWKeyNameToGLFWKey: glfwKeyNameToGLFWKey,
|
||||
UIKeyNames: uiKeyNames,
|
||||
UIKeyNameToGLFWKeyName: uiKeyNameToGLFWKeyName,
|
||||
AndroidKeyToUIKeyName: androidKeyToUIKeyName,
|
||||
GBuildKeyToUIKeyName: gbuildKeyToUIKeyName,
|
||||
OldEbitenKeyNameToUIKeyName: oldEbitenKeyNameToUIKeyName,
|
||||
}); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
13
input.go
13
input.go
@ -15,7 +15,6 @@
|
||||
package ebiten
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/gamepad"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/gamepaddb"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/ui"
|
||||
@ -69,18 +68,18 @@ func IsKeyPressed(key Key) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
var keys []driver.Key
|
||||
var keys []ui.Key
|
||||
switch key {
|
||||
case KeyAlt:
|
||||
keys = []driver.Key{driver.KeyAltLeft, driver.KeyAltRight}
|
||||
keys = []ui.Key{ui.KeyAltLeft, ui.KeyAltRight}
|
||||
case KeyControl:
|
||||
keys = []driver.Key{driver.KeyControlLeft, driver.KeyControlRight}
|
||||
keys = []ui.Key{ui.KeyControlLeft, ui.KeyControlRight}
|
||||
case KeyShift:
|
||||
keys = []driver.Key{driver.KeyShiftLeft, driver.KeyShiftRight}
|
||||
keys = []ui.Key{ui.KeyShiftLeft, ui.KeyShiftRight}
|
||||
case KeyMeta:
|
||||
keys = []driver.Key{driver.KeyMetaLeft, driver.KeyMetaRight}
|
||||
keys = []ui.Key{ui.KeyMetaLeft, ui.KeyMetaRight}
|
||||
default:
|
||||
keys = []driver.Key{driver.Key(key)}
|
||||
keys = []ui.Key{ui.Key(key)}
|
||||
}
|
||||
for _, k := range keys {
|
||||
if ui.Get().Input().IsKeyPressed(k) {
|
||||
|
@ -21,7 +21,6 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/cbackend"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/gamepad"
|
||||
)
|
||||
|
||||
@ -66,7 +65,7 @@ func (i *Input) CursorPosition() (x, y int) {
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
func (i *Input) IsKeyPressed(key driver.Key) bool {
|
||||
func (i *Input) IsKeyPressed(key Key) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,6 @@ import (
|
||||
"sync"
|
||||
"unicode"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/gamepad"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/glfw"
|
||||
)
|
||||
@ -104,7 +103,7 @@ func (i *Input) resetForFrame() {
|
||||
i.scrollX, i.scrollY = 0, 0
|
||||
}
|
||||
|
||||
func (i *Input) IsKeyPressed(key driver.Key) bool {
|
||||
func (i *Input) IsKeyPressed(key Key) bool {
|
||||
if !i.ui.isRunning() {
|
||||
return false
|
||||
}
|
||||
@ -114,7 +113,7 @@ func (i *Input) IsKeyPressed(key driver.Key) bool {
|
||||
if i.keyPressed == nil {
|
||||
i.keyPressed = map[glfw.Key]bool{}
|
||||
}
|
||||
gk, ok := driverKeyToGLFWKey[key]
|
||||
gk, ok := uiKeyToGLFWKey[key]
|
||||
return ok && i.keyPressed[gk]
|
||||
}
|
||||
|
||||
@ -182,7 +181,7 @@ func (i *Input) update(window *glfw.Window, context Context) error {
|
||||
if i.keyPressed == nil {
|
||||
i.keyPressed = map[glfw.Key]bool{}
|
||||
}
|
||||
for gk := range glfwKeyToDriverKey {
|
||||
for gk := range glfwKeyToUIKey {
|
||||
i.keyPressed[gk] = window.GetKey(gk) == glfw.Press
|
||||
}
|
||||
if i.mouseButtonPressed == nil {
|
||||
|
@ -17,8 +17,6 @@ package ui
|
||||
import (
|
||||
"syscall/js"
|
||||
"unicode"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -37,7 +35,7 @@ var (
|
||||
var jsKeys []js.Value
|
||||
|
||||
func init() {
|
||||
for _, k := range driverKeyToJSKey {
|
||||
for _, k := range uiKeyToJSKey {
|
||||
jsKeys = append(jsKeys, k)
|
||||
}
|
||||
}
|
||||
@ -109,14 +107,14 @@ func (i *Input) resetForFrame() {
|
||||
i.wheelY = 0
|
||||
}
|
||||
|
||||
func (i *Input) IsKeyPressed(key driver.Key) bool {
|
||||
func (i *Input) IsKeyPressed(key Key) bool {
|
||||
if i.keyPressed != nil {
|
||||
if i.keyPressed[jsKeyToID(driverKeyToJSKey[key])] {
|
||||
if i.keyPressed[jsKeyToID(uiKeyToJSKey[key])] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
if i.keyPressedEdge != nil {
|
||||
for c, k := range edgeKeyCodeToDriverKey {
|
||||
for c, k := range edgeKeyCodeToUIKey {
|
||||
if k != key {
|
||||
continue
|
||||
}
|
||||
@ -203,23 +201,23 @@ func (i *Input) updateFromEvent(e js.Value) {
|
||||
c := e.Get("code")
|
||||
if c.Type() != js.TypeString {
|
||||
code := e.Get("keyCode").Int()
|
||||
if edgeKeyCodeToDriverKey[code] == driver.KeyArrowUp ||
|
||||
edgeKeyCodeToDriverKey[code] == driver.KeyArrowDown ||
|
||||
edgeKeyCodeToDriverKey[code] == driver.KeyArrowLeft ||
|
||||
edgeKeyCodeToDriverKey[code] == driver.KeyArrowRight ||
|
||||
edgeKeyCodeToDriverKey[code] == driver.KeyBackspace ||
|
||||
edgeKeyCodeToDriverKey[code] == driver.KeyTab {
|
||||
if edgeKeyCodeToUIKey[code] == KeyArrowUp ||
|
||||
edgeKeyCodeToUIKey[code] == KeyArrowDown ||
|
||||
edgeKeyCodeToUIKey[code] == KeyArrowLeft ||
|
||||
edgeKeyCodeToUIKey[code] == KeyArrowRight ||
|
||||
edgeKeyCodeToUIKey[code] == KeyBackspace ||
|
||||
edgeKeyCodeToUIKey[code] == KeyTab {
|
||||
e.Call("preventDefault")
|
||||
}
|
||||
i.keyDownEdge(code)
|
||||
return
|
||||
}
|
||||
if c.Equal(driverKeyToJSKey[driver.KeyArrowUp]) ||
|
||||
c.Equal(driverKeyToJSKey[driver.KeyArrowDown]) ||
|
||||
c.Equal(driverKeyToJSKey[driver.KeyArrowLeft]) ||
|
||||
c.Equal(driverKeyToJSKey[driver.KeyArrowRight]) ||
|
||||
c.Equal(driverKeyToJSKey[driver.KeyBackspace]) ||
|
||||
c.Equal(driverKeyToJSKey[driver.KeyTab]) {
|
||||
if c.Equal(uiKeyToJSKey[KeyArrowUp]) ||
|
||||
c.Equal(uiKeyToJSKey[KeyArrowDown]) ||
|
||||
c.Equal(uiKeyToJSKey[KeyArrowLeft]) ||
|
||||
c.Equal(uiKeyToJSKey[KeyArrowRight]) ||
|
||||
c.Equal(uiKeyToJSKey[KeyBackspace]) ||
|
||||
c.Equal(uiKeyToJSKey[KeyTab]) {
|
||||
e.Call("preventDefault")
|
||||
}
|
||||
i.keyDown(c)
|
||||
|
@ -18,12 +18,8 @@
|
||||
|
||||
package ui
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
)
|
||||
|
||||
type Input struct {
|
||||
keys map[driver.Key]struct{}
|
||||
keys map[Key]struct{}
|
||||
runes []rune
|
||||
touches []Touch
|
||||
ui *UserInterface
|
||||
@ -61,7 +57,7 @@ func (i *Input) AppendInputChars(runes []rune) []rune {
|
||||
return append(runes, i.runes...)
|
||||
}
|
||||
|
||||
func (i *Input) IsKeyPressed(key driver.Key) bool {
|
||||
func (i *Input) IsKeyPressed(key Key) bool {
|
||||
i.ui.m.RLock()
|
||||
defer i.ui.m.RUnlock()
|
||||
|
||||
@ -77,12 +73,12 @@ func (i *Input) IsMouseButtonPressed(key MouseButton) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (i *Input) update(keys map[driver.Key]struct{}, runes []rune, touches []Touch) {
|
||||
func (i *Input) update(keys map[Key]struct{}, runes []rune, touches []Touch) {
|
||||
i.ui.m.Lock()
|
||||
defer i.ui.m.Unlock()
|
||||
|
||||
if i.keys == nil {
|
||||
i.keys = map[driver.Key]struct{}{}
|
||||
i.keys = map[Key]struct{}{}
|
||||
}
|
||||
for k := range i.keys {
|
||||
delete(i.keys, k)
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
// Code generated by genkeys.go using 'go generate'. DO NOT EDIT.
|
||||
|
||||
package driver
|
||||
package ui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -347,5 +347,5 @@ func (k Key) String() string {
|
||||
case KeyTab:
|
||||
return "KeyTab"
|
||||
}
|
||||
panic(fmt.Sprintf("driver: invalid key: %d", k))
|
||||
panic(fmt.Sprintf("ui: invalid key: %d", k))
|
||||
}
|
@ -20,222 +20,221 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/glfw"
|
||||
)
|
||||
|
||||
var glfwKeyToDriverKey = map[glfw.Key]driver.Key{
|
||||
glfw.KeyA: driver.KeyA,
|
||||
glfw.KeyLeftAlt: driver.KeyAltLeft,
|
||||
glfw.KeyRightAlt: driver.KeyAltRight,
|
||||
glfw.KeyDown: driver.KeyArrowDown,
|
||||
glfw.KeyLeft: driver.KeyArrowLeft,
|
||||
glfw.KeyRight: driver.KeyArrowRight,
|
||||
glfw.KeyUp: driver.KeyArrowUp,
|
||||
glfw.KeyB: driver.KeyB,
|
||||
glfw.KeyGraveAccent: driver.KeyBackquote,
|
||||
glfw.KeyBackslash: driver.KeyBackslash,
|
||||
glfw.KeyBackspace: driver.KeyBackspace,
|
||||
glfw.KeyLeftBracket: driver.KeyBracketLeft,
|
||||
glfw.KeyRightBracket: driver.KeyBracketRight,
|
||||
glfw.KeyC: driver.KeyC,
|
||||
glfw.KeyCapsLock: driver.KeyCapsLock,
|
||||
glfw.KeyComma: driver.KeyComma,
|
||||
glfw.KeyMenu: driver.KeyContextMenu,
|
||||
glfw.KeyLeftControl: driver.KeyControlLeft,
|
||||
glfw.KeyRightControl: driver.KeyControlRight,
|
||||
glfw.KeyD: driver.KeyD,
|
||||
glfw.KeyDelete: driver.KeyDelete,
|
||||
glfw.Key0: driver.KeyDigit0,
|
||||
glfw.Key1: driver.KeyDigit1,
|
||||
glfw.Key2: driver.KeyDigit2,
|
||||
glfw.Key3: driver.KeyDigit3,
|
||||
glfw.Key4: driver.KeyDigit4,
|
||||
glfw.Key5: driver.KeyDigit5,
|
||||
glfw.Key6: driver.KeyDigit6,
|
||||
glfw.Key7: driver.KeyDigit7,
|
||||
glfw.Key8: driver.KeyDigit8,
|
||||
glfw.Key9: driver.KeyDigit9,
|
||||
glfw.KeyE: driver.KeyE,
|
||||
glfw.KeyEnd: driver.KeyEnd,
|
||||
glfw.KeyEnter: driver.KeyEnter,
|
||||
glfw.KeyEqual: driver.KeyEqual,
|
||||
glfw.KeyEscape: driver.KeyEscape,
|
||||
glfw.KeyF: driver.KeyF,
|
||||
glfw.KeyF1: driver.KeyF1,
|
||||
glfw.KeyF10: driver.KeyF10,
|
||||
glfw.KeyF11: driver.KeyF11,
|
||||
glfw.KeyF12: driver.KeyF12,
|
||||
glfw.KeyF2: driver.KeyF2,
|
||||
glfw.KeyF3: driver.KeyF3,
|
||||
glfw.KeyF4: driver.KeyF4,
|
||||
glfw.KeyF5: driver.KeyF5,
|
||||
glfw.KeyF6: driver.KeyF6,
|
||||
glfw.KeyF7: driver.KeyF7,
|
||||
glfw.KeyF8: driver.KeyF8,
|
||||
glfw.KeyF9: driver.KeyF9,
|
||||
glfw.KeyG: driver.KeyG,
|
||||
glfw.KeyH: driver.KeyH,
|
||||
glfw.KeyHome: driver.KeyHome,
|
||||
glfw.KeyI: driver.KeyI,
|
||||
glfw.KeyInsert: driver.KeyInsert,
|
||||
glfw.KeyJ: driver.KeyJ,
|
||||
glfw.KeyK: driver.KeyK,
|
||||
glfw.KeyL: driver.KeyL,
|
||||
glfw.KeyM: driver.KeyM,
|
||||
glfw.KeyLeftSuper: driver.KeyMetaLeft,
|
||||
glfw.KeyRightSuper: driver.KeyMetaRight,
|
||||
glfw.KeyMinus: driver.KeyMinus,
|
||||
glfw.KeyN: driver.KeyN,
|
||||
glfw.KeyNumLock: driver.KeyNumLock,
|
||||
glfw.KeyKP0: driver.KeyNumpad0,
|
||||
glfw.KeyKP1: driver.KeyNumpad1,
|
||||
glfw.KeyKP2: driver.KeyNumpad2,
|
||||
glfw.KeyKP3: driver.KeyNumpad3,
|
||||
glfw.KeyKP4: driver.KeyNumpad4,
|
||||
glfw.KeyKP5: driver.KeyNumpad5,
|
||||
glfw.KeyKP6: driver.KeyNumpad6,
|
||||
glfw.KeyKP7: driver.KeyNumpad7,
|
||||
glfw.KeyKP8: driver.KeyNumpad8,
|
||||
glfw.KeyKP9: driver.KeyNumpad9,
|
||||
glfw.KeyKPAdd: driver.KeyNumpadAdd,
|
||||
glfw.KeyKPDecimal: driver.KeyNumpadDecimal,
|
||||
glfw.KeyKPDivide: driver.KeyNumpadDivide,
|
||||
glfw.KeyKPEnter: driver.KeyNumpadEnter,
|
||||
glfw.KeyKPEqual: driver.KeyNumpadEqual,
|
||||
glfw.KeyKPMultiply: driver.KeyNumpadMultiply,
|
||||
glfw.KeyKPSubtract: driver.KeyNumpadSubtract,
|
||||
glfw.KeyO: driver.KeyO,
|
||||
glfw.KeyP: driver.KeyP,
|
||||
glfw.KeyPageDown: driver.KeyPageDown,
|
||||
glfw.KeyPageUp: driver.KeyPageUp,
|
||||
glfw.KeyPause: driver.KeyPause,
|
||||
glfw.KeyPeriod: driver.KeyPeriod,
|
||||
glfw.KeyPrintScreen: driver.KeyPrintScreen,
|
||||
glfw.KeyQ: driver.KeyQ,
|
||||
glfw.KeyApostrophe: driver.KeyQuote,
|
||||
glfw.KeyR: driver.KeyR,
|
||||
glfw.KeyS: driver.KeyS,
|
||||
glfw.KeyScrollLock: driver.KeyScrollLock,
|
||||
glfw.KeySemicolon: driver.KeySemicolon,
|
||||
glfw.KeyLeftShift: driver.KeyShiftLeft,
|
||||
glfw.KeyRightShift: driver.KeyShiftRight,
|
||||
glfw.KeySlash: driver.KeySlash,
|
||||
glfw.KeySpace: driver.KeySpace,
|
||||
glfw.KeyT: driver.KeyT,
|
||||
glfw.KeyTab: driver.KeyTab,
|
||||
glfw.KeyU: driver.KeyU,
|
||||
glfw.KeyV: driver.KeyV,
|
||||
glfw.KeyW: driver.KeyW,
|
||||
glfw.KeyX: driver.KeyX,
|
||||
glfw.KeyY: driver.KeyY,
|
||||
glfw.KeyZ: driver.KeyZ,
|
||||
var glfwKeyToUIKey = map[glfw.Key]Key{
|
||||
glfw.KeyA: KeyA,
|
||||
glfw.KeyLeftAlt: KeyAltLeft,
|
||||
glfw.KeyRightAlt: KeyAltRight,
|
||||
glfw.KeyDown: KeyArrowDown,
|
||||
glfw.KeyLeft: KeyArrowLeft,
|
||||
glfw.KeyRight: KeyArrowRight,
|
||||
glfw.KeyUp: KeyArrowUp,
|
||||
glfw.KeyB: KeyB,
|
||||
glfw.KeyGraveAccent: KeyBackquote,
|
||||
glfw.KeyBackslash: KeyBackslash,
|
||||
glfw.KeyBackspace: KeyBackspace,
|
||||
glfw.KeyLeftBracket: KeyBracketLeft,
|
||||
glfw.KeyRightBracket: KeyBracketRight,
|
||||
glfw.KeyC: KeyC,
|
||||
glfw.KeyCapsLock: KeyCapsLock,
|
||||
glfw.KeyComma: KeyComma,
|
||||
glfw.KeyMenu: KeyContextMenu,
|
||||
glfw.KeyLeftControl: KeyControlLeft,
|
||||
glfw.KeyRightControl: KeyControlRight,
|
||||
glfw.KeyD: KeyD,
|
||||
glfw.KeyDelete: KeyDelete,
|
||||
glfw.Key0: KeyDigit0,
|
||||
glfw.Key1: KeyDigit1,
|
||||
glfw.Key2: KeyDigit2,
|
||||
glfw.Key3: KeyDigit3,
|
||||
glfw.Key4: KeyDigit4,
|
||||
glfw.Key5: KeyDigit5,
|
||||
glfw.Key6: KeyDigit6,
|
||||
glfw.Key7: KeyDigit7,
|
||||
glfw.Key8: KeyDigit8,
|
||||
glfw.Key9: KeyDigit9,
|
||||
glfw.KeyE: KeyE,
|
||||
glfw.KeyEnd: KeyEnd,
|
||||
glfw.KeyEnter: KeyEnter,
|
||||
glfw.KeyEqual: KeyEqual,
|
||||
glfw.KeyEscape: KeyEscape,
|
||||
glfw.KeyF: KeyF,
|
||||
glfw.KeyF1: KeyF1,
|
||||
glfw.KeyF10: KeyF10,
|
||||
glfw.KeyF11: KeyF11,
|
||||
glfw.KeyF12: KeyF12,
|
||||
glfw.KeyF2: KeyF2,
|
||||
glfw.KeyF3: KeyF3,
|
||||
glfw.KeyF4: KeyF4,
|
||||
glfw.KeyF5: KeyF5,
|
||||
glfw.KeyF6: KeyF6,
|
||||
glfw.KeyF7: KeyF7,
|
||||
glfw.KeyF8: KeyF8,
|
||||
glfw.KeyF9: KeyF9,
|
||||
glfw.KeyG: KeyG,
|
||||
glfw.KeyH: KeyH,
|
||||
glfw.KeyHome: KeyHome,
|
||||
glfw.KeyI: KeyI,
|
||||
glfw.KeyInsert: KeyInsert,
|
||||
glfw.KeyJ: KeyJ,
|
||||
glfw.KeyK: KeyK,
|
||||
glfw.KeyL: KeyL,
|
||||
glfw.KeyM: KeyM,
|
||||
glfw.KeyLeftSuper: KeyMetaLeft,
|
||||
glfw.KeyRightSuper: KeyMetaRight,
|
||||
glfw.KeyMinus: KeyMinus,
|
||||
glfw.KeyN: KeyN,
|
||||
glfw.KeyNumLock: KeyNumLock,
|
||||
glfw.KeyKP0: KeyNumpad0,
|
||||
glfw.KeyKP1: KeyNumpad1,
|
||||
glfw.KeyKP2: KeyNumpad2,
|
||||
glfw.KeyKP3: KeyNumpad3,
|
||||
glfw.KeyKP4: KeyNumpad4,
|
||||
glfw.KeyKP5: KeyNumpad5,
|
||||
glfw.KeyKP6: KeyNumpad6,
|
||||
glfw.KeyKP7: KeyNumpad7,
|
||||
glfw.KeyKP8: KeyNumpad8,
|
||||
glfw.KeyKP9: KeyNumpad9,
|
||||
glfw.KeyKPAdd: KeyNumpadAdd,
|
||||
glfw.KeyKPDecimal: KeyNumpadDecimal,
|
||||
glfw.KeyKPDivide: KeyNumpadDivide,
|
||||
glfw.KeyKPEnter: KeyNumpadEnter,
|
||||
glfw.KeyKPEqual: KeyNumpadEqual,
|
||||
glfw.KeyKPMultiply: KeyNumpadMultiply,
|
||||
glfw.KeyKPSubtract: KeyNumpadSubtract,
|
||||
glfw.KeyO: KeyO,
|
||||
glfw.KeyP: KeyP,
|
||||
glfw.KeyPageDown: KeyPageDown,
|
||||
glfw.KeyPageUp: KeyPageUp,
|
||||
glfw.KeyPause: KeyPause,
|
||||
glfw.KeyPeriod: KeyPeriod,
|
||||
glfw.KeyPrintScreen: KeyPrintScreen,
|
||||
glfw.KeyQ: KeyQ,
|
||||
glfw.KeyApostrophe: KeyQuote,
|
||||
glfw.KeyR: KeyR,
|
||||
glfw.KeyS: KeyS,
|
||||
glfw.KeyScrollLock: KeyScrollLock,
|
||||
glfw.KeySemicolon: KeySemicolon,
|
||||
glfw.KeyLeftShift: KeyShiftLeft,
|
||||
glfw.KeyRightShift: KeyShiftRight,
|
||||
glfw.KeySlash: KeySlash,
|
||||
glfw.KeySpace: KeySpace,
|
||||
glfw.KeyT: KeyT,
|
||||
glfw.KeyTab: KeyTab,
|
||||
glfw.KeyU: KeyU,
|
||||
glfw.KeyV: KeyV,
|
||||
glfw.KeyW: KeyW,
|
||||
glfw.KeyX: KeyX,
|
||||
glfw.KeyY: KeyY,
|
||||
glfw.KeyZ: KeyZ,
|
||||
}
|
||||
|
||||
var driverKeyToGLFWKey = map[driver.Key]glfw.Key{
|
||||
driver.KeyA: glfw.KeyA,
|
||||
driver.KeyAltLeft: glfw.KeyLeftAlt,
|
||||
driver.KeyAltRight: glfw.KeyRightAlt,
|
||||
driver.KeyArrowDown: glfw.KeyDown,
|
||||
driver.KeyArrowLeft: glfw.KeyLeft,
|
||||
driver.KeyArrowRight: glfw.KeyRight,
|
||||
driver.KeyArrowUp: glfw.KeyUp,
|
||||
driver.KeyB: glfw.KeyB,
|
||||
driver.KeyBackquote: glfw.KeyGraveAccent,
|
||||
driver.KeyBackslash: glfw.KeyBackslash,
|
||||
driver.KeyBackspace: glfw.KeyBackspace,
|
||||
driver.KeyBracketLeft: glfw.KeyLeftBracket,
|
||||
driver.KeyBracketRight: glfw.KeyRightBracket,
|
||||
driver.KeyC: glfw.KeyC,
|
||||
driver.KeyCapsLock: glfw.KeyCapsLock,
|
||||
driver.KeyComma: glfw.KeyComma,
|
||||
driver.KeyContextMenu: glfw.KeyMenu,
|
||||
driver.KeyControlLeft: glfw.KeyLeftControl,
|
||||
driver.KeyControlRight: glfw.KeyRightControl,
|
||||
driver.KeyD: glfw.KeyD,
|
||||
driver.KeyDelete: glfw.KeyDelete,
|
||||
driver.KeyDigit0: glfw.Key0,
|
||||
driver.KeyDigit1: glfw.Key1,
|
||||
driver.KeyDigit2: glfw.Key2,
|
||||
driver.KeyDigit3: glfw.Key3,
|
||||
driver.KeyDigit4: glfw.Key4,
|
||||
driver.KeyDigit5: glfw.Key5,
|
||||
driver.KeyDigit6: glfw.Key6,
|
||||
driver.KeyDigit7: glfw.Key7,
|
||||
driver.KeyDigit8: glfw.Key8,
|
||||
driver.KeyDigit9: glfw.Key9,
|
||||
driver.KeyE: glfw.KeyE,
|
||||
driver.KeyEnd: glfw.KeyEnd,
|
||||
driver.KeyEnter: glfw.KeyEnter,
|
||||
driver.KeyEqual: glfw.KeyEqual,
|
||||
driver.KeyEscape: glfw.KeyEscape,
|
||||
driver.KeyF: glfw.KeyF,
|
||||
driver.KeyF1: glfw.KeyF1,
|
||||
driver.KeyF10: glfw.KeyF10,
|
||||
driver.KeyF11: glfw.KeyF11,
|
||||
driver.KeyF12: glfw.KeyF12,
|
||||
driver.KeyF2: glfw.KeyF2,
|
||||
driver.KeyF3: glfw.KeyF3,
|
||||
driver.KeyF4: glfw.KeyF4,
|
||||
driver.KeyF5: glfw.KeyF5,
|
||||
driver.KeyF6: glfw.KeyF6,
|
||||
driver.KeyF7: glfw.KeyF7,
|
||||
driver.KeyF8: glfw.KeyF8,
|
||||
driver.KeyF9: glfw.KeyF9,
|
||||
driver.KeyG: glfw.KeyG,
|
||||
driver.KeyH: glfw.KeyH,
|
||||
driver.KeyHome: glfw.KeyHome,
|
||||
driver.KeyI: glfw.KeyI,
|
||||
driver.KeyInsert: glfw.KeyInsert,
|
||||
driver.KeyJ: glfw.KeyJ,
|
||||
driver.KeyK: glfw.KeyK,
|
||||
driver.KeyL: glfw.KeyL,
|
||||
driver.KeyM: glfw.KeyM,
|
||||
driver.KeyMetaLeft: glfw.KeyLeftSuper,
|
||||
driver.KeyMetaRight: glfw.KeyRightSuper,
|
||||
driver.KeyMinus: glfw.KeyMinus,
|
||||
driver.KeyN: glfw.KeyN,
|
||||
driver.KeyNumLock: glfw.KeyNumLock,
|
||||
driver.KeyNumpad0: glfw.KeyKP0,
|
||||
driver.KeyNumpad1: glfw.KeyKP1,
|
||||
driver.KeyNumpad2: glfw.KeyKP2,
|
||||
driver.KeyNumpad3: glfw.KeyKP3,
|
||||
driver.KeyNumpad4: glfw.KeyKP4,
|
||||
driver.KeyNumpad5: glfw.KeyKP5,
|
||||
driver.KeyNumpad6: glfw.KeyKP6,
|
||||
driver.KeyNumpad7: glfw.KeyKP7,
|
||||
driver.KeyNumpad8: glfw.KeyKP8,
|
||||
driver.KeyNumpad9: glfw.KeyKP9,
|
||||
driver.KeyNumpadAdd: glfw.KeyKPAdd,
|
||||
driver.KeyNumpadDecimal: glfw.KeyKPDecimal,
|
||||
driver.KeyNumpadDivide: glfw.KeyKPDivide,
|
||||
driver.KeyNumpadEnter: glfw.KeyKPEnter,
|
||||
driver.KeyNumpadEqual: glfw.KeyKPEqual,
|
||||
driver.KeyNumpadMultiply: glfw.KeyKPMultiply,
|
||||
driver.KeyNumpadSubtract: glfw.KeyKPSubtract,
|
||||
driver.KeyO: glfw.KeyO,
|
||||
driver.KeyP: glfw.KeyP,
|
||||
driver.KeyPageDown: glfw.KeyPageDown,
|
||||
driver.KeyPageUp: glfw.KeyPageUp,
|
||||
driver.KeyPause: glfw.KeyPause,
|
||||
driver.KeyPeriod: glfw.KeyPeriod,
|
||||
driver.KeyPrintScreen: glfw.KeyPrintScreen,
|
||||
driver.KeyQ: glfw.KeyQ,
|
||||
driver.KeyQuote: glfw.KeyApostrophe,
|
||||
driver.KeyR: glfw.KeyR,
|
||||
driver.KeyS: glfw.KeyS,
|
||||
driver.KeyScrollLock: glfw.KeyScrollLock,
|
||||
driver.KeySemicolon: glfw.KeySemicolon,
|
||||
driver.KeyShiftLeft: glfw.KeyLeftShift,
|
||||
driver.KeyShiftRight: glfw.KeyRightShift,
|
||||
driver.KeySlash: glfw.KeySlash,
|
||||
driver.KeySpace: glfw.KeySpace,
|
||||
driver.KeyT: glfw.KeyT,
|
||||
driver.KeyTab: glfw.KeyTab,
|
||||
driver.KeyU: glfw.KeyU,
|
||||
driver.KeyV: glfw.KeyV,
|
||||
driver.KeyW: glfw.KeyW,
|
||||
driver.KeyX: glfw.KeyX,
|
||||
driver.KeyY: glfw.KeyY,
|
||||
driver.KeyZ: glfw.KeyZ,
|
||||
var uiKeyToGLFWKey = map[Key]glfw.Key{
|
||||
KeyA: glfw.KeyA,
|
||||
KeyAltLeft: glfw.KeyLeftAlt,
|
||||
KeyAltRight: glfw.KeyRightAlt,
|
||||
KeyArrowDown: glfw.KeyDown,
|
||||
KeyArrowLeft: glfw.KeyLeft,
|
||||
KeyArrowRight: glfw.KeyRight,
|
||||
KeyArrowUp: glfw.KeyUp,
|
||||
KeyB: glfw.KeyB,
|
||||
KeyBackquote: glfw.KeyGraveAccent,
|
||||
KeyBackslash: glfw.KeyBackslash,
|
||||
KeyBackspace: glfw.KeyBackspace,
|
||||
KeyBracketLeft: glfw.KeyLeftBracket,
|
||||
KeyBracketRight: glfw.KeyRightBracket,
|
||||
KeyC: glfw.KeyC,
|
||||
KeyCapsLock: glfw.KeyCapsLock,
|
||||
KeyComma: glfw.KeyComma,
|
||||
KeyContextMenu: glfw.KeyMenu,
|
||||
KeyControlLeft: glfw.KeyLeftControl,
|
||||
KeyControlRight: glfw.KeyRightControl,
|
||||
KeyD: glfw.KeyD,
|
||||
KeyDelete: glfw.KeyDelete,
|
||||
KeyDigit0: glfw.Key0,
|
||||
KeyDigit1: glfw.Key1,
|
||||
KeyDigit2: glfw.Key2,
|
||||
KeyDigit3: glfw.Key3,
|
||||
KeyDigit4: glfw.Key4,
|
||||
KeyDigit5: glfw.Key5,
|
||||
KeyDigit6: glfw.Key6,
|
||||
KeyDigit7: glfw.Key7,
|
||||
KeyDigit8: glfw.Key8,
|
||||
KeyDigit9: glfw.Key9,
|
||||
KeyE: glfw.KeyE,
|
||||
KeyEnd: glfw.KeyEnd,
|
||||
KeyEnter: glfw.KeyEnter,
|
||||
KeyEqual: glfw.KeyEqual,
|
||||
KeyEscape: glfw.KeyEscape,
|
||||
KeyF: glfw.KeyF,
|
||||
KeyF1: glfw.KeyF1,
|
||||
KeyF10: glfw.KeyF10,
|
||||
KeyF11: glfw.KeyF11,
|
||||
KeyF12: glfw.KeyF12,
|
||||
KeyF2: glfw.KeyF2,
|
||||
KeyF3: glfw.KeyF3,
|
||||
KeyF4: glfw.KeyF4,
|
||||
KeyF5: glfw.KeyF5,
|
||||
KeyF6: glfw.KeyF6,
|
||||
KeyF7: glfw.KeyF7,
|
||||
KeyF8: glfw.KeyF8,
|
||||
KeyF9: glfw.KeyF9,
|
||||
KeyG: glfw.KeyG,
|
||||
KeyH: glfw.KeyH,
|
||||
KeyHome: glfw.KeyHome,
|
||||
KeyI: glfw.KeyI,
|
||||
KeyInsert: glfw.KeyInsert,
|
||||
KeyJ: glfw.KeyJ,
|
||||
KeyK: glfw.KeyK,
|
||||
KeyL: glfw.KeyL,
|
||||
KeyM: glfw.KeyM,
|
||||
KeyMetaLeft: glfw.KeyLeftSuper,
|
||||
KeyMetaRight: glfw.KeyRightSuper,
|
||||
KeyMinus: glfw.KeyMinus,
|
||||
KeyN: glfw.KeyN,
|
||||
KeyNumLock: glfw.KeyNumLock,
|
||||
KeyNumpad0: glfw.KeyKP0,
|
||||
KeyNumpad1: glfw.KeyKP1,
|
||||
KeyNumpad2: glfw.KeyKP2,
|
||||
KeyNumpad3: glfw.KeyKP3,
|
||||
KeyNumpad4: glfw.KeyKP4,
|
||||
KeyNumpad5: glfw.KeyKP5,
|
||||
KeyNumpad6: glfw.KeyKP6,
|
||||
KeyNumpad7: glfw.KeyKP7,
|
||||
KeyNumpad8: glfw.KeyKP8,
|
||||
KeyNumpad9: glfw.KeyKP9,
|
||||
KeyNumpadAdd: glfw.KeyKPAdd,
|
||||
KeyNumpadDecimal: glfw.KeyKPDecimal,
|
||||
KeyNumpadDivide: glfw.KeyKPDivide,
|
||||
KeyNumpadEnter: glfw.KeyKPEnter,
|
||||
KeyNumpadEqual: glfw.KeyKPEqual,
|
||||
KeyNumpadMultiply: glfw.KeyKPMultiply,
|
||||
KeyNumpadSubtract: glfw.KeyKPSubtract,
|
||||
KeyO: glfw.KeyO,
|
||||
KeyP: glfw.KeyP,
|
||||
KeyPageDown: glfw.KeyPageDown,
|
||||
KeyPageUp: glfw.KeyPageUp,
|
||||
KeyPause: glfw.KeyPause,
|
||||
KeyPeriod: glfw.KeyPeriod,
|
||||
KeyPrintScreen: glfw.KeyPrintScreen,
|
||||
KeyQ: glfw.KeyQ,
|
||||
KeyQuote: glfw.KeyApostrophe,
|
||||
KeyR: glfw.KeyR,
|
||||
KeyS: glfw.KeyS,
|
||||
KeyScrollLock: glfw.KeyScrollLock,
|
||||
KeySemicolon: glfw.KeySemicolon,
|
||||
KeyShiftLeft: glfw.KeyLeftShift,
|
||||
KeyShiftRight: glfw.KeyRightShift,
|
||||
KeySlash: glfw.KeySlash,
|
||||
KeySpace: glfw.KeySpace,
|
||||
KeyT: glfw.KeyT,
|
||||
KeyTab: glfw.KeyTab,
|
||||
KeyU: glfw.KeyU,
|
||||
KeyV: glfw.KeyV,
|
||||
KeyW: glfw.KeyW,
|
||||
KeyX: glfw.KeyX,
|
||||
KeyY: glfw.KeyY,
|
||||
KeyZ: glfw.KeyZ,
|
||||
}
|
||||
|
@ -18,216 +18,214 @@ package ui
|
||||
|
||||
import (
|
||||
"syscall/js"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
)
|
||||
|
||||
var driverKeyToJSKey = map[driver.Key]js.Value{
|
||||
driver.KeyA: js.ValueOf("KeyA"),
|
||||
driver.KeyAltLeft: js.ValueOf("AltLeft"),
|
||||
driver.KeyAltRight: js.ValueOf("AltRight"),
|
||||
driver.KeyArrowDown: js.ValueOf("ArrowDown"),
|
||||
driver.KeyArrowLeft: js.ValueOf("ArrowLeft"),
|
||||
driver.KeyArrowRight: js.ValueOf("ArrowRight"),
|
||||
driver.KeyArrowUp: js.ValueOf("ArrowUp"),
|
||||
driver.KeyB: js.ValueOf("KeyB"),
|
||||
driver.KeyBackquote: js.ValueOf("Backquote"),
|
||||
driver.KeyBackslash: js.ValueOf("Backslash"),
|
||||
driver.KeyBackspace: js.ValueOf("Backspace"),
|
||||
driver.KeyBracketLeft: js.ValueOf("BracketLeft"),
|
||||
driver.KeyBracketRight: js.ValueOf("BracketRight"),
|
||||
driver.KeyC: js.ValueOf("KeyC"),
|
||||
driver.KeyCapsLock: js.ValueOf("CapsLock"),
|
||||
driver.KeyComma: js.ValueOf("Comma"),
|
||||
driver.KeyContextMenu: js.ValueOf("ContextMenu"),
|
||||
driver.KeyControlLeft: js.ValueOf("ControlLeft"),
|
||||
driver.KeyControlRight: js.ValueOf("ControlRight"),
|
||||
driver.KeyD: js.ValueOf("KeyD"),
|
||||
driver.KeyDelete: js.ValueOf("Delete"),
|
||||
driver.KeyDigit0: js.ValueOf("Digit0"),
|
||||
driver.KeyDigit1: js.ValueOf("Digit1"),
|
||||
driver.KeyDigit2: js.ValueOf("Digit2"),
|
||||
driver.KeyDigit3: js.ValueOf("Digit3"),
|
||||
driver.KeyDigit4: js.ValueOf("Digit4"),
|
||||
driver.KeyDigit5: js.ValueOf("Digit5"),
|
||||
driver.KeyDigit6: js.ValueOf("Digit6"),
|
||||
driver.KeyDigit7: js.ValueOf("Digit7"),
|
||||
driver.KeyDigit8: js.ValueOf("Digit8"),
|
||||
driver.KeyDigit9: js.ValueOf("Digit9"),
|
||||
driver.KeyE: js.ValueOf("KeyE"),
|
||||
driver.KeyEnd: js.ValueOf("End"),
|
||||
driver.KeyEnter: js.ValueOf("Enter"),
|
||||
driver.KeyEqual: js.ValueOf("Equal"),
|
||||
driver.KeyEscape: js.ValueOf("Escape"),
|
||||
driver.KeyF: js.ValueOf("KeyF"),
|
||||
driver.KeyF1: js.ValueOf("F1"),
|
||||
driver.KeyF10: js.ValueOf("F10"),
|
||||
driver.KeyF11: js.ValueOf("F11"),
|
||||
driver.KeyF12: js.ValueOf("F12"),
|
||||
driver.KeyF2: js.ValueOf("F2"),
|
||||
driver.KeyF3: js.ValueOf("F3"),
|
||||
driver.KeyF4: js.ValueOf("F4"),
|
||||
driver.KeyF5: js.ValueOf("F5"),
|
||||
driver.KeyF6: js.ValueOf("F6"),
|
||||
driver.KeyF7: js.ValueOf("F7"),
|
||||
driver.KeyF8: js.ValueOf("F8"),
|
||||
driver.KeyF9: js.ValueOf("F9"),
|
||||
driver.KeyG: js.ValueOf("KeyG"),
|
||||
driver.KeyH: js.ValueOf("KeyH"),
|
||||
driver.KeyHome: js.ValueOf("Home"),
|
||||
driver.KeyI: js.ValueOf("KeyI"),
|
||||
driver.KeyInsert: js.ValueOf("Insert"),
|
||||
driver.KeyJ: js.ValueOf("KeyJ"),
|
||||
driver.KeyK: js.ValueOf("KeyK"),
|
||||
driver.KeyL: js.ValueOf("KeyL"),
|
||||
driver.KeyM: js.ValueOf("KeyM"),
|
||||
driver.KeyMetaLeft: js.ValueOf("MetaLeft"),
|
||||
driver.KeyMetaRight: js.ValueOf("MetaRight"),
|
||||
driver.KeyMinus: js.ValueOf("Minus"),
|
||||
driver.KeyN: js.ValueOf("KeyN"),
|
||||
driver.KeyNumLock: js.ValueOf("NumLock"),
|
||||
driver.KeyNumpad0: js.ValueOf("Numpad0"),
|
||||
driver.KeyNumpad1: js.ValueOf("Numpad1"),
|
||||
driver.KeyNumpad2: js.ValueOf("Numpad2"),
|
||||
driver.KeyNumpad3: js.ValueOf("Numpad3"),
|
||||
driver.KeyNumpad4: js.ValueOf("Numpad4"),
|
||||
driver.KeyNumpad5: js.ValueOf("Numpad5"),
|
||||
driver.KeyNumpad6: js.ValueOf("Numpad6"),
|
||||
driver.KeyNumpad7: js.ValueOf("Numpad7"),
|
||||
driver.KeyNumpad8: js.ValueOf("Numpad8"),
|
||||
driver.KeyNumpad9: js.ValueOf("Numpad9"),
|
||||
driver.KeyNumpadAdd: js.ValueOf("NumpadAdd"),
|
||||
driver.KeyNumpadDecimal: js.ValueOf("NumpadDecimal"),
|
||||
driver.KeyNumpadDivide: js.ValueOf("NumpadDivide"),
|
||||
driver.KeyNumpadEnter: js.ValueOf("NumpadEnter"),
|
||||
driver.KeyNumpadEqual: js.ValueOf("NumpadEqual"),
|
||||
driver.KeyNumpadMultiply: js.ValueOf("NumpadMultiply"),
|
||||
driver.KeyNumpadSubtract: js.ValueOf("NumpadSubtract"),
|
||||
driver.KeyO: js.ValueOf("KeyO"),
|
||||
driver.KeyP: js.ValueOf("KeyP"),
|
||||
driver.KeyPageDown: js.ValueOf("PageDown"),
|
||||
driver.KeyPageUp: js.ValueOf("PageUp"),
|
||||
driver.KeyPause: js.ValueOf("Pause"),
|
||||
driver.KeyPeriod: js.ValueOf("Period"),
|
||||
driver.KeyPrintScreen: js.ValueOf("PrintScreen"),
|
||||
driver.KeyQ: js.ValueOf("KeyQ"),
|
||||
driver.KeyQuote: js.ValueOf("Quote"),
|
||||
driver.KeyR: js.ValueOf("KeyR"),
|
||||
driver.KeyS: js.ValueOf("KeyS"),
|
||||
driver.KeyScrollLock: js.ValueOf("ScrollLock"),
|
||||
driver.KeySemicolon: js.ValueOf("Semicolon"),
|
||||
driver.KeyShiftLeft: js.ValueOf("ShiftLeft"),
|
||||
driver.KeyShiftRight: js.ValueOf("ShiftRight"),
|
||||
driver.KeySlash: js.ValueOf("Slash"),
|
||||
driver.KeySpace: js.ValueOf("Space"),
|
||||
driver.KeyT: js.ValueOf("KeyT"),
|
||||
driver.KeyTab: js.ValueOf("Tab"),
|
||||
driver.KeyU: js.ValueOf("KeyU"),
|
||||
driver.KeyV: js.ValueOf("KeyV"),
|
||||
driver.KeyW: js.ValueOf("KeyW"),
|
||||
driver.KeyX: js.ValueOf("KeyX"),
|
||||
driver.KeyY: js.ValueOf("KeyY"),
|
||||
driver.KeyZ: js.ValueOf("KeyZ"),
|
||||
var uiKeyToJSKey = map[Key]js.Value{
|
||||
KeyA: js.ValueOf("KeyA"),
|
||||
KeyAltLeft: js.ValueOf("AltLeft"),
|
||||
KeyAltRight: js.ValueOf("AltRight"),
|
||||
KeyArrowDown: js.ValueOf("ArrowDown"),
|
||||
KeyArrowLeft: js.ValueOf("ArrowLeft"),
|
||||
KeyArrowRight: js.ValueOf("ArrowRight"),
|
||||
KeyArrowUp: js.ValueOf("ArrowUp"),
|
||||
KeyB: js.ValueOf("KeyB"),
|
||||
KeyBackquote: js.ValueOf("Backquote"),
|
||||
KeyBackslash: js.ValueOf("Backslash"),
|
||||
KeyBackspace: js.ValueOf("Backspace"),
|
||||
KeyBracketLeft: js.ValueOf("BracketLeft"),
|
||||
KeyBracketRight: js.ValueOf("BracketRight"),
|
||||
KeyC: js.ValueOf("KeyC"),
|
||||
KeyCapsLock: js.ValueOf("CapsLock"),
|
||||
KeyComma: js.ValueOf("Comma"),
|
||||
KeyContextMenu: js.ValueOf("ContextMenu"),
|
||||
KeyControlLeft: js.ValueOf("ControlLeft"),
|
||||
KeyControlRight: js.ValueOf("ControlRight"),
|
||||
KeyD: js.ValueOf("KeyD"),
|
||||
KeyDelete: js.ValueOf("Delete"),
|
||||
KeyDigit0: js.ValueOf("Digit0"),
|
||||
KeyDigit1: js.ValueOf("Digit1"),
|
||||
KeyDigit2: js.ValueOf("Digit2"),
|
||||
KeyDigit3: js.ValueOf("Digit3"),
|
||||
KeyDigit4: js.ValueOf("Digit4"),
|
||||
KeyDigit5: js.ValueOf("Digit5"),
|
||||
KeyDigit6: js.ValueOf("Digit6"),
|
||||
KeyDigit7: js.ValueOf("Digit7"),
|
||||
KeyDigit8: js.ValueOf("Digit8"),
|
||||
KeyDigit9: js.ValueOf("Digit9"),
|
||||
KeyE: js.ValueOf("KeyE"),
|
||||
KeyEnd: js.ValueOf("End"),
|
||||
KeyEnter: js.ValueOf("Enter"),
|
||||
KeyEqual: js.ValueOf("Equal"),
|
||||
KeyEscape: js.ValueOf("Escape"),
|
||||
KeyF: js.ValueOf("KeyF"),
|
||||
KeyF1: js.ValueOf("F1"),
|
||||
KeyF10: js.ValueOf("F10"),
|
||||
KeyF11: js.ValueOf("F11"),
|
||||
KeyF12: js.ValueOf("F12"),
|
||||
KeyF2: js.ValueOf("F2"),
|
||||
KeyF3: js.ValueOf("F3"),
|
||||
KeyF4: js.ValueOf("F4"),
|
||||
KeyF5: js.ValueOf("F5"),
|
||||
KeyF6: js.ValueOf("F6"),
|
||||
KeyF7: js.ValueOf("F7"),
|
||||
KeyF8: js.ValueOf("F8"),
|
||||
KeyF9: js.ValueOf("F9"),
|
||||
KeyG: js.ValueOf("KeyG"),
|
||||
KeyH: js.ValueOf("KeyH"),
|
||||
KeyHome: js.ValueOf("Home"),
|
||||
KeyI: js.ValueOf("KeyI"),
|
||||
KeyInsert: js.ValueOf("Insert"),
|
||||
KeyJ: js.ValueOf("KeyJ"),
|
||||
KeyK: js.ValueOf("KeyK"),
|
||||
KeyL: js.ValueOf("KeyL"),
|
||||
KeyM: js.ValueOf("KeyM"),
|
||||
KeyMetaLeft: js.ValueOf("MetaLeft"),
|
||||
KeyMetaRight: js.ValueOf("MetaRight"),
|
||||
KeyMinus: js.ValueOf("Minus"),
|
||||
KeyN: js.ValueOf("KeyN"),
|
||||
KeyNumLock: js.ValueOf("NumLock"),
|
||||
KeyNumpad0: js.ValueOf("Numpad0"),
|
||||
KeyNumpad1: js.ValueOf("Numpad1"),
|
||||
KeyNumpad2: js.ValueOf("Numpad2"),
|
||||
KeyNumpad3: js.ValueOf("Numpad3"),
|
||||
KeyNumpad4: js.ValueOf("Numpad4"),
|
||||
KeyNumpad5: js.ValueOf("Numpad5"),
|
||||
KeyNumpad6: js.ValueOf("Numpad6"),
|
||||
KeyNumpad7: js.ValueOf("Numpad7"),
|
||||
KeyNumpad8: js.ValueOf("Numpad8"),
|
||||
KeyNumpad9: js.ValueOf("Numpad9"),
|
||||
KeyNumpadAdd: js.ValueOf("NumpadAdd"),
|
||||
KeyNumpadDecimal: js.ValueOf("NumpadDecimal"),
|
||||
KeyNumpadDivide: js.ValueOf("NumpadDivide"),
|
||||
KeyNumpadEnter: js.ValueOf("NumpadEnter"),
|
||||
KeyNumpadEqual: js.ValueOf("NumpadEqual"),
|
||||
KeyNumpadMultiply: js.ValueOf("NumpadMultiply"),
|
||||
KeyNumpadSubtract: js.ValueOf("NumpadSubtract"),
|
||||
KeyO: js.ValueOf("KeyO"),
|
||||
KeyP: js.ValueOf("KeyP"),
|
||||
KeyPageDown: js.ValueOf("PageDown"),
|
||||
KeyPageUp: js.ValueOf("PageUp"),
|
||||
KeyPause: js.ValueOf("Pause"),
|
||||
KeyPeriod: js.ValueOf("Period"),
|
||||
KeyPrintScreen: js.ValueOf("PrintScreen"),
|
||||
KeyQ: js.ValueOf("KeyQ"),
|
||||
KeyQuote: js.ValueOf("Quote"),
|
||||
KeyR: js.ValueOf("KeyR"),
|
||||
KeyS: js.ValueOf("KeyS"),
|
||||
KeyScrollLock: js.ValueOf("ScrollLock"),
|
||||
KeySemicolon: js.ValueOf("Semicolon"),
|
||||
KeyShiftLeft: js.ValueOf("ShiftLeft"),
|
||||
KeyShiftRight: js.ValueOf("ShiftRight"),
|
||||
KeySlash: js.ValueOf("Slash"),
|
||||
KeySpace: js.ValueOf("Space"),
|
||||
KeyT: js.ValueOf("KeyT"),
|
||||
KeyTab: js.ValueOf("Tab"),
|
||||
KeyU: js.ValueOf("KeyU"),
|
||||
KeyV: js.ValueOf("KeyV"),
|
||||
KeyW: js.ValueOf("KeyW"),
|
||||
KeyX: js.ValueOf("KeyX"),
|
||||
KeyY: js.ValueOf("KeyY"),
|
||||
KeyZ: js.ValueOf("KeyZ"),
|
||||
}
|
||||
|
||||
var edgeKeyCodeToDriverKey = map[int]driver.Key{
|
||||
8: driver.KeyBackspace,
|
||||
9: driver.KeyTab,
|
||||
13: driver.KeyEnter,
|
||||
16: driver.KeyShiftLeft,
|
||||
17: driver.KeyControlLeft,
|
||||
18: driver.KeyAltLeft,
|
||||
19: driver.KeyPause,
|
||||
20: driver.KeyCapsLock,
|
||||
27: driver.KeyEscape,
|
||||
32: driver.KeySpace,
|
||||
33: driver.KeyPageUp,
|
||||
34: driver.KeyPageDown,
|
||||
35: driver.KeyEnd,
|
||||
36: driver.KeyHome,
|
||||
37: driver.KeyArrowLeft,
|
||||
38: driver.KeyArrowUp,
|
||||
39: driver.KeyArrowRight,
|
||||
40: driver.KeyArrowDown,
|
||||
45: driver.KeyInsert,
|
||||
46: driver.KeyDelete,
|
||||
48: driver.KeyDigit0,
|
||||
49: driver.KeyDigit1,
|
||||
50: driver.KeyDigit2,
|
||||
51: driver.KeyDigit3,
|
||||
52: driver.KeyDigit4,
|
||||
53: driver.KeyDigit5,
|
||||
54: driver.KeyDigit6,
|
||||
55: driver.KeyDigit7,
|
||||
56: driver.KeyDigit8,
|
||||
57: driver.KeyDigit9,
|
||||
65: driver.KeyA,
|
||||
66: driver.KeyB,
|
||||
67: driver.KeyC,
|
||||
68: driver.KeyD,
|
||||
69: driver.KeyE,
|
||||
70: driver.KeyF,
|
||||
71: driver.KeyG,
|
||||
72: driver.KeyH,
|
||||
73: driver.KeyI,
|
||||
74: driver.KeyJ,
|
||||
75: driver.KeyK,
|
||||
76: driver.KeyL,
|
||||
77: driver.KeyM,
|
||||
78: driver.KeyN,
|
||||
79: driver.KeyO,
|
||||
80: driver.KeyP,
|
||||
81: driver.KeyQ,
|
||||
82: driver.KeyR,
|
||||
83: driver.KeyS,
|
||||
84: driver.KeyT,
|
||||
85: driver.KeyU,
|
||||
86: driver.KeyV,
|
||||
87: driver.KeyW,
|
||||
88: driver.KeyX,
|
||||
89: driver.KeyY,
|
||||
90: driver.KeyZ,
|
||||
91: driver.KeyMetaLeft,
|
||||
92: driver.KeyMetaRight,
|
||||
93: driver.KeyContextMenu,
|
||||
96: driver.KeyNumpad0,
|
||||
97: driver.KeyNumpad1,
|
||||
98: driver.KeyNumpad2,
|
||||
99: driver.KeyNumpad3,
|
||||
100: driver.KeyNumpad4,
|
||||
101: driver.KeyNumpad5,
|
||||
102: driver.KeyNumpad6,
|
||||
103: driver.KeyNumpad7,
|
||||
104: driver.KeyNumpad8,
|
||||
105: driver.KeyNumpad9,
|
||||
106: driver.KeyNumpadMultiply,
|
||||
107: driver.KeyNumpadAdd,
|
||||
109: driver.KeyNumpadSubtract,
|
||||
110: driver.KeyNumpadDecimal,
|
||||
111: driver.KeyNumpadDivide,
|
||||
112: driver.KeyF1,
|
||||
113: driver.KeyF2,
|
||||
114: driver.KeyF3,
|
||||
115: driver.KeyF4,
|
||||
116: driver.KeyF5,
|
||||
117: driver.KeyF6,
|
||||
118: driver.KeyF7,
|
||||
119: driver.KeyF8,
|
||||
120: driver.KeyF9,
|
||||
121: driver.KeyF10,
|
||||
122: driver.KeyF11,
|
||||
123: driver.KeyF12,
|
||||
144: driver.KeyNumLock,
|
||||
145: driver.KeyScrollLock,
|
||||
186: driver.KeySemicolon,
|
||||
187: driver.KeyEqual,
|
||||
188: driver.KeyComma,
|
||||
189: driver.KeyMinus,
|
||||
190: driver.KeyPeriod,
|
||||
191: driver.KeySlash,
|
||||
192: driver.KeyBackquote,
|
||||
219: driver.KeyBracketLeft,
|
||||
220: driver.KeyBackslash,
|
||||
221: driver.KeyBracketRight,
|
||||
222: driver.KeyQuote,
|
||||
var edgeKeyCodeToUIKey = map[int]Key{
|
||||
8: KeyBackspace,
|
||||
9: KeyTab,
|
||||
13: KeyEnter,
|
||||
16: KeyShiftLeft,
|
||||
17: KeyControlLeft,
|
||||
18: KeyAltLeft,
|
||||
19: KeyPause,
|
||||
20: KeyCapsLock,
|
||||
27: KeyEscape,
|
||||
32: KeySpace,
|
||||
33: KeyPageUp,
|
||||
34: KeyPageDown,
|
||||
35: KeyEnd,
|
||||
36: KeyHome,
|
||||
37: KeyArrowLeft,
|
||||
38: KeyArrowUp,
|
||||
39: KeyArrowRight,
|
||||
40: KeyArrowDown,
|
||||
45: KeyInsert,
|
||||
46: KeyDelete,
|
||||
48: KeyDigit0,
|
||||
49: KeyDigit1,
|
||||
50: KeyDigit2,
|
||||
51: KeyDigit3,
|
||||
52: KeyDigit4,
|
||||
53: KeyDigit5,
|
||||
54: KeyDigit6,
|
||||
55: KeyDigit7,
|
||||
56: KeyDigit8,
|
||||
57: KeyDigit9,
|
||||
65: KeyA,
|
||||
66: KeyB,
|
||||
67: KeyC,
|
||||
68: KeyD,
|
||||
69: KeyE,
|
||||
70: KeyF,
|
||||
71: KeyG,
|
||||
72: KeyH,
|
||||
73: KeyI,
|
||||
74: KeyJ,
|
||||
75: KeyK,
|
||||
76: KeyL,
|
||||
77: KeyM,
|
||||
78: KeyN,
|
||||
79: KeyO,
|
||||
80: KeyP,
|
||||
81: KeyQ,
|
||||
82: KeyR,
|
||||
83: KeyS,
|
||||
84: KeyT,
|
||||
85: KeyU,
|
||||
86: KeyV,
|
||||
87: KeyW,
|
||||
88: KeyX,
|
||||
89: KeyY,
|
||||
90: KeyZ,
|
||||
91: KeyMetaLeft,
|
||||
92: KeyMetaRight,
|
||||
93: KeyContextMenu,
|
||||
96: KeyNumpad0,
|
||||
97: KeyNumpad1,
|
||||
98: KeyNumpad2,
|
||||
99: KeyNumpad3,
|
||||
100: KeyNumpad4,
|
||||
101: KeyNumpad5,
|
||||
102: KeyNumpad6,
|
||||
103: KeyNumpad7,
|
||||
104: KeyNumpad8,
|
||||
105: KeyNumpad9,
|
||||
106: KeyNumpadMultiply,
|
||||
107: KeyNumpadAdd,
|
||||
109: KeyNumpadSubtract,
|
||||
110: KeyNumpadDecimal,
|
||||
111: KeyNumpadDivide,
|
||||
112: KeyF1,
|
||||
113: KeyF2,
|
||||
114: KeyF3,
|
||||
115: KeyF4,
|
||||
116: KeyF5,
|
||||
117: KeyF6,
|
||||
118: KeyF7,
|
||||
119: KeyF8,
|
||||
120: KeyF9,
|
||||
121: KeyF10,
|
||||
122: KeyF11,
|
||||
123: KeyF12,
|
||||
144: KeyNumLock,
|
||||
145: KeyScrollLock,
|
||||
186: KeySemicolon,
|
||||
187: KeyEqual,
|
||||
188: KeyComma,
|
||||
189: KeyMinus,
|
||||
190: KeyPeriod,
|
||||
191: KeySlash,
|
||||
192: KeyBackquote,
|
||||
219: KeyBracketLeft,
|
||||
220: KeyBackslash,
|
||||
221: KeyBracketRight,
|
||||
222: KeyQuote,
|
||||
}
|
||||
|
@ -22,111 +22,109 @@ package ui
|
||||
|
||||
import (
|
||||
"golang.org/x/mobile/event/key"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
)
|
||||
|
||||
var gbuildKeyToDriverKey = map[key.Code]driver.Key{
|
||||
key.CodeA: driver.KeyA,
|
||||
key.CodeB: driver.KeyB,
|
||||
key.CodeC: driver.KeyC,
|
||||
key.CodeD: driver.KeyD,
|
||||
key.CodeE: driver.KeyE,
|
||||
key.CodeF: driver.KeyF,
|
||||
key.CodeG: driver.KeyG,
|
||||
key.CodeH: driver.KeyH,
|
||||
key.CodeI: driver.KeyI,
|
||||
key.CodeJ: driver.KeyJ,
|
||||
key.CodeK: driver.KeyK,
|
||||
key.CodeL: driver.KeyL,
|
||||
key.CodeM: driver.KeyM,
|
||||
key.CodeN: driver.KeyN,
|
||||
key.CodeO: driver.KeyO,
|
||||
key.CodeP: driver.KeyP,
|
||||
key.CodeQ: driver.KeyQ,
|
||||
key.CodeR: driver.KeyR,
|
||||
key.CodeS: driver.KeyS,
|
||||
key.CodeT: driver.KeyT,
|
||||
key.CodeU: driver.KeyU,
|
||||
key.CodeV: driver.KeyV,
|
||||
key.CodeW: driver.KeyW,
|
||||
key.CodeX: driver.KeyX,
|
||||
key.CodeY: driver.KeyY,
|
||||
key.CodeZ: driver.KeyZ,
|
||||
key.Code1: driver.KeyDigit1,
|
||||
key.Code2: driver.KeyDigit2,
|
||||
key.Code3: driver.KeyDigit3,
|
||||
key.Code4: driver.KeyDigit4,
|
||||
key.Code5: driver.KeyDigit5,
|
||||
key.Code6: driver.KeyDigit6,
|
||||
key.Code7: driver.KeyDigit7,
|
||||
key.Code8: driver.KeyDigit8,
|
||||
key.Code9: driver.KeyDigit9,
|
||||
key.Code0: driver.KeyDigit0,
|
||||
key.CodeReturnEnter: driver.KeyEnter,
|
||||
key.CodeEscape: driver.KeyEscape,
|
||||
key.CodeDeleteBackspace: driver.KeyBackspace,
|
||||
key.CodeTab: driver.KeyTab,
|
||||
key.CodeSpacebar: driver.KeySpace,
|
||||
key.CodeHyphenMinus: driver.KeyMinus,
|
||||
key.CodeEqualSign: driver.KeyEqual,
|
||||
key.CodeLeftSquareBracket: driver.KeyBracketLeft,
|
||||
key.CodeRightSquareBracket: driver.KeyBracketRight,
|
||||
key.CodeBackslash: driver.KeyBackslash,
|
||||
key.CodeSemicolon: driver.KeySemicolon,
|
||||
key.CodeApostrophe: driver.KeyQuote,
|
||||
key.CodeGraveAccent: driver.KeyBackquote,
|
||||
key.CodeComma: driver.KeyComma,
|
||||
key.CodeFullStop: driver.KeyPeriod,
|
||||
key.CodeSlash: driver.KeySlash,
|
||||
key.CodeCapsLock: driver.KeyCapsLock,
|
||||
key.CodeF1: driver.KeyF1,
|
||||
key.CodeF2: driver.KeyF2,
|
||||
key.CodeF3: driver.KeyF3,
|
||||
key.CodeF4: driver.KeyF4,
|
||||
key.CodeF5: driver.KeyF5,
|
||||
key.CodeF6: driver.KeyF6,
|
||||
key.CodeF7: driver.KeyF7,
|
||||
key.CodeF8: driver.KeyF8,
|
||||
key.CodeF9: driver.KeyF9,
|
||||
key.CodeF10: driver.KeyF10,
|
||||
key.CodeF11: driver.KeyF11,
|
||||
key.CodeF12: driver.KeyF12,
|
||||
key.CodePause: driver.KeyPause,
|
||||
key.CodeInsert: driver.KeyInsert,
|
||||
key.CodeHome: driver.KeyHome,
|
||||
key.CodePageUp: driver.KeyPageUp,
|
||||
key.CodeDeleteForward: driver.KeyDelete,
|
||||
key.CodeEnd: driver.KeyEnd,
|
||||
key.CodePageDown: driver.KeyPageDown,
|
||||
key.CodeRightArrow: driver.KeyArrowRight,
|
||||
key.CodeLeftArrow: driver.KeyArrowLeft,
|
||||
key.CodeDownArrow: driver.KeyArrowDown,
|
||||
key.CodeUpArrow: driver.KeyArrowUp,
|
||||
key.CodeKeypadNumLock: driver.KeyNumLock,
|
||||
key.CodeKeypadSlash: driver.KeyNumpadDivide,
|
||||
key.CodeKeypadAsterisk: driver.KeyNumpadMultiply,
|
||||
key.CodeKeypadHyphenMinus: driver.KeyNumpadSubtract,
|
||||
key.CodeKeypadPlusSign: driver.KeyNumpadAdd,
|
||||
key.CodeKeypadEnter: driver.KeyNumpadEnter,
|
||||
key.CodeKeypad1: driver.KeyNumpad1,
|
||||
key.CodeKeypad2: driver.KeyNumpad2,
|
||||
key.CodeKeypad3: driver.KeyNumpad3,
|
||||
key.CodeKeypad4: driver.KeyNumpad4,
|
||||
key.CodeKeypad5: driver.KeyNumpad5,
|
||||
key.CodeKeypad6: driver.KeyNumpad6,
|
||||
key.CodeKeypad7: driver.KeyNumpad7,
|
||||
key.CodeKeypad8: driver.KeyNumpad8,
|
||||
key.CodeKeypad9: driver.KeyNumpad9,
|
||||
key.CodeKeypad0: driver.KeyNumpad0,
|
||||
key.CodeKeypadFullStop: driver.KeyNumpadDecimal,
|
||||
key.CodeKeypadEqualSign: driver.KeyNumpadEqual,
|
||||
key.CodeLeftControl: driver.KeyControlLeft,
|
||||
key.CodeLeftShift: driver.KeyShiftLeft,
|
||||
key.CodeLeftAlt: driver.KeyAltLeft,
|
||||
key.CodeLeftGUI: driver.KeyMetaLeft,
|
||||
key.CodeRightControl: driver.KeyControlRight,
|
||||
key.CodeRightShift: driver.KeyShiftRight,
|
||||
key.CodeRightAlt: driver.KeyAltRight,
|
||||
key.CodeRightGUI: driver.KeyMetaRight,
|
||||
var gbuildKeyToUIKey = map[key.Code]Key{
|
||||
key.CodeA: KeyA,
|
||||
key.CodeB: KeyB,
|
||||
key.CodeC: KeyC,
|
||||
key.CodeD: KeyD,
|
||||
key.CodeE: KeyE,
|
||||
key.CodeF: KeyF,
|
||||
key.CodeG: KeyG,
|
||||
key.CodeH: KeyH,
|
||||
key.CodeI: KeyI,
|
||||
key.CodeJ: KeyJ,
|
||||
key.CodeK: KeyK,
|
||||
key.CodeL: KeyL,
|
||||
key.CodeM: KeyM,
|
||||
key.CodeN: KeyN,
|
||||
key.CodeO: KeyO,
|
||||
key.CodeP: KeyP,
|
||||
key.CodeQ: KeyQ,
|
||||
key.CodeR: KeyR,
|
||||
key.CodeS: KeyS,
|
||||
key.CodeT: KeyT,
|
||||
key.CodeU: KeyU,
|
||||
key.CodeV: KeyV,
|
||||
key.CodeW: KeyW,
|
||||
key.CodeX: KeyX,
|
||||
key.CodeY: KeyY,
|
||||
key.CodeZ: KeyZ,
|
||||
key.Code1: KeyDigit1,
|
||||
key.Code2: KeyDigit2,
|
||||
key.Code3: KeyDigit3,
|
||||
key.Code4: KeyDigit4,
|
||||
key.Code5: KeyDigit5,
|
||||
key.Code6: KeyDigit6,
|
||||
key.Code7: KeyDigit7,
|
||||
key.Code8: KeyDigit8,
|
||||
key.Code9: KeyDigit9,
|
||||
key.Code0: KeyDigit0,
|
||||
key.CodeReturnEnter: KeyEnter,
|
||||
key.CodeEscape: KeyEscape,
|
||||
key.CodeDeleteBackspace: KeyBackspace,
|
||||
key.CodeTab: KeyTab,
|
||||
key.CodeSpacebar: KeySpace,
|
||||
key.CodeHyphenMinus: KeyMinus,
|
||||
key.CodeEqualSign: KeyEqual,
|
||||
key.CodeLeftSquareBracket: KeyBracketLeft,
|
||||
key.CodeRightSquareBracket: KeyBracketRight,
|
||||
key.CodeBackslash: KeyBackslash,
|
||||
key.CodeSemicolon: KeySemicolon,
|
||||
key.CodeApostrophe: KeyQuote,
|
||||
key.CodeGraveAccent: KeyBackquote,
|
||||
key.CodeComma: KeyComma,
|
||||
key.CodeFullStop: KeyPeriod,
|
||||
key.CodeSlash: KeySlash,
|
||||
key.CodeCapsLock: KeyCapsLock,
|
||||
key.CodeF1: KeyF1,
|
||||
key.CodeF2: KeyF2,
|
||||
key.CodeF3: KeyF3,
|
||||
key.CodeF4: KeyF4,
|
||||
key.CodeF5: KeyF5,
|
||||
key.CodeF6: KeyF6,
|
||||
key.CodeF7: KeyF7,
|
||||
key.CodeF8: KeyF8,
|
||||
key.CodeF9: KeyF9,
|
||||
key.CodeF10: KeyF10,
|
||||
key.CodeF11: KeyF11,
|
||||
key.CodeF12: KeyF12,
|
||||
key.CodePause: KeyPause,
|
||||
key.CodeInsert: KeyInsert,
|
||||
key.CodeHome: KeyHome,
|
||||
key.CodePageUp: KeyPageUp,
|
||||
key.CodeDeleteForward: KeyDelete,
|
||||
key.CodeEnd: KeyEnd,
|
||||
key.CodePageDown: KeyPageDown,
|
||||
key.CodeRightArrow: KeyArrowRight,
|
||||
key.CodeLeftArrow: KeyArrowLeft,
|
||||
key.CodeDownArrow: KeyArrowDown,
|
||||
key.CodeUpArrow: KeyArrowUp,
|
||||
key.CodeKeypadNumLock: KeyNumLock,
|
||||
key.CodeKeypadSlash: KeyNumpadDivide,
|
||||
key.CodeKeypadAsterisk: KeyNumpadMultiply,
|
||||
key.CodeKeypadHyphenMinus: KeyNumpadSubtract,
|
||||
key.CodeKeypadPlusSign: KeyNumpadAdd,
|
||||
key.CodeKeypadEnter: KeyNumpadEnter,
|
||||
key.CodeKeypad1: KeyNumpad1,
|
||||
key.CodeKeypad2: KeyNumpad2,
|
||||
key.CodeKeypad3: KeyNumpad3,
|
||||
key.CodeKeypad4: KeyNumpad4,
|
||||
key.CodeKeypad5: KeyNumpad5,
|
||||
key.CodeKeypad6: KeyNumpad6,
|
||||
key.CodeKeypad7: KeyNumpad7,
|
||||
key.CodeKeypad8: KeyNumpad8,
|
||||
key.CodeKeypad9: KeyNumpad9,
|
||||
key.CodeKeypad0: KeyNumpad0,
|
||||
key.CodeKeypadFullStop: KeyNumpadDecimal,
|
||||
key.CodeKeypadEqualSign: KeyNumpadEqual,
|
||||
key.CodeLeftControl: KeyControlLeft,
|
||||
key.CodeLeftShift: KeyShiftLeft,
|
||||
key.CodeLeftAlt: KeyAltLeft,
|
||||
key.CodeLeftGUI: KeyMetaLeft,
|
||||
key.CodeRightControl: KeyControlRight,
|
||||
key.CodeRightShift: KeyShiftRight,
|
||||
key.CodeRightAlt: KeyAltRight,
|
||||
key.CodeRightGUI: KeyMetaRight,
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ func (u *UserInterface) appMain(a app.App) {
|
||||
var sizeInited bool
|
||||
|
||||
touches := map[touch.Sequence]Touch{}
|
||||
keys := map[driver.Key]struct{}{}
|
||||
keys := map[Key]struct{}{}
|
||||
|
||||
for e := range a.Events() {
|
||||
var updateInput bool
|
||||
@ -196,7 +196,7 @@ func (u *UserInterface) appMain(a app.App) {
|
||||
}
|
||||
updateInput = true
|
||||
case key.Event:
|
||||
k, ok := gbuildKeyToDriverKey[e.Code]
|
||||
k, ok := gbuildKeyToUIKey[e.Code]
|
||||
if ok {
|
||||
switch e.Direction {
|
||||
case key.DirPress, key.DirNone:
|
||||
@ -460,7 +460,7 @@ type Touch struct {
|
||||
Y int
|
||||
}
|
||||
|
||||
func (u *UserInterface) UpdateInput(keys map[driver.Key]struct{}, runes []rune, touches []Touch) {
|
||||
func (u *UserInterface) UpdateInput(keys map[Key]struct{}, runes []rune, touches []Touch) {
|
||||
u.input.update(keys, runes, touches)
|
||||
if u.fpsMode == FPSModeVsyncOffMinimum {
|
||||
u.renderRequester.RequestRenderIfNeeded()
|
||||
|
290
keys.go
290
keys.go
@ -19,7 +19,7 @@ package ebiten
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/ui"
|
||||
)
|
||||
|
||||
// A Key represents a keyboard key.
|
||||
@ -29,154 +29,154 @@ type Key int
|
||||
|
||||
// Keys.
|
||||
const (
|
||||
KeyA Key = Key(driver.KeyA)
|
||||
KeyB Key = Key(driver.KeyB)
|
||||
KeyC Key = Key(driver.KeyC)
|
||||
KeyD Key = Key(driver.KeyD)
|
||||
KeyE Key = Key(driver.KeyE)
|
||||
KeyF Key = Key(driver.KeyF)
|
||||
KeyG Key = Key(driver.KeyG)
|
||||
KeyH Key = Key(driver.KeyH)
|
||||
KeyI Key = Key(driver.KeyI)
|
||||
KeyJ Key = Key(driver.KeyJ)
|
||||
KeyK Key = Key(driver.KeyK)
|
||||
KeyL Key = Key(driver.KeyL)
|
||||
KeyM Key = Key(driver.KeyM)
|
||||
KeyN Key = Key(driver.KeyN)
|
||||
KeyO Key = Key(driver.KeyO)
|
||||
KeyP Key = Key(driver.KeyP)
|
||||
KeyQ Key = Key(driver.KeyQ)
|
||||
KeyR Key = Key(driver.KeyR)
|
||||
KeyS Key = Key(driver.KeyS)
|
||||
KeyT Key = Key(driver.KeyT)
|
||||
KeyU Key = Key(driver.KeyU)
|
||||
KeyV Key = Key(driver.KeyV)
|
||||
KeyW Key = Key(driver.KeyW)
|
||||
KeyX Key = Key(driver.KeyX)
|
||||
KeyY Key = Key(driver.KeyY)
|
||||
KeyZ Key = Key(driver.KeyZ)
|
||||
KeyAltLeft Key = Key(driver.KeyAltLeft)
|
||||
KeyAltRight Key = Key(driver.KeyAltRight)
|
||||
KeyArrowDown Key = Key(driver.KeyArrowDown)
|
||||
KeyArrowLeft Key = Key(driver.KeyArrowLeft)
|
||||
KeyArrowRight Key = Key(driver.KeyArrowRight)
|
||||
KeyArrowUp Key = Key(driver.KeyArrowUp)
|
||||
KeyBackquote Key = Key(driver.KeyBackquote)
|
||||
KeyBackslash Key = Key(driver.KeyBackslash)
|
||||
KeyBackspace Key = Key(driver.KeyBackspace)
|
||||
KeyBracketLeft Key = Key(driver.KeyBracketLeft)
|
||||
KeyBracketRight Key = Key(driver.KeyBracketRight)
|
||||
KeyCapsLock Key = Key(driver.KeyCapsLock)
|
||||
KeyComma Key = Key(driver.KeyComma)
|
||||
KeyContextMenu Key = Key(driver.KeyContextMenu)
|
||||
KeyControlLeft Key = Key(driver.KeyControlLeft)
|
||||
KeyControlRight Key = Key(driver.KeyControlRight)
|
||||
KeyDelete Key = Key(driver.KeyDelete)
|
||||
KeyDigit0 Key = Key(driver.KeyDigit0)
|
||||
KeyDigit1 Key = Key(driver.KeyDigit1)
|
||||
KeyDigit2 Key = Key(driver.KeyDigit2)
|
||||
KeyDigit3 Key = Key(driver.KeyDigit3)
|
||||
KeyDigit4 Key = Key(driver.KeyDigit4)
|
||||
KeyDigit5 Key = Key(driver.KeyDigit5)
|
||||
KeyDigit6 Key = Key(driver.KeyDigit6)
|
||||
KeyDigit7 Key = Key(driver.KeyDigit7)
|
||||
KeyDigit8 Key = Key(driver.KeyDigit8)
|
||||
KeyDigit9 Key = Key(driver.KeyDigit9)
|
||||
KeyEnd Key = Key(driver.KeyEnd)
|
||||
KeyEnter Key = Key(driver.KeyEnter)
|
||||
KeyEqual Key = Key(driver.KeyEqual)
|
||||
KeyEscape Key = Key(driver.KeyEscape)
|
||||
KeyF1 Key = Key(driver.KeyF1)
|
||||
KeyF2 Key = Key(driver.KeyF2)
|
||||
KeyF3 Key = Key(driver.KeyF3)
|
||||
KeyF4 Key = Key(driver.KeyF4)
|
||||
KeyF5 Key = Key(driver.KeyF5)
|
||||
KeyF6 Key = Key(driver.KeyF6)
|
||||
KeyF7 Key = Key(driver.KeyF7)
|
||||
KeyF8 Key = Key(driver.KeyF8)
|
||||
KeyF9 Key = Key(driver.KeyF9)
|
||||
KeyF10 Key = Key(driver.KeyF10)
|
||||
KeyF11 Key = Key(driver.KeyF11)
|
||||
KeyF12 Key = Key(driver.KeyF12)
|
||||
KeyHome Key = Key(driver.KeyHome)
|
||||
KeyInsert Key = Key(driver.KeyInsert)
|
||||
KeyMetaLeft Key = Key(driver.KeyMetaLeft)
|
||||
KeyMetaRight Key = Key(driver.KeyMetaRight)
|
||||
KeyMinus Key = Key(driver.KeyMinus)
|
||||
KeyNumLock Key = Key(driver.KeyNumLock)
|
||||
KeyNumpad0 Key = Key(driver.KeyNumpad0)
|
||||
KeyNumpad1 Key = Key(driver.KeyNumpad1)
|
||||
KeyNumpad2 Key = Key(driver.KeyNumpad2)
|
||||
KeyNumpad3 Key = Key(driver.KeyNumpad3)
|
||||
KeyNumpad4 Key = Key(driver.KeyNumpad4)
|
||||
KeyNumpad5 Key = Key(driver.KeyNumpad5)
|
||||
KeyNumpad6 Key = Key(driver.KeyNumpad6)
|
||||
KeyNumpad7 Key = Key(driver.KeyNumpad7)
|
||||
KeyNumpad8 Key = Key(driver.KeyNumpad8)
|
||||
KeyNumpad9 Key = Key(driver.KeyNumpad9)
|
||||
KeyNumpadAdd Key = Key(driver.KeyNumpadAdd)
|
||||
KeyNumpadDecimal Key = Key(driver.KeyNumpadDecimal)
|
||||
KeyNumpadDivide Key = Key(driver.KeyNumpadDivide)
|
||||
KeyNumpadEnter Key = Key(driver.KeyNumpadEnter)
|
||||
KeyNumpadEqual Key = Key(driver.KeyNumpadEqual)
|
||||
KeyNumpadMultiply Key = Key(driver.KeyNumpadMultiply)
|
||||
KeyNumpadSubtract Key = Key(driver.KeyNumpadSubtract)
|
||||
KeyPageDown Key = Key(driver.KeyPageDown)
|
||||
KeyPageUp Key = Key(driver.KeyPageUp)
|
||||
KeyPause Key = Key(driver.KeyPause)
|
||||
KeyPeriod Key = Key(driver.KeyPeriod)
|
||||
KeyPrintScreen Key = Key(driver.KeyPrintScreen)
|
||||
KeyQuote Key = Key(driver.KeyQuote)
|
||||
KeyScrollLock Key = Key(driver.KeyScrollLock)
|
||||
KeySemicolon Key = Key(driver.KeySemicolon)
|
||||
KeyShiftLeft Key = Key(driver.KeyShiftLeft)
|
||||
KeyShiftRight Key = Key(driver.KeyShiftRight)
|
||||
KeySlash Key = Key(driver.KeySlash)
|
||||
KeySpace Key = Key(driver.KeySpace)
|
||||
KeyTab Key = Key(driver.KeyTab)
|
||||
KeyAlt Key = Key(driver.KeyReserved0)
|
||||
KeyControl Key = Key(driver.KeyReserved1)
|
||||
KeyShift Key = Key(driver.KeyReserved2)
|
||||
KeyMeta Key = Key(driver.KeyReserved3)
|
||||
KeyA Key = Key(ui.KeyA)
|
||||
KeyB Key = Key(ui.KeyB)
|
||||
KeyC Key = Key(ui.KeyC)
|
||||
KeyD Key = Key(ui.KeyD)
|
||||
KeyE Key = Key(ui.KeyE)
|
||||
KeyF Key = Key(ui.KeyF)
|
||||
KeyG Key = Key(ui.KeyG)
|
||||
KeyH Key = Key(ui.KeyH)
|
||||
KeyI Key = Key(ui.KeyI)
|
||||
KeyJ Key = Key(ui.KeyJ)
|
||||
KeyK Key = Key(ui.KeyK)
|
||||
KeyL Key = Key(ui.KeyL)
|
||||
KeyM Key = Key(ui.KeyM)
|
||||
KeyN Key = Key(ui.KeyN)
|
||||
KeyO Key = Key(ui.KeyO)
|
||||
KeyP Key = Key(ui.KeyP)
|
||||
KeyQ Key = Key(ui.KeyQ)
|
||||
KeyR Key = Key(ui.KeyR)
|
||||
KeyS Key = Key(ui.KeyS)
|
||||
KeyT Key = Key(ui.KeyT)
|
||||
KeyU Key = Key(ui.KeyU)
|
||||
KeyV Key = Key(ui.KeyV)
|
||||
KeyW Key = Key(ui.KeyW)
|
||||
KeyX Key = Key(ui.KeyX)
|
||||
KeyY Key = Key(ui.KeyY)
|
||||
KeyZ Key = Key(ui.KeyZ)
|
||||
KeyAltLeft Key = Key(ui.KeyAltLeft)
|
||||
KeyAltRight Key = Key(ui.KeyAltRight)
|
||||
KeyArrowDown Key = Key(ui.KeyArrowDown)
|
||||
KeyArrowLeft Key = Key(ui.KeyArrowLeft)
|
||||
KeyArrowRight Key = Key(ui.KeyArrowRight)
|
||||
KeyArrowUp Key = Key(ui.KeyArrowUp)
|
||||
KeyBackquote Key = Key(ui.KeyBackquote)
|
||||
KeyBackslash Key = Key(ui.KeyBackslash)
|
||||
KeyBackspace Key = Key(ui.KeyBackspace)
|
||||
KeyBracketLeft Key = Key(ui.KeyBracketLeft)
|
||||
KeyBracketRight Key = Key(ui.KeyBracketRight)
|
||||
KeyCapsLock Key = Key(ui.KeyCapsLock)
|
||||
KeyComma Key = Key(ui.KeyComma)
|
||||
KeyContextMenu Key = Key(ui.KeyContextMenu)
|
||||
KeyControlLeft Key = Key(ui.KeyControlLeft)
|
||||
KeyControlRight Key = Key(ui.KeyControlRight)
|
||||
KeyDelete Key = Key(ui.KeyDelete)
|
||||
KeyDigit0 Key = Key(ui.KeyDigit0)
|
||||
KeyDigit1 Key = Key(ui.KeyDigit1)
|
||||
KeyDigit2 Key = Key(ui.KeyDigit2)
|
||||
KeyDigit3 Key = Key(ui.KeyDigit3)
|
||||
KeyDigit4 Key = Key(ui.KeyDigit4)
|
||||
KeyDigit5 Key = Key(ui.KeyDigit5)
|
||||
KeyDigit6 Key = Key(ui.KeyDigit6)
|
||||
KeyDigit7 Key = Key(ui.KeyDigit7)
|
||||
KeyDigit8 Key = Key(ui.KeyDigit8)
|
||||
KeyDigit9 Key = Key(ui.KeyDigit9)
|
||||
KeyEnd Key = Key(ui.KeyEnd)
|
||||
KeyEnter Key = Key(ui.KeyEnter)
|
||||
KeyEqual Key = Key(ui.KeyEqual)
|
||||
KeyEscape Key = Key(ui.KeyEscape)
|
||||
KeyF1 Key = Key(ui.KeyF1)
|
||||
KeyF2 Key = Key(ui.KeyF2)
|
||||
KeyF3 Key = Key(ui.KeyF3)
|
||||
KeyF4 Key = Key(ui.KeyF4)
|
||||
KeyF5 Key = Key(ui.KeyF5)
|
||||
KeyF6 Key = Key(ui.KeyF6)
|
||||
KeyF7 Key = Key(ui.KeyF7)
|
||||
KeyF8 Key = Key(ui.KeyF8)
|
||||
KeyF9 Key = Key(ui.KeyF9)
|
||||
KeyF10 Key = Key(ui.KeyF10)
|
||||
KeyF11 Key = Key(ui.KeyF11)
|
||||
KeyF12 Key = Key(ui.KeyF12)
|
||||
KeyHome Key = Key(ui.KeyHome)
|
||||
KeyInsert Key = Key(ui.KeyInsert)
|
||||
KeyMetaLeft Key = Key(ui.KeyMetaLeft)
|
||||
KeyMetaRight Key = Key(ui.KeyMetaRight)
|
||||
KeyMinus Key = Key(ui.KeyMinus)
|
||||
KeyNumLock Key = Key(ui.KeyNumLock)
|
||||
KeyNumpad0 Key = Key(ui.KeyNumpad0)
|
||||
KeyNumpad1 Key = Key(ui.KeyNumpad1)
|
||||
KeyNumpad2 Key = Key(ui.KeyNumpad2)
|
||||
KeyNumpad3 Key = Key(ui.KeyNumpad3)
|
||||
KeyNumpad4 Key = Key(ui.KeyNumpad4)
|
||||
KeyNumpad5 Key = Key(ui.KeyNumpad5)
|
||||
KeyNumpad6 Key = Key(ui.KeyNumpad6)
|
||||
KeyNumpad7 Key = Key(ui.KeyNumpad7)
|
||||
KeyNumpad8 Key = Key(ui.KeyNumpad8)
|
||||
KeyNumpad9 Key = Key(ui.KeyNumpad9)
|
||||
KeyNumpadAdd Key = Key(ui.KeyNumpadAdd)
|
||||
KeyNumpadDecimal Key = Key(ui.KeyNumpadDecimal)
|
||||
KeyNumpadDivide Key = Key(ui.KeyNumpadDivide)
|
||||
KeyNumpadEnter Key = Key(ui.KeyNumpadEnter)
|
||||
KeyNumpadEqual Key = Key(ui.KeyNumpadEqual)
|
||||
KeyNumpadMultiply Key = Key(ui.KeyNumpadMultiply)
|
||||
KeyNumpadSubtract Key = Key(ui.KeyNumpadSubtract)
|
||||
KeyPageDown Key = Key(ui.KeyPageDown)
|
||||
KeyPageUp Key = Key(ui.KeyPageUp)
|
||||
KeyPause Key = Key(ui.KeyPause)
|
||||
KeyPeriod Key = Key(ui.KeyPeriod)
|
||||
KeyPrintScreen Key = Key(ui.KeyPrintScreen)
|
||||
KeyQuote Key = Key(ui.KeyQuote)
|
||||
KeyScrollLock Key = Key(ui.KeyScrollLock)
|
||||
KeySemicolon Key = Key(ui.KeySemicolon)
|
||||
KeyShiftLeft Key = Key(ui.KeyShiftLeft)
|
||||
KeyShiftRight Key = Key(ui.KeyShiftRight)
|
||||
KeySlash Key = Key(ui.KeySlash)
|
||||
KeySpace Key = Key(ui.KeySpace)
|
||||
KeyTab Key = Key(ui.KeyTab)
|
||||
KeyAlt Key = Key(ui.KeyReserved0)
|
||||
KeyControl Key = Key(ui.KeyReserved1)
|
||||
KeyShift Key = Key(ui.KeyReserved2)
|
||||
KeyMeta Key = Key(ui.KeyReserved3)
|
||||
KeyMax Key = KeyMeta
|
||||
|
||||
// Keys for backward compatibility.
|
||||
// Deprecated: as of v2.1.
|
||||
Key0 Key = Key(driver.KeyDigit0)
|
||||
Key1 Key = Key(driver.KeyDigit1)
|
||||
Key2 Key = Key(driver.KeyDigit2)
|
||||
Key3 Key = Key(driver.KeyDigit3)
|
||||
Key4 Key = Key(driver.KeyDigit4)
|
||||
Key5 Key = Key(driver.KeyDigit5)
|
||||
Key6 Key = Key(driver.KeyDigit6)
|
||||
Key7 Key = Key(driver.KeyDigit7)
|
||||
Key8 Key = Key(driver.KeyDigit8)
|
||||
Key9 Key = Key(driver.KeyDigit9)
|
||||
KeyApostrophe Key = Key(driver.KeyQuote)
|
||||
KeyDown Key = Key(driver.KeyArrowDown)
|
||||
KeyGraveAccent Key = Key(driver.KeyBackquote)
|
||||
KeyKP0 Key = Key(driver.KeyNumpad0)
|
||||
KeyKP1 Key = Key(driver.KeyNumpad1)
|
||||
KeyKP2 Key = Key(driver.KeyNumpad2)
|
||||
KeyKP3 Key = Key(driver.KeyNumpad3)
|
||||
KeyKP4 Key = Key(driver.KeyNumpad4)
|
||||
KeyKP5 Key = Key(driver.KeyNumpad5)
|
||||
KeyKP6 Key = Key(driver.KeyNumpad6)
|
||||
KeyKP7 Key = Key(driver.KeyNumpad7)
|
||||
KeyKP8 Key = Key(driver.KeyNumpad8)
|
||||
KeyKP9 Key = Key(driver.KeyNumpad9)
|
||||
KeyKPDecimal Key = Key(driver.KeyNumpadDecimal)
|
||||
KeyKPDivide Key = Key(driver.KeyNumpadDivide)
|
||||
KeyKPEnter Key = Key(driver.KeyNumpadEnter)
|
||||
KeyKPEqual Key = Key(driver.KeyNumpadEqual)
|
||||
KeyKPMultiply Key = Key(driver.KeyNumpadMultiply)
|
||||
KeyKPSubtract Key = Key(driver.KeyNumpadSubtract)
|
||||
KeyLeft Key = Key(driver.KeyArrowLeft)
|
||||
KeyLeftBracket Key = Key(driver.KeyBracketLeft)
|
||||
KeyMenu Key = Key(driver.KeyContextMenu)
|
||||
KeyRight Key = Key(driver.KeyArrowRight)
|
||||
KeyRightBracket Key = Key(driver.KeyBracketRight)
|
||||
KeyUp Key = Key(driver.KeyArrowUp)
|
||||
Key0 Key = Key(ui.KeyDigit0)
|
||||
Key1 Key = Key(ui.KeyDigit1)
|
||||
Key2 Key = Key(ui.KeyDigit2)
|
||||
Key3 Key = Key(ui.KeyDigit3)
|
||||
Key4 Key = Key(ui.KeyDigit4)
|
||||
Key5 Key = Key(ui.KeyDigit5)
|
||||
Key6 Key = Key(ui.KeyDigit6)
|
||||
Key7 Key = Key(ui.KeyDigit7)
|
||||
Key8 Key = Key(ui.KeyDigit8)
|
||||
Key9 Key = Key(ui.KeyDigit9)
|
||||
KeyApostrophe Key = Key(ui.KeyQuote)
|
||||
KeyDown Key = Key(ui.KeyArrowDown)
|
||||
KeyGraveAccent Key = Key(ui.KeyBackquote)
|
||||
KeyKP0 Key = Key(ui.KeyNumpad0)
|
||||
KeyKP1 Key = Key(ui.KeyNumpad1)
|
||||
KeyKP2 Key = Key(ui.KeyNumpad2)
|
||||
KeyKP3 Key = Key(ui.KeyNumpad3)
|
||||
KeyKP4 Key = Key(ui.KeyNumpad4)
|
||||
KeyKP5 Key = Key(ui.KeyNumpad5)
|
||||
KeyKP6 Key = Key(ui.KeyNumpad6)
|
||||
KeyKP7 Key = Key(ui.KeyNumpad7)
|
||||
KeyKP8 Key = Key(ui.KeyNumpad8)
|
||||
KeyKP9 Key = Key(ui.KeyNumpad9)
|
||||
KeyKPDecimal Key = Key(ui.KeyNumpadDecimal)
|
||||
KeyKPDivide Key = Key(ui.KeyNumpadDivide)
|
||||
KeyKPEnter Key = Key(ui.KeyNumpadEnter)
|
||||
KeyKPEqual Key = Key(ui.KeyNumpadEqual)
|
||||
KeyKPMultiply Key = Key(ui.KeyNumpadMultiply)
|
||||
KeyKPSubtract Key = Key(ui.KeyNumpadSubtract)
|
||||
KeyLeft Key = Key(ui.KeyArrowLeft)
|
||||
KeyLeftBracket Key = Key(ui.KeyBracketLeft)
|
||||
KeyMenu Key = Key(ui.KeyContextMenu)
|
||||
KeyRight Key = Key(ui.KeyArrowRight)
|
||||
KeyRightBracket Key = Key(ui.KeyBracketRight)
|
||||
KeyUp Key = Key(ui.KeyArrowUp)
|
||||
)
|
||||
|
||||
func (k Key) isValid() bool {
|
||||
|
@ -18,7 +18,6 @@
|
||||
package ebitenmobileview
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/ui"
|
||||
)
|
||||
|
||||
@ -28,7 +27,7 @@ type position struct {
|
||||
}
|
||||
|
||||
var (
|
||||
keys = map[driver.Key]struct{}{}
|
||||
keys = map[ui.Key]struct{}{}
|
||||
runes []rune
|
||||
touches = map[ui.TouchID]position{}
|
||||
)
|
||||
|
@ -201,7 +201,7 @@ func OnKeyDownOnAndroid(keyCode int, unicodeChar int, source int, deviceID int)
|
||||
case source&sourceJoystick == sourceJoystick:
|
||||
// DPAD keys can come here, but they are also treated as an axis at a motion event. Ignore them.
|
||||
case source&sourceKeyboard == sourceKeyboard:
|
||||
if key, ok := androidKeyToDriverKey[keyCode]; ok {
|
||||
if key, ok := androidKeyToUIKey[keyCode]; ok {
|
||||
keys[key] = struct{}{}
|
||||
if r := rune(unicodeChar); r != 0 && unicode.IsPrint(r) {
|
||||
runes = []rune{r}
|
||||
@ -221,7 +221,7 @@ func OnKeyUpOnAndroid(keyCode int, source int, deviceID int) {
|
||||
case source&sourceJoystick == sourceJoystick:
|
||||
// DPAD keys can come here, but they are also treated as an axis at a motion event. Ignore them.
|
||||
case source&sourceKeyboard == sourceKeyboard:
|
||||
if key, ok := androidKeyToDriverKey[keyCode]; ok {
|
||||
if key, ok := androidKeyToUIKey[keyCode]; ok {
|
||||
delete(keys, key)
|
||||
updateInput()
|
||||
}
|
||||
|
@ -17,113 +17,113 @@
|
||||
package ebitenmobileview
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/ui"
|
||||
)
|
||||
|
||||
var androidKeyToDriverKey = map[int]driver.Key{
|
||||
7: driver.KeyDigit0,
|
||||
8: driver.KeyDigit1,
|
||||
9: driver.KeyDigit2,
|
||||
10: driver.KeyDigit3,
|
||||
11: driver.KeyDigit4,
|
||||
12: driver.KeyDigit5,
|
||||
13: driver.KeyDigit6,
|
||||
14: driver.KeyDigit7,
|
||||
15: driver.KeyDigit8,
|
||||
16: driver.KeyDigit9,
|
||||
19: driver.KeyArrowUp,
|
||||
20: driver.KeyArrowDown,
|
||||
21: driver.KeyArrowLeft,
|
||||
22: driver.KeyArrowRight,
|
||||
29: driver.KeyA,
|
||||
30: driver.KeyB,
|
||||
31: driver.KeyC,
|
||||
32: driver.KeyD,
|
||||
33: driver.KeyE,
|
||||
34: driver.KeyF,
|
||||
35: driver.KeyG,
|
||||
36: driver.KeyH,
|
||||
37: driver.KeyI,
|
||||
38: driver.KeyJ,
|
||||
39: driver.KeyK,
|
||||
40: driver.KeyL,
|
||||
41: driver.KeyM,
|
||||
42: driver.KeyN,
|
||||
43: driver.KeyO,
|
||||
44: driver.KeyP,
|
||||
45: driver.KeyQ,
|
||||
46: driver.KeyR,
|
||||
47: driver.KeyS,
|
||||
48: driver.KeyT,
|
||||
49: driver.KeyU,
|
||||
50: driver.KeyV,
|
||||
51: driver.KeyW,
|
||||
52: driver.KeyX,
|
||||
53: driver.KeyY,
|
||||
54: driver.KeyZ,
|
||||
55: driver.KeyComma,
|
||||
56: driver.KeyPeriod,
|
||||
57: driver.KeyAltLeft,
|
||||
58: driver.KeyAltRight,
|
||||
59: driver.KeyShiftLeft,
|
||||
60: driver.KeyShiftRight,
|
||||
61: driver.KeyTab,
|
||||
62: driver.KeySpace,
|
||||
66: driver.KeyEnter,
|
||||
67: driver.KeyBackspace,
|
||||
68: driver.KeyBackquote,
|
||||
69: driver.KeyMinus,
|
||||
70: driver.KeyEqual,
|
||||
71: driver.KeyBracketLeft,
|
||||
72: driver.KeyBracketRight,
|
||||
73: driver.KeyBackslash,
|
||||
74: driver.KeySemicolon,
|
||||
75: driver.KeyQuote,
|
||||
76: driver.KeySlash,
|
||||
82: driver.KeyContextMenu,
|
||||
92: driver.KeyPageUp,
|
||||
93: driver.KeyPageDown,
|
||||
111: driver.KeyEscape,
|
||||
112: driver.KeyDelete,
|
||||
113: driver.KeyControlLeft,
|
||||
114: driver.KeyControlRight,
|
||||
115: driver.KeyCapsLock,
|
||||
116: driver.KeyScrollLock,
|
||||
117: driver.KeyMetaLeft,
|
||||
118: driver.KeyMetaRight,
|
||||
120: driver.KeyPrintScreen,
|
||||
121: driver.KeyPause,
|
||||
122: driver.KeyHome,
|
||||
123: driver.KeyEnd,
|
||||
124: driver.KeyInsert,
|
||||
131: driver.KeyF1,
|
||||
132: driver.KeyF2,
|
||||
133: driver.KeyF3,
|
||||
134: driver.KeyF4,
|
||||
135: driver.KeyF5,
|
||||
136: driver.KeyF6,
|
||||
137: driver.KeyF7,
|
||||
138: driver.KeyF8,
|
||||
139: driver.KeyF9,
|
||||
140: driver.KeyF10,
|
||||
141: driver.KeyF11,
|
||||
142: driver.KeyF12,
|
||||
143: driver.KeyNumLock,
|
||||
144: driver.KeyNumpad0,
|
||||
145: driver.KeyNumpad1,
|
||||
146: driver.KeyNumpad2,
|
||||
147: driver.KeyNumpad3,
|
||||
148: driver.KeyNumpad4,
|
||||
149: driver.KeyNumpad5,
|
||||
150: driver.KeyNumpad6,
|
||||
151: driver.KeyNumpad7,
|
||||
152: driver.KeyNumpad8,
|
||||
153: driver.KeyNumpad9,
|
||||
154: driver.KeyNumpadDivide,
|
||||
155: driver.KeyNumpadMultiply,
|
||||
156: driver.KeyNumpadSubtract,
|
||||
157: driver.KeyNumpadAdd,
|
||||
158: driver.KeyNumpadDecimal,
|
||||
160: driver.KeyNumpadEnter,
|
||||
161: driver.KeyNumpadEqual,
|
||||
var androidKeyToUIKey = map[int]ui.Key{
|
||||
7: ui.KeyDigit0,
|
||||
8: ui.KeyDigit1,
|
||||
9: ui.KeyDigit2,
|
||||
10: ui.KeyDigit3,
|
||||
11: ui.KeyDigit4,
|
||||
12: ui.KeyDigit5,
|
||||
13: ui.KeyDigit6,
|
||||
14: ui.KeyDigit7,
|
||||
15: ui.KeyDigit8,
|
||||
16: ui.KeyDigit9,
|
||||
19: ui.KeyArrowUp,
|
||||
20: ui.KeyArrowDown,
|
||||
21: ui.KeyArrowLeft,
|
||||
22: ui.KeyArrowRight,
|
||||
29: ui.KeyA,
|
||||
30: ui.KeyB,
|
||||
31: ui.KeyC,
|
||||
32: ui.KeyD,
|
||||
33: ui.KeyE,
|
||||
34: ui.KeyF,
|
||||
35: ui.KeyG,
|
||||
36: ui.KeyH,
|
||||
37: ui.KeyI,
|
||||
38: ui.KeyJ,
|
||||
39: ui.KeyK,
|
||||
40: ui.KeyL,
|
||||
41: ui.KeyM,
|
||||
42: ui.KeyN,
|
||||
43: ui.KeyO,
|
||||
44: ui.KeyP,
|
||||
45: ui.KeyQ,
|
||||
46: ui.KeyR,
|
||||
47: ui.KeyS,
|
||||
48: ui.KeyT,
|
||||
49: ui.KeyU,
|
||||
50: ui.KeyV,
|
||||
51: ui.KeyW,
|
||||
52: ui.KeyX,
|
||||
53: ui.KeyY,
|
||||
54: ui.KeyZ,
|
||||
55: ui.KeyComma,
|
||||
56: ui.KeyPeriod,
|
||||
57: ui.KeyAltLeft,
|
||||
58: ui.KeyAltRight,
|
||||
59: ui.KeyShiftLeft,
|
||||
60: ui.KeyShiftRight,
|
||||
61: ui.KeyTab,
|
||||
62: ui.KeySpace,
|
||||
66: ui.KeyEnter,
|
||||
67: ui.KeyBackspace,
|
||||
68: ui.KeyBackquote,
|
||||
69: ui.KeyMinus,
|
||||
70: ui.KeyEqual,
|
||||
71: ui.KeyBracketLeft,
|
||||
72: ui.KeyBracketRight,
|
||||
73: ui.KeyBackslash,
|
||||
74: ui.KeySemicolon,
|
||||
75: ui.KeyQuote,
|
||||
76: ui.KeySlash,
|
||||
82: ui.KeyContextMenu,
|
||||
92: ui.KeyPageUp,
|
||||
93: ui.KeyPageDown,
|
||||
111: ui.KeyEscape,
|
||||
112: ui.KeyDelete,
|
||||
113: ui.KeyControlLeft,
|
||||
114: ui.KeyControlRight,
|
||||
115: ui.KeyCapsLock,
|
||||
116: ui.KeyScrollLock,
|
||||
117: ui.KeyMetaLeft,
|
||||
118: ui.KeyMetaRight,
|
||||
120: ui.KeyPrintScreen,
|
||||
121: ui.KeyPause,
|
||||
122: ui.KeyHome,
|
||||
123: ui.KeyEnd,
|
||||
124: ui.KeyInsert,
|
||||
131: ui.KeyF1,
|
||||
132: ui.KeyF2,
|
||||
133: ui.KeyF3,
|
||||
134: ui.KeyF4,
|
||||
135: ui.KeyF5,
|
||||
136: ui.KeyF6,
|
||||
137: ui.KeyF7,
|
||||
138: ui.KeyF8,
|
||||
139: ui.KeyF9,
|
||||
140: ui.KeyF10,
|
||||
141: ui.KeyF11,
|
||||
142: ui.KeyF12,
|
||||
143: ui.KeyNumLock,
|
||||
144: ui.KeyNumpad0,
|
||||
145: ui.KeyNumpad1,
|
||||
146: ui.KeyNumpad2,
|
||||
147: ui.KeyNumpad3,
|
||||
148: ui.KeyNumpad4,
|
||||
149: ui.KeyNumpad5,
|
||||
150: ui.KeyNumpad6,
|
||||
151: ui.KeyNumpad7,
|
||||
152: ui.KeyNumpad8,
|
||||
153: ui.KeyNumpad9,
|
||||
154: ui.KeyNumpadDivide,
|
||||
155: ui.KeyNumpadMultiply,
|
||||
156: ui.KeyNumpadSubtract,
|
||||
157: ui.KeyNumpadAdd,
|
||||
158: ui.KeyNumpadDecimal,
|
||||
160: ui.KeyNumpadEnter,
|
||||
161: ui.KeyNumpadEqual,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user