-
Notifications
You must be signed in to change notification settings - Fork 5
input.um
Marek Maskarinec edited this page Sep 14, 2022
·
2 revisions
Module for getting keyboard and mouse input.
Keycodes are ascii chars (lower case) and the constants below.
mouse1
mouse2
mouse3
key_shift
key_backspace
key_delete
key_left
key_right
key_up
key_down
key_escape
key_enter
is* functions return info based on a us QWERTY layout. They are supposed to
be used for game controls. For text input use getStr.
fn getMousePos*(): th.Vf2 {
Returns the position of mouse cursor in relation to the screen.
fn getGlobalMousePos*(cam: rect.Rect): th.Vf2 {
Returns the position of mouse cursor in relation to cam.
fn isPressed*(code: char): bool {
Returns true if key is pressed. Either use codes defined in the file above, or pass lower case char/number.
fn isJustPressed*(code: char): bool {
Returns, whether code was just pressed this loop.
fn isJustReleased*(code: char): bool {
Returns true if a key was just released.
fn cclear*(code: char)
fn clear*(code: char) {
Clears both the pressed and justPressed state of a code.
fn getStr*(): str {
Returns a string entered by the user in the last cycle.