- Graphics.synchronize ();
- if Graphics.key_pressed ()
- then
- match M.update estate state (Graphics.read_key ()) with
- | estate, Either.Left state -> aux estate m state
- | estate, Either.Right (ModeAndState (m, state)) -> aux estate m state
- else aux estate m state
+ Raylib.end_drawing ();
+ if Modes.should_close estate || Raylib.window_should_close ()
+ then Raylib.close_window ()
+ else
+ let handle_key () =
+ match Raylib.get_key_pressed () with
+ | Raylib.Key.Null -> aux estate m state
+ | k -> (
+ match M.update estate state (Either.right k) with
+ | estate, Either.Left state -> aux estate m state
+ | estate, Either.Right (ModeAndState (m, state)) -> aux estate m state)
+ in
+ match Raylib.get_char_pressed () with
+ | c when c = Uchar.min -> handle_key ()
+ | c ->
+ let estate, ModeAndState (m, state) =
+ String.fold_left
+ (fun (estate, Modes.ModeAux.ModeAndState (m, state)) c ->
+ let module M = (val m) in
+ match M.update estate state (Either.left c) with
+ | estate, Either.Left state -> (estate, ModeAndState (m, state))
+ | estate, Either.Right ms -> (estate, ms))
+ (estate, ModeAndState (m, state))
+ (string_of_uchar c)
+ in
+ aux estate m state