zntg/allg5/mouse.go

55 lines
1.4 KiB
Go
Raw Normal View History

2018-11-21 13:35:14 +00:00
package allg5
// #include <allegro5/allegro.h>
import "C"
type MouseButton uint
const (
MouseButtonLeft MouseButton = 1
MouseButtonRight = 2
MouseButtonMiddle = 3
)
2019-03-11 16:30:41 +00:00
type MouseCursor uint
const (
MouseCursorNone MouseCursor = 0
MouseCursorDefault = 1
MouseCursorArrow = 2
MouseCursorBusy = 3
MouseCursorQuestion = 4
MouseCursorEdit = 5
MouseCursorMove = 6
MouseCursorResizeN = 7
MouseCursorResizeW = 8
MouseCursorResizeS = 9
MouseCursorResizeE = 10
MouseCursorResizeNW = 11
MouseCursorResizeSW = 12
MouseCursorResizeSE = 13
MouseCursorResizeNE = 14
MouseCursorProgress = 15
MouseCursorPrecision = 16
MouseCursorLink = 17
MouseCursorAltSelect = 18
MouseCursorUnavailable = 19
)
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
}