From 6468ff1b33dcd6484b9d1a15870a3475c18ce082 Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Thu, 20 Feb 2020 18:07:05 +0100 Subject: [PATCH] Added methods to query the current mouse position. --- mouse.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mouse.go b/mouse.go index 2e917f8..27e4363 100644 --- a/mouse.go +++ b/mouse.go @@ -52,3 +52,15 @@ func IsAnyMouseButtonDown(buttons ...MouseButton) bool { } return false } + +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) +}