Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Button iota #75

Merged
merged 1 commit into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions backends/opengl/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ func (w *Window) doUpdateInput() {
w.releaseEvents = w.tempReleaseEvents

// Clear last frame's temporary status
w.tempPressEvents = [pixel.NumKeys]bool{}
w.tempReleaseEvents = [pixel.NumKeys]bool{}
w.tempInp.repeat = [pixel.NumKeys]bool{}
w.tempPressEvents = [pixel.NumButtons]bool{}
w.tempReleaseEvents = [pixel.NumButtons]bool{}
w.tempInp.repeat = [pixel.NumButtons]bool{}
w.tempInp.scroll = pixel.ZV
w.tempInp.typed = ""

Expand Down
8 changes: 4 additions & 4 deletions backends/opengl/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ type Window struct {

prevInp, currInp, tempInp struct {
mouse pixel.Vec
buttons [pixel.NumKeys]bool
repeat [pixel.NumKeys]bool
buttons [pixel.NumButtons]bool
repeat [pixel.NumButtons]bool
scroll pixel.Vec
typed string
}

pressEvents, tempPressEvents [pixel.NumKeys]bool
releaseEvents, tempReleaseEvents [pixel.NumKeys]bool
pressEvents, tempPressEvents [pixel.NumButtons]bool
releaseEvents, tempReleaseEvents [pixel.NumButtons]bool

prevJoy, currJoy, tempJoy joystickState
}
Expand Down
20 changes: 7 additions & 13 deletions input.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,8 @@ const (
MouseButton7
MouseButton8

// Last iota
// NOTE: These will be unexported in the future when Window is move to the pixel package.
NumMouseButtons int = iota

// Aliases
MouseButtonLeft = MouseButton1
MouseButtonRight = MouseButton2
MouseButtonMiddle = MouseButton3
)

const (
// List of all keyboard buttons.
KeySpace = iota + Button(NumMouseButtons)
KeySpace
KeyApostrophe
KeyComma
KeyMinus
Expand Down Expand Up @@ -159,7 +148,12 @@ const (

// Last iota
// NOTE: These will be unexported in the future when Window is move to the pixel package.
NumKeys int = iota
NumButtons int = iota

// Aliases
MouseButtonLeft = MouseButton1
MouseButtonRight = MouseButton2
MouseButtonMiddle = MouseButton3
)

var buttonNames = map[Button]string{
Expand Down