Types
InputEventType {...}{.pure, size: 1.} = enum MOUSE, ## Mouse button. TOUCH, ## Touch screen. MOTION, ## Mouse motion. WHEEL, ## Mouse wheel. KEYBOARD, ## Keyboard input TEXT, ## Text input. UNKNOWN ## Unknown event.
InputAction = object kind*: InputEventType key_int*: cint button_index*: cint name*, key*: string
InputEvent = ref object kind*: InputEventType pressed*: bool key_int*: cint button_index*: cint x*, y*, xrel*, yrel*: float key*: string
InputEventVoid = distinct int8
InputEventMouseButton = distinct int8
InputEventMouseMotion = distinct int8
InputEventMouseWheel = distinct int8
InputEventTouchScreen = distinct int8
InputEventKeyboard = distinct int8
Vars
last_key_state: bool = false
key_state: bool = false
mouse_pressed: bool = false
press_state: int = 0
last_event: InputEvent = InputEvent()
pressed_keys_cint: seq[cint] = @[]
actionlist: seq[InputAction] = @[]
Consts
BUTTON_RELEASE = 0
BUTTON_CLICK = 1
Procs
proc isInputEventVoid(a: InputEvent): bool {...}{.inline, raises: [], tags: [].}
- Returns true, when a kind is an UNKNOWN.
proc isInputEventMouseButton(a: InputEvent): bool {...}{.inline, raises: [], tags: [].}
- Returns true, when a kind is a MOUSE.
proc isInputEventMouseMotion(a: InputEvent): bool {...}{.inline, raises: [], tags: [].}
- Returns true, when a kind is a MOTION.
proc isInputEventMouseWheel(a: InputEvent): bool {...}{.inline, raises: [], tags: [].}
- Returns true, when a kind is a WHEEL.
proc isInputEventTouchScreen(a: InputEvent): bool {...}{.inline, raises: [], tags: [].}
- Returns true, when a kind is a TOUCH.
proc isInputEventKeyboard(a: InputEvent): bool {...}{.inline, raises: [], tags: [].}
- Returns true, when a kind is a KEYBOARD.
proc isInputEventText(a: InputEvent): bool {...}{.inline, raises: [], tags: [].}
- Returns true, when a kind is a KEYBOARD.
proc addButtonAction(name: string; button: uint8 | cint) {...}{.inline.}
-
Adds a new action on button.
Arguments:
- name - action name.
- button - button index, e.g.: BUTTON_LEFT, BUTTON_RIGHT or BUTTON_MIDDLE.
proc addKeyAction(name, key: string) {...}{.inline, raises: [], tags: [].}
-
Adds a new action on keyboard.
Arguments:
- name - action name.
- key - key, e.g.: "w", "1", etc.
proc addKeyAction(name: string; key: cint) {...}{.inline, raises: [], tags: [].}
-
Adds a new action on keyboard.
Arguments:
- name - action name.
- key - key, e.g.: K_ESCAPE, K_0, etc.
proc addTouchAction(name: string) {...}{.inline, raises: [], tags: [].}
-
Adds a new action on touch screen.
Arguments:
- name - action name.
proc isActionJustPressed(name: string): bool {...}{.raises: [], tags: [].}
-
Returns true, when action active one times.
Arguments:
- name - action name.
proc isActionPressed(name: string): bool {...}{.raises: [], tags: [].}
-
Returns true, when action active one or more times.
Arguments:
- name - action name.
proc isActionReleased(name: string): bool {...}{.raises: [], tags: [].}
-
Returns true, when action no more active.
Arguments:
- name - action name.
proc `$`(event: InputEvent): string {...}{.raises: [], tags: [].}
proc `$`(action: InputAction): string {...}{.raises: [], tags: [].}