Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaning and completing callback interface #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions examples/maze/maze.ml
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,21 @@ let _ =
Egl.set_key_release_callback handle_key_release

let _ =
let handle_leave_window ~state ~x ~y =
Printf.printf "leave window event\n%!";
camera.r_speed <- 0.0;
camera.r_speed <- 0.0;
camera.t_speed <- 0.0;
camera.t_speed <- 0.0;
camera.u_speed <- 0.0;
camera.u_speed <- 0.0;
camera.speed <- 0.0
in
Egl.set_leave_window_callback handle_leave_window;
let handle_enter_window ~state ~x ~y =
Printf.printf "enter window event\n%!"
in
Egl.set_enter_window_callback handle_enter_window;
let last_x = ref 0 in
let last_y = ref 0 in
let valid = ref false in
Expand Down
50 changes: 50 additions & 0 deletions lib/egl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -106,25 +106,75 @@ external unset_idle_callback : unit -> unit
external set_reshape_callback : (width:int -> height:int -> unit) -> unit
= "ml_egl_set_reshape_callback"

external unset_reshape_callback : unit -> unit
= "ml_egl_unset_reshape_callback"

external set_delete_callback : (unit -> unit) -> unit
= "ml_egl_set_delete_callback"

external unset_delete_callback : unit -> unit
= "ml_egl_unset_delete_callback"

external set_key_press_callback
: (key:keysym -> state:int -> x:int -> y:int -> unit) -> unit
= "ml_egl_set_key_press_callback"

external unset_key_press_callback
: unit -> unit
= "ml_egl_unset_key_press_callback"

external set_key_release_callback
: (key:keysym -> state:int -> x:int -> y:int -> unit) -> unit
= "ml_egl_set_key_release_callback"

external unset_key_release_callback
: unit -> unit
= "ml_egl_unset_key_release_callback"

external set_button_press_callback
: (button:button -> state:int -> x:int -> y:int -> unit) -> unit
= "ml_egl_set_button_press_callback"

external unset_button_press_callback
: unit -> unit
= "ml_egl_unset_button_press_callback"

external set_button_release_callback
: (button:button -> state:int -> x:int -> y:int -> unit) -> unit
= "ml_egl_set_button_release_callback"

external unset_button_release_callback
: unit -> unit
= "ml_egl_unset_button_release_callback"

external set_motion_notify_callback
: (state:int -> x:int -> y:int -> unit) -> unit
= "ml_egl_set_motion_notify_callback"

external unset_motion_notify_callback
: unit -> unit
= "ml_egl_unset_motion_notify_callback"

external set_enter_window_callback
: (state:int -> x:int -> y:int -> unit) -> unit
= "ml_egl_set_enter_window_callback"

external unset_enter_window_callback
: unit -> unit
= "ml_egl_unset_enter_window_callback"

external set_leave_window_callback
: (state:int -> x:int -> y:int -> unit) -> unit
= "ml_egl_set_leave_window_callback"

external unset_leave_window_callback
: unit -> unit
= "ml_egl_unset_leave_window_callback"

external set_change_focus_callback
: (bool -> unit) -> unit
= "ml_egl_set_change_focus_callback"

external unset_change_focus_callback
: unit -> unit
= "ml_egl_unset_change_focus_callback"
101 changes: 74 additions & 27 deletions lib/egl.mli
Original file line number Diff line number Diff line change
Expand Up @@ -94,38 +94,85 @@ external exit_loop : unit -> unit = "ml_egl_exit_loop"
(** {b SETTING CALLBACKS} *)
(****************************************************************************)

external set_idle_callback :
(unit -> unit) -> unit
= "ml_egl_set_idle_callback"

external unset_idle_callback :
unit -> unit
= "ml_egl_unset_idle_callback"
external set_idle_callback : (unit -> unit) -> unit
= "ml_egl_set_idle_callback"

external set_reshape_callback :
(width:int -> height:int -> unit) -> unit
= "ml_egl_set_reshape_callback"
external unset_idle_callback : unit -> unit
= "ml_egl_unset_idle_callback"

external set_delete_callback :
(unit -> unit) -> unit
= "ml_egl_set_delete_callback"
external set_reshape_callback : (width:int -> height:int -> unit) -> unit
= "ml_egl_set_reshape_callback"

external set_key_press_callback :
(key:keysym -> state:int -> x:int -> y:int -> unit) -> unit
= "ml_egl_set_key_press_callback"
external unset_reshape_callback : unit -> unit
= "ml_egl_unset_reshape_callback"

external set_key_release_callback :
(key:keysym -> state:int -> x:int -> y:int -> unit) -> unit
= "ml_egl_set_key_release_callback"
external set_delete_callback : (unit -> unit) -> unit
= "ml_egl_set_delete_callback"

external set_button_press_callback :
(button:button -> state:int -> x:int -> y:int -> unit) -> unit
= "ml_egl_set_button_press_callback"
external unset_delete_callback : unit -> unit
= "ml_egl_unset_delete_callback"

external set_button_release_callback :
(button:button -> state:int -> x:int -> y:int -> unit) -> unit
= "ml_egl_set_button_release_callback"
external set_key_press_callback
: (key:keysym -> state:int -> x:int -> y:int -> unit) -> unit
= "ml_egl_set_key_press_callback"

external set_motion_notify_callback :
(state:int -> x:int -> y:int -> unit) -> unit
= "ml_egl_set_motion_notify_callback"
external unset_key_press_callback
: unit -> unit
= "ml_egl_unset_key_press_callback"

external set_key_release_callback
: (key:keysym -> state:int -> x:int -> y:int -> unit) -> unit
= "ml_egl_set_key_release_callback"

external unset_key_release_callback
: unit -> unit
= "ml_egl_unset_key_release_callback"

external set_button_press_callback
: (button:button -> state:int -> x:int -> y:int -> unit) -> unit
= "ml_egl_set_button_press_callback"

external unset_button_press_callback
: unit -> unit
= "ml_egl_unset_button_press_callback"

external set_button_release_callback
: (button:button -> state:int -> x:int -> y:int -> unit) -> unit
= "ml_egl_set_button_release_callback"

external unset_button_release_callback
: unit -> unit
= "ml_egl_unset_button_release_callback"

external set_motion_notify_callback
: (state:int -> x:int -> y:int -> unit) -> unit
= "ml_egl_set_motion_notify_callback"

external unset_motion_notify_callback
: unit -> unit
= "ml_egl_unset_motion_notify_callback"

external set_enter_window_callback
: (state:int -> x:int -> y:int -> unit) -> unit
= "ml_egl_set_enter_window_callback"

external unset_enter_window_callback
: unit -> unit
= "ml_egl_unset_enter_window_callback"

external set_leave_window_callback
: (state:int -> x:int -> y:int -> unit) -> unit
= "ml_egl_set_leave_window_callback"

external unset_leave_window_callback
: unit -> unit
= "ml_egl_unset_leave_window_callback"

external set_change_focus_callback
: (bool -> unit) -> unit
= "ml_egl_set_change_focus_callback"

external unset_change_focus_callback
: unit -> unit
= "ml_egl_unset_change_focus_callback"
Loading