2019-12-19 06:08:52 +00:00
|
|
|
package allg5
|
|
|
|
|
|
|
|
// #include <allegro5/allegro.h>
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
type MouseButton uint
|
|
|
|
|
|
|
|
const (
|
|
|
|
MouseButtonLeft MouseButton = 1
|
|
|
|
MouseButtonRight = 2
|
|
|
|
MouseButtonMiddle = 3
|
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
2020-02-20 17:07:05 +00:00
|
|
|
|
|
|
|
func MousePosition() (int, int) {
|
|
|
|
var state C.ALLEGRO_MOUSE_STATE
|
|
|
|
C.al_get_mouse_state(&state)
|
|
|
|
return int(state.x), int(state.y)
|
|
|
|
}
|
|
|
|
|
|
|
|
func MousePositionScreen() (int, int, bool) {
|
|
|
|
var x, y C.int
|
|
|
|
var result = C.al_get_mouse_cursor_position(&x, &y)
|
|
|
|
return int(x), int(y), bool(result)
|
|
|
|
}
|