mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
examples/keyboard: Add more keys
This commit is contained in:
parent
95cb0133de
commit
a6e4cc51a3
Binary file not shown.
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.8 KiB |
@ -30,10 +30,10 @@ import (
|
||||
)
|
||||
|
||||
var keyboardKeys = [][]string{
|
||||
{"Esc", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", " ", " ", " ", "Del"},
|
||||
{"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", ",", ".", " ", " "},
|
||||
{"Esc", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "`", "Del"},
|
||||
{"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", ",", ".", "/", " "},
|
||||
{" ", "Alt", "Space", " ", " "},
|
||||
{},
|
||||
{"", "Up", ""},
|
||||
@ -118,9 +118,7 @@ func outputKeyboardImage() (map[string]image.Rectangle, error) {
|
||||
width = 16 * 3
|
||||
}
|
||||
if key != "" {
|
||||
if err := drawKey(img, key, x, y, width); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
drawKey(img, key, x, y, width)
|
||||
if key != " " {
|
||||
keyMap[key] = image.Rect(x, y, x+width, y+height)
|
||||
}
|
||||
|
@ -25,8 +25,11 @@ import (
|
||||
var keyboardKeyRects = map[string]image.Rectangle{}
|
||||
|
||||
func init() {
|
||||
keyboardKeyRects["'"] = image.Rect(208, 36, 224, 54)
|
||||
keyboardKeyRects[","] = image.Rect(168, 54, 184, 72)
|
||||
keyboardKeyRects["-"] = image.Rect(192, 0, 208, 18)
|
||||
keyboardKeyRects["."] = image.Rect(184, 54, 200, 72)
|
||||
keyboardKeyRects["/"] = image.Rect(200, 54, 216, 72)
|
||||
keyboardKeyRects["0"] = image.Rect(176, 0, 192, 18)
|
||||
keyboardKeyRects["1"] = image.Rect(32, 0, 48, 18)
|
||||
keyboardKeyRects["2"] = image.Rect(48, 0, 64, 18)
|
||||
@ -37,6 +40,8 @@ func init() {
|
||||
keyboardKeyRects["7"] = image.Rect(128, 0, 144, 18)
|
||||
keyboardKeyRects["8"] = image.Rect(144, 0, 160, 18)
|
||||
keyboardKeyRects["9"] = image.Rect(160, 0, 176, 18)
|
||||
keyboardKeyRects[";"] = image.Rect(192, 36, 208, 54)
|
||||
keyboardKeyRects["="] = image.Rect(208, 0, 224, 18)
|
||||
keyboardKeyRects["A"] = image.Rect(48, 36, 64, 54)
|
||||
keyboardKeyRects["Alt"] = image.Rect(64, 72, 96, 90)
|
||||
keyboardKeyRects["B"] = image.Rect(120, 54, 136, 72)
|
||||
@ -76,6 +81,9 @@ func init() {
|
||||
keyboardKeyRects["X"] = image.Rect(72, 54, 88, 72)
|
||||
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(216, 18, 232, 36)
|
||||
keyboardKeyRects["`"] = image.Rect(224, 0, 240, 18)
|
||||
}
|
||||
|
||||
func KeyRect(name string) (image.Rectangle, bool) {
|
||||
|
@ -49,6 +49,14 @@ var keyNames = map[ebiten.Key]string{
|
||||
ebiten.KeyPeriod: ".",
|
||||
ebiten.KeySpace: "Space",
|
||||
ebiten.KeyTab: "Tab",
|
||||
ebiten.KeyMinus: "-",
|
||||
ebiten.KeyEqual: "=",
|
||||
ebiten.KeyGraveAccent: "`",
|
||||
ebiten.KeyLeftBracket: "[",
|
||||
ebiten.KeyRightBracket: "]",
|
||||
ebiten.KeySemicolon: ";",
|
||||
ebiten.KeyApostrophe: "'",
|
||||
ebiten.KeySlash: "/",
|
||||
|
||||
// Arrows
|
||||
ebiten.KeyDown: "Down",
|
||||
|
Loading…
Reference in New Issue
Block a user