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 issue 54. #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
20 changes: 17 additions & 3 deletions sdl/sdl.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,9 +725,19 @@ func WaitEvent() Event {
return goEvent((*cevent)(cast(&cev)))
}

// Push the event onto the event queue
// Push the event onto the event queue. Note that it must be passed a
// pointer to one of the Event structs, not a value. Thus
//
// PushEvent(&UserEvent{})
//
// will succeed, but
//
// PushEvent(UserEvent{})
//
// will result in a panic.
func PushEvent(event Event) bool {
ret := C.SDL_PushEvent((*C.SDL_Event)(cast(cEvent(event))))
cev := cEvent(event)
ret := C.SDL_PushEvent((*C.SDL_Event)(cast(cev)))

return ret != 0
}
Expand Down Expand Up @@ -778,7 +788,11 @@ func goEvent(cev *cevent) Event {

func cEvent(ev Event) *cevent {
evv := reflect.ValueOf(ev)
return (*cevent)(cast(evv.UnsafeAddr()))
if k := evv.Kind(); k != reflect.Ptr {
panic("Can't handle kind: " + k.String())
}

return (*cevent)(cast(evv.Elem().UnsafeAddr()))
}

// Time
Expand Down