#include <SDL.h>
#include "Keyboard.h"

void
Keyboard::check(void)
{
    Uint8 *keys = SDL_GetKeyState(NULL);

    if (keys[SDLK_UP] == SDL_PRESSED) {
	up.push_work();
    } else {
	up.release_work();
    }

    if (keys[SDLK_DOWN] == SDL_PRESSED) {
	down.push_work();
    } else {
	down.release_work();
    }

    if (keys[SDLK_RIGHT] == SDL_PRESSED) {
	right.push_work();
    } else {
	right.release_work();
    }

    if (keys[SDLK_LEFT] == SDL_PRESSED) {
	left.push_work();
    } else {
	left.release_work();
    }

    if (keys[SDLK_RETURN] == SDL_PRESSED) {
	start.push_work();
    } else {
	start.release_work();
    }

    if (keys[SDLK_ESCAPE] == SDL_PRESSED) {
	select.push_work();
    } else {
	select.release_work();
    }

    if (keys[SDLK_a] == SDL_PRESSED) {
	square.push_work();
    } else {
	square.release_work();
    }

    if (keys[SDLK_s] == SDL_PRESSED) {
	triangle.push_work();
    } else {
	triangle.release_work();
    }

    if (keys[SDLK_z] == SDL_PRESSED) {
	cross.push_work();
    } else {
	cross.release_work();
    }

    if (keys[SDLK_x] == SDL_PRESSED) {
	circle.push_work();
    } else {
	circle.release_work();
    }

    if (keys[SDLK_k] == SDL_PRESSED) {
	l1.push_work();
    } else {
	l1.release_work();
    }

    if (keys[SDLK_o] == SDL_PRESSED) {
	l2.push_work();
    } else {
	l2.release_work();
    }

    if (keys[SDLK_l] == SDL_PRESSED) {
	r1.push_work();
    } else {
	r1.release_work();
    }

    if (keys[SDLK_p] == SDL_PRESSED) {
	r2.push_work();
    } else {
	r2.release_work();
    }
}
