From e06334c95f3c7852d4566aa0304661b30dc9966f Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 14 Apr 2017 03:31:13 +0900 Subject: [PATCH] examples/keyboard: Add backslash key (#339) --- .../_resources/images/keyboard/keyboard.png | Bin 1894 -> 1861 bytes examples/keyboard/keyboard/gen.go | 8 +++++--- examples/keyboard/keyboard/keyrects.go | 4 ++-- examples/keyboard/main.go | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/_resources/images/keyboard/keyboard.png b/examples/_resources/images/keyboard/keyboard.png index 0cc8f98b22c7f9e5410f79acf43c82c470cb9b2f..6dfd5782cfd64cc6fbd0697568968f6f3fb74a5d 100644 GIT binary patch delta 1702 zcmV;X23h&$4#f_TLVpJBNklabO zE!w|m7wezIX&1e{UVq874+N5`{XN*j1Z=l@J1qG>TbF%-%zyUs3DDi1Y@=@UC$>Mk zzqY@sy?Fq_r~z(?P#xi_!z$y9K)npC1T_cXzjH@G?*MASs*J7rYuSqe{&l#?Rv%#_ z;Al!Z8KMNR@y-%a3DOa;-kuexIc1N}KtDtJ19SzFPP@$@y(axn;848TUq{f^ls#6! z_v{&DpbXZqRDVs$uz>wF)=cr9AfmK6`7E3d+-M3pXH9#=#m0ARdsg)PllGs@DA6N5 zN5Ed|{0@GH9j6x~ru`S}IPEAg?Z08ikruZ7M{IzH(VW6Jn_7q2gK>uSoAmhf;(nan zA7_-As5@L<9BKE)8D%c!^B1_s+AS6oL_qBq=6{G;Ll^7i)W1iqiv(|nM%l`==c+}o zOl9rV-jnnJC4bM=rlSQc4v;qmoB_yF1?;M^EMPGv-O1XNm95I%5YT&ea;kvM3^_=^ z*M>U+I)e2waQJMcE6`ZLdJXIgSh{#(?G&&Sua$vj5l?*qQ~%k=ZUJ?Fp(%WZfH?#G zHSjP0+Ed8O$o>?r*2K|Sd+>BGa27sz3J<+pK_6?kSbq?3Dn^Xo)9v0k6AyhxU&WiTd>A$61#zrGJ!I%%?Aa z&$@ul{$UVM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MOHy?~U%-@f!L|@ICGVL_zrXeN z@$s(+QPDFQm@D2{=6Lp{e@Q_9X`Q~=GHc+!oPo3L`>(_|6p&jv6Mt1yj%>$|+V9ri zYUJMX&vN_S`dd~W000000000000000DtJh3f9ClLBR?H+}Hz>4#qeMi&3IyB!d@t60o;n{lsw!2 zX+$pyXZt^m=(gl+|ECcxke==TI1q3rpL^Tt&*C-|-%y`C`sVK(FI)Kw+KTQ9Re$IAql@qDOTWBT`)~b-{^I)g8}5&z6i}MK;+ws_f@-_K zTKzh&l>IpUT`=N<(E{4FYFa?)3#fk;_{9Qlf1O$b^S?idIvJ=xm~9HbM?k$ORlmNG zy;VjP?&AK0iJ8Lc{!aNnd<_hEAL8HK20c(fZsm4EF<~!fm#3os0F&|tHt<807*qoM6N<$f(F=jG5`Po diff --git a/examples/keyboard/keyboard/gen.go b/examples/keyboard/keyboard/gen.go index 006ba76ec..f6214ffca 100644 --- a/examples/keyboard/keyboard/gen.go +++ b/examples/keyboard/keyboard/gen.go @@ -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,7 +99,9 @@ func outputKeyboardImage() (map[string]image.Rectangle, error) { case 0: width = 16 + 8*(j+2) case len(line) - 1: - width = 16 + 8*(j+2) + if j > 0 { + width = 16 + 8*(j+2) + } } case 4: switch i { @@ -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) { diff --git a/examples/keyboard/keyboard/keyrects.go b/examples/keyboard/keyboard/keyrects.go index f3edf9f3c..faaea182e 100644 --- a/examples/keyboard/keyboard/keyrects.go +++ b/examples/keyboard/keyboard/keyrects.go @@ -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) { diff --git a/examples/keyboard/main.go b/examples/keyboard/main.go index eb0c1f4dc..cd097a707 100644 --- a/examples/keyboard/main.go +++ b/examples/keyboard/main.go @@ -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: "]",