2023-10-23 15:45:18 +03:00
|
|
|
package gg
|
2023-02-18 07:46:33 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hajimehoshi/ebiten/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Key = ebiten.Key
|
2023-11-23 22:05:22 +03:00
|
|
|
const (
|
|
|
|
KeyA Key = Key(ebiten.KeyA)
|
|
|
|
KeyB Key = Key(ebiten.KeyB)
|
|
|
|
KeyC Key = Key(ebiten.KeyC)
|
|
|
|
KeyD Key = Key(ebiten.KeyD)
|
|
|
|
KeyE Key = Key(ebiten.KeyE)
|
|
|
|
KeyF Key = Key(ebiten.KeyF)
|
|
|
|
KeyG Key = Key(ebiten.KeyG)
|
|
|
|
KeyH Key = Key(ebiten.KeyH)
|
|
|
|
KeyI Key = Key(ebiten.KeyI)
|
|
|
|
KeyJ Key = Key(ebiten.KeyJ)
|
|
|
|
KeyK Key = Key(ebiten.KeyK)
|
|
|
|
KeyL Key = Key(ebiten.KeyL)
|
|
|
|
KeyM Key = Key(ebiten.KeyM)
|
|
|
|
KeyN Key = Key(ebiten.KeyN)
|
|
|
|
KeyO Key = Key(ebiten.KeyO)
|
|
|
|
KeyP Key = Key(ebiten.KeyP)
|
|
|
|
KeyQ Key = Key(ebiten.KeyQ)
|
|
|
|
KeyR Key = Key(ebiten.KeyR)
|
|
|
|
KeyS Key = Key(ebiten.KeyS)
|
|
|
|
KeyT Key = Key(ebiten.KeyT)
|
|
|
|
KeyU Key = Key(ebiten.KeyU)
|
|
|
|
KeyV Key = Key(ebiten.KeyV)
|
|
|
|
KeyW Key = Key(ebiten.KeyW)
|
|
|
|
KeyX Key = Key(ebiten.KeyX)
|
|
|
|
KeyY Key = Key(ebiten.KeyY)
|
|
|
|
KeyZ Key = Key(ebiten.KeyZ)
|
|
|
|
KeyAltLeft Key = Key(ebiten.KeyAltLeft)
|
|
|
|
KeyAltRight Key = Key(ebiten.KeyAltRight)
|
|
|
|
//KeyArrowDown Key = Key(ebiten.KeyArrowDown)
|
|
|
|
//KeyArrowLeft Key = Key(ebiten.KeyArrowLeft)
|
|
|
|
//KeyArrowRight Key = Key(ebiten.KeyArrowRight)
|
|
|
|
//KeyArrowUp Key = Key(ebiten.KeyArrowUp)
|
|
|
|
KeyBackquote Key = Key(ebiten.KeyBackquote)
|
|
|
|
KeyBackslash Key = Key(ebiten.KeyBackslash)
|
|
|
|
KeyBackspace Key = Key(ebiten.KeyBackspace)
|
|
|
|
KeyBracketLeft Key = Key(ebiten.KeyBracketLeft)
|
|
|
|
KeyBracketRight Key = Key(ebiten.KeyBracketRight)
|
|
|
|
KeyCapsLock Key = Key(ebiten.KeyCapsLock)
|
|
|
|
KeyComma Key = Key(ebiten.KeyComma)
|
|
|
|
KeyContextMenu Key = Key(ebiten.KeyContextMenu)
|
|
|
|
KeyControlLeft Key = Key(ebiten.KeyControlLeft)
|
|
|
|
KeyControlRight Key = Key(ebiten.KeyControlRight)
|
|
|
|
KeyDelete Key = Key(ebiten.KeyDelete)
|
|
|
|
KeyDigit0 Key = Key(ebiten.KeyDigit0)
|
|
|
|
KeyDigit1 Key = Key(ebiten.KeyDigit1)
|
|
|
|
KeyDigit2 Key = Key(ebiten.KeyDigit2)
|
|
|
|
KeyDigit3 Key = Key(ebiten.KeyDigit3)
|
|
|
|
KeyDigit4 Key = Key(ebiten.KeyDigit4)
|
|
|
|
KeyDigit5 Key = Key(ebiten.KeyDigit5)
|
|
|
|
KeyDigit6 Key = Key(ebiten.KeyDigit6)
|
|
|
|
KeyDigit7 Key = Key(ebiten.KeyDigit7)
|
|
|
|
KeyDigit8 Key = Key(ebiten.KeyDigit8)
|
|
|
|
KeyDigit9 Key = Key(ebiten.KeyDigit9)
|
|
|
|
KeyEnd Key = Key(ebiten.KeyEnd)
|
|
|
|
KeyEnter Key = Key(ebiten.KeyEnter)
|
|
|
|
KeyEqual Key = Key(ebiten.KeyEqual)
|
|
|
|
KeyEscape Key = Key(ebiten.KeyEscape)
|
|
|
|
KeyF1 Key = Key(ebiten.KeyF1)
|
|
|
|
KeyF2 Key = Key(ebiten.KeyF2)
|
|
|
|
KeyF3 Key = Key(ebiten.KeyF3)
|
|
|
|
KeyF4 Key = Key(ebiten.KeyF4)
|
|
|
|
KeyF5 Key = Key(ebiten.KeyF5)
|
|
|
|
KeyF6 Key = Key(ebiten.KeyF6)
|
|
|
|
KeyF7 Key = Key(ebiten.KeyF7)
|
|
|
|
KeyF8 Key = Key(ebiten.KeyF8)
|
|
|
|
KeyF9 Key = Key(ebiten.KeyF9)
|
|
|
|
KeyF10 Key = Key(ebiten.KeyF10)
|
|
|
|
KeyF11 Key = Key(ebiten.KeyF11)
|
|
|
|
KeyF12 Key = Key(ebiten.KeyF12)
|
|
|
|
KeyHome Key = Key(ebiten.KeyHome)
|
|
|
|
KeyInsert Key = Key(ebiten.KeyInsert)
|
|
|
|
KeyMetaLeft Key = Key(ebiten.KeyMetaLeft)
|
|
|
|
KeyMetaRight Key = Key(ebiten.KeyMetaRight)
|
|
|
|
KeyMinus Key = Key(ebiten.KeyMinus)
|
|
|
|
KeyNumLock Key = Key(ebiten.KeyNumLock)
|
|
|
|
KeyNumpad0 Key = Key(ebiten.KeyNumpad0)
|
|
|
|
KeyNumpad1 Key = Key(ebiten.KeyNumpad1)
|
|
|
|
KeyNumpad2 Key = Key(ebiten.KeyNumpad2)
|
|
|
|
KeyNumpad3 Key = Key(ebiten.KeyNumpad3)
|
|
|
|
KeyNumpad4 Key = Key(ebiten.KeyNumpad4)
|
|
|
|
KeyNumpad5 Key = Key(ebiten.KeyNumpad5)
|
|
|
|
KeyNumpad6 Key = Key(ebiten.KeyNumpad6)
|
|
|
|
KeyNumpad7 Key = Key(ebiten.KeyNumpad7)
|
|
|
|
KeyNumpad8 Key = Key(ebiten.KeyNumpad8)
|
|
|
|
KeyNumpad9 Key = Key(ebiten.KeyNumpad9)
|
|
|
|
KeyNumpadAdd Key = Key(ebiten.KeyNumpadAdd)
|
|
|
|
KeyNumpadDecimal Key = Key(ebiten.KeyNumpadDecimal)
|
|
|
|
KeyNumpadDivide Key = Key(ebiten.KeyNumpadDivide)
|
|
|
|
KeyNumpadEnter Key = Key(ebiten.KeyNumpadEnter)
|
|
|
|
KeyNumpadEqual Key = Key(ebiten.KeyNumpadEqual)
|
|
|
|
KeyNumpadMultiply Key = Key(ebiten.KeyNumpadMultiply)
|
|
|
|
KeyNumpadSubtract Key = Key(ebiten.KeyNumpadSubtract)
|
|
|
|
KeyPageDown Key = Key(ebiten.KeyPageDown)
|
|
|
|
KeyPageUp Key = Key(ebiten.KeyPageUp)
|
|
|
|
KeyPause Key = Key(ebiten.KeyPause)
|
|
|
|
KeyPeriod Key = Key(ebiten.KeyPeriod)
|
|
|
|
KeyPrintScreen Key = Key(ebiten.KeyPrintScreen)
|
|
|
|
KeyQuote Key = Key(ebiten.KeyQuote)
|
|
|
|
KeyScrollLock Key = Key(ebiten.KeyScrollLock)
|
|
|
|
KeySemicolon Key = Key(ebiten.KeySemicolon)
|
|
|
|
KeyShiftLeft Key = Key(ebiten.KeyShiftLeft)
|
|
|
|
KeyShiftRight Key = Key(ebiten.KeyShiftRight)
|
|
|
|
KeySlash Key = Key(ebiten.KeySlash)
|
|
|
|
KeySpace Key = Key(ebiten.KeySpace)
|
|
|
|
KeyTab Key = Key(ebiten.KeyTab)
|
|
|
|
KeyAlt Key = Key(ebiten.KeyAlt)
|
|
|
|
KeyControl Key = Key(ebiten.KeyControl)
|
|
|
|
KeyShift Key = Key(ebiten.KeyShift)
|
|
|
|
KeyMeta Key = Key(ebiten.KeyMeta)
|
|
|
|
KeyMax Key = KeyMeta
|
2023-02-18 07:46:33 +03:00
|
|
|
|
2023-11-23 22:05:22 +03:00
|
|
|
// Keys for backward compatibility.
|
|
|
|
// Deprecated: as of v2.1.
|
|
|
|
Key0 Key = Key(ebiten.KeyDigit0)
|
|
|
|
Key1 Key = Key(ebiten.KeyDigit1)
|
|
|
|
Key2 Key = Key(ebiten.KeyDigit2)
|
|
|
|
Key3 Key = Key(ebiten.KeyDigit3)
|
|
|
|
Key4 Key = Key(ebiten.KeyDigit4)
|
|
|
|
Key5 Key = Key(ebiten.KeyDigit5)
|
|
|
|
Key6 Key = Key(ebiten.KeyDigit6)
|
|
|
|
Key7 Key = Key(ebiten.KeyDigit7)
|
|
|
|
Key8 Key = Key(ebiten.KeyDigit8)
|
|
|
|
Key9 Key = Key(ebiten.KeyDigit9)
|
|
|
|
KeyApostrophe Key = Key(ebiten.KeyQuote)
|
|
|
|
KeyArrowDown Key = Key(ebiten.KeyArrowDown)
|
|
|
|
KeyGraveAccent Key = Key(ebiten.KeyBackquote)
|
|
|
|
KeyKP0 Key = Key(ebiten.KeyNumpad0)
|
|
|
|
KeyKP1 Key = Key(ebiten.KeyNumpad1)
|
|
|
|
KeyKP2 Key = Key(ebiten.KeyNumpad2)
|
|
|
|
KeyKP3 Key = Key(ebiten.KeyNumpad3)
|
|
|
|
KeyKP4 Key = Key(ebiten.KeyNumpad4)
|
|
|
|
KeyKP5 Key = Key(ebiten.KeyNumpad5)
|
|
|
|
KeyKP6 Key = Key(ebiten.KeyNumpad6)
|
|
|
|
KeyKP7 Key = Key(ebiten.KeyNumpad7)
|
|
|
|
KeyKP8 Key = Key(ebiten.KeyNumpad8)
|
|
|
|
KeyKP9 Key = Key(ebiten.KeyNumpad9)
|
|
|
|
KeyKPAdd Key = Key(ebiten.KeyNumpadAdd)
|
|
|
|
KeyKPDecimal Key = Key(ebiten.KeyNumpadDecimal)
|
|
|
|
KeyKPDivide Key = Key(ebiten.KeyNumpadDivide)
|
|
|
|
KeyKPEnter Key = Key(ebiten.KeyNumpadEnter)
|
|
|
|
KeyKPEqual Key = Key(ebiten.KeyNumpadEqual)
|
|
|
|
KeyKPMultiply Key = Key(ebiten.KeyNumpadMultiply)
|
|
|
|
KeyKPSubtract Key = Key(ebiten.KeyNumpadSubtract)
|
|
|
|
KeyArrowLeft Key = Key(ebiten.KeyArrowLeft)
|
|
|
|
KeyLeftBracket Key = Key(ebiten.KeyBracketLeft)
|
|
|
|
KeyMenu Key = Key(ebiten.KeyContextMenu)
|
|
|
|
KeyArrowRight Key = Key(ebiten.KeyArrowRight)
|
|
|
|
KeyRightBracket Key = Key(ebiten.KeyBracketRight)
|
|
|
|
KeyArrowUp Key = Key(ebiten.KeyArrowUp)
|
|
|
|
)
|
|
|
|
func (e *Engine) IsPressed(k Key) bool {
|
2023-02-18 13:26:54 +03:00
|
|
|
keys := e.Keys()
|
|
|
|
for _, v := range keys {
|
|
|
|
if v == k {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|