Stk.Key
Utils for managing keys.
type keystate = {
key : Tsdl.Sdl.keycode;
mask : Tsdl.Sdl.keymod;
mods : Tsdl.Sdl.keymod;
pred : Tsdl.Sdl.keymod -> bool;
}
A keyboard state corresponds to a key state if the specified key
is pressed and the active modifiers after applying mask
are equal to mods
. mods
is not used directly but instead a predicate is built to handle modifiers having left and right variants. mods
is kept only for printing or storing purpose. mask
is used to keep only modifiers of interest. For example not containing Sdl.Kmod.caps
results in ignoring the state of Caps Lock when testing. Modifiers with left and right variants are not concerned by the mask since they are handled in the predicate.
val pp_keystate : Stdlib.Format.formatter -> keystate -> unit
Set default mask used by keystate
if no mask is specified in argument. Default is Tsdl
.Sdl.Kmod.none. Sdl.Kmod.(reserved+mode)
.
Set default modifiers used by keystate
if no modifier is specified in argument. Default is Sdl.Kmod.(reserved+mode)
.
val keystate :
?mask:Tsdl.Sdl.keymod ->
?mods:Tsdl.Sdl.keymod ->
Tsdl.Sdl.keycode ->
keystate
Create a keystate
from the given key. Optional parameters are:
mask
to set the modifiers whose state will be ignored. If not specified, default_keymask
is used.mods
to set the required modifiers. If not specified, default_keymods
is used.val match_keys :
keystate ->
key:Tsdl.Sdl.keycode ->
kmod:Tsdl.Sdl.keymod ->
bool
match_keys keystate ~key ~kmod
returns true
if the given key
and modifier kmod
maths the given keystate
.
val keystate_of_string : string -> keystate
val string_of_keystate : keystate -> string
val keystate_ocf_wrapper : keystate Ocf.Wrapper.t
val keystate_list_ocf_wrapper : keystate list Ocf.Wrapper.t
val keystate_list_of_string : string -> keystate list
val string_of_keystate_list : keystate list -> string