mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
ebiten: refactoring: replace JSKey with JSCode
This commit is contained in:
parent
7dd22fdc61
commit
be0ce08663
20
genkeys.go
20
genkeys.go
@ -33,7 +33,7 @@ var (
|
|||||||
uiKeyNameToGLFWKeyName map[string]string
|
uiKeyNameToGLFWKeyName map[string]string
|
||||||
androidKeyToUIKeyName map[int]string
|
androidKeyToUIKeyName map[int]string
|
||||||
iosKeyToUIKeyName map[int]string
|
iosKeyToUIKeyName map[int]string
|
||||||
uiKeyNameToJSKey map[string]string
|
uiKeyNameToJSCode map[string]string
|
||||||
oldEbitengineKeyNameToUIKeyName map[string]string
|
oldEbitengineKeyNameToUIKeyName map[string]string
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The UI key and JS key are almost same but very slightly different (e.g., 'A' vs 'KeyA').
|
// The UI key and JS key are almost same but very slightly different (e.g., 'A' vs 'KeyA').
|
||||||
uiKeyNameToJSKey = map[string]string{
|
uiKeyNameToJSCode = map[string]string{
|
||||||
"Comma": "Comma",
|
"Comma": "Comma",
|
||||||
"Period": "Period",
|
"Period": "Period",
|
||||||
"AltLeft": "AltLeft",
|
"AltLeft": "AltLeft",
|
||||||
@ -348,7 +348,7 @@ func init() {
|
|||||||
} else {
|
} else {
|
||||||
iosKeyToUIKeyName[0x1E+int(c)-'1'] = name
|
iosKeyToUIKeyName[0x1E+int(c)-'1'] = name
|
||||||
}
|
}
|
||||||
uiKeyNameToJSKey[name] = name
|
uiKeyNameToJSCode[name] = name
|
||||||
|
|
||||||
}
|
}
|
||||||
// ASCII: A - Z
|
// ASCII: A - Z
|
||||||
@ -357,7 +357,7 @@ func init() {
|
|||||||
uiKeyNameToGLFWKeyName[string(c)] = string(c)
|
uiKeyNameToGLFWKeyName[string(c)] = string(c)
|
||||||
androidKeyToUIKeyName[29+int(c)-'A'] = string(c)
|
androidKeyToUIKeyName[29+int(c)-'A'] = string(c)
|
||||||
iosKeyToUIKeyName[0x04+int(c)-'A'] = string(c)
|
iosKeyToUIKeyName[0x04+int(c)-'A'] = string(c)
|
||||||
uiKeyNameToJSKey[string(c)] = "Key" + string(c)
|
uiKeyNameToJSCode[string(c)] = "Key" + string(c)
|
||||||
}
|
}
|
||||||
// Function keys
|
// Function keys
|
||||||
for i := 1; i <= 24; i++ {
|
for i := 1; i <= 24; i++ {
|
||||||
@ -377,7 +377,7 @@ func init() {
|
|||||||
} else {
|
} else {
|
||||||
iosKeyToUIKeyName[0x68+i-13] = name
|
iosKeyToUIKeyName[0x68+i-13] = name
|
||||||
}
|
}
|
||||||
uiKeyNameToJSKey[name] = name
|
uiKeyNameToJSCode[name] = name
|
||||||
}
|
}
|
||||||
// Numpad
|
// Numpad
|
||||||
// https://www.w3.org/TR/uievents-code/#key-numpad-section
|
// https://www.w3.org/TR/uievents-code/#key-numpad-section
|
||||||
@ -393,7 +393,7 @@ func init() {
|
|||||||
} else {
|
} else {
|
||||||
iosKeyToUIKeyName[0x59+int(c)-'1'] = name
|
iosKeyToUIKeyName[0x59+int(c)-'1'] = name
|
||||||
}
|
}
|
||||||
uiKeyNameToJSKey[name] = name
|
uiKeyNameToJSCode[name] = name
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keys for backward compatibility
|
// Keys for backward compatibility
|
||||||
@ -594,7 +594,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var uiKeyToJSCode = map[Key]js.Value{
|
var uiKeyToJSCode = map[Key]js.Value{
|
||||||
{{range $name, $code := .UIKeyNameToJSKey}}Key{{$name}}: js.ValueOf({{$code | printf "%q"}}),
|
{{range $name, $code := .UIKeyNameToJSCode}}Key{{$name}}: js.ValueOf({{$code | printf "%q"}}),
|
||||||
{{end}}
|
{{end}}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
@ -743,7 +743,7 @@ func main() {
|
|||||||
ebitengineKeyNamesWithoutMods := []string{}
|
ebitengineKeyNamesWithoutMods := []string{}
|
||||||
uiKeyNames := []string{}
|
uiKeyNames := []string{}
|
||||||
|
|
||||||
for name := range uiKeyNameToJSKey {
|
for name := range uiKeyNameToJSCode {
|
||||||
uiKeyNames = append(uiKeyNames, name)
|
uiKeyNames = append(uiKeyNames, name)
|
||||||
ebitengineKeyNames = append(ebitengineKeyNames, name)
|
ebitengineKeyNames = append(ebitengineKeyNames, name)
|
||||||
ebitengineKeyNamesWithoutOld = append(ebitengineKeyNamesWithoutOld, name)
|
ebitengineKeyNamesWithoutOld = append(ebitengineKeyNamesWithoutOld, name)
|
||||||
@ -804,7 +804,7 @@ func main() {
|
|||||||
License string
|
License string
|
||||||
DoNotEdit string
|
DoNotEdit string
|
||||||
BuildTag string
|
BuildTag string
|
||||||
UIKeyNameToJSKey map[string]string
|
UIKeyNameToJSCode map[string]string
|
||||||
EbitengineKeyNames []string
|
EbitengineKeyNames []string
|
||||||
EbitengineKeyNamesWithoutOld []string
|
EbitengineKeyNamesWithoutOld []string
|
||||||
EbitengineKeyNamesWithoutMods []string
|
EbitengineKeyNamesWithoutMods []string
|
||||||
@ -818,7 +818,7 @@ func main() {
|
|||||||
License: license,
|
License: license,
|
||||||
DoNotEdit: doNotEdit,
|
DoNotEdit: doNotEdit,
|
||||||
BuildTag: buildTag,
|
BuildTag: buildTag,
|
||||||
UIKeyNameToJSKey: uiKeyNameToJSKey,
|
UIKeyNameToJSCode: uiKeyNameToJSCode,
|
||||||
EbitengineKeyNames: ebitengineKeyNames,
|
EbitengineKeyNames: ebitengineKeyNames,
|
||||||
EbitengineKeyNamesWithoutOld: ebitengineKeyNamesWithoutOld,
|
EbitengineKeyNamesWithoutOld: ebitengineKeyNamesWithoutOld,
|
||||||
EbitengineKeyNamesWithoutMods: ebitengineKeyNamesWithoutMods,
|
EbitengineKeyNamesWithoutMods: ebitengineKeyNamesWithoutMods,
|
||||||
|
Loading…
Reference in New Issue
Block a user