Skip to content

Instantly share code, notes, and snippets.

@BigETI
Created October 27, 2020 18:25
Show Gist options
  • Save BigETI/300592aa21861e86d6dcf9ebc77e5467 to your computer and use it in GitHub Desktop.
Save BigETI/300592aa21861e86d6dcf9ebc77e5467 to your computer and use it in GitHub Desktop.
Helper function to check key states in PAWN
bool:AreKeysDown(keys, oldKeys, newKeys)
{
return ((oldKeys & keys) != keys) && ((newKeys & keys) == keys);
}
bool:AreKeysUp(keys, oldKeys, newKeys)
{
return ((oldKeys & keys) == keys) && ((newKeys & keys) != keys)
}
bool:AreKeysPressed(keys, newKeys)
{
return (newKeys & keys) == keys;
}
bool:IsAnyKeyFromKeysDown(keys, oldKeys, newKeys)
{
return !(oldKeys & keys) && (newKeys & keys);
}
bool:IsAnyKeyFromKeysUp(keys, oldKeys, newKeys)
{
return (oldKeys & keys) && !(newKeys & keys);
}
bool:IsAnyKeyFromKeysPressed(keys, newKeys)
{
return !!(newKeys & keys);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment