mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
examples/keyboard: Add backslash key (#339)
This commit is contained in:
parent
a6e4cc51a3
commit
e06334c95f
Binary file not shown.
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
@ -30,7 +30,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var keyboardKeys = [][]string{
|
var keyboardKeys = [][]string{
|
||||||
{"Esc", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "`", "Del"},
|
{"Esc", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "\\", "`", " "},
|
||||||
{"Tab", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "[", "]", "BS"},
|
{"Tab", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "[", "]", "BS"},
|
||||||
{"Ctrl", "A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "'", "Enter"},
|
{"Ctrl", "A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "'", "Enter"},
|
||||||
{"Shift", "Z", "X", "C", "V", "B", "N", "M", ",", ".", "/", " "},
|
{"Shift", "Z", "X", "C", "V", "B", "N", "M", ",", ".", "/", " "},
|
||||||
@ -99,8 +99,10 @@ func outputKeyboardImage() (map[string]image.Rectangle, error) {
|
|||||||
case 0:
|
case 0:
|
||||||
width = 16 + 8*(j+2)
|
width = 16 + 8*(j+2)
|
||||||
case len(line) - 1:
|
case len(line) - 1:
|
||||||
|
if j > 0 {
|
||||||
width = 16 + 8*(j+2)
|
width = 16 + 8*(j+2)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
case 4:
|
case 4:
|
||||||
switch i {
|
switch i {
|
||||||
case 0:
|
case 0:
|
||||||
@ -160,7 +162,7 @@ import (
|
|||||||
var keyboardKeyRects = map[string]image.Rectangle{}
|
var keyboardKeyRects = map[string]image.Rectangle{}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
{{range $key, $rect := .KeyRectsMap}} keyboardKeyRects["{{$key}}"] = image.Rect({{$rect.Min.X}}, {{$rect.Min.Y}}, {{$rect.Max.X}}, {{$rect.Max.Y}})
|
{{range $key, $rect := .KeyRectsMap}} keyboardKeyRects[{{printf "%q" $key}}] = image.Rect({{$rect.Min.X}}, {{$rect.Min.Y}}, {{$rect.Max.X}}, {{$rect.Max.Y}})
|
||||||
{{end}}}
|
{{end}}}
|
||||||
|
|
||||||
func KeyRect(name string) (image.Rectangle, bool) {
|
func KeyRect(name string) (image.Rectangle, bool) {
|
||||||
|
@ -49,7 +49,6 @@ func init() {
|
|||||||
keyboardKeyRects["C"] = image.Rect(88, 54, 104, 72)
|
keyboardKeyRects["C"] = image.Rect(88, 54, 104, 72)
|
||||||
keyboardKeyRects["Ctrl"] = image.Rect(0, 36, 48, 54)
|
keyboardKeyRects["Ctrl"] = image.Rect(0, 36, 48, 54)
|
||||||
keyboardKeyRects["D"] = image.Rect(80, 36, 96, 54)
|
keyboardKeyRects["D"] = image.Rect(80, 36, 96, 54)
|
||||||
keyboardKeyRects["Del"] = image.Rect(240, 0, 272, 18)
|
|
||||||
keyboardKeyRects["Down"] = image.Rect(48, 126, 96, 144)
|
keyboardKeyRects["Down"] = image.Rect(48, 126, 96, 144)
|
||||||
keyboardKeyRects["E"] = image.Rect(72, 18, 88, 36)
|
keyboardKeyRects["E"] = image.Rect(72, 18, 88, 36)
|
||||||
keyboardKeyRects["Enter"] = image.Rect(224, 36, 272, 54)
|
keyboardKeyRects["Enter"] = image.Rect(224, 36, 272, 54)
|
||||||
@ -82,8 +81,9 @@ func init() {
|
|||||||
keyboardKeyRects["Y"] = image.Rect(120, 18, 136, 36)
|
keyboardKeyRects["Y"] = image.Rect(120, 18, 136, 36)
|
||||||
keyboardKeyRects["Z"] = image.Rect(56, 54, 72, 72)
|
keyboardKeyRects["Z"] = image.Rect(56, 54, 72, 72)
|
||||||
keyboardKeyRects["["] = image.Rect(200, 18, 216, 36)
|
keyboardKeyRects["["] = image.Rect(200, 18, 216, 36)
|
||||||
|
keyboardKeyRects["\\"] = image.Rect(224, 0, 240, 18)
|
||||||
keyboardKeyRects["]"] = image.Rect(216, 18, 232, 36)
|
keyboardKeyRects["]"] = image.Rect(216, 18, 232, 36)
|
||||||
keyboardKeyRects["`"] = image.Rect(224, 0, 240, 18)
|
keyboardKeyRects["`"] = image.Rect(240, 0, 256, 18)
|
||||||
}
|
}
|
||||||
|
|
||||||
func KeyRect(name string) (image.Rectangle, bool) {
|
func KeyRect(name string) (image.Rectangle, bool) {
|
||||||
|
@ -43,7 +43,6 @@ func init() {
|
|||||||
var keyNames = map[ebiten.Key]string{
|
var keyNames = map[ebiten.Key]string{
|
||||||
ebiten.KeyBackspace: "BS",
|
ebiten.KeyBackspace: "BS",
|
||||||
ebiten.KeyComma: ",",
|
ebiten.KeyComma: ",",
|
||||||
ebiten.KeyDelete: "Del",
|
|
||||||
ebiten.KeyEnter: "Enter",
|
ebiten.KeyEnter: "Enter",
|
||||||
ebiten.KeyEscape: "Esc",
|
ebiten.KeyEscape: "Esc",
|
||||||
ebiten.KeyPeriod: ".",
|
ebiten.KeyPeriod: ".",
|
||||||
@ -51,6 +50,7 @@ var keyNames = map[ebiten.Key]string{
|
|||||||
ebiten.KeyTab: "Tab",
|
ebiten.KeyTab: "Tab",
|
||||||
ebiten.KeyMinus: "-",
|
ebiten.KeyMinus: "-",
|
||||||
ebiten.KeyEqual: "=",
|
ebiten.KeyEqual: "=",
|
||||||
|
ebiten.KeyBackslash: "\\",
|
||||||
ebiten.KeyGraveAccent: "`",
|
ebiten.KeyGraveAccent: "`",
|
||||||
ebiten.KeyLeftBracket: "[",
|
ebiten.KeyLeftBracket: "[",
|
||||||
ebiten.KeyRightBracket: "]",
|
ebiten.KeyRightBracket: "]",
|
||||||
|
Loading…
Reference in New Issue
Block a user