36 lines
535 B
C++
36 lines
535 B
C++
#include "jinput.h"
|
|
#include <SDL2/SDL.h>
|
|
#include "crt.h"
|
|
|
|
namespace input
|
|
{
|
|
static const uint8_t *keys = nullptr;
|
|
static uint8_t keypressed = 0;
|
|
|
|
void init()
|
|
{
|
|
keys = SDL_GetKeyboardState(NULL);
|
|
}
|
|
|
|
bool anyKey()
|
|
{
|
|
update();
|
|
return keypressed != 0;
|
|
}
|
|
|
|
bool keyPressed(uint8_t tecla)
|
|
{
|
|
update();
|
|
return keys[tecla];
|
|
}
|
|
|
|
uint8_t getKey()
|
|
{
|
|
return keypressed;
|
|
}
|
|
|
|
void updateKey(uint8_t key)
|
|
{
|
|
keypressed = key;
|
|
}
|
|
} |