1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
open Riot
type key =
| Up
| Down
| Left
| Right
| Space
| Escape
| Backspace
| Enter
| Key of string
let key_to_string key =
match key with
| Up -> "<up>"
| Down -> "<down>"
| Left -> "<left>"
| Right -> "<right>"
| Space -> "<space>"
| Escape -> "<esc>"
| Backspace -> "<backspace>"
| Enter -> "<enter>"
| Key k -> k
type t =
| KeyDown of key
| Timer of unit Ref.t
| Frame of Ptime.t
| Custom of Message.t
let pp fmt t =
match t with
| KeyDown key -> Format.fprintf fmt "KeyDown(%S)" (key_to_string key)
| Timer ref -> Format.fprintf fmt "Timer(%a)" Ref.pp ref
| Frame delta -> Format.fprintf fmt "Frame(%a)" Ptime.pp delta
| Custom _msg -> Format.fprintf fmt "Custom"