diff --git a/input.go b/input.go index 1f0cff6..814cf82 100644 --- a/input.go +++ b/input.go @@ -36,6 +36,16 @@ func (b Button) String() string { return name } +// IsMouseButton returns true if the button is one of the mouse buttons. +func (b Button) IsMouseButton() bool { + return b >= mouseButtonStart && b <= mouseButtonEnd +} + +// IsKeyboardButton returns true if the button is one of the keyboard buttons. +func (b Button) IsKeyboardButton() bool { + return b >= keyButtonStart && b <= keyButtonEnd +} + const UnknownButton Button = -1 const ( // List of all mouse buttons. @@ -173,6 +183,11 @@ const ( // Last iota NumButtons int = iota + mouseButtonStart = MouseButton1 + mouseButtonEnd = MouseButton8 + keyButtonStart = KeySpace + keyButtonEnd = KeyMenu + // Aliases MouseButtonLeft = MouseButton1 MouseButtonRight = MouseButton2