Skip to content

Commit

Permalink
Use -1 for unknown button value, shared by mouse and keyboard inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
bhperry committed Oct 13, 2023
1 parent 34b47dc commit 2a03061
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion backends/opengl/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ var mouseButtonMapping = map[glfw.MouseButton]pixel.Button{
}

var keyButtonMapping = map[glfw.Key]pixel.Button{
glfw.KeyUnknown: pixel.KeyUnknown,
glfw.KeyUnknown: pixel.ButtonUnknown,
glfw.KeySpace: pixel.KeySpace,
glfw.KeyApostrophe: pixel.KeyApostrophe,
glfw.KeyComma: pixel.KeyComma,
Expand Down
7 changes: 4 additions & 3 deletions input.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ func (b Button) String() string {
return name
}

const ButtonUnknown Button = -1

const (
// List of all mouse buttons.
MouseButton1 Button = iota
Expand All @@ -34,8 +36,7 @@ const (

const (
// List of all keyboard buttons.
KeyUnknown Button = iota + Button(NumMouseButtons)
KeySpace
KeySpace = iota + Button(NumMouseButtons)
KeyApostrophe
KeyComma
KeyMinus
Expand Down Expand Up @@ -162,6 +163,7 @@ const (
)

var buttonNames = map[Button]string{
ButtonUnknown: "Unknown",
MouseButton4: "MouseButton4",
MouseButton5: "MouseButton5",
MouseButton6: "MouseButton6",
Expand All @@ -170,7 +172,6 @@ var buttonNames = map[Button]string{
MouseButtonLeft: "MouseButtonLeft",
MouseButtonRight: "MouseButtonRight",
MouseButtonMiddle: "MouseButtonMiddle",
KeyUnknown: "Unknown",
KeySpace: "Space",
KeyApostrophe: "Apostrophe",
KeyComma: "Comma",
Expand Down

0 comments on commit 2a03061

Please sign in to comment.