Exemple #1
0
// PollEvent (https://wiki.libsdl.org/SDL_PollEvent)
func PollEvent() Event {
	ret := C.SDL_PollEvent(&cevent)
	if ret == 0 {
		return nil
	}
	return goEvent((*CEvent)(unsafe.Pointer(&cevent)))
}
Exemple #2
0
func PollEvent() (*SDLEvent, bool) {
	var ev *SDLEvent = &SDLEvent{}
	if C.SDL_PollEvent((*C.SDL_Event)(cast(ev))) != 0 {
		return ev, true
	}
	return nil, false
}
Exemple #3
0
// Polls for currently pending events
func PollEvent() Event {
	var cev C.SDL_Event
	ret := C.SDL_PollEvent(&cev)
	if ret == 0 {
		return nil
	}

	return goEvent((*cevent)(cast(&cev)))
}
Exemple #4
0
// Polls for currently pending events
func (event *Event) poll() bool {
	GlobalMutex.Lock()

	var ret = C.SDL_PollEvent((*C.SDL_Event)(cast(event)))

	GlobalMutex.Unlock()

	return ret != 0
}
Exemple #5
0
func PollEvent(ev *Event) bool {
	evLock.Lock()
	defer evLock.Unlock()

	if C.SDL_PollEvent(evCache.c()) == 0 {
		return false
	}

	*ev = evCache.toGo()

	return true
}
Exemple #6
0
// Polls for currently pending events
func (event *Event) poll() bool {
	GlobalMutex.Lock()

	var ret = C.SDL_PollEvent((*C.SDL_Event)(cast(event)))

	if ret != 0 {
		if (event.Type == VIDEORESIZE) && (currentVideoSurface != nil) {
			currentVideoSurface.reload()
		}
	}

	GlobalMutex.Unlock()

	return ret != 0
}
Exemple #7
0
func (window *Screen) runEventQueue() {
	var event C.SDL_Event

	for C.SDL_PollEvent(&event) != 0 {
		switch int(C.getEventType(event)) {
		case WindowQuit:
			window.SetToClose()
			break

		case KeyEventDown, KeyEventUp:
			if listener, found := listenerList[int(C.getEventKey(event))]; found {
				listener.callback(int(C.getEventKeyState(event)))
			}
			break
		}
	}
}
Exemple #8
0
// PollEvent polls for currently pending events.
//
// Events not supported by this binding set are discarded.
func pollEvent() interface{} {
	for {
		var ev C.SDL_Event
		if C.SDL_PollEvent(&ev) == 0 {
			return nil
		}

		switch C.eventType(&ev) {
		case C.SDL_KEYDOWN, C.SDL_KEYUP:
			return newKeyboardEvent(&ev)
		case C.SDL_WINDOWEVENT:
			return newWindowEvent(&ev)
		case C.SDL_MOUSEWHEEL:
			return newMouseWheelEvent(&ev)
		case C.SDL_MOUSEMOTION:
			return newMouseMotionEvent(&ev)
		case C.SDL_MOUSEBUTTONDOWN, C.SDL_MOUSEBUTTONUP:
			return newMouseButtonEvent(&ev)
		}
	}
}
Exemple #9
0
// Polls for currently pending events
func (event *Event) Poll() bool {
	var ret = C.SDL_PollEvent((*C.SDL_Event)(cast(event)))
	return ret != 0
}
Exemple #10
0
func (e *event) poll() bool {
	return C.SDL_PollEvent((*C.SDL_Event)(unsafe.Pointer(e))) != 0
}