Skip to content

Commit

Permalink
Merge pull request #110 from dusk125/main
Browse files Browse the repository at this point in the history
  • Loading branch information
dusk125 authored Aug 21, 2024
2 parents dda5970 + 16c8042 commit d660cfa
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions input.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -173,6 +183,12 @@ const (
// Last iota
NumButtons int = iota

// Internal mappings bookending keyboard and mouse buttons.
mouseButtonStart = MouseButton1
mouseButtonEnd = MouseButton8
keyButtonStart = KeySpace
keyButtonEnd = KeyMenu

// Aliases
MouseButtonLeft = MouseButton1
MouseButtonRight = MouseButton2
Expand Down

0 comments on commit d660cfa

Please sign in to comment.