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

Ignore invalidValue at PollEvents, WaitEvents, and WaitEventsTimeout #327

Merged
merged 1 commit into from
Jul 15, 2021
Merged
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
21 changes: 18 additions & 3 deletions v3.3/glfw/window.go
Original file line number Diff line number Diff line change
@@ -936,6 +936,21 @@ func (w *Window) GetClipboardString() string {
return C.GoString(cs)
}

// panicErrorExceptForInvalidValue is the same as panicError but ignores
// invalidValue.
func panicErrorExceptForInvalidValue() {
// invalidValue can happen when specific joysticks are used. This issue
// will be fixed in GLFW 3.3.5. As a temporary fix, ignore this error.
// See go-gl/glfw#292, go-gl/glfw#324, and glfw/glfw#1763.
err := acceptError(invalidValue)
if e, ok := err.(*Error); ok && e.Code == invalidValue {
return
}
if err != nil {
panic(err)
}
}

// PollEvents processes only those events that have already been received and
// then returns immediately. Processing events will cause the window and input
// callbacks associated with those events to be called.
@@ -947,7 +962,7 @@ func (w *Window) GetClipboardString() string {
// This function may only be called from the main thread.
func PollEvents() {
C.glfwPollEvents()
panicError()
panicErrorExceptForInvalidValue()
}

// WaitEvents puts the calling thread to sleep until at least one event has been
@@ -965,7 +980,7 @@ func PollEvents() {
// This function may only be called from the main thread.
func WaitEvents() {
C.glfwWaitEvents()
panicError()
panicErrorExceptForInvalidValue()
}

// WaitEventsTimeout puts the calling thread to sleep until at least one event is available in the
@@ -992,7 +1007,7 @@ func WaitEvents() {
// Event processing is not required for joystick input to work.
func WaitEventsTimeout(timeout float64) {
C.glfwWaitEventsTimeout(C.double(timeout))
panicError()
panicErrorExceptForInvalidValue()
}

// PostEmptyEvent posts an empty event from the current thread to the main