examples/keyboard: Add backslash key (#339)

This commit is contained in:
Hajime Hoshi 2017-04-14 03:31:13 +09:00
parent a6e4cc51a3
commit e06334c95f
4 changed files with 8 additions and 6 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -30,7 +30,7 @@ import (
)
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"},
{"Ctrl", "A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "'", "Enter"},
{"Shift", "Z", "X", "C", "V", "B", "N", "M", ",", ".", "/", " "},
@ -99,8 +99,10 @@ func outputKeyboardImage() (map[string]image.Rectangle, error) {
case 0:
width = 16 + 8*(j+2)
case len(line) - 1:
if j > 0 {
width = 16 + 8*(j+2)
}
}
case 4:
switch i {
case 0:
@ -160,7 +162,7 @@ import (
var keyboardKeyRects = map[string]image.Rectangle{}
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}}}
func KeyRect(name string) (image.Rectangle, bool) {

View File

@ -49,7 +49,6 @@ func init() {
keyboardKeyRects["C"] = image.Rect(88, 54, 104, 72)
keyboardKeyRects["Ctrl"] = image.Rect(0, 36, 48, 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["E"] = image.Rect(72, 18, 88, 36)
keyboardKeyRects["Enter"] = image.Rect(224, 36, 272, 54)
@ -82,8 +81,9 @@ func init() {
keyboardKeyRects["Y"] = image.Rect(120, 18, 136, 36)
keyboardKeyRects["Z"] = image.Rect(56, 54, 72, 72)
keyboardKeyRects["["] = image.Rect(200, 18, 216, 36)
keyboardKeyRects["\\"] = image.Rect(224, 0, 240, 18)
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) {

View File

@ -43,7 +43,6 @@ func init() {
var keyNames = map[ebiten.Key]string{
ebiten.KeyBackspace: "BS",
ebiten.KeyComma: ",",
ebiten.KeyDelete: "Del",
ebiten.KeyEnter: "Enter",
ebiten.KeyEscape: "Esc",
ebiten.KeyPeriod: ".",
@ -51,6 +50,7 @@ var keyNames = map[ebiten.Key]string{
ebiten.KeyTab: "Tab",
ebiten.KeyMinus: "-",
ebiten.KeyEqual: "=",
ebiten.KeyBackslash: "\\",
ebiten.KeyGraveAccent: "`",
ebiten.KeyLeftBracket: "[",
ebiten.KeyRightBracket: "]",