Skip to content

Commit

Permalink
add convienence methods for type of button
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Ray committed Aug 21, 2024
1 parent dda5970 commit 7456e0c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions input.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ func (b Button) String() string {
return name
}

func (b Button) IsMouseButton() bool {
return b >= mouseButtonStart && b <= mouseButtonEnd
}

func (b Button) IsKeyboardButton() bool {
return b >= keyButtonStart && b <= keyButtonEnd
}

const UnknownButton Button = -1
const (
// List of all mouse buttons.
Expand Down Expand Up @@ -173,6 +181,11 @@ const (
// Last iota
NumButtons int = iota

mouseButtonStart = MouseButton1
mouseButtonEnd = MouseButton8
keyButtonStart = KeySpace
keyButtonEnd = KeyMenu

// Aliases
MouseButtonLeft = MouseButton1
MouseButtonRight = MouseButton2
Expand Down

0 comments on commit 7456e0c

Please sign in to comment.