Пример #1
0
// Retrieve the current state of the mouse.
// The current button state is returned as a button bitmask, which can
// be tested using the sdl.BUTTON(X) functions, and x and y are set
// to the current mouse cursor position.
func GetMouseState() (uint8, int, int) {
	var x, y int
	px := (*C.int)(unsafe.Pointer(&x))
	py := (*C.int)(unsafe.Pointer(&y))
	but := uint8(C.SDL_GetMouseState(px, py))
	return but, x, y
}
Пример #2
0
func HandleInput() {
	for running := true; running; {
		e := <-inputChan
		switch C.eventType(&e) {
		case C.SDL_QUIT:
			go QuitFunc()
			running = false
		case C.SDL_KEYDOWN:
			{
				var ke KeyEvent
				ke.Key = int(C.eventKey(&e))
				go KeyDown(ke)
			}
		case C.SDL_KEYUP:
			{
				var ke KeyEvent
				ke.Key = int(C.eventKey(&e))
				go KeyUp(ke)
			}
		case C.SDL_MOUSEWHEEL:
			var mwe MouseWheelEvent
			var x, y C.int
			C.SDL_GetMouseState(&x, &y)
			mwe.X = int(x)
			mwe.Y = int(y)
			mwe.Up = C.eventMouseWheelY(&e) > 0
			go MouseWheelFunc(mwe)
		case C.SDL_MOUSEBUTTONDOWN:
			x := int(C.eventMouseX(&e))
			y := int(C.eventMouseY(&e))
			var me MouseEvent
			me.X = x
			me.Y = y
			me.Button = int(C.eventMouseButton(&e))
			go MouseButtonDown(me)
		case C.SDL_MOUSEBUTTONUP:
			var me MouseEvent
			me.Button = int(C.eventMouseButton(&e))
			me.X = int(C.eventMouseX(&e))
			me.Y = int(C.eventMouseY(&e))
			me.Button = int(C.eventMouseButton(&e))
			go MouseButtonUp(me)
		}
	}
}
Пример #3
0
// Retrieves the current state of the mouse.
func GetMouseState(x, y *int) uint8 {
	GlobalMutex.Lock()
	state := uint8(C.SDL_GetMouseState((*C.int)(cast(x)), (*C.int)(cast(y))))
	GlobalMutex.Unlock()
	return state
}
Пример #4
0
// Retrieves the current state of the mouse.
func GetMouseState(x, y *int) uint8 {
	return uint8(C.SDL_GetMouseState((*C.int)(cast(x)), (*C.int)(cast(y))))
}
Пример #5
0
// Retrieves the current state of the mouse.
// returns state, x, y
func GetMouseState() (uint32, int, int) {
	var x C.int = 0
	var y C.int = 0
	state := uint32(C.SDL_GetMouseState(&x, &y))
	return state, int(x), int(y)
}
Пример #6
0
func GetMouseState(x, y *int) uint32 {
	_x := (*C.int)(unsafe.Pointer(x))
	_y := (*C.int)(unsafe.Pointer(y))
	return (uint32)(C.SDL_GetMouseState(_x, _y))
}
Пример #7
0
func Mouse() (int, int, uint32) {
	var x C.int
	var y C.int
	state := C.SDL_GetMouseState(&x, &y)
	return int(x), int(y), uint32(state)
}
Пример #8
0
// GetMouseState (https://wiki.libsdl.org/SDL_GetMouseState)
func GetMouseState() (x, y int, state uint32) {
	var _x, _y C.int
	_state := uint32(C.SDL_GetMouseState(&_x, &_y))
	return int(_x), int(_y), _state
}
Пример #9
0
func GetMouseState() (state uint8, x, y int) {
	var cx, cy C.int
	cstate := C.SDL_GetMouseState(&cx, &cy)

	return uint8(cstate), int(cx), int(cy)
}