zntg/allegro5/mouse.go
Sander Schobers 6bd3bad160 Added MouseButton type.
Added IsAny{MouseButton,Key}Down and IsMouseButtonDown methods.
2018-03-29 17:21:10 +02:00

30 lines
609 B
Go

package allegro5
// #include <allegro5/allegro.h>
import "C"
type MouseButton uint
const (
MouseButtonLeft MouseButton = 1
MouseButtonRight = 2
MouseButtonMiddle = 3
)
func IsMouseButtonDown(b MouseButton) bool {
var state C.ALLEGRO_MOUSE_STATE
C.al_get_mouse_state(&state)
return bool(C.al_mouse_button_down(&state, C.int(b)))
}
func IsAnyMouseButtonDown(buttons ...MouseButton) bool {
var state C.ALLEGRO_MOUSE_STATE
C.al_get_mouse_state(&state)
for _, b := range buttons {
if bool(C.al_mouse_button_down(&state, C.int(b))) {
return true
}
}
return false
}