mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
parent
d1b9a0a9a1
commit
c74eb058d3
@ -78,11 +78,13 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
screen.DrawImage(keyboardImage.SubImage(r).(*ebiten.Image), op)
|
||||
}
|
||||
|
||||
keyStrs := []string{}
|
||||
var keyStrs []string
|
||||
var keyNames []string
|
||||
for _, k := range g.keys {
|
||||
keyStrs = append(keyStrs, k.String())
|
||||
keyNames = append(keyNames, ebiten.KeyName(k))
|
||||
}
|
||||
ebitenutil.DebugPrint(screen, strings.Join(keyStrs, ", "))
|
||||
ebitenutil.DebugPrint(screen, strings.Join(keyStrs, ", ")+"\n"+strings.Join(keyNames, ", "))
|
||||
}
|
||||
|
||||
func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
|
||||
|
4
input.go
4
input.go
@ -69,6 +69,10 @@ func IsKeyPressed(key Key) bool {
|
||||
return theInputState.isKeyPressed(key)
|
||||
}
|
||||
|
||||
func KeyName(key Key) string {
|
||||
return ui.KeyName(ui.Key(key))
|
||||
}
|
||||
|
||||
// CursorPosition returns a position of a mouse cursor relative to the game screen (window). The cursor position is
|
||||
// 'logical' position and this considers the scale of the screen.
|
||||
//
|
||||
|
@ -273,6 +273,10 @@ func CreateWindow(width, height int, title string, monitor *Monitor, share *Wind
|
||||
return theWindows.add(w), nil
|
||||
}
|
||||
|
||||
func GetKeyName(key Key, scancode int) string {
|
||||
return glfw.GetKeyName(glfw.Key(key), scancode)
|
||||
}
|
||||
|
||||
func GetMonitors() []*Monitor {
|
||||
ms := []*Monitor{}
|
||||
for _, m := range glfw.GetMonitors() {
|
||||
|
@ -76,3 +76,11 @@ func (u *userInterfaceImpl) updateInputState() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func KeyName(key Key) string {
|
||||
gk, ok := uiKeyToGLFWKey[key]
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
return glfw.GetKeyName(gk, 0)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user