keyboard - C++ GetAsyncKeyState alternative -
i using windows.h library's getasynckeystate function define key pushed on keyboard . here program returns int value of pushed key example.
#include <iostream> #include <windows.h> using namespace std; int main (){ char i; for(i=8;i<190;i++){ if(getasynckeystate(i)== -32767){ cout<<int (i)<<endl; } } return 0; }
but trying make opengl simple game , function appeared slow . there function not need cycle 180 times , if statement .
thanks
you're trying make opengl game, you're going use glfw. if that's case can away using glfwgetkey()
such:
if (glfwgetkey(glfw_key_up) == glfw_press) {...} if (glfwgetkey(glfw_key_down) == glfw_press) {...}
that method nicely explained in tutorial 6 opengl-tutorial.org. should start first tutorial of beginners tutorials , later intermediate tutorials.
if you're going make win32 window can listen wm_keydown
or wm_keyup
messages , virtual key code wparam. after minute of googling found these 2 sites examples here , here.
Comments
Post a Comment