Page 1 of 1

SDL Input problem

Posted: Sun Jul 08, 2012 4:54 pm
by lalacomun
Well, i am making a engine, and my input core is not working corectly, it looks something like this:

Code: Select all

class acInput
{
  acInput();
  bool acKeyDown(Key key) //this is an enum of keys i made
  ...
that is for the Input.h
now the input.cpp:

Code: Select all

#include "input.h"
...
bool acInput::acKeyDown(Key key)
{
    Uint8 *keystates = SDL_GetKeyState(NULL);
    if(keystates[key])
    return true;
}
and in the main funtion i use it like this:

Code: Select all

int main(int argc,char *argv[])
{
 ...
 acInput input;
 ...
 if(input.acKeyDown(KEY_UP)
 {
    //Do something, but it doesnt work!!!!!
 }
but the problem is that it doesnt do anything!!
any suggestions??

Re: SDL Input problem

Posted: Sun Jul 08, 2012 5:27 pm
by lalacomun
Well, its solved! :mrgreen: , i needed to put "while(SDL_PollEvent(&event)" before using the function, i have no idea why as i am using keystates, no events =p