u/AskComprehensive7867

Checking inputs efficiently in C

im trying to check inputs in a command line program, using windows api here (runs on command prompt or windows powershell)

if (GetAsyncKeyState(VK_UP))

playerY -= moveSpeed;

else if (GetAsyncKeyState(VK_DOWN))

playerY += moveSpeed;

else if (GetAsyncKeyState(VK_LEFT))

playerX -= moveSpeed;

else if (GetAsyncKeyState(VK_RIGHT))

playerX += moveSpeed;

but is there any way to make it more efficient, 4 system level calls for checking something this trivial is very inefficient? i tried using getkeyboardstate(), but it doesnt work in c. Tried the event driven approach, but it says that it goes through more layers and data structures which brings it back to square one even with low syscalls, im sort of confused

need help pls

reddit.com
u/AskComprehensive7867 — 21 hours ago