add callbacks for mouse movement and mouse clicking

This commit is contained in:
2024-07-30 17:10:48 +01:00
parent 75b82fd888
commit e97768b18a
12 changed files with 102 additions and 49 deletions

24
ffi/glfw-input.sml Normal file
View File

@@ -0,0 +1,24 @@
structure Input =
struct
type window = MLton.Pointer.t
(* Export function to C. *)
val exportMouseMoveCallback =
_export "mltonMouseMoveCallback" public : (int * int -> unit) -> unit;
(* Import function to set callback for GLFW. *)
val setMouseMoveCallback = _import "setMouseMoveCallback" public reentrant : window -> unit;
val exportMouseClickCallback =
_export "mltonMouseClickCallback" public : (int * int -> unit) -> unit;
val setMouseClickCallback = _import "setMouseClickCallback" public reentrant : window -> unit;
(* Constants for mouse input. *)
val (MOUSE_PRESSED, _) =
_symbol "MOUSE_PRESSED" public : ( unit -> int ) * ( int -> unit );
val (MOUSE_RELEASED, _) =
_symbol "MOUSE_RELEASED" public : ( unit -> int ) * ( int -> unit );
val (LEFT_MOUSE_BUTTON, _) =
_symbol "LEFT_MOUSE_BUTTON" public : ( unit -> int ) * ( int -> unit );
end