I want to make simple games in the termux terminal in c++ and I need a way to get keyboard input into the game code like this :
void gameLoop() {
char c = <the last key pressed>
/*
And here will be the code that will be executed
continuously.
*/
}
First I tried to include the <conio.h> library but then I realized it is only for windows, so I found the <linux/input.h> library and included it.
It seemed to work at first because Termux is a Linux emulator so it has almost all of the Linux libraries.
But then I realized it needs to read a file named event1
located in the /dev/input
directory, but I couldn’t access it because because I am using Android. So I need a way to access it and read its contents or just use another library that can be used to get user input.