update Game.ml
This commit is contained in:
parent
0473b1fa60
commit
28a12ac806
1 changed files with 33 additions and 25 deletions
58
Game.ml
58
Game.ml
|
@ -1,32 +1,40 @@
|
||||||
|
(* vim: set st=2 sw=2 et : *)
|
||||||
|
|
||||||
let rec refresh_input () =
|
let rec refresh_input () =
|
||||||
(* poll events *)
|
(* poll events *)
|
||||||
let get_handler_fun ev =
|
let get_handler_fun ev =
|
||||||
match ev with
|
match ev with
|
||||||
| Sdlevent.KEYDOWN _ -> Keyboard.handle_event
|
(* key events *)
|
||||||
| Sdlevent.KEYUP _ -> Keyboard.handle_event
|
| Sdlevent.KEYDOWN _ -> Keyboard.handle_event
|
||||||
|
| Sdlevent.KEYUP _ -> Keyboard.handle_event
|
||||||
|
(* mouse events *)
|
||||||
|
| Sdlevent.MOUSEMOTION _ -> Mouse.handle_event
|
||||||
|
| Sdlevent.MOUSEBUTTONDOWN _ -> Mouse.handle_event
|
||||||
|
| Sdlevent.MOUSEBUTTONUP _ -> Mouse.handle_event
|
||||||
|
(* joystick events *)
|
||||||
|
| Sdlevent.JOYAXISMOTION _ -> Joystick.handle_event
|
||||||
|
| Sdlevent.JOYBALLMOTION _ -> Joystick.handle_event
|
||||||
|
| Sdlevent.JOYHATMOTION _ -> Joystick.handle_event
|
||||||
|
| Sdlevent.JOYBUTTONDOWN _ -> Joystick.handle_event
|
||||||
|
| Sdlevent.JOYBUTTONUP _ -> Joystick.handle_event
|
||||||
|
(* video events *)
|
||||||
|
| Sdlevent.VIDEORESIZE _ -> ignore
|
||||||
|
| Sdlevent.VIDEOEXPOSE -> ignore
|
||||||
|
| Sdlevent.ACTIVE _ -> ignore
|
||||||
|
(* system events *)
|
||||||
|
| Sdlevent.QUIT -> ignore
|
||||||
|
| Sdlevent.SYSWM -> ignore
|
||||||
|
(* user defined events *)
|
||||||
|
| Sdlevent.USER _ -> ignore
|
||||||
|
in
|
||||||
|
|
||||||
| Sdlevent.MOUSEMOTION _ -> Mouse.handle_event
|
let some_event = Sdlevent.poll ()
|
||||||
| Sdlevent.MOUSEBUTTONDOWN _ -> Mouse.handle_event
|
in
|
||||||
| Sdlevent.MOUSEBUTTONUP _ -> Mouse.handle_event
|
|
||||||
|
|
||||||
(*
|
match some_event with
|
||||||
| Sdlevent.JOYAXISMOTION _ -> Joystick.handle_event
|
| Some ev ->
|
||||||
| Sdlevent.JOYBALLMOTION _ -> Joystick.handle_event
|
if ev = Sdlevent.QUIT then ()
|
||||||
| Sdlevent.JOYHATMOTION _ -> Joystick.handle_event
|
else
|
||||||
| Sdlevent.JOYBUTTONDOWN _ -> Joystick.handle_event
|
|
||||||
| Sdlevent.JOYBUTTONUP _ -> Joystick.handle_event
|
|
||||||
*)
|
|
||||||
|
|
||||||
| _ -> ignore
|
|
||||||
in
|
|
||||||
|
|
||||||
let some_event = Sdlevent.poll ()
|
|
||||||
in
|
|
||||||
|
|
||||||
match some_event with
|
|
||||||
| Some Sdlevent.QUIT -> ()
|
|
||||||
| Some ev ->
|
|
||||||
let handler_fun = get_handler_fun ev
|
let handler_fun = get_handler_fun ev
|
||||||
in
|
in
|
||||||
handler_fun ev ;
|
handler_fun ev ;
|
||||||
|
|
Loading…
Reference in a new issue