ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


input_functions

This is an old revision of the document!


Input functions

Introduction

ACSUtils provides a simplified interface to GetPlayerInput.

Every key can be

  • Up or down at any moment.
  • Pressed, if it was up during the previous tick but is now down.
  • Released, if it was down during the previous tick but is now up.

Pressed and released states are especially useful for menus as they allow the user to perform the action as many times as the key was pressed.

Some mods don't detect pressed state but instead check for down state periodically, causing the user to perform the action less or more times than desired, e.g.:

while (true)
{
   if (KeyDown(BT_MOVELEFT))
       menupos++;
   Delay(5);
}

will move the menu cursor 7 times per second if the button is held, and won't move the cursor at all if the key press falls in between the checks, whereas:

while (true)
{
    if (KeyPressed(BT_MOVELEFT))
        menupos++;
    Delay(1);
}

will move the menu cursor down as many times as the key was hit.

Functions

ACSUtils provides many functions with names in the following formats:

  • bool KeyState(int key)
  • bool KeyStateAny(int key)
  • bool PlayerKeyState(int player, int key)
  • bool PlayerKeyStateAny(int player, int key)

Here's a breakdown of the parts:

  1. State is any of Up, Down, Pressed, Released.
  2. If multiple keys are passed in (e.g. BT_ATTACK | BT_ALTATTACK), then functions with the Any suffix return true if any of them are in the needed state, while functions without the suffix return true only if all of them are.
  3. If the Player prefix is present, the function checks the keys of the specified player. Functions without the prefix check the activator's keys (equivalent to passing -1 to GetPlayerInput.

Function list

input_functions.1492269210.txt.gz · Last modified: 2017/04/15 18:13 by korshun