![]() |
cmdfx 0.1.1
Lightweight game engine for your terminal
|
Device command functions. More...
Go to the source code of this file.
Functions | |
int * | Device_getKeyboardKeysPressed () |
Gets the current keys being pressed. | |
char | Device_fromKeyCode (int keyCode) |
Converts a key code to a character. | |
int * | Device_getMouseButtonsPressed () |
Gets the current mouse button being pressed. | |
Device command functions.
char Device_fromKeyCode | ( | int | keyCode | ) |
Converts a key code to a character.
keyCode | The key code to convert. |
int * Device_getKeyboardKeysPressed | ( | ) |
Gets the current keys being pressed.
The size of the array is always 256, with each index corresponding to a key code native to the operating system. If the key is being pressed, the value at the index will be 1. If the key is not being pressed, the value at the index will be 0.
This is a non-blocking method. This method gets the current key being pressed on the keyboard. If no key is being pressed, it will return -1.
The array must be freed after use.
Preconditions:
On macOS, the application must be added to the "Input Monitoring" permission in the "Security & Privacy" settings. Otherwise, only control keys will be detected.
On Linux, method requires administrator privileges.
int * Device_getMouseButtonsPressed | ( | ) |
Gets the current mouse button being pressed.
This is a non-blocking method. This method gets the current mouse event. If no mouse button is being pressed, it will return -1.
On most systems, the button values are as follows (according to index):
The array must be freed after use.
This method requires administrator privileges on Linux.